### Question:
CloudFoundryDiscoveryClient implements DiscoveryClient { @Override public List<ServiceInstance> getInstances(String serviceId) { return this.cloudFoundryService.getApplicationInstances(serviceId).map(tuple -> { ApplicationDetail applicationDetail = tuple.getT1(); InstanceDetail instanceDetail = tuple.getT2(); String applicationId = applicationDetail.getId(); String applicationIndex = instanceDetail.getIndex(); String instanceId = applicationId + "." + applicationIndex; String name = applicationDetail.getName(); String url = applicationDetail.getUrls().size() > 0 ? applicationDetail.getUrls().get(0) : null; boolean secure = (url + "").toLowerCase().startsWith("https"); HashMap<String, String> metadata = new HashMap<>(); metadata.put("applicationId", applicationId); metadata.put("instanceId", applicationIndex); return (ServiceInstance) new DefaultServiceInstance(instanceId, name, url, secure ? 443 : 80, secure, metadata); }).collectList().blockOptional().orElse(new ArrayList<>()); } CloudFoundryDiscoveryClient(CloudFoundryOperations cloudFoundryOperations, CloudFoundryService svc,
			CloudFoundryDiscoveryProperties properties); @Override String description(); @Override List<ServiceInstance> getInstances(String serviceId); @Override List<String> getServices(); @Override int getOrder();  }### Answer:
@Test public void testInstances() { ApplicationDetail applicationDetail = ApplicationDetail.builder().instances(2).name("my-app").stack("stack") .memoryLimit(1024).id("id").requestedState("requestedState").runningInstances(2) .url("http: InstanceDetail instanceDetail = InstanceDetail.builder().index("0").build(); Tuple2<ApplicationDetail, InstanceDetail> tuple2 = Tuples.of(applicationDetail, instanceDetail); Mockito.when(this.svc.getApplicationInstances(this.hiServiceServiceId)).thenReturn(Flux.just(tuple2)); List<ServiceInstance> instances = this.cloudFoundryDiscoveryClient.getInstances(this.hiServiceServiceId); assertThat(instances.size()).as("Wrong instances: " + instances).isEqualTo(1); assertThat(instances.get(0).getInstanceId()).as("Wrong instance ID").isEqualTo("id.0"); }