ServiceBrokerWebFluxExceptionHandler extends ServiceBrokerExceptionHandler { @ExceptionHandler(WebExchangeBindException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public ErrorMessage handleException(WebExchangeBindException ex) { return handleBindingException(ex, ex.getBindingResult()); }  @ExceptionHandler(WebExchangeBindException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) ErrorMessage handleException(WebExchangeBindException ex); @ExceptionHandler(ServerWebInputException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) ErrorMessage handleException(ServerWebInputException ex);  }
@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"); }
@Test void stringParameterIsNotPresent() throws NoSuchMethodException { Method method = this.getClass().getMethod("setUp", (Class<?>[]) null); MethodParameter parameter = new MethodParameter(method, -1); ServerWebInputException exception = new ServerWebInputException("reason", parameter); ErrorMessage errorMessage = exceptionHandler.handleException(exception); assertThat(errorMessage.getError()).isNull(); assertThat(errorMessage.getMessage()).contains("reason"); }