Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Green2012-11-01 12:15:56 -0400
committerSteffen Pingel2012-11-01 12:15:56 -0400
commit3868f0b4d76671cf286e4c24869c59418cbaadd7 (patch)
treea840d0c5e83220e9d51b3f9941d07b801cbf51bf
parentc34a18920e37212c314f940127b4919abb30d746 (diff)
downloadorg.eclipse.mylyn.tasks-3868f0b4d76671cf286e4c24869c59418cbaadd7.tar.gz
org.eclipse.mylyn.tasks-3868f0b4d76671cf286e4c24869c59418cbaadd7.tar.xz
org.eclipse.mylyn.tasks-3868f0b4d76671cf286e4c24869c59418cbaadd7.zip
391841: task list index is incorrectly constructed for task key in some
circumstances modify the task list index to avoid indexing the task key twice. Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=391841 Conflicts: org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockTaskDataHandler.java
-rw-r--r--org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java5
-rw-r--r--org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java32
-rw-r--r--org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/util/MockTestContext.java1
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorWithTaskDataHandler.java1
4 files changed, 39 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
index 95d4f728f..c26a417f0 100644
--- a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
+++ b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
@@ -177,6 +177,10 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
}
+ /**
+ * keeps track of fields that are handled specially in the code so that we don't use the generalized field handling
+ * for indexing them.
+ */
private final Set<AbstractTaskSchema.Field> specialFields = new HashSet<AbstractTaskSchema.Field>();
private final Set<AbstractTaskSchema.Field> indexedFields = new LinkedHashSet<AbstractTaskSchema.Field>();
@@ -185,6 +189,7 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
specialFields.add(FIELD_REPOSITORY_URL);
specialFields.add(FIELD_CONTENT);
specialFields.add(FIELD_PERSON);
+ specialFields.add(FIELD_TASK_KEY);
addIndexedField(FIELD_IDENTIFIER);
addIndexedField(FIELD_TASK_KEY);
diff --git a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
index 2453801df..5d5ac6baa 100644
--- a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
+++ b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
@@ -229,6 +229,38 @@ public class TaskListIndexTest extends AbstractTaskListIndexTest {
}
@Test
+ public void testMatchesOnTaskKey() throws Exception {
+ setupIndex();
+
+ ITask repositoryTask = context.createRepositoryTask();
+
+ index.waitUntilIdle();
+
+ index.setDefaultField(TaskListIndex.FIELD_CONTENT);
+
+ TaskData taskData = context.getDataManager().getTaskData(repositoryTask);
+
+ // sanity
+ assertNotNull(taskData);
+ assertNotNull(taskData.getRoot().getMappedAttribute(TaskAttribute.TASK_KEY));
+
+ String taskKey = repositoryTask.getTaskKey();
+ assertTrue(taskKey.length() > 1);
+
+ final String querySuffix = " AND " + TaskListIndex.FIELD_CONTENT.getIndexKey() + ":\""
+ + index.escapeFieldValue(taskData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).getValue())
+ + "\"";
+
+ assertTrue(index.matches(repositoryTask, TaskListIndex.FIELD_TASK_KEY.getIndexKey() + ":" + taskKey
+ + querySuffix));
+
+ // does not match on task key prefix
+ assertTrue(index.matches(repositoryTask,
+ TaskListIndex.FIELD_TASK_KEY.getIndexKey() + ":" + taskKey.substring(0, taskKey.length() - 1)
+ + querySuffix));
+ }
+
+ @Test
public void testMatchesSummaryWithExpectedQueryBehaviour() throws InterruptedException {
setupIndex();
diff --git a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/util/MockTestContext.java b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/util/MockTestContext.java
index 117b06884..d809db29b 100644
--- a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/util/MockTestContext.java
+++ b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/util/MockTestContext.java
@@ -151,6 +151,7 @@ public class MockTestContext {
taskData.getRoot()
.getMappedAttribute(TaskAttribute.DESCRIPTION)
.setValue("task description " + task.getTaskKey());
+ taskData.getRoot().getMappedAttribute(TaskAttribute.TASK_KEY).setValue(task.getTaskKey());
mockRepositoryConnector.getTaskMapping(taskData).applyTo(task);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorWithTaskDataHandler.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorWithTaskDataHandler.java
index fe36414fb..20c15eb5b 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorWithTaskDataHandler.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorWithTaskDataHandler.java
@@ -85,6 +85,7 @@ public class MockRepositoryConnectorWithTaskDataHandler extends MockRepositoryCo
mapper.setReporter("");
mapper.setStatus("NEW");
mapper.setSummary("");
+ mapper.setTaskKey("");
return true;
}

Back to the top