Search in sources :

Example 6 with DeleteServiceInstanceRequest

use of org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceControllerIntegrationTest method deleteServiceInstanceFiltersPlansSucceeds.

@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);
}
Also used : DeleteServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 7 with DeleteServiceInstanceRequest

use of org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceControllerIntegrationTest method deleteServiceInstanceFiltersPlansSucceeds.

@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);
}
Also used : DeleteServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 8 with DeleteServiceInstanceRequest

use of org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceControllerIntegrationTest method deleteServiceInstanceWithAsyncAndHeadersSucceeds.

@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);
}
Also used : DeleteServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 9 with DeleteServiceInstanceRequest

use of org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceControllerIntegrationTest method deleteServiceInstanceWithoutAsyncAndHeadersSucceeds.

@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);
}
Also used : DeleteServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 10 with DeleteServiceInstanceRequest

use of org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceControllerRequestTest method deleteServiceInstanceWithInvalidPlanIdThrowsException.

@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());
}
Also used : DeleteServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest) Test(org.junit.jupiter.api.Test)

Aggregations

DeleteServiceInstanceRequest (org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest)10 Test (org.junit.jupiter.api.Test)9 AbstractServiceInstanceControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest)6 MvcResult (org.springframework.test.web.servlet.MvcResult)3 ServiceInstanceDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException)1 ServiceDefinition (org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition)1 DeleteServiceInstanceResponse (org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceResponse)1 ResponseEntity (org.springframework.http.ResponseEntity)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1