ServiceInstanceEventService implements ServiceInstanceService { @Override public Mono<GetLastServiceOperationResponse> getLastOperation(GetLastServiceOperationRequest request) { return flows.getAsyncOperationRegistry().getInitializationFlows(request) .then(service.getLastOperation(request)) .onErrorResume(e -> flows.getAsyncOperationRegistry().getErrorFlows(request, e) .then(Mono.error(e))) .flatMap(response -> flows.getAsyncOperationRegistry().getCompletionFlows(request, response) .then(Mono.just(response))); } ServiceInstanceEventService(ServiceInstanceService serviceInstanceService,
			EventFlowRegistries eventFlowRegistries); @Override Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest request); @Override Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request); @Override Mono<GetLastServiceOperationResponse> getLastOperation(GetLastServiceOperationRequest request); @Override Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest request); @Override Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request);  }
@Test void getLastOperationSucceeds() { prepareLastOperationEventFlows(); StepVerifier .create(serviceInstanceEventService.getLastOperation(GetLastServiceOperationRequest.builder() .serviceInstanceId("service-instance-id") .serviceDefinitionId("service-def-id") .build())) .expectNext(GetLastServiceOperationResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeLastOperation()).isEqualTo("before service-instance-id"); assertThat(this.results.getAfterLastOperation()).isEqualTo("after service-instance-id"); assertThat(this.results.getErrorLastOperation()).isNullOrEmpty(); }
@Test void getLastOperationFails() { prepareLastOperationEventFlows(); StepVerifier .create(serviceInstanceEventService.getLastOperation(GetLastServiceOperationRequest.builder() .serviceInstanceId("service-instance-id") .build())) .expectError() .verify(); assertThat(this.results.getBeforeLastOperation()).isEqualTo("before service-instance-id"); assertThat(this.results.getAfterLastOperation()).isNullOrEmpty(); assertThat(this.results.getErrorLastOperation()).isEqualTo("error service-instance-id"); }