### Question:
CloudFoundryAppDeployer implements AppDeployer, ResourceLoaderAware { @Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest request) { String serviceInstanceName = request.getServiceInstanceName(); Map<String, String> deploymentProperties = request.getProperties(); Mono<Void> requestDeleteServiceInstance; if (deploymentProperties.containsKey(DeploymentProperties.TARGET_PROPERTY_KEY)) { String space = deploymentProperties.get(DeploymentProperties.TARGET_PROPERTY_KEY); requestDeleteServiceInstance = operationsUtils.getOperations(deploymentProperties) .flatMap(cfOperations -> unbindServiceInstance(serviceInstanceName, cfOperations) .then(deleteServiceInstance(serviceInstanceName, cfOperations, deploymentProperties))) .then(deleteSpace(space)); } else { requestDeleteServiceInstance = unbindServiceInstance(serviceInstanceName, operations) .then(deleteServiceInstance(serviceInstanceName, operations, deploymentProperties)); } return requestDeleteServiceInstance .doOnSuccess(v -> LOG.info("Success deleting service instance. serviceInstanceName={}", serviceInstanceName)) .doOnError(logError(String.format("Error deleting service instance. serviceInstanceName=%s", serviceInstanceName))) .thenReturn(DeleteServiceInstanceResponse.builder() .name(serviceInstanceName) .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 deleteServiceInstanceShouldUnbindServices() { given(operationsServices.deleteInstance( org.cloudfoundry.operations.services.DeleteServiceInstanceRequest.builder() .name("service-instance-name") .completionTimeout(Duration.ofSeconds(DEFAULT_COMPLETION_DURATION)) .build())) .willReturn(Mono.empty()); given(operationsServices.getInstance(GetServiceInstanceRequest.builder().name("service-instance-name").build())) .willReturn(Mono.just(ServiceInstance.builder() .id("siid") .type(ServiceInstanceType.MANAGED) .name("service-instance-name") .applications("app1", "app2") .build())); given(operationsServices.unbind(UnbindServiceInstanceRequest.builder() .serviceInstanceName("service-instance-name") .applicationName("app1") .build())) .willReturn(Mono.empty()); given(operationsServices.unbind(UnbindServiceInstanceRequest.builder() .serviceInstanceName("service-instance-name") .applicationName("app2") .build())) .willReturn(Mono.empty()); DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceName("service-instance-name") .properties(emptyMap()) .build(); StepVerifier.create( appDeployer.deleteServiceInstance(request)) .assertNext(response -> assertThat(response.getName()).isEqualTo("service-instance-name")) .verifyComplete(); }