Search in sources :

Example 1 with ErrorMessage

use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.

the class BaseControllerTest method unknownExceptionGivesExpectedStatus.

@Test
public void unknownExceptionGivesExpectedStatus() {
    Exception exception = new Exception("test message");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
    assertThat(responseEntity.getBody().getError()).isNull();
    assertThat(responseEntity.getBody().getMessage()).contains("test message");
}
Also used : ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) ServiceBrokerInvalidParametersException(org.springframework.cloud.servicebroker.exception.ServiceBrokerInvalidParametersException) ServiceBrokerUnavailableException(org.springframework.cloud.servicebroker.exception.ServiceBrokerUnavailableException) ServiceBrokerOperationInProgressException(org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException) ServiceBrokerConcurrencyException(org.springframework.cloud.servicebroker.exception.ServiceBrokerConcurrencyException) ServiceBrokerException(org.springframework.cloud.servicebroker.exception.ServiceBrokerException) WebExchangeBindException(org.springframework.web.bind.support.WebExchangeBindException) ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) ServiceDefinitionDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceDefinitionDoesNotExistException) ServiceBrokerAsyncRequiredException(org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException) MethodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException) HttpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException) ServiceBrokerApiVersionException(org.springframework.cloud.servicebroker.exception.ServiceBrokerApiVersionException) Test(org.junit.Test)

Example 2 with ErrorMessage

use of org.springframework.cloud.servicebroker.model.error.ErrorMessage 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 3 with ErrorMessage

use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.

the class BaseControllerTest method serviceInstanceDoesNotExistExceptionGivesExpectedStatus.

@Test
public void serviceInstanceDoesNotExistExceptionGivesExpectedStatus() {
    ServiceInstanceDoesNotExistException exception = new ServiceInstanceDoesNotExistException("service-instance-id");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
    assertThat(responseEntity.getBody().getError()).isNull();
    assertThat(responseEntity.getBody().getMessage()).contains("id=service-instance-id");
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Example 4 with ErrorMessage

use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.

the class BaseControllerTest method serviceBrokerExceptionWithErrorCodeGivesExpectedStatus.

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

Example 5 with ErrorMessage

use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.

the class BaseControllerTest method serviceDefinitionDoesNotExistExceptionGivesExpectedStatus.

@Test
public void serviceDefinitionDoesNotExistExceptionGivesExpectedStatus() {
    ServiceDefinitionDoesNotExistException exception = new ServiceDefinitionDoesNotExistException("service-definition-id");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
    assertThat(responseEntity.getBody().getError()).isNull();
    assertThat(responseEntity.getBody().getMessage()).contains("id=service-definition-id");
}
Also used : ServiceDefinitionDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceDefinitionDoesNotExistException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Aggregations

ErrorMessage (org.springframework.cloud.servicebroker.model.error.ErrorMessage)19 Test (org.junit.Test)18 ServiceBrokerException (org.springframework.cloud.servicebroker.exception.ServiceBrokerException)3 Method (java.lang.reflect.Method)2 ServiceBrokerApiVersionException (org.springframework.cloud.servicebroker.exception.ServiceBrokerApiVersionException)2 ServiceBrokerAsyncRequiredException (org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException)2 ServiceBrokerConcurrencyException (org.springframework.cloud.servicebroker.exception.ServiceBrokerConcurrencyException)2 ServiceBrokerInvalidParametersException (org.springframework.cloud.servicebroker.exception.ServiceBrokerInvalidParametersException)2 ServiceBrokerOperationInProgressException (org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException)2 ServiceBrokerUnavailableException (org.springframework.cloud.servicebroker.exception.ServiceBrokerUnavailableException)2 ServiceDefinitionDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceDefinitionDoesNotExistException)2 ServiceInstanceDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException)2 MethodParameter (org.springframework.core.MethodParameter)2 HttpMessageNotReadableException (org.springframework.http.converter.HttpMessageNotReadableException)2 BindingResult (org.springframework.validation.BindingResult)2 FieldError (org.springframework.validation.FieldError)2 MapBindingResult (org.springframework.validation.MapBindingResult)2 MethodArgumentNotValidException (org.springframework.web.bind.MethodArgumentNotValidException)2 WebExchangeBindException (org.springframework.web.bind.support.WebExchangeBindException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1