@Override public void removeTask(LocalTask task) { if (task.isDefault()) return; if (myActiveTask.equals(task)) { activateTask(myTasks.get(LocalTaskImpl.DEFAULT_TASK_ID), true); } myTasks.remove(task.getId()); myDispatcher.getMulticaster().taskRemoved(task); myContextManager.removeContext(task); }
@Override public LocalTask put(String key, LocalTask task) { LocalTask result = super.put(key, task); if (size() > myConfig.taskHistoryLength) { ArrayList<LocalTask> list = new ArrayList<LocalTask>(values()); Collections.sort(list, TASK_UPDATE_COMPARATOR); for (LocalTask oldest : list) { if (!oldest.isDefault()) { remove(oldest); break; } } } return result; }
public void testInitialState() { assertEquals(1, myTaskManager.getLocalTasks().size()); final LocalTask defaultTask = myTaskManager.getLocalTasks().get(0); assertEquals(defaultTask, myTaskManager.getActiveTask()); assertTrue(defaultTask.isDefault()); assertEquals(1, myChangeListManager.getChangeListsCopy().size()); assertEquals(1, defaultTask.getChangeLists().size()); assertEquals( defaultTask, myTaskManager.getAssociatedTask(myChangeListManager.getChangeListsCopy().get(0))); assertEquals( defaultTask.getChangeLists().get(0).id, myChangeListManager.getChangeListsCopy().get(0).getId()); assertEquals( defaultTask.getChangeLists().get(0), new ChangeListInfo(myChangeListManager.getChangeListsCopy().get(0))); }