use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerWebMvcExceptionHandlerTest method stringParameterIsNotPresent.
@Test
void stringParameterIsNotPresent() {
final String parameterType = "String";
final String parameterName = "plan_id";
MissingServletRequestParameterException exception = new MissingServletRequestParameterException(parameterName, parameterType);
ErrorMessage errorMessage = exceptionHandler.handleException(exception);
assertThat(errorMessage.getError()).isNull();
assertThat(errorMessage.getMessage()).contains(parameterType);
assertThat(errorMessage.getMessage()).contains(parameterName);
}
use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerWebMvcExceptionHandlerTest method methodArgumentNotValidException.
@Test
void methodArgumentNotValidException() throws NoSuchMethodException {
BindingResult bindingResult = new MapBindingResult(new HashMap<>(), "objectName");
bindingResult.addError(new FieldError("objectName", "field1", "message"));
bindingResult.addError(new FieldError("objectName", "field2", "message"));
Method method = this.getClass().getMethod("setUp", (Class<?>[]) null);
MethodParameter parameter = new MethodParameter(method, -1);
MethodArgumentNotValidException exception = new MethodArgumentNotValidException(parameter, bindingResult);
ErrorMessage errorMessage = exceptionHandler.handleException(exception);
assertThat(errorMessage.getError()).isNull();
assertThat(errorMessage.getMessage()).contains("field1");
assertThat(errorMessage.getMessage()).contains("field2");
}
use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerExceptionHandlerTest method serviceDefinitionPlanDoesNotExistExceptionWithCustomCode.
@Test
void serviceDefinitionPlanDoesNotExistExceptionWithCustomCode() {
final String errorCode = "error";
ServiceDefinitionPlanDoesNotExistException exception = new ServiceDefinitionPlanDoesNotExistException(errorCode, "service-definition-plan-id");
ErrorMessage errorMessage = exceptionHandler.handleException(exception);
assertThat(errorMessage.getError()).isEqualTo(errorCode);
assertThat(errorMessage.getMessage()).contains("Service Definition Plan does not exist: " + "id=service-definition-plan-id");
}
use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerExceptionHandlerTest method operationInProgressException.
@Test
void operationInProgressException() {
ServiceBrokerOperationInProgressException exception = new ServiceBrokerOperationInProgressException("task_10");
ErrorMessage errorMessage = exceptionHandler.handleException(exception);
assertThat(errorMessage.getError()).isNull();
assertThat(errorMessage.getMessage()).contains("task_10");
}
use of org.springframework.cloud.servicebroker.model.error.ErrorMessage in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerExceptionHandlerTest method serviceInstanceExistsException.
@Test
void serviceInstanceExistsException() {
ServiceInstanceExistsException exception = new ServiceInstanceExistsException("service-instance-id", "service-definition-id");
ErrorMessage errorMessage = exceptionHandler.handleException(exception);
assertThat(errorMessage.getMessage()).contains("serviceInstanceId=service-instance-id");
assertThat(errorMessage.getMessage()).contains("serviceDefinitionId=service-definition-id");
}
Aggregations