org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest.
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: MailServiceInstanceBindingServiceUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenServiceBindingExists_whenDeleteServiceBinding_thenExistingBindingIsDeleted() { // given service binding exists when(mailService.serviceBindingExists(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)).thenReturn(Mono.just(true)); when(mailService.deleteServiceBinding(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.empty()); // when delete service binding DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .bindingId(MAIL_SERVICE_BINDING_ID) .build(); // then the existing service binding is retrieved StepVerifier.create(mailServiceInstanceBindingService.deleteServiceInstanceBinding(request)) .consumeNextWith(response -> { assertFalse(response.isAsync()); assertNull(response.getOperation()); }) .verifyComplete(); }
Example #2
Source File: ServiceInstanceBindingEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceBindingFails() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId("service-instance-id") .build())) .expectError() .verify(); assertThat(this.results.getBeforeCreate()).isNullOrEmpty(); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isEqualTo("before delete service-instance-id"); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isEqualTo("error delete service-instance-id"); }
Example #3
Source File: ServiceInstanceBindingEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceBindingSucceeds() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId("service-instance-id") .bindingId("service-binding-id") .build())) .expectNext(DeleteServiceInstanceBindingResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeCreate()).isNullOrEmpty(); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isEqualTo("before delete service-instance-id"); assertThat(this.results.getAfterDelete()).isEqualTo("after delete service-instance-id"); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
Example #4
Source File: ServiceInstanceBindingControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceBindingParametersAreMappedToRequest() { DeleteServiceInstanceBindingRequest expectedRequest = DeleteServiceInstanceBindingRequest.builder() .asyncAccepted(true) .serviceInstanceId("service-instance-id") .serviceDefinitionId(serviceDefinition.getId()) .planId("plan-id") .bindingId("binding-id") .platformInstanceId("platform-instance-id") .apiInfoLocation("api-info-location") .originatingIdentity(identityContext) .requestIdentity("request-id") .serviceDefinition(serviceDefinition) .plan(plan) .build(); ServiceInstanceBindingController controller = createControllerUnderTest(expectedRequest); controller.deleteServiceInstanceBinding(pathVariables, "service-instance-id", "binding-id", serviceDefinition.getId(), "plan-id", true, "api-info-location", encodeOriginatingIdentity(identityContext), "request-id"); }
Example #5
Source File: MailServiceInstanceBindingServiceUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenServiceBindingDoesNotExist_whenDeleteServiceBinding_thenException() { // given service binding does not exist when(mailService.serviceBindingExists(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)).thenReturn(Mono.just(false)); // when delete service binding DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .bindingId(MAIL_SERVICE_BINDING_ID) .build(); // then ServiceInstanceBindingDoesNotExistException is thrown StepVerifier.create(mailServiceInstanceBindingService.deleteServiceInstanceBinding(request)) .expectErrorMatches(ex -> ex instanceof ServiceInstanceBindingDoesNotExistException) .verify(); }
Example #6
Source File: ServiceInstanceBindingControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
private void validateDeleteServiceBindingWithResponseStatus(DeleteServiceInstanceBindingResponse response, HttpStatus expectedStatus) { Mono<DeleteServiceInstanceBindingResponse> responseMono; if (response == null) { responseMono = Mono.empty(); } else { responseMono = Mono.just(response); } given(bindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class))) .willReturn(responseMono); ResponseEntity<DeleteServiceInstanceBindingResponse> responseEntity = controller .deleteServiceInstanceBinding(pathVariables, null, null, "service-definition-id", "service-definition-plan-id", false, null, null, null) .block(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(expectedStatus); assertThat(responseEntity.getBody()).isEqualTo(response); then(bindingService) .should() .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); }
Example #7
Source File: WorkflowServiceInstanceBindingService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Mono<Void> delete(DeleteServiceInstanceBindingRequest request, DeleteServiceInstanceBindingResponse response) { return stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.IN_PROGRESS, "delete service instance binding started") .thenMany(invokeDeleteWorkflows(request, response) .doOnRequest(l -> { LOG.info("Deleting service instance binding"); LOG.debug("request={}", request); }) .doOnComplete(() -> { LOG.info("Finish deleting service instance binding"); LOG.debug("request={}, response={}", request, response); }) .doOnError(e -> LOG.error(String.format("Error deleting service instance binding. error=%s", e.getMessage()), e))) .thenEmpty(stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.SUCCEEDED, "delete service instance binding completed") .then()) .onErrorResume( exception -> stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.FAILED, exception.getMessage()) .then()); }
Example #8
Source File: BookStoreServiceInstanceBindingService.java From bookstore-service-broker with Apache License 2.0 | 6 votes |
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest request) { return Mono.just(request.getBindingId()) .flatMap(bindingId -> bindingRepository.existsById(bindingId) .flatMap(exists -> { if (exists) { return bindingRepository.deleteById(bindingId) .then(userService.deleteUser(bindingId)) .thenReturn(DeleteServiceInstanceBindingResponse.builder().build()); } else { return Mono.error(new ServiceInstanceBindingDoesNotExistException(bindingId)); } })); }
Example #9
Source File: CredHubPersistingDeleteServiceInstanceBindingWorkflowTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Test void deleteCredentialsFromCredHubWhenNotFound() { DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest .builder() .bindingId("foo-binding-id") .serviceInstanceId("foo-instance-id") .serviceDefinitionId("foo-definition-id") .build(); DeleteServiceInstanceBindingResponseBuilder responseBuilder = DeleteServiceInstanceBindingResponse.builder(); given(this.credHubOperations.credentials()) .willReturn(credHubCredentialOperations); given(this.credHubCredentialOperations.findByName(any())) .willReturn(Flux.fromIterable(Collections.emptyList())); StepVerifier .create(this.workflow.buildResponse(request, responseBuilder)) .expectNext(responseBuilder) .verifyComplete(); verifyNoMoreInteractions(this.credHubCredentialOperations); verifyNoMoreInteractions(this.credHubPermissionOperations); }
Example #10
Source File: BookstoreServiceInstanceBindingServiceTests.java From bookstore-service-broker with Apache License 2.0 | 6 votes |
@Test public void deleteBindingWhenBindingDoesNotExist() { when(repository.existsById(SERVICE_BINDING_ID)) .thenReturn(Mono.just(false)); DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId(SERVICE_INSTANCE_ID) .bindingId(SERVICE_BINDING_ID) .build(); StepVerifier.create(service.deleteServiceInstanceBinding(request)) .expectErrorMatches(e -> e instanceof ServiceInstanceBindingDoesNotExistException) .verify(); verify(repository).existsById(SERVICE_BINDING_ID); verifyNoMoreInteractions(repository); }
Example #11
Source File: TestServiceInstanceBindingService.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest request) { if (IN_PROGRESS_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.error(new ServiceBrokerDeleteOperationInProgressException("task_10")); } if (UNKNOWN_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.error(new ServiceInstanceDoesNotExistException(request.getServiceInstanceId())); } if (UNKNOWN_BINDING_ID.equals(request.getBindingId())) { return Mono.error(new ServiceInstanceBindingDoesNotExistException(request.getBindingId())); } if (request.isAsyncAccepted()) { return Mono.just(DeleteServiceInstanceBindingResponse.builder() .async(true) .operation("working") .build()); } else { return Mono.just(DeleteServiceInstanceBindingResponse.builder() .build()); } }
Example #12
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteBindingWithUnknownInstanceIdFails() { setupCatalogService(); given(serviceInstanceBindingService .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID)); client.delete().uri(buildDeleteUrl()) .exchange() .expectStatus().is4xxClientError() .expectStatus().isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY) .expectBody() .jsonPath("$.description").isNotEmpty() .consumeWith(result -> assertDescriptionContains(result, SERVICE_INSTANCE_ID)); }
Example #13
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteBindingWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .async(true) .operation("working") .build()); client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID, true)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isAccepted() .expectBody() .jsonPath("$.operation").isEqualTo("working"); then(serviceInstanceBindingService) .should() .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }
Example #14
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteBindingFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .build()); client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isOk() .expectBody() .json("{}"); then(serviceInstanceBindingService) .should() .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesSet(actualRequest); }
Example #15
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteBindingWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .build()); client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isOk() .expectBody() .json("{}"); then(serviceInstanceBindingService) .should() .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesSet(actualRequest); }
Example #16
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteBindingWithoutAsyncAndHeadersOperationInProgress() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(new ServiceBrokerDeleteOperationInProgressException("task_10")); MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isAccepted()) .andExpect(jsonPath("$.operation", is("task_10"))); then(serviceInstanceBindingService) .should() .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); verifyDeleteBinding(); }
Example #17
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteBindingWithUnknownBindingIdFails() throws Exception { setupCatalogService(); doThrow(new ServiceInstanceBindingDoesNotExistException(SERVICE_INSTANCE_BINDING_ID)) .when(serviceInstanceBindingService) .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isGone()); }
Example #18
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteBindingWithUnknownInstanceIdFails() throws Exception { setupCatalogService(); doThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID)) .when(serviceInstanceBindingService) .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isUnprocessableEntity()) .andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID))); }
Example #19
Source File: ExampleServiceBindingService.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest request) { String serviceInstanceId = request.getServiceInstanceId(); String bindingId = request.getBindingId(); // // delete any binding-specific credentials // return Mono.just(DeleteServiceInstanceBindingResponse.builder() .async(true) .build()); }
Example #20
Source File: ServiceInstanceBindingControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void deleteServiceBindingWithMissingBindingGivesExpectedStatus() { given(bindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceBindingDoesNotExistException("binding-id")); ResponseEntity<DeleteServiceInstanceBindingResponse> responseEntity = controller .deleteServiceInstanceBinding(pathVariables, null, null, "service-definition-id", "service-definition-plan-id", false, null, null, null) .block(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.GONE); }
Example #21
Source File: ExampleServiceBindingEventFlowsConfiguration2.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceBindingCompletionFlow deleteServiceInstanceBindingCompletionFlow() { return new DeleteServiceInstanceBindingCompletionFlow() { @Override public Mono<Void> complete(DeleteServiceInstanceBindingRequest request, DeleteServiceInstanceBindingResponse response) { // // do something after the service instance binding is deleted // return Mono.empty(); } }; }
Example #22
Source File: ExampleServiceBindingEventFlowsConfiguration2.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceBindingErrorFlow deleteServiceInstanceBindingErrorFlow() { return new DeleteServiceInstanceBindingErrorFlow() { @Override public Mono<Void> error(DeleteServiceInstanceBindingRequest request, Throwable t) { // // do something if an error occurs while deleting a service instance binding // return Mono.empty(); } }; }
Example #23
Source File: ServiceInstanceBindingEventService.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest request) { return flows.getDeleteInstanceBindingRegistry().getInitializationFlows(request) .then(service.deleteServiceInstanceBinding(request)) .onErrorResume(e -> flows.getDeleteInstanceBindingRegistry().getErrorFlows(request, e) .then(Mono.error(e))) .flatMap(response -> flows.getDeleteInstanceBindingRegistry().getCompletionFlows(request, response) .then(Mono.just(response))); }
Example #24
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceBindingCompletionFlow createCompleteFlow() { return new DeleteServiceInstanceBindingCompletionFlow() { @Override public Mono<Void> complete(DeleteServiceInstanceBindingRequest request, DeleteServiceInstanceBindingResponse response) { return Mono.empty(); } }; }
Example #25
Source File: ServiceInstanceBindingEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest request) { if (request.getBindingId() == null) { return Mono.error(new ServiceInstanceBindingDoesNotExistException("service-binding-id")); } return Mono.just(DeleteServiceInstanceBindingResponse.builder().build()); }
Example #26
Source File: MailServiceInstanceBindingService.java From tutorials with MIT License | 5 votes |
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest request) { return mailService.serviceBindingExists(request.getServiceInstanceId(), request.getBindingId()) .flatMap(exists -> { if (exists) { return mailService.deleteServiceBinding(request.getServiceInstanceId()) .thenReturn(DeleteServiceInstanceBindingResponse.builder().build()); } else { return Mono.error(new ServiceInstanceBindingDoesNotExistException(request.getBindingId())); } }); }
Example #27
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceBindingErrorFlow createErrorFlow() { return new DeleteServiceInstanceBindingErrorFlow() { @Override public Mono<Void> error(DeleteServiceInstanceBindingRequest request, Throwable t) { return Mono.empty(); } }; }
Example #28
Source File: WorkflowServiceInstanceBindingService.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest request) { return invokeDeleteResponseBuilders(request) .flatMap(response -> { if (response.isAsync()) { return Mono.just(response).publishOn(Schedulers.parallel()) .doOnNext(r -> delete(request, r) .subscribe()); } else { return delete(request, response).thenReturn(response); } }); }
Example #29
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceBindingInitializationFlow createInitFlow() { return new DeleteServiceInstanceBindingInitializationFlow() { @Override public Mono<Void> initialize(DeleteServiceInstanceBindingRequest request) { return Mono.empty(); } }; }
Example #30
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void deleteBindingWithUnknownBindingIdFails() { setupCatalogService(); given(serviceInstanceBindingService .deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceBindingDoesNotExistException(SERVICE_INSTANCE_BINDING_ID)); client.delete().uri(buildDeleteUrl()) .exchange() .expectStatus().is4xxClientError() .expectStatus().isEqualTo(HttpStatus.GONE); }