Search in sources :

Example 6 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 serviceBrokerInvalidParametersExceptionGivesExpectedStatus.

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

Example 7 with ErrorMessage

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

the class ServiceInstanceBindingControllerResponseCodeTest method appRequiredExistsGivesExpectedStatus.

@Test
public void appRequiredExistsGivesExpectedStatus() {
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(new ServiceBrokerBindingRequiresAppException("app GUID is required"));
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
    assertThat(responseEntity.getBody().getError()).isEqualTo(APP_REQUIRED_ERROR);
    assertThat(responseEntity.getBody().getMessage()).contains("app GUID is required");
}
Also used : ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) ServiceBrokerBindingRequiresAppException(org.springframework.cloud.servicebroker.exception.ServiceBrokerBindingRequiresAppException) Test(org.junit.Test)

Example 8 with ErrorMessage

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

the class ServiceBrokerExceptionHandlerTest method unknownException.

@Test
void unknownException() {
    Exception exception = new Exception("test message");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isNull();
    assertThat(errorMessage.getMessage()).contains("test message");
}
Also used : ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) ServiceBrokerInvalidParametersException(org.springframework.cloud.servicebroker.exception.ServiceBrokerInvalidParametersException) ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) ServiceBrokerInvalidOriginatingIdentityException(org.springframework.cloud.servicebroker.exception.ServiceBrokerInvalidOriginatingIdentityException) ServiceDefinitionDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceDefinitionDoesNotExistException) ServiceBrokerAsyncRequiredException(org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException) ServiceBrokerBindingRequiresAppException(org.springframework.cloud.servicebroker.exception.ServiceBrokerBindingRequiresAppException) 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) ServiceInstanceBindingExistsException(org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException) ServiceBrokerApiVersionException(org.springframework.cloud.servicebroker.exception.ServiceBrokerApiVersionException) ServiceInstanceBindingDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException) ServiceInstanceExistsException(org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException) ServiceInstanceUpdateNotSupportedException(org.springframework.cloud.servicebroker.exception.ServiceInstanceUpdateNotSupportedException) ServiceDefinitionPlanDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceDefinitionPlanDoesNotExistException) Test(org.junit.jupiter.api.Test)

Example 9 with ErrorMessage

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

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

the class ServiceBrokerExceptionHandlerTest method serviceBrokerUnavailableException.

@Test
void serviceBrokerUnavailableException() {
    ServiceBrokerUnavailableException exception = new ServiceBrokerUnavailableException("maintenance in progress");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isNull();
    assertThat(errorMessage.getMessage()).contains("maintenance in progress");
}
Also used : ServiceBrokerUnavailableException(org.springframework.cloud.servicebroker.exception.ServiceBrokerUnavailableException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.jupiter.api.Test)

Aggregations

ErrorMessage (org.springframework.cloud.servicebroker.model.error.ErrorMessage)41 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)18 ServiceBrokerException (org.springframework.cloud.servicebroker.exception.ServiceBrokerException)6 Method (java.lang.reflect.Method)5 MethodParameter (org.springframework.core.MethodParameter)5 ServiceBrokerApiVersionException (org.springframework.cloud.servicebroker.exception.ServiceBrokerApiVersionException)4 ServiceBrokerAsyncRequiredException (org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException)4 ServiceBrokerConcurrencyException (org.springframework.cloud.servicebroker.exception.ServiceBrokerConcurrencyException)4 ServiceBrokerInvalidParametersException (org.springframework.cloud.servicebroker.exception.ServiceBrokerInvalidParametersException)4 ServiceBrokerOperationInProgressException (org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException)4 ServiceBrokerUnavailableException (org.springframework.cloud.servicebroker.exception.ServiceBrokerUnavailableException)4 ServiceDefinitionDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceDefinitionDoesNotExistException)4 ServiceInstanceDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException)4 BindingResult (org.springframework.validation.BindingResult)4 FieldError (org.springframework.validation.FieldError)4 MapBindingResult (org.springframework.validation.MapBindingResult)4 ServiceBrokerBindingRequiresAppException (org.springframework.cloud.servicebroker.exception.ServiceBrokerBindingRequiresAppException)3 ServiceDefinitionPlanDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceDefinitionPlanDoesNotExistException)3 ServiceInstanceBindingExistsException (org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException)3