Search in sources :

Example 1 with ServiceInstanceBindingDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceBrokerExceptionHandlerTest method bindingDoesNotExistException.

@Test
void bindingDoesNotExistException() {
    ErrorMessage errorMessage = exceptionHandler.handleException(new ServiceInstanceBindingDoesNotExistException("binding-id"));
    assertThat(errorMessage.getError()).isNull();
    assertThat(errorMessage.getMessage()).contains("id=binding-id");
}
Also used : ServiceInstanceBindingDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.jupiter.api.Test)

Example 2 with ServiceInstanceBindingDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingWithUnknownBindingIdFails.

@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);
}
Also used : ServiceInstanceBindingDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException) 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 ServiceInstanceBindingDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingWithUnknownBindingIdFails.

@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());
}
Also used : ServiceInstanceBindingDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException) 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 ServiceInstanceBindingDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException 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 ServiceInstanceBindingDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerResponseCodeTest method deleteServiceBindingWithMissingBindingGivesExpectedStatus.

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

Aggregations

ServiceInstanceBindingDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException)6 Test (org.junit.jupiter.api.Test)5 DeleteServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest)4 AbstractServiceInstanceBindingControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest)2 DeleteServiceInstanceBindingResponse (org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingResponse)1 GetServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest)1 GetServiceInstanceBindingResponse (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse)1 ErrorMessage (org.springframework.cloud.servicebroker.model.error.ErrorMessage)1 ResponseEntity (org.springframework.http.ResponseEntity)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1