TaskController { @RequestMapping(value = "/task", method = RequestMethod.GET) @ResponseBody public List<TaskDto> getAllTasks() { return taskWebService.getAllTasks(); }  @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 shouldGetAllTasks() { TaskActionInformationDto action = new TaskActionInformationDto("receive", "test", "receiveDisplay", "action1", "action", "0.15", "receive", "serviceInterface", "serviceMethod", new HashMap<>()); TaskTriggerInformationDto trigger = new TaskTriggerInformationDto("send", "trigger1", "trigger", "0.16", "send", "send", "triggerSubject"); List<TaskDto> expected = new ArrayList<>(); expected.add(new TaskDto("name", trigger, asList(action))); expected.add(new TaskDto("name", trigger, asList(action))); expected.add(new TaskDto("name", trigger, asList(action))); when(taskWebService.getAllTasks()).thenReturn(expected); List<TaskDto> actual = controller.getAllTasks(); verify(taskWebService, times(1)).getAllTasks(); assertNotNull(actual); assertEquals(expected, actual); }