Java Code Examples for org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceResponse#builder()
The following examples show how to use
org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceResponse#builder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkflowServiceInstanceService.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
private Mono<DeleteServiceInstanceResponse> invokeDeleteResponseBuilders(DeleteServiceInstanceRequest request) { AtomicReference<DeleteServiceInstanceResponseBuilder> responseBuilder = new AtomicReference<>(DeleteServiceInstanceResponse.builder()); return Flux.fromIterable(deleteServiceInstanceWorkflows) .filterWhen(workflow -> workflow.accept(request)) .flatMap(workflow -> workflow.buildResponse(request, responseBuilder.get()) .doOnNext(responseBuilder::set)) .last(responseBuilder.get()) .map(DeleteServiceInstanceResponseBuilder::build); }
Example 2
Source File: WorkflowServiceInstanceServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void deleteServiceInstanceWithResponseError() { DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceId("foo") .build(); DeleteServiceInstanceResponseBuilder responseBuilder = DeleteServiceInstanceResponse.builder(); given(deleteServiceInstanceWorkflow1.accept(request)) .willReturn(Mono.just(true)); given( deleteServiceInstanceWorkflow1 .buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class))) .willReturn(Mono.error(new ServiceBrokerException("delete foo error"))); given(deleteServiceInstanceWorkflow2.accept(request)) .willReturn(Mono.just(true)); given( deleteServiceInstanceWorkflow2 .buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); StepVerifier.create(workflowServiceInstanceService.deleteServiceInstance(request)) .expectErrorSatisfies(e -> assertThat(e) .isInstanceOf(ServiceBrokerException.class) .hasMessage("delete foo error")) .verify(); }
Example 3
Source File: WorkflowServiceInstanceServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void deleteServiceInstance() { given(serviceInstanceStateRepository.saveState(anyString(), any(OperationState.class), anyString())) .willReturn( Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "delete service instance started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn( Mono.just( new ServiceInstanceState(OperationState.SUCCEEDED, "delete service instance completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceId("foo") .build(); DeleteServiceInstanceResponseBuilder responseBuilder = DeleteServiceInstanceResponse.builder(); DeleteServiceInstanceResponse builtResponse = DeleteServiceInstanceResponse.builder() .async(true) .operation("working2") .build(); TestPublisher<Void> lowerOrderFlow = TestPublisher.create(); TestPublisher<Void> higherOrderFlow = TestPublisher.create(); given(deleteServiceInstanceWorkflow1.accept(request)) .willReturn(Mono.just(true)); given( deleteServiceInstanceWorkflow1 .buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class))) .willReturn(Mono.just(responseBuilder .async(true) .operation("working1"))); given(deleteServiceInstanceWorkflow1.delete(eq(request), eq(builtResponse))) .willReturn(lowerOrderFlow.mono()); given(deleteServiceInstanceWorkflow2.accept(request)) .willReturn(Mono.just(true)); given( deleteServiceInstanceWorkflow2 .buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class))) .willReturn(Mono.just(responseBuilder .operation("working2"))); given(deleteServiceInstanceWorkflow2.delete(eq(request), eq(builtResponse))) .willReturn(higherOrderFlow.mono()); StepVerifier.create(workflowServiceInstanceService.deleteServiceInstance(request)) .assertNext(response -> { InOrder repoOrder = inOrder(serviceInstanceStateRepository); repoOrder.verify(serviceInstanceStateRepository) .saveState(eq("foo"), eq(OperationState.IN_PROGRESS), eq("delete service instance started")); repoOrder.verify(serviceInstanceStateRepository) .saveState(eq("foo"), eq(OperationState.SUCCEEDED), eq("delete service instance completed")); repoOrder.verifyNoMoreInteractions(); lowerOrderFlow.complete(); lowerOrderFlow.assertWasNotRequested(); higherOrderFlow.complete(); lowerOrderFlow.assertWasRequested(); InOrder deleteOrder = inOrder(deleteServiceInstanceWorkflow1, deleteServiceInstanceWorkflow2); deleteOrder.verify(deleteServiceInstanceWorkflow2).buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class)); deleteOrder.verify(deleteServiceInstanceWorkflow1).buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class)); deleteOrder.verify(deleteServiceInstanceWorkflow2).delete(request, responseBuilder.build()); deleteOrder.verify(deleteServiceInstanceWorkflow1).delete(request, responseBuilder.build()); deleteOrder.verifyNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response.isAsync()).isTrue(); assertThat(response.getOperation()).isEqualTo("working2"); }) .verifyComplete(); }
Example 4
Source File: WorkflowServiceInstanceServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void deleteServiceInstanceWithAsyncError() { given(serviceInstanceStateRepository.saveState(anyString(), any(OperationState.class), anyString())) .willReturn( Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "delete service instance started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn(Mono.just(new ServiceInstanceState(OperationState.FAILED, "delete service instance failed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceId("foo") .build(); DeleteServiceInstanceResponseBuilder responseBuilder = DeleteServiceInstanceResponse.builder(); given(deleteServiceInstanceWorkflow1.accept(request)) .willReturn(Mono.just(true)); given(deleteServiceInstanceWorkflow1.delete(request, responseBuilder.build())) .willReturn(Mono.error(new RuntimeException("delete foo error"))); given( deleteServiceInstanceWorkflow1 .buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); given(deleteServiceInstanceWorkflow2.accept(request)) .willReturn(Mono.just(true)); given(deleteServiceInstanceWorkflow2.delete(request, responseBuilder.build())) .willReturn(Mono.empty()); given( deleteServiceInstanceWorkflow2 .buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); StepVerifier.create(workflowServiceInstanceService.deleteServiceInstance(request)) .assertNext(response -> { InOrder repoOrder = inOrder(serviceInstanceStateRepository); repoOrder.verify(serviceInstanceStateRepository) .saveState(eq("foo"), eq(OperationState.IN_PROGRESS), eq("delete service instance started")); repoOrder.verify(serviceInstanceStateRepository) .saveState(eq("foo"), eq(OperationState.FAILED), eq("delete foo error")); repoOrder.verifyNoMoreInteractions(); InOrder deleteOrder = inOrder(deleteServiceInstanceWorkflow1, deleteServiceInstanceWorkflow2); deleteOrder.verify(deleteServiceInstanceWorkflow2).buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class)); deleteOrder.verify(deleteServiceInstanceWorkflow1).buildResponse(eq(request), any(DeleteServiceInstanceResponseBuilder.class)); deleteOrder.verify(deleteServiceInstanceWorkflow2).delete(request, responseBuilder.build()); deleteOrder.verify(deleteServiceInstanceWorkflow1).delete(request, responseBuilder.build()); deleteOrder.verifyNoMoreInteractions(); assertThat(response).isNotNull(); }) .verifyComplete(); }