Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2007-06-25 22:22:21 -0400
committerrelves2007-06-25 22:22:21 -0400
commite780209406955493e7c27c95005dae961e504901 (patch)
tree03435032fbbfea60354567a6b174e471a0b27b84
parente6f1b8189314a371b758ce9a11aabc5d19284af7 (diff)
downloadorg.eclipse.mylyn.tasks-e780209406955493e7c27c95005dae961e504901.tar.gz
org.eclipse.mylyn.tasks-e780209406955493e7c27c95005dae961e504901.tar.xz
org.eclipse.mylyn.tasks-e780209406955493e7c27c95005dae961e504901.zip
NEW - bug 186882: Guaranteed visibility of Archive elements can fail upon query deletion
https://bugs.eclipse.org/bugs/show_bug.cgi?id=186882
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java9
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java41
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java19
3 files changed, 58 insertions, 11 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
index f761f6a90..f2bce3f0d 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
@@ -302,6 +302,13 @@ public class TaskList {
public void deleteQuery(AbstractRepositoryQuery query) {
queries.remove(query.getHandleIdentifier());
+ for (AbstractTask task : query.getChildren()) {
+ if (task.getParentContainers().size() == 0 && task.getLastReadTimeStamp() != null) {
+ task.addParentContainer(archiveContainer);
+ archiveContainer.internalAddChild(task);
+ }
+ }
+
Set<TaskContainerDelta> delta = new HashSet<TaskContainerDelta>();
delta.add(new TaskContainerDelta(query, TaskContainerDelta.Kind.REMOVED));
for (ITaskListChangeListener listener : changeListeners) {
@@ -439,7 +446,7 @@ public class TaskList {
public boolean isEmpty() {
boolean archiveIsEmpty = getCategories().size() == 2
- && getCategories().iterator().next().equals(archiveContainer)
+ && getCategories().contains(archiveContainer) && getCategories().contains(defaultCategory)
&& archiveContainer.getChildren().isEmpty();
return getAllTasks().size() == 0 && archiveIsEmpty && getQueries().size() == 0;
}
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 89d6d870b..23f2f494a 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
@@ -515,9 +515,17 @@ public class TaskListManagerTest extends TestCase {
Set<AbstractTaskCategory> readCats = manager.getTaskList().getTaskContainers();
assertTrue(manager.getTaskList().getCategories().contains(cat1));
Iterator<AbstractTaskCategory> iterator = readCats.iterator();
- AbstractTaskContainer readCat1 = iterator.next();
- assertEquals(cat1, readCat1);
- assertEquals(1, readCat1.getChildren().size());
+
+ boolean found = false;
+ while (iterator.hasNext()) {
+ AbstractTaskContainer readCat1 = iterator.next();
+ if (cat1.equals(readCat1)) {
+ found = true;
+ assertEquals(1, readCat1.getChildren().size());
+ }
+ }
+ if (!found)
+ fail(" Category not found afer tasklist read");
manager.saveTaskList();
assertNotNull(manager.getTaskList());
@@ -529,10 +537,16 @@ public class TaskListManagerTest extends TestCase {
assertTrue(manager.getTaskList().getCategories().contains(cat1));
iterator = readCats.iterator();
- AbstractTaskContainer reReadCat1 = iterator.next();
- assertEquals(cat1, reReadCat1);
-
- assertEquals(1, reReadCat1.getChildren().size());
+ found = false;
+ while (iterator.hasNext()) {
+ AbstractTaskContainer readCat1 = iterator.next();
+ if (cat1.equals(readCat1)) {
+ found = true;
+ assertEquals(1, readCat1.getChildren().size());
+ }
+ }
+ if (!found)
+ fail(" Category not found afer tasklist read");
}
public void testSubTaskExternalization() {
@@ -630,9 +644,16 @@ public class TaskListManagerTest extends TestCase {
Set<AbstractTaskCategory> readCats = manager.getTaskList().getTaskContainers();
assertTrue(manager.getTaskList().getCategories().contains(cat1));
Iterator<AbstractTaskCategory> iterator = readCats.iterator();
- AbstractTaskContainer readCat1 = iterator.next();
- assertEquals(cat1, readCat1);
- assertEquals(cat1Contents, readCat1.getChildren());
+ boolean found = false;
+ while (iterator.hasNext()) {
+ AbstractTaskContainer readCat1 = iterator.next();
+ if (cat1.equals(readCat1)) {
+ found = true;
+ assertEquals(cat1Contents, readCat1.getChildren());
+ }
+ }
+ if (!found)
+ fail(" Category not found afer tasklist read");
}
public void testExternalizationOfHandlesWithDash() {
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java
index 52715b0f2..e1172b91a 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java
@@ -17,9 +17,12 @@ import junit.framework.TestCase;
import org.eclipse.mylyn.internal.tasks.core.RepositoryTaskHandleUtil;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryQuery;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryTask;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
/**
@@ -52,6 +55,21 @@ public class TaskRepositoryManagerTest extends TestCase {
}
}
+ public void testQueryDeletion() {
+ MockRepositoryTask task = new MockRepositoryTask("1");
+ task.setLastReadTimeStamp("now");
+ MockRepositoryQuery query = new MockRepositoryQuery("Test");
+ TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
+ TasksUiPlugin.getTaskListManager().getTaskList().addTask(task, query);
+
+ assertNotNull(TasksUiPlugin.getTaskListManager().getTaskList().getTask(task.getHandleIdentifier()));
+ TasksUiPlugin.getTaskListManager().getTaskList().deleteQuery(query);
+ AbstractTask task2 = TasksUiPlugin.getTaskListManager().getTaskList().getTask(task.getHandleIdentifier());
+ assertNotNull(task2);
+ assertEquals(1, task2.getParentContainers().size());
+
+ }
+
public void testHandles() {
String url = "http://foo.bar";
String id = "123";
@@ -201,4 +219,5 @@ public class TaskRepositoryManagerTest extends TestCase {
assertEquals("got: " + manager.getAllRepositories(), 2, manager.getAllRepositories().size());
}
+
}

Back to the top