Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaxsun McCarthy Huggan2017-06-20 18:36:28 -0400
committerJaxsun McCarthy Huggan2017-06-20 19:33:10 -0400
commit3903deed2e964f8e650a588ea5472fdcb765bee0 (patch)
treedfbf2d72f8dbdd24fd624135f3e62cfbb8287fb9 /org.eclipse.mylyn.tasks.index.tests
parent1b0cf590566558e26da4515a1cf700ae700f5e48 (diff)
downloadorg.eclipse.mylyn.tasks-3903deed2e964f8e650a588ea5472fdcb765bee0.tar.gz
org.eclipse.mylyn.tasks-3903deed2e964f8e650a588ea5472fdcb765bee0.tar.xz
org.eclipse.mylyn.tasks-3903deed2e964f8e650a588ea5472fdcb765bee0.zip
518536: TaskListIndex respects all submitted query terms
Change-Id: If058bfb65718e15370b9f569d30125c709b22208 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=518536
Diffstat (limited to 'org.eclipse.mylyn.tasks.index.tests')
-rw-r--r--org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java52
1 files changed, 50 insertions, 2 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 89cc805b7..f458b3dc5 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
@@ -120,12 +120,15 @@ public class TaskListIndexTest extends AbstractTaskListIndexTest {
index.setDefaultField(TaskListIndex.FIELD_CONTENT);
- assertTrue(index.matches(task, task.getSummary()));
+ String summary = task.getSummary();
+ assertTrue(index.matches(task, summary));
+ assertTrue(index.matches(task, summary.substring(0, summary.length() - 3) + "*"));
assertFalse(index.matches(task, "" + System.currentTimeMillis()));
index.setDefaultField(FIELD_SUMMARY);
- assertTrue(index.matches(task, task.getSummary()));
+ assertTrue(index.matches(task, summary));
+ assertTrue(index.matches(task, summary.substring(0, summary.length() - 3) + "*"));
assertFalse(index.matches(task, "" + System.currentTimeMillis()));
}
@@ -626,6 +629,51 @@ public class TaskListIndexTest extends AbstractTaskListIndexTest {
TaskListIndex.FIELD_ATTACHMENT_NAME.getIndexKey() + ":\"" + attachmentMapper.getDescription() + "\""));
}
+ @Test
+ public void testFindWithComplexQuery() throws Exception {
+ setupIndex();
+
+ ITask task1 = context.createRepositoryTask();
+ setSummary(task1, "one two three");
+ ITask task2 = context.createRepositoryTask();
+ setSummary(task2, "two three four");
+ ITask task3 = context.createRepositoryTask();
+ setSummary(task3, "three four five");
+
+ String repositoryUrl = task1.getRepositoryUrl();
+ assertEquals(repositoryUrl, task2.getRepositoryUrl());
+ assertEquals(repositoryUrl, task3.getRepositoryUrl());
+ repositoryUrl = index.escapeFieldValue(repositoryUrl);
+
+ index.reindex();
+ index.waitUntilIdle();
+ index.setDefaultField(TaskListIndex.FIELD_CONTENT);
+
+ String pattern = "repository_url:%s AND (summary:%s* OR task_key:%s)";
+ String query = String.format(pattern, repositoryUrl, "five", task1.getTaskKey());
+ assertTrue(index.matches(task1, query));
+ assertFalse(index.matches(task2, query));
+ assertTrue(index.matches(task3, query));
+
+ query = String.format(pattern, repositoryUrl, task2.getTaskKey(), task2.getTaskKey());
+ assertFalse(index.matches(task1, query));
+ assertTrue(index.matches(task2, query));
+ assertFalse(index.matches(task3, query));
+
+ query = String.format(pattern, repositoryUrl, "two", "something.irrelevant");
+ assertTrue(index.matches(task1, query));
+ assertTrue(index.matches(task2, query));
+ assertFalse(index.matches(task3, query));
+ }
+
+ private void setSummary(ITask task, String summary) throws CoreException {
+ task.setSummary(summary);
+ TaskData taskData = context.getDataManager().getTaskData(task);
+ taskData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).setValue(summary);
+ context.getDataManager().putSubmittedTaskData(task, taskData, new DelegatingProgressMonitor());
+ context.getTaskList().notifyElementsChanged(Collections.singleton(task));
+ }
+
private void assertCanFindTask(ITask task) {
TestTaskCollector collector = new TestTaskCollector();
index.find(task.getSummary(), collector, 1000);

Back to the top