### Question:
Resolver { List<URI> resolve(final String srvName, final String domain) { return resolve(srvName, domain, DEFAULT_RESOLVER); }    }### Answer:
@Test public void testResolve() throws Exception { final List<LookupResult> lookupResults = ImmutableList.of( LookupResult.create("master1.example.com", 443, 1, 1, 1), LookupResult.create("master2.example.com", 443, 1, 1, 1), LookupResult.create("master3.example.com", 443, 1, 1, 1) ); final URI[] expectedUris = { new URI("https: new URI("https: new URI("https: }; when(resolver.resolve("_helios._https.example.com")).thenReturn(lookupResults); final List<URI> uris = new Resolver().resolve("helios", "example.com", resolver); assertThat(uris.size(), equalTo(3)); assertThat(uris, Matchers.containsInAnyOrder(expectedUris)); }
@Test public void testResolveWithHttpFallback() throws Exception { final List<LookupResult> lookupResults = ImmutableList.of( LookupResult.create("master1.example.com", 80, 1, 1, 1), LookupResult.create("master2.example.com", 80, 1, 1, 1), LookupResult.create("master3.example.com", 80, 1, 1, 1) ); final URI[] expectedUris = { new URI("http: new URI("http: new URI("http: }; when(resolver.resolve("_helios._https.example.com")) .thenReturn(Collections.emptyList()); when(resolver.resolve("_helios._http.example.com")).thenReturn(lookupResults); final List<URI> uris = new Resolver().resolve("helios", "example.com", resolver); assertThat(uris.size(), equalTo(3)); assertThat(uris, Matchers.containsInAnyOrder(expectedUris)); }