SrvResolver implements Resolver { @Override public List<ResolveResult> resolve() { return dnsSrvResolver .resolve(srvRecord) .stream() .map(result -> new ResolveResult(result.host(), result.port(), result.ttl())) .collect(Collectors.toList()); } private  SrvResolver(final DnsSrvResolver dnsSrvResolver, final String srvRecord); static Builder newBuilder(final String srvRecord); @Override List<ResolveResult> resolve();  }
@Test public void testResolve() { Mockito.when(dnsSrvResolver.resolve(SRV_RECORD)) .thenReturn(of(create("host1", 1, 2, 3, 4), create("host2", 5, 6, 7, 8))); final SrvResolver resolver = SrvResolver.newBuilder(SRV_RECORD).withSrvResolver(dnsSrvResolver).build(); final List<ResolveResult> result = resolver.resolve(); assertEquals(of(new ResolveResult("host1", 1, 4), new ResolveResult("host2", 5, 8)), result); }