Search in sources :

Example 1 with DeleteServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingSucceeds.

@Test
public void deleteBindingSucceeds() throws Exception {
    setupCatalogService();
    mockMvc.perform(delete(buildDeleteUrl(PLATFORM_INSTANCE_ID)).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(jsonPath("$", is("{}")));
    verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
    DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding();
    assertHeaderValuesSet(actualRequest);
}
Also used : DeleteServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.Test)

Example 2 with DeleteServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingFiltersPlansSucceeds.

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

Example 3 with DeleteServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingFiltersPlansSucceeds.

@Test
void deleteBindingFiltersPlansSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder().build());
    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().isOk()).andExpect(content().string("{}"));
    then(serviceInstanceBindingService).should().deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
    DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
    assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId());
    assertHeaderValuesSet(actualRequest);
}
Also used : DeleteServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with DeleteServiceInstanceBindingRequest

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

the class ServiceInstanceBindingController method deleteServiceInstanceBinding.

@DeleteMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}/service_bindings/{bindingId}", "/v2/service_instances/{instanceId}/service_bindings/{bindingId}" })
public ResponseEntity<String> deleteServiceInstanceBinding(@PathVariable Map<String, String> pathVariables, @PathVariable(INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @PathVariable(BINDING_ID_PATH_VARIABLE) String bindingId, @RequestParam(SERVICE_ID_PARAMETER) String serviceDefinitionId, @RequestParam(PLAN_ID_PARAMETER) String planId, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString) {
    DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder().serviceInstanceId(serviceInstanceId).bindingId(bindingId).serviceDefinitionId(serviceDefinitionId).planId(planId).serviceDefinition(getServiceDefinition(serviceDefinitionId)).platformInstanceId(pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE)).apiInfoLocation(apiInfoLocation).originatingIdentity(parseOriginatingIdentity(originatingIdentityString)).build();
    LOGGER.debug("Deleting a service instance binding: request={}", request);
    try {
        serviceInstanceBindingService.deleteServiceInstanceBinding(request);
    } catch (ServiceInstanceBindingDoesNotExistException e) {
        LOGGER.debug(e.getMessage(), e);
        return new ResponseEntity<>("{}", HttpStatus.GONE);
    }
    LOGGER.debug("Deleting a service instance binding succeeded: bindingId={}", bindingId);
    return new ResponseEntity<>("{}", HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ServiceInstanceBindingDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException) DeleteServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 5 with DeleteServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingSucceeds.

@Test
public void deleteBindingSucceeds() throws Exception {
    setupCatalogService();
    client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID)).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).exchange().expectStatus().isOk().expectBody().json("{}");
    verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
    DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding();
    assertHeaderValuesSet(actualRequest);
}
Also used : DeleteServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.Test)

Aggregations

DeleteServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest)10 AbstractServiceInstanceBindingControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest)8 Test (org.junit.jupiter.api.Test)7 MvcResult (org.springframework.test.web.servlet.MvcResult)3 Test (org.junit.Test)2 ServiceInstanceBindingDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException)1 ResponseEntity (org.springframework.http.ResponseEntity)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1