### Question:
DeployerClient { public Mono<String> deploy(BackingApplication backingApplication, String serviceInstanceId) { return appDeployer .deploy(DeployApplicationRequest .builder() .name(backingApplication.getName()) .path(backingApplication.getPath()) .properties(backingApplication.getProperties()) .environment(backingApplication.getEnvironment()) .services(backingApplication.getServices().stream() .map(ServicesSpec::getServiceInstanceName) .collect(Collectors.toList())) .serviceInstanceId(serviceInstanceId) .build()) .doOnRequest(l -> { LOG.info("Deploying application. backingAppName={}", backingApplication.getName()); LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApplication); }) .doOnSuccess(response -> { LOG.info("Success deploying application. backingAppName={}", backingApplication.getName()); LOG.debug("response={}, backingApp={}", response, backingApplication); }) .doOnError(e -> { LOG.error(String.format("Error deploying application. backingAppName=%s, error=%s", backingApplication.getName(), e.getMessage()), e); LOG.debug(BACKINGAPP_LOG_TEMPLATE, backingApplication); }) .map(DeployApplicationResponse::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 shouldDeployApp() { setupAppDeployer(); BackingApplication application = BackingApplication.builder() .name(APP_NAME) .path(APP_PATH) .build(); StepVerifier.create(deployerClient.deploy(application, "instance-id")) .expectNext(APP_NAME) .verifyComplete(); then(appDeployer).should().deploy(argThat(matchesRequest(APP_NAME, APP_PATH, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList()))); }
@Test @SuppressWarnings("serial") void shouldDeployAppWithProperties() { setupAppDeployer(); Map<String, String> properties = new HashMap<String, String>() {{ put("memory", "1G"); put("instances", "2"); }}; BackingApplication application = BackingApplication.builder() .name(APP_NAME) .path(APP_PATH) .properties(properties) .build(); StepVerifier.create(deployerClient.deploy(application, "instance-id")) .expectNext(APP_NAME) .verifyComplete(); then(appDeployer).should().deploy(argThat(matchesRequest(APP_NAME, APP_PATH, properties, Collections.emptyMap(), Collections.emptyList()))); }
@Test @SuppressWarnings("serial") void shouldDeployAppWithService() { setupAppDeployer(); BackingApplication application = BackingApplication .builder() .name(APP_NAME) .path(APP_PATH) .services(ServicesSpec.builder() .serviceInstanceName("my-db-service") .build()) .build(); StepVerifier.create(deployerClient.deploy(application, "instance-id")) .expectNext(APP_NAME) .verifyComplete(); then(appDeployer).should().deploy(argThat(matchesRequest(APP_NAME, APP_PATH, Collections.emptyMap(), Collections.emptyMap(), Collections.singletonList("my-db-service")))); }
@Test @SuppressWarnings("serial") void shouldDeployAppWithEnvironmentVariables() { setupAppDeployer(); Map<String, Object> environment = new HashMap<String, Object>() {{ put("ENV_VAR_1", "value1"); put("ENV_VAR_2", "value2"); }}; BackingApplication application = BackingApplication.builder() .name(APP_NAME) .path(APP_PATH) .environment(environment) .build(); StepVerifier.create(deployerClient.deploy(application, "instance-id")) .expectNext(APP_NAME) .verifyComplete(); then(appDeployer).should().deploy(argThat(matchesRequest(APP_NAME, APP_PATH, Collections.emptyMap(), environment, Collections.emptyList()))); }