@Override
  public void setUp() throws Exception {
    taskList = TasksUiPlugin.getTaskList();

    TaskTestUtil.resetTaskListAndRepositories();
    TasksUiPlugin.getDefault().getLocalTaskRepository();

    cat1 = new TaskCategory("First Category");
    taskList.addCategory(cat1);

    cat1task1 = TasksUiInternal.createNewLocalTask("task 1");
    cat1task1.setPriority(PriorityLevel.P1.toString());
    cat1task1.setCompletionDate(new Date());
    taskList.addTask(cat1task1, cat1);

    cat1task2 = TasksUiInternal.createNewLocalTask("task 2");
    cat1task2.setPriority(PriorityLevel.P2.toString());
    taskList.addTask(cat1task2, cat1);

    assertEquals(cat1.getChildren().size(), 2);

    activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    assertTrue(activePage.closeAllEditors(false));
    assertEquals(0, activePage.getEditorReferences().length);
  }
  public void testDeleteFromCategory() {
    assertEquals(0, taskList.getAllTasks().size());
    assertEquals(0, taskList.getDefaultCategory().getChildren().size());
    // assertEquals(0, taskList.getArchiveContainer().getChildren().size());
    assertEquals(1, taskList.getCategories().size());

    AbstractTask task = new LocalTask("1", "label");
    TaskCategory category = new TaskCategory("handleAndDescription");
    taskList.addTask(task);
    assertEquals(1, taskList.getDefaultCategory().getChildren().size());

    taskList.addCategory(category);
    taskList.addTask(task, category);
    assertEquals(2, taskList.getCategories().size());
    assertEquals(1, category.getChildren().size());
    assertEquals(0, taskList.getDefaultCategory().getChildren().size());
    assertEquals(1, taskList.getAllTasks().size());

    taskList.deleteTask(task);
    assertEquals(0, taskList.getAllTasks().size());
    assertEquals(0, taskList.getDefaultCategory().getChildren().size());
    assertEquals(0, category.getChildren().size());
  }
  public void testMoveToRoot() {
    AbstractTask task1 = new LocalTask("t1", "t1");
    taskList.addTask(
        task1, taskList.getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
    assertEquals(1, taskList.getDefaultCategory().getChildren().size());
    assertEquals(taskList.getDefaultCategory(), TaskCategory.getParentTaskCategory(task1));

    TaskCategory cat1 = new TaskCategory("c1");
    taskList.addCategory(cat1);

    taskList.addTask(task1, cat1);
    assertEquals(0, taskList.getDefaultCategory().getChildren().size());
    assertEquals(cat1, TaskCategory.getParentTaskCategory(task1));

    taskList.addTask(
        task1, taskList.getUnmatchedContainer(LocalRepositoryConnector.REPOSITORY_URL));
    assertEquals(1, taskList.getDefaultCategory().getChildren().size());
    assertEquals(0, cat1.getChildren().size());
    assertEquals(taskList.getDefaultCategory(), TaskCategory.getParentTaskCategory(task1));
  }