TodoActivityGenerator implements ActivityGenerator { @Override public Activity generateUpdateActivity(BaseProjectItem item, BaseProjectItem modifiedItem) { Todo todo = (Todo) item; Todo modifiedTodo = (Todo) modifiedItem; if (modifiedTodo.getDeleted() != null && todo.getDeleted() != modifiedTodo.getDeleted()) { if (modifiedTodo.getDeleted()) { return generateActivityByActionType(ActivityActionType.DISCARD, DISCARD_SUBJECT, todo); } else { return generateActivityByActionType(ActivityActionType.RECOVER, RECOVER_SUBJECT, todo); } } else if (modifiedTodo.getStatus() != null && !todo.getStatus().equals(modifiedTodo.getStatus())) { return generateUpdateStatusActivity(todo, modifiedTodo); } else if (modifiedTodo.getTodoType() != null && !todo.getTodoType().equals(modifiedTodo.getTodoType())) { return generateUpdateTodoTypeActivity(todo, modifiedTodo); } else { logger.info("To move todo..."); return generateUpdateActivityWithContent(todo, modifiedTodo); } }  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 testGenerateUpdateActivity() { Todo originTodo = new Todo(todo); Todo modifiedTodo = new Todo(todo); modifiedTodo.setDeleted(true); Activity ret = todoActivityGenerator.generateUpdateActivity(originTodo, modifiedTodo); assertEquals(ret.getAction(), ActivityActionType.DISCARD); assertEquals(ret.getCompanyId(), new Integer(todo.getCompanyId())); assertEquals(ret.getProjectId(), new Integer(todo.getProjectId())); assertEquals(ret.getTarget(), todo.getContent()); ret = todoActivityGenerator.generateUpdateActivity(modifiedTodo, originTodo); assertEquals(ret.getAction(), ActivityActionType.RECOVER); assertEquals(ret.getCompanyId(), new Integer(todo.getCompanyId())); assertEquals(ret.getProjectId(), new Integer(todo.getProjectId())); assertEquals(ret.getTarget(), todo.getContent()); modifiedTodo = new Todo(originTodo); modifiedTodo.setContent(originTodo.getContent() + "modified"); ret = todoActivityGenerator.generateUpdateActivity(originTodo, modifiedTodo); assertEquals(ret.getAction(), ActivityActionType.UPDATE); assertEquals(ret.getCompanyId(), new Integer(todo.getCompanyId())); assertEquals(ret.getProjectId(), new Integer(todo.getProjectId())); }