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");
}
Aggregations