@Test
public void shouldCreateValidationErrorsForBindException() {
BindingResult bindingResult = mock(BindingResult.class);
ApiError someFieldError = testProjectApiErrors.getMissingExpectedContentApiError();
ApiError otherFieldError = testProjectApiErrors.getTypeConversionApiError();
List<ObjectError> errorsList = Arrays.<ObjectError>asList(
new FieldError("someObj", "someField", someFieldError.getName()),
new FieldError("otherObj", "otherField", otherFieldError.getName()));
when(bindingResult.getAllErrors()).thenReturn(errorsList);
BindException ex = new BindException(bindingResult);
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(ex);
validateResponse(result, true, Arrays.asList(
new ApiErrorWithMetadata(someFieldError, Pair.of("field", (Object)"someField")),
new ApiErrorWithMetadata(otherFieldError, Pair.of("field", (Object)"otherField"))
));
verify(bindingResult).getAllErrors();
}
ConventionBasedSpringValidationErrorToApiErrorHandlerListenerTest.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:backstopper
作者:
评论列表
文章目录