diff options
author | David Green | 2012-10-12 22:47:27 +0000 |
---|---|---|
committer | Steffen Pingel | 2012-10-30 10:43:53 +0000 |
commit | 8f8a84b050f645df615c00acf1bcaf778026c6d5 (patch) | |
tree | bbba5581cd75c5b9673612e52aa16c7fbee41492 /org.eclipse.mylyn.tasks.index.tests | |
parent | 46d751a396962abc1a7f32e11db4e00365316f9e (diff) | |
download | org.eclipse.mylyn.tasks-8f8a84b050f645df615c00acf1bcaf778026c6d5.tar.gz org.eclipse.mylyn.tasks-8f8a84b050f645df615c00acf1bcaf778026c6d5.tar.xz org.eclipse.mylyn.tasks-8f8a84b050f645df615c00acf1bcaf778026c6d5.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.
Change-Id: I3040e4797a33468e627fd3ad5466b074ad84035a
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=391841
Diffstat (limited to 'org.eclipse.mylyn.tasks.index.tests')
2 files changed, 33 insertions, 0 deletions
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); |