### Question:
DeployerClient { public Mono<String> deleteServiceInstance(BackingService backingService) { return appDeployer .deleteServiceInstance( DeleteServiceInstanceRequest .builder() .serviceInstanceName(backingService.getServiceInstanceName()) .properties(backingService.getProperties()) .build()) .doOnRequest(l -> { LOG.info("Deleting backing service {}", backingService.getName()); LOG.debug(BACKINGSERVICE_LOG_TEMPLATE, backingService); }) .doOnSuccess(response -> { LOG.info("Success deleting backing service {}", backingService.getName()); LOG.debug("response={}, backingService={}", response, backingService); }) .doOnError(e -> { LOG.error(String.format("Error deleting backing service. backingServiceName=%s, error=%s", backingService.getName(), e.getMessage()), e); LOG.debug(BACKINGSERVICE_LOG_TEMPLATE, backingService); }) .onErrorReturn(DeleteServiceInstanceResponse.builder() .name(backingService.getServiceInstanceName()) .build()) .map(DeleteServiceInstanceResponse::getName); } DeployerClient(AppDeployer appDeployer); Mono<String> deploy(BackingApplication backingApplication, String serviceInstanceId); Mono<String> update(BackingApplication backingApplication, String serviceInstanceId); Mono<String> undeploy(BackingApplication backingApplication); Mono<String> createServiceInstance(BackingService backingService); Mono<String> updateServiceInstance(BackingService backingService); Mono<String> deleteServiceInstance(BackingService backingService);  }### Answer:
@Test void shouldDeleteServiceInstance() { given(appDeployer.deleteServiceInstance(any())) .willReturn(Mono.just(DeleteServiceInstanceResponse.builder() .name(SERVICE_INSTANCE_NAME) .build())); BackingService service = BackingService.builder() .serviceInstanceName(SERVICE_INSTANCE_NAME) .build(); StepVerifier.create(deployerClient.deleteServiceInstance(service)) .expectNext(SERVICE_INSTANCE_NAME) .verifyComplete(); then(appDeployer).should().deleteServiceInstance(argThat(request -> SERVICE_INSTANCE_NAME.equals(request.getServiceInstanceName()))); }
@Test void shouldNotReturnErrorWhenDeletingServiceInstanceThatDoesNotExist() { given(appDeployer.deleteServiceInstance(any())) .willReturn(Mono.error(new IllegalStateException("service instance does not exist"))); BackingService service = BackingService.builder() .serviceInstanceName(SERVICE_INSTANCE_NAME) .build(); StepVerifier.create(deployerClient.deleteServiceInstance(service)) .expectNext(SERVICE_INSTANCE_NAME) .verifyComplete(); then(appDeployer).should().deleteServiceInstance(argThat(request -> SERVICE_INSTANCE_NAME.equals(request.getServiceInstanceName()))); }