public void testScheduledTaskSorting() { final TaskListInterestSorter sorter = new TaskListInterestSorter(); MockTask task1 = new MockTask("local", "MYLN:1", "1"); MockTask task2 = new MockTask("local", "MYLN:2", "2"); Calendar start1 = TaskActivityUtil.getCalendar(); start1.add(Calendar.WEEK_OF_YEAR, -1); TaskActivityUtil.snapStartOfWorkWeek(start1); Calendar end1 = TaskActivityUtil.getCalendar(); end1.setTimeInMillis(start1.getTimeInMillis()); TaskActivityUtil.snapEndOfWeek(end1); WeekDateRange range1 = new WeekDateRange(start1, end1); TasksUiPlugin.getTaskActivityManager().setScheduledFor(task1, range1); Calendar start2 = TaskActivityUtil.getCalendar(); start2.add(Calendar.HOUR_OF_DAY, -1); Calendar end2 = TaskActivityUtil.getCalendar(); DateRange range2 = new DateRange(start2, end2); TasksUiPlugin.getTaskActivityManager().setScheduledFor(task2, range2); assertTrue(sorter.compare(new EmptyViewer(), task1, task2) < 0); }
protected static boolean hasActivity(ITask task, Date startDate, Date endDate) { Calendar startCal = Calendar.getInstance(); startCal.setTime(startDate); Calendar endCal = Calendar.getInstance(); endCal.setTime(endDate); return TasksUiPlugin.getTaskActivityManager().getElapsedTime(task, startCal, endCal) > 0; // IInteractionContext interactionContext = ContextCorePlugin.getContextManager().loadContext( // task.getHandleIdentifier()); // if (interactionContext != null) { // List<InteractionEvent> events = interactionContext.getInteractionHistory(); // if (events.size() > 0) { // InteractionEvent latestEvent = events.get(events.size() - 1); // if (latestEvent.getDate().compareTo(startDate) > 0) { // return true; // } // } // } // return false; }