Search in sources :

Example 26 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 bindingExistsGivesExpectedStatus.

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

Example 27 with ErrorMessage

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

the class ServiceInstanceControllerResponseCodeTest method serviceInstanceUpdateNotSupportedExceptionGivesExpectedStatus.

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

Example 28 with ErrorMessage

use of org.springframework.cloud.servicebroker.model.error.ErrorMessage 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");
}
Also used : ServiceInstanceExistsException(org.springframework.cloud.servicebroker.exception.ServiceInstanceExistsException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Example 29 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 serviceInstanceUpdateNotSupportedException.

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

Example 30 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 serviceBrokerExceptionWithErrorCode.

@Test
void serviceBrokerExceptionWithErrorCode() {
    ServiceBrokerException exception = new ServiceBrokerException("ErrorCode", "test message");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isEqualTo("ErrorCode");
    assertThat(errorMessage.getMessage()).contains("test message");
}
Also used : ServiceBrokerException(org.springframework.cloud.servicebroker.exception.ServiceBrokerException) 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