TodoActivityGenerator implements ActivityGenerator { @Override public Activity generateCreateActivity(BaseProjectItem item) { Todo todo = (Todo) item; String subject = String.format(CREATE_SUBJECT, TODO_TYPE_MAP.get(todo.getTodoType())); if (todo.getComments() != null) { subject = COPY_SUBJECT; } Activity activity = generateActivityByActionType(ActivityActionType.CREATE, subject, todo); User user = null; if (todo.getAssigneeId() != null) { user = userService.getById(todo.getAssigneeId()); } if (todo.getAssigneeId() != null && todo.getDueDate() != null) { activity.setContent(String.format(ASSIGNEE_AND_DUEDATE_SET, user.getName(), dateFormat.format(todo.getDueDate()))); } else if (todo.getAssigneeId() != null) { activity.setContent(String.format(ASSIGNEE_SET, user.getName())); } else if (todo.getDueDate() != null) { activity.setContent(String.format(DUEDATE_SET, dateFormat.format(todo.getDueDate()))); } return activity; }  String appendString(String str, String toAppend); @Override String modelType(); @Override Activity generateCreateActivity(BaseProjectItem item); @Override Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem); @Override BaseProjectItem enrichModel(BaseProjectItem identifiable); @Override String modelService(); static final int MAX_CONTENT_LENGTH; static final String CREATE_SUBJECT; static final String COPY_SUBJECT; static final String UPDATE_SUBJECT; static final String STATUS_SUBJECT; static final String TODOTYPE_SUBJECT; static final String DISCARD_SUBJECT; static final String RECOVER_SUBJECT; static final String MOVE_SUBJECT; static final String RELOCATE_SUBJECT; static final String DOING_SUBJECT; static final String UNDOING_SUBJECT; static final String ASSIGNEE_SET; static final String DUEDATE_SET; static final String ASSIGNEE_AND_DUEDATE_SET; static final String ASSIGNEE_UPDATE; static final String DUEDATE_UPDATE; static final String NAME_UPDATE; static final String TODOLIST_MOVE; static final String PROJECT_MOVE; static final String STATUS_UPDATE_CONTENT; static final String STATUS_UPDATE_TODOTYPE_CONTENT; static final String ASSIGNEE_NULL; static final String DUEDATE_NULL; static final SimpleDateFormat dateFormat; }
@Test public void testGenerateCreateActivity() { Activity ret = todoActivityGenerator.generateCreateActivity(todo); assertEquals(ret.getAction(), ActivityActionType.CREATE); assertEquals(ret.getCompanyId(), new Integer(todo.getCompanyId())); assertEquals(ret.getProjectId(), new Integer(todo.getProjectId())); assertEquals(ret.getTarget(), todo.getContent()); assertNotNull(ret.getContent()); }