assertEquals(ERROR_MESSAGE_EMPTY_TODO_TITLE, titleFieldErrorDTO.getMessage());
}
@Test
public void handleFormValidationErrorWhenErrorMessagesAreNotFound() {
FieldError titleError = createFieldError(OBJECT_NAME, FIELD_TITLE, ERROR_MESSAGE_CODE_EMPTY_TODO_TITLE);
FieldError descriptionError = createFieldError(OBJECT_NAME, FIELD_DESCRIPTION, ERROR_MESSAGE_CODE_TOO_LONG_DESCRIPTION);
List<FieldError> errors = new ArrayList<FieldError>();
errors.add(titleError);
errors.add(descriptionError);
FormValidationError validationError = new FormValidationError(errors);
when(localeHolderWrapperMock.getCurrentLocale()).thenReturn(Locale.US);
when(messageSourceMock.getMessage(ERROR_MESSAGE_CODE_EMPTY_TODO_TITLE, titleError.getArguments(), Locale.US)).thenReturn(ERROR_MESSAGE_CODE_EMPTY_TODO_TITLE);
when(messageSourceMock.getMessage(ERROR_MESSAGE_CODE_TOO_LONG_DESCRIPTION, descriptionError.getArguments(), Locale.US)).thenReturn(ERROR_MESSAGE_CODE_TOO_LONG_DESCRIPTION);
FormValidationErrorDTO dto = controller.handleFormValidationError(validationError);
verify(localeHolderWrapperMock, times(1)).getCurrentLocale();
verifyNoMoreInteractions(localeHolderWrapperMock);
verify(messageSourceMock, times(1)).getMessage(ERROR_MESSAGE_CODE_EMPTY_TODO_TITLE, titleError.getArguments(), Locale.US);
verify(messageSourceMock, times(1)).getMessage(ERROR_MESSAGE_CODE_TOO_LONG_DESCRIPTION, descriptionError.getArguments(), Locale.US);
verifyNoMoreInteractions(messageSourceMock);
verifyZeroInteractions(serviceMock);
List<FieldValidationErrorDTO> fieldErrorDTOs = dto.getFieldErrors();