@Test
public void add() {
TodoDTO formObject = TodoTestUtil.createFormObject(null, TodoTestUtil.DESCRIPTION, TodoTestUtil.TITLE);
Todo model = TodoTestUtil.createModel(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION, TodoTestUtil.TITLE);
when(serviceMock.add(formObject)).thenReturn(model);
MockHttpServletRequest mockRequest = new MockHttpServletRequest("POST", "/todo/add");
BindingResult result = bindAndValidate(mockRequest, formObject);
RedirectAttributesModelMap attributes = new RedirectAttributesModelMap();
initMessageSourceForFeedbackMessage(TodoController.FEEDBACK_MESSAGE_KEY_TODO_ADDED);
String view = controller.add(formObject, result, attributes);
verify(serviceMock, times(1)).add(formObject);
verifyNoMoreInteractions(serviceMock);
String expectedView = TodoTestUtil.createRedirectViewPath(TodoController.REQUEST_MAPPING_TODO_VIEW);
assertEquals(expectedView, view);
assertEquals(Long.valueOf((String) attributes.get(TodoController.PARAMETER_TODO_ID)), model.getId());
assertFeedbackMessage(attributes, TodoController.FEEDBACK_MESSAGE_KEY_TODO_ADDED);
}