TaskController { @RequestMapping(value = "/task/{taskId}", method = RequestMethod.GET) @ResponseBody public TaskDto getTask(@PathVariable Long taskId) { return taskWebService.getTask(taskId); }  @RequestMapping(value = "/task", method = RequestMethod.GET) @ResponseBody List<TaskDto> getAllTasks(); @RequestMapping(value = "/task/import", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) void importTask(@RequestParam(value = "file") MultipartFile file); @RequestMapping(value = "/task/{taskId}", method = RequestMethod.GET) @ResponseBody TaskDto getTask(@PathVariable Long taskId); @RequestMapping(value = "/task/{taskId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @ResponseBody Set<TaskErrorDto> saveTask(@RequestBody Task task); @RequestMapping(value = "/task/enable-or-disable/{taskId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @ResponseBody void setTaskEnabledOrDisabled(@RequestBody Task task); @RequestMapping(value = "/task/{taskId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteTask(@PathVariable Long taskId); @RequestMapping(value = "/task/{taskId}/export", method = RequestMethod.GET) void exportTask(@PathVariable Long taskId, HttpServletResponse response); @RequestMapping(value = "/task/save", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) @ResponseBody Set<TaskErrorDto> save(@RequestBody Task task); @ExceptionHandler(ValidationException.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody Set<TaskErrorDto> handleException(ValidationException e); @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody String handleException(Exception e);  }
@Test public void shouldGetTaskWithId() { TaskDto expected = new TaskDto(); expected.setId(TASK_ID); when(taskWebService.getTask(expected.getId())).thenReturn(expected); TaskDto actual = controller.getTask(expected.getId()); verify(taskWebService).getTask(expected.getId()); assertNotNull(actual); assertEquals(expected.getId(), actual.getId()); }