use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerIntegrationTest method createBindingWithDuplicateIdFails.
@Test
void createBindingWithDuplicateIdFails() {
setupCatalogService();
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))).willThrow(new ServiceInstanceBindingExistsException(SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID));
client.put().uri(buildCreateUrl()).contentType(MediaType.APPLICATION_JSON).bodyValue(createRequestBody).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().is4xxClientError().expectStatus().isEqualTo(HttpStatus.CONFLICT).expectBody().jsonPath("$.description").isNotEmpty().consumeWith(result -> assertDescriptionContains(result, String.format("serviceInstanceId=%s, bindingId=%s", SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID)));
}
use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerIntegrationTest method createBindingWithDuplicateIdFails.
@Test
void createBindingWithDuplicateIdFails() throws Exception {
setupCatalogService();
given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))).willThrow(new ServiceInstanceBindingExistsException(SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID));
MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl()).content(createRequestBody).accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isConflict()).andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID))).andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_BINDING_ID)));
}
use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerResponseCodeTest method bindingExistsGivesExpectedStatus.
@Test
public void bindingExistsGivesExpectedStatus() {
ResponseEntity<ErrorMessage> responseEntity = controller.handleException(new ServiceInstanceBindingExistsException("service-instance-id", "binding-id"));
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CONFLICT);
assertThat(responseEntity.getBody().getError()).isNull();
assertThat(responseEntity.getBody().getMessage()).contains("serviceInstanceId=service-instance-id").contains("bindingId=binding-id");
}
use of org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerExceptionHandlerTest method bindingExistsException.
@Test
void bindingExistsException() {
ErrorMessage errorMessage = exceptionHandler.handleException(new ServiceInstanceBindingExistsException("service-instance-id", "binding-id"));
assertThat(errorMessage.getError()).isNull();
assertThat(errorMessage.getMessage()).contains("serviceInstanceId=service-instance-id").contains("bindingId=binding-id");
}
Aggregations