### Question:
AppDeploymentUpdateServiceInstanceWorkflow extends AppDeploymentInstanceWorkflow implements UpdateServiceInstanceWorkflow { @Override public Mono<Void> update(UpdateServiceInstanceRequest request, UpdateServiceInstanceResponse response) { return updateBackingServices(request) .thenMany(updateBackingApplications(request)) .then(); } AppDeploymentUpdateServiceInstanceWorkflow(BrokeredServices brokeredServices,
		BackingAppDeploymentService deploymentService,
		BackingAppManagementService backingAppManagementService,
		BackingServicesProvisionService backingServicesProvisionService,
		BackingApplicationsParametersTransformationService appsParametersTransformationService,
		BackingServicesParametersTransformationService servicesParametersTransformationService,
		TargetService targetService); @Override Mono<Void> update(UpdateServiceInstanceRequest request, UpdateServiceInstanceResponse response); @Override Mono<Boolean> accept(UpdateServiceInstanceRequest request); @Override Mono<UpdateServiceInstanceResponseBuilder> buildResponse(UpdateServiceInstanceRequest request,
		UpdateServiceInstanceResponseBuilder responseBuilder);  }### Answer:
@Test @SuppressWarnings({"UnassignedFluxMonoInstance"}) void updateServiceInstanceSucceeds() { UpdateServiceInstanceRequest request = buildRequest("service1", "plan1"); UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().build(); setupMocks(request); mockNoChangeInBackingServices(request); StepVerifier .create(updateServiceInstanceWorkflow.update(request, response)) .expectNext() .expectNext() .verifyComplete(); verify(appDeploymentService).update(backingApps, request.getServiceInstanceId()); verify(servicesProvisionService).updateServiceInstance(backingServices); final String expectedServiceId = "service-instance-id"; verify(targetService).addToBackingServices(backingServices, targetSpec, expectedServiceId); verify(targetService).addToBackingApplications(backingApps, targetSpec, expectedServiceId); verifyNoMoreInteractionsWithServices(); }
@Test void updateServiceInstanceWithParametersSucceeds() { UpdateServiceInstanceRequest request = buildRequest("service1", "plan1", singletonMap("ENV_VAR_1", "value from parameters")); UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().build(); setupMocks(request); mockNoChangeInBackingServices(request); StepVerifier .create(updateServiceInstanceWorkflow.update(request, response)) .expectNext() .expectNext() .verifyComplete(); verifyNoMoreInteractionsWithServices(); }
@Test @SuppressWarnings({"UnassignedFluxMonoInstance"}) void updateServiceInstanceWithNewBackingServiceSucceeds() { UpdateServiceInstanceRequest request = buildRequest("service1", "plan1"); UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().build(); setupMocks(request); given(this.backingAppManagementService.getDeployedBackingApplications(request.getServiceInstanceId(), request.getServiceDefinition().getName(), request.getPlan().getName())) .willReturn(Mono.just(getExistingBackingAppsWithService("existing-service-instance"))); given(this.servicesProvisionService.createServiceInstance(any())) .willReturn(Flux.just("my-service-instance")); given(this.servicesProvisionService.deleteServiceInstance(any())) .willReturn(Flux.just("existing-service-instance")); given(this.servicesProvisionService.updateServiceInstance(eq(Collections.emptyList()))) .willReturn(Flux.empty()); StepVerifier .create(updateServiceInstanceWorkflow.update(request, response)) .expectNext() .expectNext() .verifyComplete(); verify(servicesProvisionService).createServiceInstance(backingServices); verify(servicesProvisionService).deleteServiceInstance(BackingServices .builder() .backingService(BackingService .builder() .serviceInstanceName("existing-service-instance") .build()) .build()); verifyNoMoreInteractionsWithServices(); }
@Test void updateServiceInstanceWithNoAppsDoesNothing() { UpdateServiceInstanceRequest request = buildRequest("unsupported-service", "plan1"); UpdateServiceInstanceResponse response = UpdateServiceInstanceResponse.builder().build(); given(this.backingAppManagementService.getDeployedBackingApplications(request.getServiceInstanceId(), request.getServiceDefinition().getName(), request.getPlan().getName())) .willReturn(Mono.empty()); StepVerifier .create(updateServiceInstanceWorkflow.update(request, response)) .verifyComplete(); verifyNoMoreInteractionsWithServices(); }