### Question:
EndpointDiscovery { List<DiscoveryResult> discoverApiUrls(final List<String> apiUrls) { ExecutorService executorService = Executors.newFixedThreadPool(DEFAULT_THREADS); try { List<Future<DiscoveryResult>> futureList = new ArrayList<>(); for (final String apiUrl : apiUrls) { Callable<DiscoveryResult> discoveryResultCallable = () -> { long start = System.currentTimeMillis(); log.debug("Starting check for {}", apiUrl); Stats stats = getStats(apiUrl, DEFAULT_TIMEOUT_MILLIS); long duration = System.currentTimeMillis() - start; log.debug("Finished check for {}, took {} ms", apiUrl, duration); return new DiscoveryResult(apiUrl, duration, stats); }; futureList.add(executorService.submit(discoveryResultCallable)); } List<DiscoveryResult> discoveryResults = new ArrayList<>(); for (Future<DiscoveryResult> future : futureList) { try { DiscoveryResult discoveryResult = future.get( DEFAULT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); discoveryResults.add(discoveryResult); } catch (ExecutionException | TimeoutException | InterruptedException e) { log.warn("Endpoint " + (apiUrls.get(futureList.indexOf(future))) + " had an exception", e); } } return discoveryResults; } finally { executorService.shutdown(); } } EndpointDiscovery(@NonNull final String myUserAgent); Optional<String> discover();  }### Answer:
@Test public void discoverApiUrls(@Mocked Client clientMock, @Mocked ClientBuilder clientBuilderMock, @Mocked WebTarget webTargetMock) { new Expectations() {{ ClientBuilder.newBuilder(); result = clientBuilderMock; clientBuilderMock.build(); result = clientMock; clientMock.target("https: }}; List<EndpointDiscovery.DiscoveryResult> results = endpointDiscovery.discoverApiUrls(Collections.singletonList("https: assertThat(results.size(), is(1)); assertThat(results.get(0).getDuration(), is(Matchers.greaterThan(0L))); new Verifications() {{ clientMock.target("https: }}; }