@Test public void findAll_ShouldReturnTodoList() { Todo model = TodoTestUtil.createModel(TodoTestUtil.ID, TodoTestUtil.DESCRIPTION, TodoTestUtil.TITLE); List<Todo> expected = createModels(model); when(serviceMock.findAll()).thenReturn(expected); List<TodoDTO> actual = controller.findAll(); verify(serviceMock, times(1)).findAll(); verifyNoMoreInteractions(serviceMock); verifyZeroInteractions(localeHolderWrapperMock, messageSourceMock); assertTodos(expected, actual); }
@RequestMapping(value = "/api/todo", method = RequestMethod.GET) @ResponseBody public List<TodoDTO> findAll() { LOGGER.debug("Finding all todo entries."); List<Todo> models = service.findAll(); LOGGER.debug("Found {} to-do entries.", models.size()); return createDTOs(models); }
TodoController { @RequestMapping(value = "/api/todo", method = RequestMethod.GET) @ResponseBody public List<TodoDTO> findAll() { LOGGER.debug("Finding all todo entries."); List<Todo> models = service.findAll(); LOGGER.debug("Found {} to-do entries.", models.size()); return createDTOs(models); } }
TodoController { @RequestMapping(value = "/api/todo", method = RequestMethod.GET) @ResponseBody public List<TodoDTO> findAll() { LOGGER.debug("Finding all todo entries."); List<Todo> models = service.findAll(); LOGGER.debug("Found {} to-do entries.", models.size()); return createDTOs(models); }  }
TodoController { @RequestMapping(value = "/api/todo", method = RequestMethod.GET) @ResponseBody public List<TodoDTO> findAll() { LOGGER.debug("Finding all todo entries."); List<Todo> models = service.findAll(); LOGGER.debug("Found {} to-do entries.", models.size()); return createDTOs(models); }  @RequestMapping(value = "/api/todo", method = RequestMethod.POST) @ResponseBody TodoDTO add(@RequestBody TodoDTO dto); @RequestMapping(value = "/api/todo/search/count/{searchTerm}", method = RequestMethod.GET) @ResponseBody long countSearchResults(@PathVariable("searchTerm") String searchTerm); @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.DELETE) @ResponseBody TodoDTO deleteById(@PathVariable("id") Long id); @RequestMapping(value = "/api/todo", method = RequestMethod.GET) @ResponseBody List<TodoDTO> findAll(); @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.GET) @ResponseBody TodoDTO findById(@PathVariable("id") Long id); @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.PUT) @ResponseBody TodoDTO update(@RequestBody TodoDTO dto, @PathVariable("id") Long todoId); @ExceptionHandler(FormValidationError.class) @ResponseBody @ResponseStatus(HttpStatus.BAD_REQUEST) FormValidationErrorDTO handleFormValidationError(FormValidationError validationError); @RequestMapping(value = "/api/todo/search/{searchTerm}", method = RequestMethod.GET) @ResponseBody List<TodoDTO> search(@PathVariable("searchTerm") String searchTerm, Pageable page); @ExceptionHandler(TodoNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) void handleTodoNotFoundException(TodoNotFoundException ex); }
TodoController { @RequestMapping(value = "/api/todo", method = RequestMethod.GET) @ResponseBody public List<TodoDTO> findAll() { LOGGER.debug("Finding all todo entries."); List<Todo> models = service.findAll(); LOGGER.debug("Found {} to-do entries.", models.size()); return createDTOs(models); }  @RequestMapping(value = "/api/todo", method = RequestMethod.POST) @ResponseBody TodoDTO add(@RequestBody TodoDTO dto); @RequestMapping(value = "/api/todo/search/count/{searchTerm}", method = RequestMethod.GET) @ResponseBody long countSearchResults(@PathVariable("searchTerm") String searchTerm); @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.DELETE) @ResponseBody TodoDTO deleteById(@PathVariable("id") Long id); @RequestMapping(value = "/api/todo", method = RequestMethod.GET) @ResponseBody List<TodoDTO> findAll(); @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.GET) @ResponseBody TodoDTO findById(@PathVariable("id") Long id); @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.PUT) @ResponseBody TodoDTO update(@RequestBody TodoDTO dto, @PathVariable("id") Long todoId); @ExceptionHandler(FormValidationError.class) @ResponseBody @ResponseStatus(HttpStatus.BAD_REQUEST) FormValidationErrorDTO handleFormValidationError(FormValidationError validationError); @RequestMapping(value = "/api/todo/search/{searchTerm}", method = RequestMethod.GET) @ResponseBody List<TodoDTO> search(@PathVariable("searchTerm") String searchTerm, Pageable page); @ExceptionHandler(TodoNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) void handleTodoNotFoundException(TodoNotFoundException ex);  }