ServiceInstanceBindingEventService implements ServiceInstanceBindingService { @Override public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding( CreateServiceInstanceBindingRequest request) { return flows.getCreateInstanceBindingRegistry().getInitializationFlows(request) .then(service.createServiceInstanceBinding(request)) .onErrorResume(e -> flows.getCreateInstanceBindingRegistry().getErrorFlows(request, e) .then(Mono.error(e))) .flatMap(response -> flows.getCreateInstanceBindingRegistry().getCompletionFlows(request, response) .then(Mono.just(response))); } ServiceInstanceBindingEventService(ServiceInstanceBindingService service, EventFlowRegistries flows); @Override Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding(
			CreateServiceInstanceBindingRequest request); @Override Mono<GetServiceInstanceBindingResponse> getServiceInstanceBinding(GetServiceInstanceBindingRequest request); @Override Mono<GetLastServiceBindingOperationResponse> getLastOperation(
			GetLastServiceBindingOperationRequest request); @Override Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(
			DeleteServiceInstanceBindingRequest request);  }
@Test void createServiceInstanceBindingSucceeds() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.createServiceInstanceBinding( CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("service-instance-id") .serviceDefinitionId("service-binding-id") .build())) .expectNext(CreateServiceInstanceAppBindingResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeCreate()).isEqualTo("before create service-instance-id"); assertThat(this.results.getAfterCreate()).isEqualTo("after create service-instance-id"); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isNullOrEmpty(); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
@Test void createServiceInstanceBindingFails() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.createServiceInstanceBinding( CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("service-instance-id") .build())) .expectError() .verify(); assertThat(this.results.getBeforeCreate()).isEqualTo("before create service-instance-id"); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isEqualTo("error create service-instance-id"); assertThat(this.results.getBeforeDelete()).isNullOrEmpty(); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }