Search in sources :

Example 16 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 serviceBrokerInvalidParametersException.

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

Example 17 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 serviceBrokerApiVersionException.

@Test
void serviceBrokerApiVersionException() {
    ServiceBrokerApiVersionException exception = new ServiceBrokerApiVersionException("expected-version", "actual-version");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isNull();
    assertThat(errorMessage.getMessage()).contains("expected version=expected-version");
    assertThat(errorMessage.getMessage()).contains("provided version=actual-version");
}
Also used : ServiceBrokerApiVersionException(org.springframework.cloud.servicebroker.exception.ServiceBrokerApiVersionException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.jupiter.api.Test)

Example 18 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 serviceBrokerApiVersionExceptionGivesExpectedStatus.

@Test
public void serviceBrokerApiVersionExceptionGivesExpectedStatus() {
    ServiceBrokerApiVersionException exception = new ServiceBrokerApiVersionException("expected-version", "actual-version");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.PRECONDITION_FAILED);
    assertThat(responseEntity.getBody().getError()).isNull();
    assertThat(responseEntity.getBody().getMessage()).contains("expected version=expected-version");
    assertThat(responseEntity.getBody().getMessage()).contains("provided version=actual-version");
}
Also used : ServiceBrokerApiVersionException(org.springframework.cloud.servicebroker.exception.ServiceBrokerApiVersionException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Example 19 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 serviceBrokerConcurrencyExceptionGivesExpectedStatus.

@Test
public void serviceBrokerConcurrencyExceptionGivesExpectedStatus() {
    ServiceBrokerConcurrencyException exception = new ServiceBrokerConcurrencyException("operation in progress");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);
    assertThat(responseEntity.getBody().getError()).isEqualTo(CONCURRENCY_ERROR);
    assertThat(responseEntity.getBody().getMessage()).contains("operation in progress");
}
Also used : ServiceBrokerConcurrencyException(org.springframework.cloud.servicebroker.exception.ServiceBrokerConcurrencyException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Example 20 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 operationInProgressExceptionGivesExpectedStatus.

@Test
public void operationInProgressExceptionGivesExpectedStatus() {
    ServiceBrokerOperationInProgressException exception = new ServiceBrokerOperationInProgressException("still working");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
    assertThat(responseEntity.getBody().getError()).isNull();
    assertThat(responseEntity.getBody().getMessage()).contains("still working");
}
Also used : ServiceBrokerOperationInProgressException(org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.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