@Test public void shouldGetTaskActivities() { when(taskWebService.getTaskActivities(eq(TASK_ID), anySet(), any(QueryParams.class), anyBoolean())).thenReturn(expected); GridSettings settings = new GridSettings(); settings.setPage(page); settings.setRows(pageSize); TaskActivityRecords actual = controller.getTaskActivities(TASK_ID, settings); verify(taskWebService).getTaskActivities(eq(TASK_ID), anySet(), any(QueryParams.class), anyBoolean()); assertEquals(expected, actual.getRows()); assertEquals(page, actual.getPage()); }
@RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET) @ResponseBody public TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings) { if (settings != null) { QueryParams params = getParams(settings); Set<TaskActivityType> types = settings.getTypesFromString(); Range<DateTime> dateTimeRange = settings.convertToDateRange(settings.getDateTimeFrom(), settings.getDateTimeTo()); List<TaskActivityDto> activities; long count; if (dateTimeRange != null) { activities = taskWebService.getTaskActivities(taskId, types, dateTimeRange, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, dateTimeRange, settings.isLastExecution()); } else { activities = taskWebService.getTaskActivities(taskId, types, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, settings.isLastExecution()); } int totalPages = (int) Math.ceil((double) count / settings.getRows()); return new TaskActivityRecords(settings.getPage(), totalPages, count, activities); } else { return null; } }
ActivityController { @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET) @ResponseBody public TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings) { if (settings != null) { QueryParams params = getParams(settings); Set<TaskActivityType> types = settings.getTypesFromString(); Range<DateTime> dateTimeRange = settings.convertToDateRange(settings.getDateTimeFrom(), settings.getDateTimeTo()); List<TaskActivityDto> activities; long count; if (dateTimeRange != null) { activities = taskWebService.getTaskActivities(taskId, types, dateTimeRange, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, dateTimeRange, settings.isLastExecution()); } else { activities = taskWebService.getTaskActivities(taskId, types, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, settings.isLastExecution()); } int totalPages = (int) Math.ceil((double) count / settings.getRows()); return new TaskActivityRecords(settings.getPage(), totalPages, count, activities); } else { return null; } } }
ActivityController { @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET) @ResponseBody public TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings) { if (settings != null) { QueryParams params = getParams(settings); Set<TaskActivityType> types = settings.getTypesFromString(); Range<DateTime> dateTimeRange = settings.convertToDateRange(settings.getDateTimeFrom(), settings.getDateTimeTo()); List<TaskActivityDto> activities; long count; if (dateTimeRange != null) { activities = taskWebService.getTaskActivities(taskId, types, dateTimeRange, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, dateTimeRange, settings.isLastExecution()); } else { activities = taskWebService.getTaskActivities(taskId, types, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, settings.isLastExecution()); } int totalPages = (int) Math.ceil((double) count / settings.getRows()); return new TaskActivityRecords(settings.getPage(), totalPages, count, activities); } else { return null; } } @Autowired  ActivityController(final TaskActivityService activityService, TriggerHandler taskTriggerHandler, TaskWebService taskWebService); }
ActivityController { @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET) @ResponseBody public TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings) { if (settings != null) { QueryParams params = getParams(settings); Set<TaskActivityType> types = settings.getTypesFromString(); Range<DateTime> dateTimeRange = settings.convertToDateRange(settings.getDateTimeFrom(), settings.getDateTimeTo()); List<TaskActivityDto> activities; long count; if (dateTimeRange != null) { activities = taskWebService.getTaskActivities(taskId, types, dateTimeRange, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, dateTimeRange, settings.isLastExecution()); } else { activities = taskWebService.getTaskActivities(taskId, types, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, settings.isLastExecution()); } int totalPages = (int) Math.ceil((double) count / settings.getRows()); return new TaskActivityRecords(settings.getPage(), totalPages, count, activities); } else { return null; } } @Autowired  ActivityController(final TaskActivityService activityService, TriggerHandler taskTriggerHandler, TaskWebService taskWebService); @RequestMapping(value = "/activity", method = RequestMethod.GET) @ResponseBody List<TaskActivityDto> getRecentActivities(); @RequestMapping(value = "/activity/all", method = RequestMethod.GET) @ResponseBody TaskActivityRecords getAllActivities(GridSettings settings); @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET) @ResponseBody TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings); @RequestMapping(value = "/activity/{taskId}/{activityType}", method = RequestMethod.GET) @ResponseBody long getTaskActivityCount(@PathVariable Long taskId, @PathVariable String activityType); @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteActivitiesForTask(@PathVariable Long taskId); @RequestMapping(value = "/activity/retry/{activityId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) void retryTask(@PathVariable Long activityId); @RequestMapping(value = "/activity/retryMultiple", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) void retryMultipleTasks(@RequestBody List<Long> activityIds); }
ActivityController { @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET) @ResponseBody public TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings) { if (settings != null) { QueryParams params = getParams(settings); Set<TaskActivityType> types = settings.getTypesFromString(); Range<DateTime> dateTimeRange = settings.convertToDateRange(settings.getDateTimeFrom(), settings.getDateTimeTo()); List<TaskActivityDto> activities; long count; if (dateTimeRange != null) { activities = taskWebService.getTaskActivities(taskId, types, dateTimeRange, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, dateTimeRange, settings.isLastExecution()); } else { activities = taskWebService.getTaskActivities(taskId, types, params, settings.isLastExecution()); count = activityService.getTaskActivitiesCount(taskId, types, settings.isLastExecution()); } int totalPages = (int) Math.ceil((double) count / settings.getRows()); return new TaskActivityRecords(settings.getPage(), totalPages, count, activities); } else { return null; } } @Autowired  ActivityController(final TaskActivityService activityService, TriggerHandler taskTriggerHandler, TaskWebService taskWebService); @RequestMapping(value = "/activity", method = RequestMethod.GET) @ResponseBody List<TaskActivityDto> getRecentActivities(); @RequestMapping(value = "/activity/all", method = RequestMethod.GET) @ResponseBody TaskActivityRecords getAllActivities(GridSettings settings); @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.GET) @ResponseBody TaskActivityRecords getTaskActivities(@PathVariable Long taskId, GridSettings settings); @RequestMapping(value = "/activity/{taskId}/{activityType}", method = RequestMethod.GET) @ResponseBody long getTaskActivityCount(@PathVariable Long taskId, @PathVariable String activityType); @RequestMapping(value = "/activity/{taskId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteActivitiesForTask(@PathVariable Long taskId); @RequestMapping(value = "/activity/retry/{activityId}", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) void retryTask(@PathVariable Long activityId); @RequestMapping(value = "/activity/retryMultiple", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) void retryMultipleTasks(@RequestBody List<Long> activityIds);  }