Search in sources :

Example 1 with ServiceBrokerException

use of org.springframework.cloud.servicebroker.exception.ServiceBrokerException 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 2 with ServiceBrokerException

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

the class ServiceBrokerExceptionHandlerTest method serviceBrokerException.

@Test
void serviceBrokerException() {
    ServiceBrokerException exception = new ServiceBrokerException("test message");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isNull();
    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)

Example 3 with ServiceBrokerException

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

the class BaseControllerTest method serviceBrokerExceptionGivesExpectedStatus.

@Test
public void serviceBrokerExceptionGivesExpectedStatus() {
    ServiceBrokerException exception = new ServiceBrokerException("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 : ServiceBrokerException(org.springframework.cloud.servicebroker.exception.ServiceBrokerException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Example 4 with ServiceBrokerException

use of org.springframework.cloud.servicebroker.exception.ServiceBrokerException 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

ServiceBrokerException (org.springframework.cloud.servicebroker.exception.ServiceBrokerException)4 ErrorMessage (org.springframework.cloud.servicebroker.model.error.ErrorMessage)4 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2