@Test
public void testGetPeerAddress() {

    Map<String, String> peerMap = new HashMap<>();
    peerMap.put("peer1", "peerAddress1");
    peerMap.put("peer2", null);
    DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
    RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
            "test", new ElectionTermImpl(createProvider(), "test", LOG), -1, -1,
            peerMap, configParams, createProvider(), applyState -> { }, LOG,  MoreExecutors.directExecutor());
    assertEquals("getPeerAddress", "peerAddress1", context.getPeerAddress("peer1"));
    assertEquals("getPeerAddress", null, context.getPeerAddress("peer2"));
    PeerAddressResolver mockResolver = mock(PeerAddressResolver.class);
    doReturn("peerAddress2").when(mockResolver).resolve("peer2");
    doReturn("peerAddress3").when(mockResolver).resolve("peer3");
    configParams.setPeerAddressResolver(mockResolver);
    assertEquals("getPeerAddress", "peerAddress2", context.getPeerAddress("peer2"));
    assertEquals("getPeerAddress", "peerAddress3", context.getPeerAddress("peer3"));
    reset(mockResolver);
    assertEquals("getPeerAddress", "peerAddress1", context.getPeerAddress("peer1"));
    assertEquals("getPeerAddress", "peerAddress2", context.getPeerAddress("peer2"));
    verify(mockResolver, never()).resolve(anyString());
}