use of org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerIntegrationTest method createDuplicateServiceInstanceIdFails.
@Test
void createDuplicateServiceInstanceIdFails() {
setupCatalogService();
setupServiceInstanceService(new ServiceInstanceExistsException(SERVICE_INSTANCE_ID, serviceDefinition.getId()));
client.put().uri(buildCreateUpdateUrl()).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, serviceDefinitionId=%s", SERVICE_INSTANCE_ID, serviceDefinition.getId())));
}
use of org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerIntegrationTest method createDuplicateServiceInstanceIdFails.
@Test
void createDuplicateServiceInstanceIdFails() throws Exception {
setupCatalogService();
setupServiceInstanceService(new ServiceInstanceExistsException(SERVICE_INSTANCE_ID, serviceDefinition.getId()));
MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl()).content(createRequestBody).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isConflict()).andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID)));
}
use of org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerResponseCodeTest method serviceInstanceExistsExceptionGivesExpectedStatus.
@Test
public void serviceInstanceExistsExceptionGivesExpectedStatus() {
ServiceInstanceExistsException exception = new ServiceInstanceExistsException("service-instance-id", "service-definition-id");
ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CONFLICT);
assertThat(responseEntity.getBody().getMessage()).contains("serviceInstanceId=service-instance-id");
assertThat(responseEntity.getBody().getMessage()).contains("serviceDefinitionId=service-definition-id");
}
use of org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerExceptionHandlerTest method serviceInstanceExistsException.
@Test
void serviceInstanceExistsException() {
ServiceInstanceExistsException exception = new ServiceInstanceExistsException("service-instance-id", "service-definition-id");
ErrorMessage errorMessage = exceptionHandler.handleException(exception);
assertThat(errorMessage.getMessage()).contains("serviceInstanceId=service-instance-id");
assertThat(errorMessage.getMessage()).contains("serviceDefinitionId=service-definition-id");
}
Aggregations