Search in sources :

Example 1 with ServiceBrokerAsyncRequiredException

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

the class BaseControllerTest method serviceBrokerAsyncRequiredExceptionGivesExpectedStatus.

@Test
public void serviceBrokerAsyncRequiredExceptionGivesExpectedStatus() {
    ServiceBrokerAsyncRequiredException exception = new ServiceBrokerAsyncRequiredException("test message");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
    assertThat(responseEntity.getBody().getError()).isEqualTo(ASYNC_REQUIRED_ERROR);
    assertThat(responseEntity.getBody().getMessage()).contains("test message");
}
Also used : ServiceBrokerAsyncRequiredException(org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Example 2 with ServiceBrokerAsyncRequiredException

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

the class ServiceBrokerExceptionHandlerTest method serviceBrokerAsyncRequiredException.

@Test
void serviceBrokerAsyncRequiredException() {
    ServiceBrokerAsyncRequiredException exception = new ServiceBrokerAsyncRequiredException("test message");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isEqualTo(ASYNC_REQUIRED_ERROR);
    assertThat(errorMessage.getMessage()).contains("test message");
}
Also used : ServiceBrokerAsyncRequiredException(org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.jupiter.api.Test)

Example 3 with ServiceBrokerAsyncRequiredException

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

the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithAsyncRequiredFails.

@Test
void createServiceInstanceWithAsyncRequiredFails() {
    setupCatalogService();
    setupServiceInstanceService(new ServiceBrokerAsyncRequiredException("async required description"));
    client.put().uri(buildCreateUpdateUrl()).contentType(MediaType.APPLICATION_JSON).bodyValue(createRequestBody).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().is4xxClientError().expectStatus().isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY).expectBody().jsonPath("$.error").isEqualTo(ASYNC_REQUIRED_ERROR).jsonPath("$.description").isNotEmpty().consumeWith(result -> assertDescriptionContains(result, "async required description"));
}
Also used : ServiceBrokerAsyncRequiredException(org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with ServiceBrokerAsyncRequiredException

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

the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithAsyncRequiredFails.

@Test
void createServiceInstanceWithAsyncRequiredFails() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(new ServiceBrokerAsyncRequiredException("async required description"));
    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().isUnprocessableEntity()).andExpect(jsonPath("$.error", is(ASYNC_REQUIRED_ERROR))).andExpect(jsonPath("$.description", endsWith("async required description")));
}
Also used : ServiceBrokerAsyncRequiredException(org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ServiceBrokerAsyncRequiredException (org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException)4 Test (org.junit.jupiter.api.Test)3 AbstractServiceInstanceControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest)2 ErrorMessage (org.springframework.cloud.servicebroker.model.error.ErrorMessage)2 Test (org.junit.Test)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1