@Test public void testGenerateUpdateActivity6() { User user = new User(); user.setId(ModuleHelper.id); user.setName(ModuleHelper.name); Iteration iteration = getASampleIteration("completed"); Iteration modifiedIteration = getASampleIteration("completed"); when(sessionService.getCurrentUser()).thenReturn(user); Activity activity = iterationActivityGenerator.generateUpdateActivity(iteration, modifiedIteration); verify(sessionService, times(0)).getCurrentUser(); assertNull(activity); }
@Override public Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem) { Iteration original = (Iteration) item; Iteration updated = (Iteration) modifiedItem; Activity activity = null; if (isStartIterration(original, updated)) { activity = generateActivityByActionType(START_ITERATION_ACTION, START_ITERATION_SUBJECT, updated); activity.setContent(String.format(START_ITERATION_CONTENT, dateFormat.format(updated.getStartTime()), dateFormat.format(updated.getEndTime()))); } else if (isCompleteIterration(original, updated)) { activity = generateActivityByActionType(COMPLETE_ITERATION_ACTION, COMPLETE_ITERATION_SUBJECT, updated); } else { String content = getUpdateIterationInfoContent(original, updated); if (!(content == null || content.length() == 0)) { activity = generateActivityByActionType(ActivityActionType.UPDATE, UPDATE_ITERATION_SUBJECT, updated); activity.setContent(content); } } return activity; }
IterationActivityGenerator implements ActivityGenerator { @Override public Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem) { Iteration original = (Iteration) item; Iteration updated = (Iteration) modifiedItem; Activity activity = null; if (isStartIterration(original, updated)) { activity = generateActivityByActionType(START_ITERATION_ACTION, START_ITERATION_SUBJECT, updated); activity.setContent(String.format(START_ITERATION_CONTENT, dateFormat.format(updated.getStartTime()), dateFormat.format(updated.getEndTime()))); } else if (isCompleteIterration(original, updated)) { activity = generateActivityByActionType(COMPLETE_ITERATION_ACTION, COMPLETE_ITERATION_SUBJECT, updated); } else { String content = getUpdateIterationInfoContent(original, updated); if (!(content == null || content.length() == 0)) { activity = generateActivityByActionType(ActivityActionType.UPDATE, UPDATE_ITERATION_SUBJECT, updated); activity.setContent(content); } } return activity; } }
IterationActivityGenerator implements ActivityGenerator { @Override public Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem) { Iteration original = (Iteration) item; Iteration updated = (Iteration) modifiedItem; Activity activity = null; if (isStartIterration(original, updated)) { activity = generateActivityByActionType(START_ITERATION_ACTION, START_ITERATION_SUBJECT, updated); activity.setContent(String.format(START_ITERATION_CONTENT, dateFormat.format(updated.getStartTime()), dateFormat.format(updated.getEndTime()))); } else if (isCompleteIterration(original, updated)) { activity = generateActivityByActionType(COMPLETE_ITERATION_ACTION, COMPLETE_ITERATION_SUBJECT, updated); } else { String content = getUpdateIterationInfoContent(original, updated); if (!(content == null || content.length() == 0)) { activity = generateActivityByActionType(ActivityActionType.UPDATE, UPDATE_ITERATION_SUBJECT, updated); activity.setContent(content); } } return activity; }  }
IterationActivityGenerator implements ActivityGenerator { @Override public Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem) { Iteration original = (Iteration) item; Iteration updated = (Iteration) modifiedItem; Activity activity = null; if (isStartIterration(original, updated)) { activity = generateActivityByActionType(START_ITERATION_ACTION, START_ITERATION_SUBJECT, updated); activity.setContent(String.format(START_ITERATION_CONTENT, dateFormat.format(updated.getStartTime()), dateFormat.format(updated.getEndTime()))); } else if (isCompleteIterration(original, updated)) { activity = generateActivityByActionType(COMPLETE_ITERATION_ACTION, COMPLETE_ITERATION_SUBJECT, updated); } else { String content = getUpdateIterationInfoContent(original, updated); if (!(content == null || content.length() == 0)) { activity = generateActivityByActionType(ActivityActionType.UPDATE, UPDATE_ITERATION_SUBJECT, updated); activity.setContent(content); } } return activity; }  @Override String modelType(); @Override String modelService(); @Override BaseProjectItem enrichModel(BaseProjectItem identifiable); @Override Activity generateCreateActivity(BaseProjectItem item); @Override Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem); }
IterationActivityGenerator implements ActivityGenerator { @Override public Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem) { Iteration original = (Iteration) item; Iteration updated = (Iteration) modifiedItem; Activity activity = null; if (isStartIterration(original, updated)) { activity = generateActivityByActionType(START_ITERATION_ACTION, START_ITERATION_SUBJECT, updated); activity.setContent(String.format(START_ITERATION_CONTENT, dateFormat.format(updated.getStartTime()), dateFormat.format(updated.getEndTime()))); } else if (isCompleteIterration(original, updated)) { activity = generateActivityByActionType(COMPLETE_ITERATION_ACTION, COMPLETE_ITERATION_SUBJECT, updated); } else { String content = getUpdateIterationInfoContent(original, updated); if (!(content == null || content.length() == 0)) { activity = generateActivityByActionType(ActivityActionType.UPDATE, UPDATE_ITERATION_SUBJECT, updated); activity.setContent(content); } } return activity; }  @Override String modelType(); @Override String modelService(); @Override BaseProjectItem enrichModel(BaseProjectItem identifiable); @Override Activity generateCreateActivity(BaseProjectItem item); @Override Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem); static final SimpleDateFormat dateFormat; static final String START_ITERATION_ACTION; static final String COMPLETE_ITERATION_ACTION; static final String CREATE_ITERATION_SUBJECT; static final String UPDATE_ITERATION_SUBJECT; static final String START_ITERATION_SUBJECT; static final String COMPLETE_ITERATION_SUBJECT; static final String UPDATE_ITERATION_NAME_CONTENT; static final String UPDATE_ITERATION_STARTTIME_CONTENT; static final String UPDATE_ITERATION_ENDTIME_CONTENT; static final String START_ITERATION_CONTENT; }