Search in sources :

Example 41 with ErrorMessage

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

the class ServiceBrokerWebFluxExceptionHandlerTest method webExchangeBindException.

@Test
void webExchangeBindException() 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);
    WebExchangeBindException exception = new WebExchangeBindException(parameter, bindingResult);
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isNull();
    assertThat(errorMessage.getMessage()).contains("field1");
    assertThat(errorMessage.getMessage()).contains("field2");
}
Also used : MapBindingResult(org.springframework.validation.MapBindingResult) BindingResult(org.springframework.validation.BindingResult) MapBindingResult(org.springframework.validation.MapBindingResult) FieldError(org.springframework.validation.FieldError) Method(java.lang.reflect.Method) MethodParameter(org.springframework.core.MethodParameter) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) WebExchangeBindException(org.springframework.web.bind.support.WebExchangeBindException) 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