Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-06-27 17:12:48 -0400
committermkersten2005-06-27 17:12:48 -0400
commit9fa4576e36e0ed40d7b1e9e3379eb977186a3224 (patch)
tree6fa543d2c86e7a3d0b1f529c8602a020c44e6830 /org.eclipse.mylyn.tasks.tests/src
parentb72040c93d6ffcb1b53cd1dc9ee6f2e488819ef5 (diff)
downloadorg.eclipse.mylyn.tasks-9fa4576e36e0ed40d7b1e9e3379eb977186a3224.tar.gz
org.eclipse.mylyn.tasks-9fa4576e36e0ed40d7b1e9e3379eb977186a3224.tar.xz
org.eclipse.mylyn.tasks-9fa4576e36e0ed40d7b1e9e3379eb977186a3224.zip
Applied Ken's patch for Bugzilla Bug 101561
Categories and Tasks should be different
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java29
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java65
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java106
3 files changed, 129 insertions, 71 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
index ccb6e297b..01eac4a6a 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
@@ -24,9 +24,8 @@ import org.eclipse.mylar.core.search.IActiveSearchListener;
import org.eclipse.mylar.core.tests.support.WorkspaceSetupHelper;
import org.eclipse.mylar.core.tests.support.search.SearchPluginTestHelper;
import org.eclipse.mylar.tasks.BugzillaTask;
-import org.eclipse.mylar.tasks.ITask;
+import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
-import org.eclipse.mylar.tasks.Task;
import org.eclipse.mylar.tasks.TaskList;
import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState;
import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode;
@@ -215,26 +214,26 @@ public class BugzillaSearchPluginTest extends TestCase{
TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
MylarTasksPlugin.getTaskListManager().setTaskList(t);
- ITask cat = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Testing Category");
- t.addRootTask(cat);
+ Category cat = new Category("Testing Category");
+ t.addCategory(cat);
BugzillaTask bugTask1 = new BugzillaTask(bugPrefix +94185, "<bugzilla info>");
- cat.addSubtask(bugTask1);
+ cat.addTask(bugTask1);
while(bugTask1.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask2 = new BugzillaTask(bugPrefix + 3692, "<bugzilla info>");
- bugTask1.addSubtask(bugTask2);
+ cat.addTask(bugTask2);
while(bugTask2.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask3 = new BugzillaTask(bugPrefix + 3693, "<bugzilla info>");
- cat.addSubtask(bugTask3);
+ cat.addTask(bugTask3);
while(bugTask3.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask4 = new BugzillaTask(bugPrefix + 9583, "<bugzilla info>");
- bugTask3.addSubtask(bugTask4);
+ cat.addTask(bugTask4);
while(bugTask4.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
@@ -265,7 +264,7 @@ public class BugzillaSearchPluginTest extends TestCase{
assertEquals("Results not the right size", 3, c.size());
MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
- MylarTasksPlugin.getTaskListManager().deleteTask(cat);
+ MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat);
}
//TODO need to test a bug that wraps...should fail since we can only search on a single line
@@ -277,21 +276,21 @@ public class BugzillaSearchPluginTest extends TestCase{
TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
MylarTasksPlugin.getTaskListManager().setTaskList(t);
- ITask cat = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Testing Category");
- t.addRootTask(cat);
+ Category cat = new Category("Testing Category");
+ t.addCategory(cat);
BugzillaTask bugTask1 = new BugzillaTask(bugPrefix + 94185, "<bugzilla info>");
- cat.addSubtask(bugTask1);
+ cat.addTask(bugTask1);
while(bugTask1.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask2 = new BugzillaTask(bugPrefix + 9583, "<bugzilla info>");
- bugTask1.addSubtask(bugTask2);
+ cat.addTask(bugTask2);
while(bugTask2.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
BugzillaTask bugTask3 = new BugzillaTask(bugPrefix + 3693, "<bugzilla info>");
- cat.addSubtask(bugTask3);
+ cat.addTask(bugTask3);
while(bugTask3.getState() != BugTaskState.FREE){
Thread.sleep(500);
}
@@ -323,7 +322,7 @@ public class BugzillaSearchPluginTest extends TestCase{
assertEquals("Results not the right size", 1, c.size());
MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType);
- MylarTasksPlugin.getTaskListManager().deleteTask(cat);
+ MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat);
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
index c5ce152db..492df5ec5 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
@@ -13,12 +13,16 @@
*/
package org.eclipse.mylar.tasks.tests;
+import java.util.List;
import java.io.File;
import junit.framework.TestCase;
+import org.eclipse.mylar.tasks.Category;
+import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.TaskList;
import org.eclipse.mylar.tasks.TaskListManager;
/**
@@ -31,20 +35,59 @@ public class TaskListManagerTest extends TestCase {
file.deleteOnExit();
TaskListManager manager = new TaskListManager(file);
- manager.createNewTaskList();
-// Category category = taskList.createCategory("category");
+ TaskList tlist = manager.getTaskList();
Task task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
-// category.addTask(task1);
- task1.addSubtask(new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1"));
- assertEquals(task1.getChildren().size(), 1);
+ tlist.addRootTask(task1);
+ Task sub1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub 1");
+ task1.addSubTask(sub1);
+ sub1.setParent(task1);
+ Task task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 2");
+ tlist.addRootTask(task2);
+
+ Category cat1 = new Category("Category 1");
+ tlist.addCategory(cat1);
+ Task task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 3");
+ cat1.addTask(task3);
+ Task sub2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub 2");
+ task3.addSubTask(sub2);
+ sub2.setParent(task3);
+ Task task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 4");
+ cat1.addTask(task4);
+
+ Category cat2 = new Category("Category 2");
+ tlist.addCategory(cat2);
+ Task task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 5");
+ cat2.addTask(task5);
+ Task task6 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 6");
+ cat2.addTask(task6);
+
+ assertEquals(manager.getTaskList().getRoots().size(), 4);
manager.saveTaskList();
assertNotNull(manager.getTaskList());
- manager.setTaskList(null);
-// manager.readTaskList();
-// assertNotNull(manager.getTaskList());
-// assertEquals(manager.getTaskList().getCategories().size(), 1);
-// assertEquals(manager.getTaskList().findCategory("category").getTasks().size(), 1);
-// assertEquals(manager.getTaskList().findCategory("category").getTasks().get(0).getLabel(), "task 1");
+ TaskList list = new TaskList();
+ manager.setTaskList(list);
+ manager.readTaskList();
+ assertNotNull(manager.getTaskList());
+ assertEquals(manager.getTaskList().getRootTasks().size(), 2);
+ assertEquals(manager.getTaskList().getCategories().size(), 2);
+ check(manager);
+ }
+
+ public boolean check(TaskListManager manager) {
+ List<ITask> list = manager.getTaskList().getRootTasks();
+ assertTrue(list.get(0).getLabel().equals("task 1"));
+ assertTrue(list.get(0).getChildren().get(0).getLabel().equals("sub 1"));
+ assertTrue(list.get(1).getLabel().equals("task 2"));
+
+ List<Category> clist = manager.getTaskList().getCategories();
+ list = clist.get(0).getTasks();
+ assertTrue(list.get(0).getLabel().equals("task 3"));
+ assertTrue(list.get(0).getChildren().get(0).getLabel().equals("sub 2"));
+ assertTrue(list.get(1).getLabel().equals("task 4"));
+ list = clist.get(1).getTasks();
+ assertTrue(list.get(0).getLabel().equals("task 5"));
+ assertTrue(list.get(1).getLabel().equals("task 6"));
+ return true;
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
index 1bdcd3ed3..254914ffa 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
@@ -19,6 +19,7 @@ import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
@@ -36,19 +37,21 @@ import org.eclipse.ui.PartInitException;
*/
public class TaskListUiTest extends TestCase {
private TaskList tlist = null;
- private Task cat1 = null;
+ private Category cat1 = null;
private Task cat1task1 = null;
private Task cat1task2 = null;
private Task cat1task3 = null;
private Task cat1task4 = null;
private Task cat1task5 = null;
+ private Task cat1task1sub1 = null;
- private Task cat2 = null;
+ private Category cat2 = null;
private Task cat2task1 = null;
private Task cat2task2 = null;
private Task cat2task3 = null;
private Task cat2task4 = null;
private Task cat2task5 = null;
+ private Task cat2task1sub1 = null;
private final static int CHECK_COMPLETE_FILTER = 1;
@@ -60,61 +63,80 @@ public class TaskListUiTest extends TestCase {
File file = new File("foo" + MylarTasksPlugin.FILE_EXTENSION);
TaskListManager manager = new TaskListManager(file);
tlist = manager.createNewTaskList();
- cat1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "First Category");
- cat1.setIsCategory(true);
+ cat1 = new Category("First Category");
- cat1task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat1task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
cat1task1.setPriority("P1");
cat1task1.setCompleted(true);
- cat1.addSubtask(cat1task1);
+ cat1task1.setCategory(cat1);
+ cat1.addTask(cat1task1);
- cat1task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 2");
+ cat1task1sub1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat1task1sub1.setPriority("P1");
+ cat1task1sub1.setCompleted(true);
+ cat1task1sub1.setParent(cat1task1);
+ cat1task1.addSubTask(cat1task1sub1);
+
+ cat1task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 2");
cat1task2.setPriority("P2");
- cat1.addSubtask(cat1task2);
+ cat1task2.setCategory(cat1);
+ cat1.addTask(cat1task2);
- cat1task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 3");
+ cat1task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 3");
cat1task3.setPriority("P3");
cat1task3.setCompleted(true);
- cat1.addSubtask(cat1task3);
+ cat1task3.setCategory(cat1);
+ cat1.addTask(cat1task3);
- cat1task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 4");
+ cat1task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 4");
cat1task4.setPriority("P4");
- cat1.addSubtask(cat1task4);
+ cat1task4.setCategory(cat1);
+ cat1.addTask(cat1task4);
- cat1task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 5");
+ cat1task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 5");
cat1task5.setPriority("P5");
cat1task5.setCompleted(true);
- cat1.addSubtask(cat1task5);
+ cat1task5.setCategory(cat1);
+ cat1.addTask(cat1task5);
- tlist.addRootTask(cat1);
- assertEquals(cat1.getChildren().size(), 5);
+ tlist.addCategory(cat1);
+ assertEquals(cat1.getTasks().size(), 5);
- cat2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "Second Category");
- cat2.setIsCategory(true);
+ cat2 = new Category("Second Category");
- cat2task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat2task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
cat2task1.setPriority("P1");
- cat2.addSubtask(cat2task1);
+ cat2task1.setCategory(cat2);
+ cat2.addTask(cat2task1);
+
+ cat2task1sub1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 1");
+ cat2task1sub1.setPriority("P1");
+ cat2task1sub1.setParent(cat2task1);
+ cat2task1.addSubTask(cat2task1sub1);
- cat2task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 2");
+ cat2task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 2");
cat2task2.setPriority("P2");
cat2task2.setCompleted(true);
- cat2.addSubtask(cat2task2);
+ cat2task2.setCategory(cat2);
+ cat2.addTask(cat2task2);
- cat2task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 3");
+ cat2task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 3");
cat2task3.setPriority("P3");
- cat2.addSubtask(cat2task3);
+ cat2task3.setCategory(cat2);
+ cat2.addTask(cat2task3);
- cat2task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 4");
+ cat2task4 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 4");
cat2task4.setPriority("P4");
cat2task4.setCompleted(true);
- cat2.addSubtask(cat2task4);
+ cat2task4.setCategory(cat2);
+ cat2.addTask(cat2task4);
- cat2task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub task 5");
+ cat2task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 5");
cat2task5.setPriority("P5");
- cat2.addSubtask(cat2task5);
+ cat2task5.setCategory(cat2);
+ cat2.addTask(cat2task5);
- tlist.addRootTask(cat2);
+ tlist.addCategory(cat2);
manager.saveTaskList();
}
@@ -169,10 +191,7 @@ public class TaskListUiTest extends TestCase {
assertTrue(items.length == 2);
int count = 0;
for (int i = 0; i < items.length; i++) {
- assertTrue(items[i].getData() instanceof ITask);
- ITask cat = (ITask) items[i].getData();
- assertTrue(cat.isCategory());
-
+ assertTrue(items[i].getData() instanceof Category);
TreeItem[] sub = items[i].getItems();
for (int j = 0; j < sub.length; j++) {
assertTrue(sub[j].getData() instanceof ITask);
@@ -194,10 +213,7 @@ public class TaskListUiTest extends TestCase {
int p2Count = 0;
int p5Count = 0;
for (int i = 0; i < items.length; i++) {
- assertTrue(items[i].getData() instanceof ITask);
- ITask cat = (ITask) items[i].getData();
- assertTrue(cat.isCategory());
-
+ assertTrue(items[i].getData() instanceof Category);
TreeItem[] sub = items[i].getItems();
for (int j = 0; j < sub.length; j++) {
assertTrue(sub[j].getData() instanceof ITask);
@@ -222,24 +238,24 @@ public class TaskListUiTest extends TestCase {
// don't care if we are disposed
}
public Object[] getElements(Object parent) {
- return tlist.getRootTasks().toArray();
+ return tlist.getRoots().toArray();
}
public Object getParent(Object child) {
- if (child instanceof Task) {
- return ((Task)child).getParent();
+ if (child instanceof Category) {
+ return ((Task)child).getCategory();
}
return null;
}
public Object [] getChildren(Object parent) {
- if (parent instanceof ITask) {
- return ((ITask)parent).getChildren().toArray();
+ if (parent instanceof Category) {
+ return ((Category)parent).getTasks().toArray();
}
return new Object[0];
}
public boolean hasChildren(Object parent) {
- if (parent instanceof ITask) {
- ITask task = (ITask)parent;
- return task.getChildren() != null && task.getChildren().size() > 0;
+ if (parent instanceof Category) {
+ Category cat = (Category)parent;
+ return cat.getTasks() != null && cat.getTasks().size() > 0;
}
return false;
}

Back to the top