@Test public void shouldAddTaskSuccessActivity() { when(taskActivitiesDataService.findById(TASK_ACTIVITY_ID)).thenReturn(createInProgress()); String messageKey = "task.success.ok"; ArgumentCaptor<TaskActivity> captor = ArgumentCaptor.forClass(TaskActivity.class); activityService.addSuccessfulExecution(TASK_ACTIVITY_ID); verify(taskActivitiesDataService).findById(TASK_ACTIVITY_ID); verify(taskActivitiesDataService).update(captor.capture()); TaskActivity activity = captor.getValue(); assertEquals(1, activity.getTaskExecutionProgress().getActionsSucceeded()); assertActivity(messageKey, Collections.<String>emptyList(), TASK_ID, TaskActivityType.SUCCESS, null, null, activity); }
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean addSuccessfulExecution(Long activityId) { TaskActivity activity = taskActivitiesDataService.findById(activityId); if (activity == null) { return false; } TaskExecutionProgress progress = activity.getTaskExecutionProgress(); progress.addSuccess(); return updateTaskProgress(progress, activity); }
TaskActivityServiceImpl implements TaskActivityService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean addSuccessfulExecution(Long activityId) { TaskActivity activity = taskActivitiesDataService.findById(activityId); if (activity == null) { return false; } TaskExecutionProgress progress = activity.getTaskExecutionProgress(); progress.addSuccess(); return updateTaskProgress(progress, activity); } }
TaskActivityServiceImpl implements TaskActivityService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean addSuccessfulExecution(Long activityId) { TaskActivity activity = taskActivitiesDataService.findById(activityId); if (activity == null) { return false; } TaskExecutionProgress progress = activity.getTaskExecutionProgress(); progress.addSuccess(); return updateTaskProgress(progress, activity); } @Autowired  TaskActivityServiceImpl(TaskActivitiesDataService taskActivitiesDataService); }
TaskActivityServiceImpl implements TaskActivityService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean addSuccessfulExecution(Long activityId) { TaskActivity activity = taskActivitiesDataService.findById(activityId); if (activity == null) { return false; } TaskExecutionProgress progress = activity.getTaskExecutionProgress(); progress.addSuccess(); return updateTaskProgress(progress, activity); } @Autowired  TaskActivityServiceImpl(TaskActivitiesDataService taskActivitiesDataService); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) long addTaskStarted(Task task, Map<String, Object> parameters); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addTaskFiltered(Long activityId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) boolean addSuccessfulExecution(Long activityId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addFilteredExecution(Long activityId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addFailedExecution(Long activityId, Throwable e); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addTaskDisabledWarning(Task task); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addWarning(Task task, String key, String field); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addWarningWithException(Task task, String key, String field, Exception e); @Override @Transactional void deleteActivitiesForTask(Long taskId); @Override @Transactional TaskActivity getTaskActivityById(Long activityId); @Override @Transactional List<TaskActivity> getLatestActivities(); @Override @Transactional List<TaskActivity> getAllActivities(Set<TaskActivityType> activityTypes, QueryParams queryParams, boolean lastExecution); @Override @Transactional List<TaskActivity> getAllActivities(Set<TaskActivityType> activityTypes, Range<DateTime> dateRange,
                                               QueryParams queryParams, boolean lastExecution); @Override @Transactional List<TaskActivity> getTaskActivities(Long taskId, Set<TaskActivityType> activityTypes, QueryParams queryParams, boolean lastExecution); @Override @Transactional List<TaskActivity> getTaskActivities(Long taskId, Set<TaskActivityType> activityTypes, Range<DateTime> dateRange,
                                                QueryParams queryParams, boolean lastExecution); @Override @Transactional long getTaskActivitiesCount(Long taskId, Set<TaskActivityType> activityTypes, boolean lastExecution); @Override @Transactional long getTaskActivitiesCount(Long taskId, TaskActivityType type); @Override @Transactional long getTaskActivitiesCount(Long taskId, Set<TaskActivityType> activityTypes, Range<DateTime> dateRange, boolean lastExecution); @Override @Transactional long getAllTaskActivitiesCount(Set<TaskActivityType> activityTypes, boolean lastExecution); @Override @Transactional long getAllTaskActivitiesCount(Set<TaskActivityType> activityTypes, Range<DateTime> dateRange, boolean lastExecution); }
TaskActivityServiceImpl implements TaskActivityService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public boolean addSuccessfulExecution(Long activityId) { TaskActivity activity = taskActivitiesDataService.findById(activityId); if (activity == null) { return false; } TaskExecutionProgress progress = activity.getTaskExecutionProgress(); progress.addSuccess(); return updateTaskProgress(progress, activity); } @Autowired  TaskActivityServiceImpl(TaskActivitiesDataService taskActivitiesDataService); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) long addTaskStarted(Task task, Map<String, Object> parameters); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addTaskFiltered(Long activityId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) boolean addSuccessfulExecution(Long activityId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addFilteredExecution(Long activityId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addFailedExecution(Long activityId, Throwable e); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addTaskDisabledWarning(Task task); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addWarning(Task task, String key, String field); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void addWarningWithException(Task task, String key, String field, Exception e); @Override @Transactional void deleteActivitiesForTask(Long taskId); @Override @Transactional TaskActivity getTaskActivityById(Long activityId); @Override @Transactional List<TaskActivity> getLatestActivities(); @Override @Transactional List<TaskActivity> getAllActivities(Set<TaskActivityType> activityTypes, QueryParams queryParams, boolean lastExecution); @Override @Transactional List<TaskActivity> getAllActivities(Set<TaskActivityType> activityTypes, Range<DateTime> dateRange,
                                               QueryParams queryParams, boolean lastExecution); @Override @Transactional List<TaskActivity> getTaskActivities(Long taskId, Set<TaskActivityType> activityTypes, QueryParams queryParams, boolean lastExecution); @Override @Transactional List<TaskActivity> getTaskActivities(Long taskId, Set<TaskActivityType> activityTypes, Range<DateTime> dateRange,
                                                QueryParams queryParams, boolean lastExecution); @Override @Transactional long getTaskActivitiesCount(Long taskId, Set<TaskActivityType> activityTypes, boolean lastExecution); @Override @Transactional long getTaskActivitiesCount(Long taskId, TaskActivityType type); @Override @Transactional long getTaskActivitiesCount(Long taskId, Set<TaskActivityType> activityTypes, Range<DateTime> dateRange, boolean lastExecution); @Override @Transactional long getAllTaskActivitiesCount(Set<TaskActivityType> activityTypes, boolean lastExecution); @Override @Transactional long getAllTaskActivitiesCount(Set<TaskActivityType> activityTypes, Range<DateTime> dateRange, boolean lastExecution);  }