From b9a7552f5892b88fb40727c55db62c63864fbd68 Mon Sep 17 00:00:00 2001 From: Jaxsun McCarthy Huggan Date: Tue, 17 May 2016 15:10:23 -0700 Subject: 493037: Check if a task is in unmatched before removing from unmatched This gives a considerable performance increase when loading large task lists where there are more tasks than any one task has parents. Change-Id: I18ccd3ba7387d937b78fb21e766d299f2a88491b Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=493037 Signed-off-by: Jaxsun McCarthy Huggan --- .../mylyn/internal/tasks/core/TaskListTest.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 org.eclipse.mylyn.tasks.core.tests/src/org/eclipse/mylyn/internal/tasks/core/TaskListTest.java (limited to 'org.eclipse.mylyn.tasks.core.tests') diff --git a/org.eclipse.mylyn.tasks.core.tests/src/org/eclipse/mylyn/internal/tasks/core/TaskListTest.java b/org.eclipse.mylyn.tasks.core.tests/src/org/eclipse/mylyn/internal/tasks/core/TaskListTest.java new file mode 100644 index 000000000..b10536fc3 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core.tests/src/org/eclipse/mylyn/internal/tasks/core/TaskListTest.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2016 Tasktop Technologies and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.tasks.core; + +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.junit.Before; +import org.junit.Test; + +public class TaskListTest { + + private TaskList taskList; + + @Before + public void setUp() throws Exception { + taskList = new TaskList(); + } + + @Test + public void removeMatchedTaskFromUnmatched() { + UnmatchedTaskContainer unmatched = spy(new UnmatchedTaskContainer("kind", "repoUrl")); + TaskCategory category1 = new TaskCategory("cat1"); + TaskCategory category2 = new TaskCategory("cat2"); + AbstractTask task = spy(new TaskTask("kind", "repoUrl", "id")); + taskList.addCategory(category1); + taskList.addCategory(category2); + taskList.addUnmatchedContainer(unmatched); + + // add to unmatched + taskList.addTask(task); + // should remove from unmatched + taskList.addTask(task, category1); + verify(unmatched, times(1)).internalRemoveChild(task); + // should not remove from unmatched again + taskList.addTask(task, category2); + verify(unmatched, times(1)).internalRemoveChild(task); + } + +} -- cgit v1.2.3