### Question:
DeployerClient { public Mono<String> undeploy(BackingApplication backingApplication) { return appDeployer .undeploy(UndeployApplicationRequest .builder() .properties(backingApplication.getProperties()) .name(backingApplication.getName()) .build()) .doOnRequest(l -> { LOG.info("Undeploying application. backingAppName={}", backingApplication.getName()); LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApplication); }) .doOnSuccess(response -> { LOG.info("Success undeploying application. backingAppName={}", backingApplication.getName()); LOG.debug("response={}, backingApp={}", response, backingApplication); }) .doOnError(e -> { LOG.error(String.format("Error undeploying application. backingAppName=%s, error=%s", backingApplication.getName(), e.getMessage()), e); LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApplication); }) .onErrorReturn(UndeployApplicationResponse.builder() .name(backingApplication.getName()) .build()) .map(UndeployApplicationResponse::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 shouldUndeployApp() { given(appDeployer.undeploy(any())) .willReturn(Mono.just(UndeployApplicationResponse.builder() .name(APP_NAME) .build())); BackingApplication application = BackingApplication.builder() .name(APP_NAME) .path(APP_PATH) .build(); StepVerifier.create(deployerClient.undeploy(application)) .expectNext(APP_NAME) .verifyComplete(); then(appDeployer).should().undeploy(argThat(request -> APP_NAME.equals(request.getName()))); }
@Test void shouldNotReturnErrorWhenUndeployingAppThatDoesNotExist() { given(appDeployer.undeploy(any())) .willReturn(Mono.error(new IllegalStateException("app does not exist"))); BackingApplication application = BackingApplication.builder() .name(APP_NAME) .path(APP_PATH) .build(); StepVerifier.create(deployerClient.undeploy(application)) .expectNext(APP_NAME) .verifyComplete(); then(appDeployer).should().undeploy(argThat(request -> APP_NAME.equals(request.getName()))); }