org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest.
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: MailServiceInstanceServiceUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenServiceInstanceExists_whenDeleteServiceInstance_thenSuccess() { // given service instance exists when(mailService.serviceInstanceExists(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.just(true)); // when delete service instance when(mailService.deleteServiceInstance(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.empty()); DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .build(); // then success StepVerifier.create(mailServiceInstanceService.deleteServiceInstance(request)) .consumeNextWith(response -> { assertFalse(response.isAsync()); assertNull(response.getOperation()); }) .verifyComplete(); }
Example #2
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceFiltersPlansSucceeds() { setupCatalogService(); setupServiceInstanceService(DeleteServiceInstanceResponse .builder() .build()); client.delete().uri(buildDeleteUrl()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk() .expectBody() .json("{}"); DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo("plan-three-id"); assertHeaderValuesNotSet(actualRequest); }
Example #3
Source File: TestServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest 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(UNKNOWN_SERVICE_INSTANCE_ID)); } if (request.isAsyncAccepted()) { return Mono.just(DeleteServiceInstanceResponse.builder() .async(true) .operation("working") .build()); } else { return Mono.just(DeleteServiceInstanceResponse.builder() .build()); } }
Example #4
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceWithoutAsyncAndHeadersSucceeds() { setupCatalogService(); setupServiceInstanceService(DeleteServiceInstanceResponse.builder() .build()); client.delete().uri(buildDeleteUrl()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk() .expectBody() .json("{}"); DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesNotSet(actualRequest); }
Example #5
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(DeleteServiceInstanceResponse.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()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isAccepted() .expectBody() .jsonPath("$.operation").isEqualTo("working"); DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }
Example #6
Source File: AppDeploymentDeleteServiceInstanceWorkflowTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private DeleteServiceInstanceRequest buildRequest(String serviceName, String planName) { return DeleteServiceInstanceRequest .builder() .serviceDefinitionId(serviceName + "-id") .serviceInstanceId("service-instance-id") .planId(planName + "-id") .serviceDefinition(ServiceDefinition.builder() .id(serviceName + "-id") .name(serviceName) .plans(Plan.builder() .id(planName + "-id") .name(planName) .build()) .build()) .plan(Plan.builder() .id(planName + "-id") .name(planName) .build()) .build(); }
Example #7
Source File: ServiceInstanceControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceParametersAreMappedToRequest() { DeleteServiceInstanceRequest expectedRequest = DeleteServiceInstanceRequest.builder() .asyncAccepted(true) .serviceInstanceId("service-instance-id") .serviceDefinitionId("service-definition-id") .planId("plan-id") .platformInstanceId("platform-instance-id") .apiInfoLocation("api-info-location") .originatingIdentity(identityContext) .requestIdentity("request-id") .serviceDefinition(serviceDefinition) .plan(plan) .build(); ServiceInstanceController controller = createControllerUnderTest(expectedRequest); controller.deleteServiceInstance(pathVariables, "service-instance-id", "service-definition-id", "plan-id", true, "api-info-location", encodeOriginatingIdentity(identityContext), "request-id") .block(); }
Example #8
Source File: AppDeploymentDeleteServiceInstanceWorkflow.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Flux<BackingService> collectBoundBackingServices(DeleteServiceInstanceRequest request) { return backingAppManagementService.getDeployedBackingApplications(request.getServiceInstanceId(), request.getServiceDefinition().getName(), request.getPlan().getName()) .flatMapMany(Flux::fromIterable) .flatMap(backingApplication -> Mono.justOrEmpty(backingApplication.getServices()) .flatMapMany(Flux::fromIterable) .flatMap(servicesSpec -> Mono.justOrEmpty(servicesSpec.getServiceInstanceName())) .map(serviceInstanceName -> { Map<String, String> properties = null; if (!CollectionUtils.isEmpty(backingApplication.getProperties())) { String target = backingApplication.getProperties() .get(DeploymentProperties.TARGET_PROPERTY_KEY); properties = Collections.singletonMap(DeploymentProperties.TARGET_PROPERTY_KEY, target); } return BackingService.builder() .serviceInstanceName(serviceInstanceName) .properties(properties) .build(); })); }
Example #9
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(DeleteServiceInstanceResponse.builder() .build()); MvcResult mvcResult = mockMvc .perform(delete(buildDeleteUrl()) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().string("{}")); DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesNotSet(actualRequest); }
Example #10
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
private void validateDeleteServiceInstanceWithResponseStatus(DeleteServiceInstanceResponse response, HttpStatus expectedStatus) { Mono<DeleteServiceInstanceResponse> responseMono; if (response == null) { responseMono = Mono.empty(); } else { responseMono = Mono.just(response); } given(serviceInstanceService.deleteServiceInstance(any(DeleteServiceInstanceRequest.class))) .willReturn(responseMono); ResponseEntity<DeleteServiceInstanceResponse> responseEntity = controller .deleteServiceInstance(pathVariables, 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); }
Example #11
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(DeleteServiceInstanceResponse.builder() .build()); MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl()) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().string("{}")); DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesNotSet(actualRequest); }
Example #12
Source File: ServiceInstanceEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceSucceeds() { prepareDeleteEventFlows(); StepVerifier .create(serviceInstanceEventService.deleteServiceInstance( DeleteServiceInstanceRequest.builder() .serviceInstanceId("service-instance-id") .serviceDefinitionId("service-def-id") .build())) .expectNext(DeleteServiceInstanceResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeDelete()).isEqualTo("before service-instance-id"); assertThat(this.results.getAfterDelete()).isEqualTo("after service-instance-id"); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
Example #13
Source File: ServiceInstanceEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceFails() { prepareDeleteEventFlows(); StepVerifier .create(serviceInstanceEventService.deleteServiceInstance( DeleteServiceInstanceRequest.builder() .serviceInstanceId("service-instance-id") .build())) .expectError() .verify(); assertThat(this.results.getBeforeDelete()).isEqualTo("before service-instance-id"); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isEqualTo("error service-instance-id"); }
Example #14
Source File: WorkflowServiceInstanceService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Mono<Void> delete(DeleteServiceInstanceRequest request, DeleteServiceInstanceResponse response) { return stateRepository.saveState(request.getServiceInstanceId(), OperationState.IN_PROGRESS, "delete service instance started") .thenMany(invokeDeleteWorkflows(request, response) .doOnRequest(l -> { LOG.info("Deleting service instance"); LOG.debug("request={}", request); }) .doOnComplete(() -> { LOG.info("Finish deleting service instance"); LOG.debug("request={}, response={}", request, response); }) .doOnError(e -> LOG.error(String.format("Error deleting service instance. error=%s", e.getMessage()), e))) .thenEmpty(stateRepository.saveState(request.getServiceInstanceId(), OperationState.SUCCEEDED, "delete service instance completed") .then()) .onErrorResume(e -> stateRepository.saveState(request.getServiceInstanceId(), OperationState.FAILED, e.getMessage()) .then()); }
Example #15
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void deleteServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(DeleteServiceInstanceResponse.builder() .async(true) .operation("working") .build()); MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl(PLATFORM_INSTANCE_ID, true)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isAccepted()) .andExpect(jsonPath("$.operation", equalTo("working"))); DeleteServiceInstanceRequest actualRequest = verifyDeleteServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }
Example #16
Source File: ExampleServiceInstanceEventFlowsConfiguration2.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceErrorFlow deleteServiceInstanceErrorFlow() { return new DeleteServiceInstanceErrorFlow() { @Override public Mono<Void> error(DeleteServiceInstanceRequest request, Throwable t) { // // do something if an error occurs while deleting the instance // return Mono.empty(); } }; }
Example #17
Source File: ServiceInstanceControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void deleteServiceInstanceWithInvalidPlanIdThrowsException() { DeleteServiceInstanceRequest expectedRequest = DeleteServiceInstanceRequest.builder() .asyncAccepted(true) .serviceDefinitionId("service-definition-id") .planId("unknown-plan-id") .build(); ServiceInstanceController controller = createControllerUnderTest(expectedRequest); assertThrows(ServiceDefinitionPlanDoesNotExistException.class, () -> controller.deleteServiceInstance(pathVariables, null, "service-definition-id", "unknown-plan-id", true, null, encodeOriginatingIdentity(identityContext), "request-id") .block()); }
Example #18
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void deleteServiceInstanceWithMissingInstanceGivesExpectedStatus() { given(serviceInstanceService.deleteServiceInstance(any(DeleteServiceInstanceRequest.class))) .willReturn(Mono.error(new ServiceInstanceDoesNotExistException("instance does not exist"))); ResponseEntity<DeleteServiceInstanceResponse> responseEntity = controller .deleteServiceInstance(pathVariables, null, "service-definition-id", "service-definition-plan-id", false, null, null, null) .block(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.GONE); }
Example #19
Source File: ExampleServiceInstanceEventFlowsConfiguration2.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceInitializationFlow deleteServiceInstanceInitializationFlow() { return new DeleteServiceInstanceInitializationFlow() { @Override public Mono<Void> initialize( DeleteServiceInstanceRequest request) { // // do something before the instance is deleted // return Mono.empty(); } }; }
Example #20
Source File: Fixtures.java From ecs-cf-service-broker with Apache License 2.0 | 5 votes |
public static DeleteServiceInstanceRequest namespaceDeleteRequestFixture() { return DeleteServiceInstanceRequest.builder() .serviceDefinitionId(NAMESPACE_SERVICE_ID) .planId(NAMESPACE_PLAN_ID1) .serviceInstanceId(NAMESPACE) .build(); }
Example #21
Source File: ExampleServiceInstanceEventFlowsConfiguration2.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceCompletionFlow deleteServiceInstanceCompletionFlow() { return new DeleteServiceInstanceCompletionFlow() { @Override public Mono<Void> complete(DeleteServiceInstanceRequest request, DeleteServiceInstanceResponse response) { // // do something after the instance is deleted // return Mono.empty(); } }; }
Example #22
Source File: ServiceInstanceEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance( DeleteServiceInstanceRequest request) { if (request.getServiceDefinitionId() == null) { return Mono.error(new ServiceInstanceDoesNotExistException("service-instance-id")); } return Mono.just(DeleteServiceInstanceResponse.builder().build()); }
Example #23
Source File: MailServiceInstanceService.java From tutorials with MIT License | 5 votes |
@Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest request) { return Mono.just(request.getServiceInstanceId()) .flatMap(instanceId -> mailService.serviceInstanceExists(instanceId) .flatMap(exists -> { if (exists) { return mailService.deleteServiceInstance(instanceId) .thenReturn(DeleteServiceInstanceResponse.builder().build()); } else { return Mono.error(new ServiceInstanceDoesNotExistException(instanceId)); } })); }
Example #24
Source File: MailServiceInstanceServiceUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenServiceInstanceDoesNotExist_whenDeleteServiceInstance_thenException() { // given service instance does not exist when(mailService.serviceInstanceExists(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.just(false)); // when delete service instance DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .build(); // then ServiceInstanceDoesNotExistException is thrown StepVerifier.create(mailServiceInstanceService.deleteServiceInstance(request)) .expectErrorMatches(ex -> ex instanceof ServiceInstanceDoesNotExistException) .verify(); }
Example #25
Source File: ServiceInstanceControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void deleteServiceInstanceWithInvalidServiceDefinitionIdThrowsException() { DeleteServiceInstanceRequest expectedRequest = DeleteServiceInstanceRequest.builder() .asyncAccepted(true) .serviceDefinitionId("service-definition-id") .planId("plan-id") .build(); ServiceInstanceController controller = createControllerUnderTest(expectedRequest); assertThrows(ServiceDefinitionDoesNotExistException.class, () -> controller.deleteServiceInstance(pathVariables, null, "unknown-service-definition-id", null, true, null, encodeOriginatingIdentity(identityContext), "request-id") .block()); }
Example #26
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceErrorFlow deleteErrorFlow2() { return new DeleteServiceInstanceErrorFlow() { @Override public Mono<Void> error(DeleteServiceInstanceRequest request, Throwable t) { return Mono.empty(); } }; }
Example #27
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceErrorFlow deleteErrorFlow1() { return new DeleteServiceInstanceErrorFlow() { @Override public Mono<Void> error(DeleteServiceInstanceRequest request, Throwable t) { return Mono.empty(); } }; }
Example #28
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceCompletionFlow deleteCompleteFlow() { return new DeleteServiceInstanceCompletionFlow() { @Override public Mono<Void> complete(DeleteServiceInstanceRequest request, DeleteServiceInstanceResponse response) { return Mono.empty(); } }; }
Example #29
Source File: Fixtures.java From ecs-cf-service-broker with Apache License 2.0 | 5 votes |
public static DeleteServiceInstanceRequest bucketDeleteRequestFixture() { return DeleteServiceInstanceRequest.builder() .serviceDefinitionId(BUCKET_SERVICE_ID) .serviceInstanceId(BUCKET_NAME) .planId(BUCKET_PLAN_ID1) .build(); }
Example #30
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public DeleteServiceInstanceInitializationFlow deleteInitFlow() { return new DeleteServiceInstanceInitializationFlow() { @Override public Mono<Void> initialize(DeleteServiceInstanceRequest request) { return Mono.empty(); } }; }