### Question:
CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware { @Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { return Mono.defer(() -> { if (StringUtils.hasText(request.getServiceInstanceId())) { return getServiceInstance(request.getServiceInstanceId()) .flatMap(serviceInstanceEntity -> getSpace(serviceInstanceEntity.getSpaceId()) .flatMap(spaceEntity -> getServiceInstance(serviceInstanceEntity.getName(), spaceEntity))); } else { return operationsUtils.getOperations(request.getProperties()) .flatMap(cfOperations -> cfOperations.services() .getInstance(org.cloudfoundry.operations.services.GetServiceInstanceRequest.builder() .name(request.getName()) .build())); } }) .map(serviceInstance -> GetServiceInstanceResponse.builder() .name(serviceInstance.getName()) .service(serviceInstance.getService()) .plan(serviceInstance.getPlan()) .build()); } CloudFoundryAppDeployer(CloudFoundryDeploymentProperties deploymentProperties,
		CloudFoundryOperations operations,
		CloudFoundryClient client,
		CloudFoundryOperationsUtils operationsUtils,
		CloudFoundryTargetProperties targetProperties,
		ResourceLoader resourceLoader); @Override void setResourceLoader(ResourceLoader resourceLoader); @Override Mono<GetApplicationResponse> get(GetApplicationRequest request); @Override Mono<DeployApplicationResponse> deploy(DeployApplicationRequest request); @Override Mono<UpdateApplicationResponse> update(UpdateApplicationRequest request); @Override Mono<UndeployApplicationResponse> undeploy(UndeployApplicationRequest request); @Override Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request); @Override Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest request); @Override Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request); @Override Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest request);  }### Answer:
@Test void getServiceInstanceByName() { given(operationsServices.getInstance(any(GetServiceInstanceRequest.class))) .willReturn(Mono.just(ServiceInstance.builder() .id("foo-service-instance-id") .name("my-foo-service") .service("foo-service") .plan("foo-plan") .type(ServiceInstanceType.MANAGED) .build())); org.springframework.cloud.appbroker.deployer.GetServiceInstanceRequest request = org.springframework.cloud.appbroker.deployer.GetServiceInstanceRequest .builder() .name("my-foo-service") .build(); StepVerifier.create(appDeployer.getServiceInstance(request)) .assertNext(response -> { assertThat(response.getName()).isEqualTo("my-foo-service"); assertThat(response.getService()).isEqualTo("foo-service"); assertThat(response.getPlan()).isEqualTo("foo-plan"); }) .verifyComplete(); then(operationsUtils).should().getOperations(argThat(CollectionUtils::isEmpty)); then(cloudFoundryOperations).should().services(); then(operationsServices).should().getInstance(argThat(req -> "my-foo-service".equals(req.getName()))); then(cloudFoundryClient).shouldHaveNoInteractions(); then(cloudFoundryOperations).shouldHaveNoMoreInteractions(); then(operationsUtils).shouldHaveNoMoreInteractions(); }