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");
}
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);
}
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());
}
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);
}
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);
}
Aggregations