### Question:
EndpointDiscovery { List<String> apiUrls() throws UnknownHostException { InetAddress[] addresses = InetAddress.getAllByName(DNS_API_ADDRESS); List<String> fqdns = new ArrayList<>(); for (InetAddress inetAddress : addresses) { fqdns.add(inetAddress.getCanonicalHostName()); } return fqdns.stream() .map(s -> String.format("https: .collect(Collectors.toList()); } EndpointDiscovery(@NonNull final String myUserAgent); Optional<String> discover();  }### Answer:
@Test public void apiUrls(@Mocked InetAddress inetAddressMock) throws UnknownHostException { InetAddress[] inetAddresses = new InetAddress[1]; inetAddresses[0] = inetAddressMock; new Expectations() {{ InetAddress.getAllByName(EndpointDiscovery.DNS_API_ADDRESS); result = inetAddresses; inetAddressMock.getCanonicalHostName(); result = "127.0.0.1"; }}; List<String> urls = endpointDiscovery.apiUrls(); assertThat(urls, is(Collections.singletonList("https: new Verifications() {{ InetAddress.getAllByName(EndpointDiscovery.DNS_API_ADDRESS); times = 1; }}; }