@Test
public void testResolveReturnsFirstResults() {

    AdvancedHostResolver firstResolver = mock(AdvancedHostResolver.class);
    AdvancedHostResolver secondResolver = mock(AdvancedHostResolver.class);
    ChainedHostResolver chainResolver = new ChainedHostResolver(ImmutableList.of(firstResolver, secondResolver));
    when(firstResolver.resolve("1.1.1.1")).thenReturn(TestConstants.addressOnesList);
    when(secondResolver.resolve("1.1.1.1")).thenReturn(Collections.<InetAddress>emptyList());
    Collection<InetAddress> results = chainResolver.resolve("1.1.1.1");
    assertNotNull("Resolver should not return null results", results);
    assertThat("Expected resolver to return a result", results, not(empty()));
    Assert.assertEquals("Resolver returned unexpected result", TestConstants.addressOnes, Iterables.get(results, 0));
    verify(secondResolver, never()).resolve("1.1.1.1");
    reset(firstResolver);
    reset(secondResolver);
    when(firstResolver.resolve("2.2.2.2")).thenReturn(Collections.<InetAddress>emptyList());
    when(secondResolver.resolve("2.2.2.2")).thenReturn(TestConstants.addressTwosList);
    results = chainResolver.resolve("2.2.2.2");
    assertNotNull("Resolver should not return null results", results);
    assertThat("Expected resolver to return a result", results, not(empty()));
    Assert.assertEquals("Resolver returned unexpected result", TestConstants.addressTwos, Iterables.get(results, 0));
    verify(firstResolver).resolve("2.2.2.2");
    verify(secondResolver).resolve("2.2.2.2");
}