Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-09-17 03:44:17 -0400
committerspingel2008-09-17 03:44:17 -0400
commita7fb6a3006fe640b4c59b8ac2086380bde1d3a91 (patch)
tree2ad4389d8cea2bdfe0abfa9831580bdafa8d3f7f
parented73ce722ef60a020b5a18277f3013243e3e9d33 (diff)
downloadorg.eclipse.mylyn.tasks-a7fb6a3006fe640b4c59b8ac2086380bde1d3a91.tar.gz
org.eclipse.mylyn.tasks-a7fb6a3006fe640b4c59b8ac2086380bde1d3a91.tar.xz
org.eclipse.mylyn.tasks-a7fb6a3006fe640b4c59b8ac2086380bde1d3a91.zip
NEW - bug 237552: [api] remove deprecated classes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=237552
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java11
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java75
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskWizardRepositorySelectionTest.java4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineCachingStorageTest.java173
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineStorageTest.java314
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java18
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/PersonProposalProviderTest.java20
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java9
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationActionTest.java12
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java207
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java15
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java7
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java (renamed from org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AttachmentJobTest.java)41
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskContainerTest.java (renamed from org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AbstractTaskContainerTest.java)7
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStorageManagerTest.java261
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java196
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskHistoryTest.java237
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java (renamed from org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDnDTest.java)24
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListExternalizationTest.java9
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMapperTest.java (renamed from org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMappingTest.java)2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java15
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java3
23 files changed, 516 insertions, 1148 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java
index 33bb56ece..c6db9fadd 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataExternalizer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -102,7 +102,7 @@ public class TaskDataExternalizer {
}
return taskDataState;
} catch (SAXException e) {
- e.printStackTrace();
+ //e.printStackTrace();
throw new IOException("Error parsing task data: " + e.getMessage());
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
index fbd12801b..570280fe9 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
@@ -29,7 +29,6 @@ public class AllTasksTests {
suite.addTestSuite(TaskListPresentationTest.class);
suite.addTestSuite(TaskRepositoryTest.class);
suite.addTestSuite(TaskRepositorySorterTest.class);
- suite.addTestSuite(TaskDataStorageManagerTest.class);
suite.addTestSuite(CopyDetailsActionTest.class);
suite.addTestSuite(NewTaskFromSelectionActionTest.class);
suite.addTestSuite(TaskListTest.class);
@@ -47,25 +46,23 @@ public class AllTasksTests {
suite.addTestSuite(TaskKeyComparatorTest.class);
suite.addTestSuite(TaskTest.class);
suite.addTestSuite(TaskListUiTest.class);
- suite.addTestSuite(TaskListDnDTest.class);
+ suite.addTestSuite(TaskListDropAdapterTest.class);
suite.addTestSuite(TasksUiUtilTest.class);
suite.addTestSuite(TaskDataExportTest.class);
// XXX: Put back
//suite.addTestSuite(TaskDataImportTest.class);
suite.addTestSuite(ScheduledPresentationTest.class);
suite.addTestSuite(TaskActivityTimingTest.class);
- suite.addTestSuite(AttachmentJobTest.class);
+ suite.addTestSuite(TaskAttachmentTest.class);
suite.addTestSuite(RepositorySettingsPageTest.class);
- suite.addTestSuite(TaskHistoryTest.class);
suite.addTestSuite(CommentQuoterTest.class);
- suite.addTestSuite(OfflineStorageTest.class);
- suite.addTestSuite(OfflineCachingStorageTest.class);
+ suite.addTestSuite(TaskDataStoreTest.class);
suite.addTestSuite(QueryExportImportTest.class);
suite.addTestSuite(TaskExportImportTest.class);
suite.addTestSuite(PersonProposalProviderTest.class);
suite.addTestSuite(TaskRepositoryLocationTest.class);
suite.addTestSuite(AttachmentSizeFormatterTest.class);
- suite.addTestSuite(TaskMappingTest.class);
+ suite.addTestSuite(TaskMapperTest.class);
suite.addTestSuite(OrphanedTasksTest.class);
suite.addTestSuite(TaskWorkingSetTest.class);
suite.addTestSuite(TaskActivationHistoryTest.class);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java
index c33c2c363..0060db199 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java
@@ -12,17 +12,17 @@
package org.eclipse.mylyn.tasks.tests;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
import junit.framework.TestCase;
import org.eclipse.jface.text.TextSelection;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractAttributeFactory;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.TaskComment;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.mylyn.internal.tasks.core.TaskComment;
import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskFromSelectionAction;
-import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTaskSelection;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.connector.MockTask;
/**
* @author Frank Becker
@@ -30,21 +30,23 @@ import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTaskSelection;
*/
public class NewTaskFromSelectionActionTest extends TestCase {
- // Steffen: re-enable?
-// public void testNoSelection() throws Exception {
-// NewTaskFromSelectionAction action = new NewTaskFromSelectionAction();
-// assertNull(action.getTaskSelection());
-// action.run();
-// action.selectionChanged(null);
-// assertNull(action.getTaskSelection());
-// }
+ public void testNoSelection() throws Exception {
+ NewTaskFromSelectionAction action = new NewTaskFromSelectionAction();
+ assertNull(action.getTaskSelection());
+ action.run();
+ action.selectionChanged(null);
+ assertNull(action.getTaskSelection());
+ }
public void testComment() throws Exception {
- StubAttributeFactory targetFactory = new StubAttributeFactory();
- TaskComment comment = new TaskComment(targetFactory, 1);
+ TaskRepository taskRepository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL);
+ TaskData taskData = new TaskData(new TaskAttributeMapper(taskRepository), "kind", "http://url", "1");
+ TaskComment comment = new TaskComment(taskRepository, new MockTask("1"), taskData.getRoot().createAttribute(
+ "id"));
NewTaskFromSelectionAction action = new NewTaskFromSelectionAction();
- action.selectionChanged(new RepositoryTaskSelection("id", "server", "kind", "", comment, "summary"));
+ action.selectionChanged(new StructuredSelection(comment));
assertNotNull(action.getTaskSelection());
}
@@ -62,41 +64,4 @@ public class NewTaskFromSelectionActionTest extends TestCase {
assertNull(action.getTaskSelection());
}
- private class StubAttributeFactory extends AbstractAttributeFactory {
-
- private static final long serialVersionUID = 1L;
-
- private final Map<String, String> attributeMap = new HashMap<String, String>();
-
- @Override
- public Date getDateForAttributeType(String attributeKey, String dateString) {
- // ignore
- return null;
- }
-
- @Override
- public String getName(String key) {
- // ignore
- return null;
- }
-
- @Override
- public boolean isHidden(String key) {
- // ignore
- return false;
- }
-
- @Override
- public boolean isReadOnly(String key) {
- // ignore
- return false;
- }
-
- @Override
- public String mapCommonAttributeKey(String key) {
- String mappedKey = attributeMap.get(key);
- return (mappedKey != null) ? mappedKey : key;
- }
-
- }
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskWizardRepositorySelectionTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskWizardRepositorySelectionTest.java
index e05df5450..21e05d5da 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskWizardRepositorySelectionTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskWizardRepositorySelectionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -75,7 +75,7 @@ public class NewTaskWizardRepositorySelectionTest extends TestCase {
TaskListView view = (TaskListView) TasksUiUtil.openTasksViewInActivePerspective();
view.getViewer().setSelection(new StructuredSelection());
- NewTaskWizard wizard = new NewTaskWizard(null);
+ NewTaskWizard wizard = new NewTaskWizard(null, null);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
WizardDialog dialog = null;
dialog = new WizardDialog(shell, wizard);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineCachingStorageTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineCachingStorageTest.java
deleted file mode 100644
index 8f427099d..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineCachingStorageTest.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2008 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.tasks.tests;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.tasks.core.TaskDataState;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
-import org.eclipse.mylyn.internal.tasks.ui.OfflineCachingStorage;
-import org.eclipse.mylyn.internal.tasks.ui.OfflineFileStorage;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.tests.connector.MockAttributeFactory;
-import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
-
-/**
- * @author Rob Elves
- */
-public class OfflineCachingStorageTest extends TestCase {
-
- private static final String MOCK_ID = "1";
-
- private File dataDir;
-
- private OfflineCachingStorage storage;
-
- @Override
- protected void setUp() throws Exception {
- //dataDir = new File("c:/offline");
- dataDir = new File(TasksUiPlugin.getDefault().getDataDirectory() + '/' + "offline");
- storage = new OfflineCachingStorage(new OfflineFileStorage(dataDir));
- storage.start();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- storage.stop();
- storage.clear();
- }
-
- public void testPutAndGet() throws Exception {
-
- TaskDataState state = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
-
- RepositoryTaskData newData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
-
- newData.setAttributeValue("attributeKey1", "attValue!");
- newData.setDescription("description");
- newData.setNew(true);
- newData.setNewComment("new comment");
- newData.setSummary("summary");
- newData.setTaskKey("task key");
-
- RepositoryTaskData oldData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
-
- Set<RepositoryTaskAttribute> edits = new HashSet<RepositoryTaskAttribute>();
-
- state.setNewTaskData(newData);
- state.setOldTaskData(oldData);
- state.setEdits(edits);
-
- storage.put(state);
-
- TaskDataState retrieved = storage.get(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
- assertNotNull(retrieved);
- RepositoryTaskData newTaskData = retrieved.getNewTaskData();
- assertNotNull(newTaskData);
- assertEquals(MockRepositoryConnector.REPOSITORY_KIND, newTaskData.getConnectorKind());
- assertEquals("description", newTaskData.getDescription());
- assertEquals("new comment", newTaskData.getNewComment());
- assertEquals("task key", newTaskData.getTaskKey());
- }
-
- public void testRemove() throws Exception {
- assertNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID));
-
- TaskDataState state = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
-
- RepositoryTaskData newData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
-
- newData.setAttributeValue("attributeKey1", "attValue!");
- newData.setDescription("description");
- newData.setNew(true);
- newData.setNewComment("new comment");
- newData.setSummary("summary");
- newData.setTaskKey("task key");
-
- RepositoryTaskData oldData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
-
- Set<RepositoryTaskAttribute> edits = new HashSet<RepositoryTaskAttribute>();
-
- state.setNewTaskData(newData);
- state.setOldTaskData(oldData);
- state.setEdits(edits);
-
- storage.put(state);
- assertEquals(1, storage.getReadQueue().size());
- assertEquals("1", storage.getReadQueue().iterator().next().getId());
- assertNotNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID));
- storage.remove(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
- assertEquals(0, storage.getReadQueue().size());
- assertNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID));
-
- }
-
- public void testLRUQueue() {
- assertNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID));
- assertEquals(0, storage.getReadQueue().size());
- TaskDataState state1 = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
- TaskDataState state2 = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, "2");
- TaskDataState state3 = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, "3");
-
- storage.put(state1);
- storage.put(state2);
- storage.put(state3);
-
- assertEquals(3, storage.getReadQueue().size());
-
- // should return least recently used
- assertEquals("1", storage.getReadQueue().iterator().next().getId());
-
- assertNotNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, "3"));
- assertNotNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, "2"));
- assertNotNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, MOCK_ID));
-
- assertEquals(3, storage.getReadQueue().size());
-
- // should return least recently used
- assertEquals("3", storage.getReadQueue().iterator().next().getId());
- storage.put(state1);
- storage.put(state3);
- // should return least recently used
- assertEquals("2", storage.getReadQueue().iterator().next().getId());
- assertEquals(3, storage.getReadQueue().size());
- }
-
- public void testPendingWrites() {
- assertEquals(0, storage.getReadCache().size());
- assertEquals(0, storage.getWriteCache().size());
- assertEquals(0, storage.getReadQueue().size());
-
- TaskDataState state1 = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, "1");
- storage.put(state1);
-
- storage.flushReadCache(true);
-
- assertEquals(0, storage.getReadCache().size());
- assertEquals(1, storage.getWriteCache().size());
-
- TaskDataState data = storage.get(MockRepositoryConnector.REPOSITORY_URL, "1");
- assertNotNull(data);
- assertEquals(state1, data);
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineStorageTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineStorageTest.java
deleted file mode 100644
index 8536bf9d7..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OfflineStorageTest.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2008 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.tasks.tests;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.tasks.core.TaskDataState;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryAttachment;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryOperation;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.TaskComment;
-import org.eclipse.mylyn.internal.tasks.ui.OfflineFileStorage;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.tests.connector.MockAttributeFactory;
-import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
-import org.eclipse.ui.XMLMemento;
-
-/**
- * @author Rob Elves
- */
-public class OfflineStorageTest extends TestCase {
-
- File dataDir;
-
- OfflineFileStorage storage;
-
- @Override
- protected void setUp() throws Exception {
- //dataDir = new File("c:/offline");
- dataDir = new File(TasksUiPlugin.getDefault().getDataDirectory() + "/offline");
- storage = new OfflineFileStorage(dataDir);
- storage.start();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- storage.stop();
- removeTestFiles(dataDir);
- }
-
- private void removeTestFiles(File folder) {
- if (folder.isDirectory()) {
- for (File file : folder.listFiles()) {
- removeTestFiles(file);
- }
- }
- folder.delete();
- }
-
- public void testPutAndGet() throws Exception {
-
- TaskDataState state = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, "1");
-
- RepositoryTaskData newData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1", "kind");
-
- newData.setAttributeValue("attributeKey1", "attValue!");
- newData.setDescription("description");
- newData.setNew(true);
- newData.setNewComment("new comment");
- newData.setSummary("summary");
- newData.setTaskKey("task key");
-
- RepositoryTaskData oldData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1", "kind");
-
- Set<RepositoryTaskAttribute> edits = new HashSet<RepositoryTaskAttribute>();
-
- state.setNewTaskData(newData);
- state.setOldTaskData(oldData);
- state.setEdits(edits);
-
- storage.put(state);
-
- TaskDataState retrieved = storage.get(MockRepositoryConnector.REPOSITORY_URL, "1");
- assertNotNull(retrieved);
- RepositoryTaskData newTaskData = retrieved.getNewTaskData();
- assertNotNull(newTaskData);
- assertEquals(MockRepositoryConnector.REPOSITORY_KIND, newTaskData.getConnectorKind());
- assertEquals("description", newTaskData.getDescription());
- assertEquals("new comment", newTaskData.getNewComment());
- assertEquals("task key", newTaskData.getTaskKey());
- assertEquals("kind", newTaskData.getTaskKind());
- }
-
- public void testRemove() throws Exception {
- assertNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, "1"));
-
- TaskDataState state = new TaskDataState(MockRepositoryConnector.REPOSITORY_URL, "1");
-
- RepositoryTaskData newData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
-
- newData.setAttributeValue("attributeKey1", "attValue!");
- newData.setDescription("description");
- newData.setNew(true);
- newData.setNewComment("new comment");
- newData.setSummary("summary");
- newData.setTaskKey("task key");
-
- RepositoryTaskData oldData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
-
- Set<RepositoryTaskAttribute> edits = new HashSet<RepositoryTaskAttribute>();
-
- state.setNewTaskData(newData);
- state.setOldTaskData(oldData);
- state.setEdits(edits);
-
- storage.put(state);
- assertNotNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, "1"));
- storage.remove(MockRepositoryConnector.REPOSITORY_URL, "1");
- assertNull(storage.get(MockRepositoryConnector.REPOSITORY_URL, "1"));
-
- }
-
- public void testAttributes() throws Exception {
- List<RepositoryTaskAttribute> attributes = new ArrayList<RepositoryTaskAttribute>();
- RepositoryTaskAttribute attribute = new RepositoryTaskAttribute("testId", "testName", true);
- attribute.setReadOnly(true);
- attribute.addOption("Option Name 1", "Option Value 1");
- attribute.addOption("Option Name 2", "Option Value 2");
- attribute.addValue("Value 1");
- attribute.addValue("Value 2");
- attribute.addValue("Value 3");
- attribute.putMetaDataValue("MetaKey1", "MetaValue1");
- attribute.putMetaDataValue("MetaKey2", "MetaValue2");
- attribute.putMetaDataValue("MetaKey3", "MetaValue3");
- attribute.putMetaDataValue("MetaKey4", "MetaValue4");
-
- attributes.add(attribute);
-
- XMLMemento memento = XMLMemento.createWriteRoot("Attributes");
- storage.addAttributes(memento, attributes);
- List<RepositoryTaskAttribute> readAttributes = storage.readAttributes(memento);
- assertNotNull(readAttributes);
- assertEquals(1, readAttributes.size());
- RepositoryTaskAttribute attr = readAttributes.get(0);
-
- assertEquals("testId", attr.getId());
- assertEquals("testName", attr.getName());
- assertEquals(true, attr.isHidden());
- assertEquals(true, attr.isReadOnly());
-
- assertNotNull(attr.getOptions());
- assertEquals(2, attr.getOptions().size());
-
- assertEquals("Option Name 1", attr.getOptions().get(0));
- assertEquals("Option Name 2", attr.getOptions().get(1));
- assertEquals("Option Value 1", attr.getOptionParameter(attr.getOptions().get(0)));
- assertEquals("Option Value 2", attr.getOptionParameter(attr.getOptions().get(1)));
-
- assertEquals("Value 1", attr.getValues().get(0));
- assertEquals("Value 2", attr.getValues().get(1));
- assertEquals("Value 3", attr.getValues().get(2));
-
- assertEquals("MetaValue1", attribute.getMetaDataValue("MetaKey1"));
- assertEquals("MetaValue2", attribute.getMetaDataValue("MetaKey2"));
- assertEquals("MetaValue3", attribute.getMetaDataValue("MetaKey3"));
- assertEquals("MetaValue4", attribute.getMetaDataValue("MetaKey4"));
- }
-
- public void testOperations() throws Exception {
- RepositoryOperation op = new RepositoryOperation("knob1", "operationName1");
- op.setChecked(true);
- op.setInputName("InputName");
- op.setInputValue("InputValue");
- op.setUpOptions("TheOptionName");
- op.addOption("optionName1", "optionValue1");
- op.addOption("optionName2", "optionValue2");
- op.setOptionSelection("optionSelection1");
-
- RepositoryOperation op2 = new RepositoryOperation("knob2", "operationName2");
- op2.setChecked(true);
- op2.setInputName("InputName2");
- op2.setInputValue("InputValue2");
- op2.setUpOptions("TheOptionName2");
- op2.addOption("optionName1", "optionValue1");
- op2.addOption("optionName2", "optionValue2");
- op2.setOptionSelection("optionSelection2");
- XMLMemento memento = XMLMemento.createWriteRoot("Operations");
-
- List<RepositoryOperation> operations = new ArrayList<RepositoryOperation>();
- operations.add(op);
- operations.add(op2);
- storage.addOperations(memento, operations);
- List<RepositoryOperation> readOperations = storage.readOperations(memento);
- RepositoryOperation op1 = readOperations.get(0);
- assertEquals("knob1", op1.getKnobName());
- assertEquals("operationName1", op1.getOperationName());
- assertEquals("InputName", op1.getInputName());
- assertEquals("InputValue", op1.getInputValue());
-
- assertEquals("TheOptionName", op1.getOptionName());
- assertEquals(2, op1.getOptionNames().size());
- assertEquals("optionValue1", op1.getOptionValue(op1.getOptionNames().get(0)));
- assertEquals("optionValue2", op1.getOptionValue(op1.getOptionNames().get(1)));
- assertEquals("optionSelection1", op1.getOptionSelection());
-
- RepositoryOperation op2ver2 = readOperations.get(1);
- assertEquals("knob2", op2ver2.getKnobName());
- assertEquals("operationName2", op2ver2.getOperationName());
- assertEquals("InputName2", op2ver2.getInputName());
- assertEquals("InputValue2", op2ver2.getInputValue());
-
- assertEquals("TheOptionName2", op2ver2.getOptionName());
- assertEquals(2, op2ver2.getOptionNames().size());
- assertEquals("optionValue1", op2ver2.getOptionValue(op1.getOptionNames().get(0)));
- assertEquals("optionValue2", op2ver2.getOptionValue(op1.getOptionNames().get(1)));
- assertEquals("optionSelection2", op2ver2.getOptionSelection());
- }
-
- public void testComments() throws Exception {
- TaskComment comment1 = new TaskComment(new MockAttributeFactory(), 1);
- comment1.setAttachmentId("attachmentId1");
- comment1.setHasAttachment(true);
- comment1.addAttribute("attr1", new RepositoryTaskAttribute("attr1", "attr1Name", false));
-
- TaskComment comment2 = new TaskComment(new MockAttributeFactory(), 2);
- comment2.setAttachmentId("attachmentId2");
- comment2.setHasAttachment(false);
- comment2.addAttribute("attr2", new RepositoryTaskAttribute("attr2", "attr2Name", false));
- comment2.addAttribute("attr3", new RepositoryTaskAttribute("attr3", "attr3Name", true));
-
- XMLMemento memento = XMLMemento.createWriteRoot("Comments");
- List<TaskComment> comments = new ArrayList<TaskComment>();
- comments.add(comment1);
- comments.add(comment2);
- storage.addComments(memento, comments);
- List<TaskComment> returnedComments = storage.readComments(memento);
- assertEquals(2, returnedComments.size());
-
- assertEquals("attachmentId1", returnedComments.get(0).getAttachmentId());
- assertEquals(true, returnedComments.get(0).hasAttachment());
- assertEquals(1, returnedComments.get(0).getAttributes().size());
- assertEquals("attr1", returnedComments.get(0).getAttributes().get(0).getId());
- assertEquals("attr1Name", returnedComments.get(0).getAttributes().get(0).getName());
-
- assertEquals("attachmentId2", returnedComments.get(1).getAttachmentId());
- assertEquals(false, returnedComments.get(1).hasAttachment());
- assertEquals(2, returnedComments.get(1).getAttributes().size());
- assertEquals("attr2", returnedComments.get(1).getAttributes().get(0).getId());
- assertEquals("attr2Name", returnedComments.get(1).getAttributes().get(0).getName());
- assertEquals("attr3Name", returnedComments.get(1).getAttributes().get(1).getName());
- }
-
- public void testAttachments() throws Exception {
-
- List<RepositoryAttachment> attachments = new ArrayList<RepositoryAttachment>();
- RepositoryAttachment attachment1 = new RepositoryAttachment(new MockAttributeFactory());
- attachment1.setCreator("thecreator");
- attachment1.setObsolete(false);
- attachment1.setPatch(true);
- attachment1.setRepositoryKind("bugzilla");
- attachment1.setRepositoryUrl("repUrl");
- attachment1.setTaskId("taskid1");
- attachment1.addAttribute("attr1", new RepositoryTaskAttribute("attr1", "attr1Name", true));
- attachment1.addAttribute("attr2", new RepositoryTaskAttribute("attr2", "attr2Name", true));
-
- RepositoryAttachment attachment2 = new RepositoryAttachment(new MockAttributeFactory());
- attachment2.setCreator("thecreator2");
- attachment2.setObsolete(true);
- attachment2.setPatch(false);
- attachment2.setRepositoryKind("bugzilla2");
- attachment2.setRepositoryUrl("repUrl2");
- attachment2.setTaskId("taskid2");
- attachment2.addAttribute("attr3", new RepositoryTaskAttribute("attr3", "attr3Name", true));
- attachment2.addAttribute("attr4", new RepositoryTaskAttribute("attr4", "attr4Name", true));
-
- attachments.add(attachment1);
- attachments.add(attachment2);
- XMLMemento memento = XMLMemento.createWriteRoot("Attachments");
- storage.addAttachments(memento, attachments);
- List<RepositoryAttachment> readAttachments = storage.readAttachments(memento);
-
- assertEquals(2, readAttachments.size());
- RepositoryAttachment readAttachment = readAttachments.get(0);
- assertEquals(attachment1.getTaskId(), readAttachment.getTaskId());
- assertEquals(attachment1.getCreator(), readAttachment.getCreator());
- assertEquals(attachment1.isObsolete(), readAttachment.isObsolete());
- assertEquals(attachment1.isPatch(), readAttachment.isPatch());
- assertEquals(attachment1.getRepositoryKind(), readAttachment.getRepositoryKind());
- assertEquals(attachment1.getRepositoryUrl(), readAttachment.getRepositoryUrl());
- assertEquals(attachment1.getAttributeValue("attr1"), readAttachment.getAttributeValue("attr1"));
- assertEquals(attachment1.getAttributeValue("attr2"), readAttachment.getAttributeValue("attr2"));
-
- readAttachment = readAttachments.get(1);
- assertEquals(attachment2.getTaskId(), readAttachment.getTaskId());
- assertEquals(attachment2.getCreator(), readAttachment.getCreator());
- assertEquals(attachment2.isObsolete(), readAttachment.isObsolete());
- assertEquals(attachment2.isPatch(), readAttachment.isPatch());
- assertEquals(attachment2.getRepositoryKind(), readAttachment.getRepositoryKind());
- assertEquals(attachment2.getRepositoryUrl(), readAttachment.getRepositoryUrl());
- assertEquals(attachment2.getAttributeValue("attr3"), readAttachment.getAttributeValue("attr3"));
- assertEquals(attachment2.getAttributeValue("attr4"), readAttachment.getAttributeValue("attr4"));
- }
-}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java
index b71401702..640f3f086 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/OrphanedTasksTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -38,7 +38,7 @@ public class OrphanedTasksTest extends TestCase {
@Override
protected void setUp() throws Exception {
- TasksUiPlugin.getTaskListManager().resetTaskList();
+ TaskTestUtil.resetTaskList();
taskList = TasksUiPlugin.getTaskList();
assertTrue(taskList.getDefaultCategory().isEmpty());
@@ -100,7 +100,6 @@ public class OrphanedTasksTest extends TestCase {
*/
public void testTaskRemovedFromQuery() {
MockTask mockTask = new MockTask("1");
- mockTask.setLastReadTimeStamp("now");
MockRepositoryQuery mockQuery = new MockRepositoryQuery("mock query");
taskList.addQuery(mockQuery);
taskList.addTask(mockTask, mockQuery);
@@ -117,7 +116,6 @@ public class OrphanedTasksTest extends TestCase {
*/
public void testTaskRemovedFromQueryButInCategory() {
MockTask mockTask = new MockTask("1");
- mockTask.setLastReadTimeStamp("now");
MockRepositoryQuery mockQuery = new MockRepositoryQuery("mock query");
taskList.addQuery(mockQuery);
taskList.addTask(mockTask, mockQuery);
@@ -188,17 +186,14 @@ public class OrphanedTasksTest extends TestCase {
taskList.addTask(mockTask, taskList.getDefaultCategory());
assertEquals(1, taskList.getCategories().size());
assertFalse(taskList.getDefaultCategory().isEmpty());
- // save tasklist, restore tasklist
- TasksUiPlugin.getExternalizationManager().save(true);
- TasksUiPlugin.getTaskListManager().resetTaskList();
- TasksUiPlugin.getTaskListManager().readExistingOrCreateNewList();
+
+ TaskTestUtil.saveAndReadTasklist();
assertEquals(1, taskList.getCategories().size());
assertEquals(1, taskList.getQueries().size());
assertFalse(taskList.getDefaultCategory().isEmpty());
+
taskList.deleteQuery(mockQuery);
- TasksUiPlugin.getTaskListManager().saveTaskList();
- TasksUiPlugin.getTaskListManager().resetTaskList();
- TasksUiPlugin.getTaskListManager().readExistingOrCreateNewList();
+ TaskTestUtil.saveAndReadTasklist();
assertEquals(1, taskList.getCategories().size());
assertEquals(0, taskList.getQueries().size());
assertFalse(taskList.getDefaultCategory().isEmpty());
@@ -270,7 +265,6 @@ public class OrphanedTasksTest extends TestCase {
public void testRefactorOrphanedHandle() {
MockTask mockTask = new MockTask("1");
- mockTask.setLastReadTimeStamp("now");
MockRepositoryQuery mockQuery = new MockRepositoryQuery("mock query");
taskList.addQuery(mockQuery);
taskList.addTask(mockTask, mockQuery);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/PersonProposalProviderTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/PersonProposalProviderTest.java
index 938ce1ffd..170001121 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/PersonProposalProviderTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/PersonProposalProviderTest.java
@@ -16,10 +16,9 @@ import junit.framework.TestCase;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
import org.eclipse.mylyn.internal.tasks.ui.PersonProposalProvider;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryQuery;
import org.eclipse.mylyn.tasks.tests.connector.MockTask;
@@ -30,22 +29,17 @@ import org.eclipse.mylyn.tasks.tests.connector.MockTask;
*/
public class PersonProposalProviderTest extends TestCase {
- private TaskListManager manager;
-
@Override
protected void setUp() throws Exception {
- manager = TasksUiPlugin.getTaskListManager();
- manager.resetTaskList();
+ TaskTestUtil.resetTaskList();
}
@Override
protected void tearDown() throws Exception {
- manager.resetTaskList();
- TasksUiPlugin.getRepositoryManager().clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
}
public void testGetProposalsNullParameters() {
- PersonProposalProvider provider = new PersonProposalProvider((AbstractTask) null, (RepositoryTaskData) null);
+ PersonProposalProvider provider = new PersonProposalProvider((AbstractTask) null, (TaskData) null);
IContentProposal[] result = provider.getProposals("", 0);
assertNotNull(result);
assertEquals(0, result.length);
@@ -58,7 +52,7 @@ public class PersonProposalProviderTest extends TestCase {
public void testGetProposalsCurrentTask() {
MockTask task = new MockTask(null, "1", null);
task.setOwner("foo");
- PersonProposalProvider provider = new PersonProposalProvider(task, (RepositoryTaskData) null);
+ PersonProposalProvider provider = new PersonProposalProvider(task, (TaskData) null);
IContentProposal[] result = provider.getProposals("", 0);
assertNotNull(result);
assertEquals(1, result.length);
@@ -84,7 +78,7 @@ public class PersonProposalProviderTest extends TestCase {
MockTask task = new MockTask(null, "1", null);
task.setOwner("foo");
- PersonProposalProvider provider = new PersonProposalProvider(task, (RepositoryTaskData) null);
+ PersonProposalProvider provider = new PersonProposalProvider(task, (TaskData) null);
result = provider.getProposals("f,xx", 1);
assertNotNull(result);
@@ -177,8 +171,8 @@ public class PersonProposalProviderTest extends TestCase {
PersonProposalProvider provider = new PersonProposalProvider(MockRepositoryConnector.REPOSITORY_URL,
MockRepositoryConnector.REPOSITORY_KIND);
MockRepositoryQuery query = new MockRepositoryQuery("summary");
- manager.getTaskList().addQuery(query);
- manager.getTaskList().addTask(task1, query);
+ TasksUiPlugin.getTaskList().addQuery(query);
+ TasksUiPlugin.getTaskList().addTask(task1, query);
result = provider.getProposals("f,xx", 1);
assertNotNull(result);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java
index 25f575ac1..3b2885249 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/RepositorySettingsPageTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -95,7 +95,6 @@ public class RepositorySettingsPageTest extends TestCase {
MockRepositorySettingsPage page = new MockRepositorySettingsPage(repository);
page.setNeedsAnonymousLogin(true);
- page.setRepository(repository);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
page.createControl(shell);
@@ -148,7 +147,6 @@ public class RepositorySettingsPageTest extends TestCase {
assertTrue(repository.getSavePassword(AuthenticationType.REPOSITORY));
MockRepositorySettingsPage page = new MockRepositorySettingsPage(repository);
- page.setRepository(repository);
try {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
page.createControl(shell);
@@ -159,7 +157,6 @@ public class RepositorySettingsPageTest extends TestCase {
repository.setCredentials(AuthenticationType.REPOSITORY, null, false);
page = new MockRepositorySettingsPage(repository);
- page.setRepository(repository);
try {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
page.createControl(shell);
@@ -177,7 +174,6 @@ public class RepositorySettingsPageTest extends TestCase {
MockRepositorySettingsPage page = new MockRepositorySettingsPage(repository);
page.setNeedsHttpAuth(true);
- page.setRepository(repository);
try {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
page.createControl(shell);
@@ -189,7 +185,6 @@ public class RepositorySettingsPageTest extends TestCase {
repository.setCredentials(AuthenticationType.HTTP, null, false);
// page = new MockRepositorySettingsPage(repository);
page.setNeedsHttpAuth(true);
- page.setRepository(repository);
try {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
page.createControl(shell);
@@ -207,7 +202,6 @@ public class RepositorySettingsPageTest extends TestCase {
MockRepositorySettingsPage page = new MockRepositorySettingsPage(repository);
page.setNeedsProxy(true);
- page.setRepository(repository);
try {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
page.createControl(shell);
@@ -219,7 +213,6 @@ public class RepositorySettingsPageTest extends TestCase {
repository.setCredentials(AuthenticationType.PROXY, null, false);
page = new MockRepositorySettingsPage(repository);
page.setNeedsProxy(true);
- page.setRepository(repository);
try {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
page.createControl(shell);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationActionTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationActionTest.java
index a99170996..30b4ac9ba 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationActionTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationActionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -13,9 +13,9 @@ package org.eclipse.mylyn.tasks.tests;
import junit.framework.TestCase;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.ToggleTaskActivationAction;
import org.eclipse.mylyn.tasks.tests.connector.MockTask;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
/**
* @author Mik Kersten
@@ -27,18 +27,18 @@ public class TaskActivationActionTest extends TestCase {
ToggleTaskActivationAction action = new ToggleTaskActivationAction(task);
assertFalse(action.isChecked());
- TasksUiPlugin.getTaskListManager().activateTask(task);
+ TasksUi.getTaskActivityManager().activateTask(task);
assertTrue(action.isChecked());
- TasksUiPlugin.getTaskListManager().deactivateTask(task);
+ TasksUi.getTaskActivityManager().deactivateTask(task);
assertFalse(action.isChecked());
action.dispose();
- TasksUiPlugin.getTaskListManager().activateTask(task);
+ TasksUi.getTaskActivityManager().activateTask(task);
assertFalse(action.isChecked());
- TasksUiPlugin.getTaskListManager().deactivateTask(task);
+ TasksUi.getTaskActivityManager().deactivateTask(task);
assertFalse(action.isChecked());
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java
index 1de4a5ec0..89ac9b85f 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivationHistoryTest.java
@@ -19,17 +19,20 @@ import java.util.Set;
import junit.framework.TestCase;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.TaskActivationHistory;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListManager;
+import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.actions.ActivateTaskHistoryDropDownAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.TaskActivateAction;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.internal.tasks.ui.workingsets.TaskWorkingSetUpdater;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryQuery;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
@@ -37,20 +40,49 @@ import org.eclipse.ui.internal.WorkingSet;
/**
* @author Frank Becker
- *
- * TODO merge with TaskHistoryTest
+ * @author Wesley Coelho
*/
public class TaskActivationHistoryTest extends TestCase {
- protected TaskListManager manager = TasksUiPlugin.getTaskListManager();
+ private TaskActivationHistory history;
- protected TaskActivationHistory history;
+ private TaskList taskList;
+
+ private AbstractTask task1;
+
+ private AbstractTask task2;
+
+ private AbstractTask task3;
+
+ private AbstractTask task4;
+
+ private AbstractTask task5;
+
+ private ActivateTaskHistoryDropDownAction previousTaskAction;
@Override
protected void setUp() throws Exception {
super.setUp();
history = TasksUiPlugin.getTaskActivityManager().getTaskActivationHistory();
+ taskList = TasksUiPlugin.getTaskList();
+
+ TasksUiPlugin.getTaskActivityManager().deactivateActiveTask();
+ TasksUiPlugin.getTaskActivityManager().clear();
+ ContextCorePlugin.getContextManager().resetActivityMetaContext();
+
+ task1 = TasksUiInternal.createNewLocalTask("task 1");
+ taskList.addTask(task1);
+ task2 = TasksUiInternal.createNewLocalTask("task 2");
+ taskList.addTask(task2);
+ task3 = TasksUiInternal.createNewLocalTask("task 3");
+ taskList.addTask(task3);
+ task4 = TasksUiInternal.createNewLocalTask("task 4");
+ taskList.addTask(task4);
+ task5 = TasksUiInternal.createNewLocalTask("task 5");
+ taskList.addTask(task5);
+
+ previousTaskAction = new ActivateTaskHistoryDropDownAction();
}
@Override
@@ -66,22 +98,22 @@ public class TaskActivationHistoryTest extends TestCase {
AbstractTask task12 = TasksUiInternal.createNewLocalTask("Query1 Task 2");
AbstractTask task21 = TasksUiInternal.createNewLocalTask("Query2 Task 1");
AbstractTask task22 = TasksUiInternal.createNewLocalTask("Query2 Task 2");
- manager.getTaskList().addQuery(query1);
- manager.getTaskList().addQuery(query2);
+ taskList.addQuery(query1);
+ taskList.addQuery(query2);
createWorkingSet(query1);
(new TaskActivateAction()).run(task11);
history.addTask(task11);
- manager.getTaskList().addTask(task11, query1);
+ taskList.addTask(task11, query1);
(new TaskActivateAction()).run(task12);
history.addTask(task12);
- manager.getTaskList().addTask(task12, query1);
+ taskList.addTask(task12, query1);
(new TaskActivateAction()).run(task21);
history.addTask(task21);
- manager.getTaskList().addTask(task21, query2);
+ taskList.addTask(task21, query2);
(new TaskActivateAction()).run(task22);
history.addTask(task22);
- manager.getTaskList().addTask(task22, query2);
+ taskList.addTask(task22, query2);
List<AbstractTask> prevHistoryList = history.getPreviousTasks();
@@ -121,4 +153,157 @@ public class TaskActivationHistoryTest extends TestCase {
return workingSet;
}
+ /**
+ * Tests the next task and previous task navigation.
+ */
+ public void testBasicHistoryNavigation() {
+ // NOTE: legacy test
+ TasksUi.getTaskActivityManager().activateTask(task1);
+ history.addTask(task1);
+ TasksUi.getTaskActivityManager().activateTask(task2);
+ history.addTask(task2);
+ TasksUi.getTaskActivityManager().activateTask(task3);
+ history.addTask(task3);
+
+ assertTrue(task3.isActive());
+ assertFalse(task2.isActive());
+ assertFalse(task1.isActive());
+
+ previousTaskAction.run();
+ assertTrue(task2.isActive());
+
+ previousTaskAction.run();
+ assertTrue(task1.isActive());
+
+ previousTaskAction.run();
+ assertTrue(task1.isActive());
+
+ // taskView.getPreviousTaskAction().run();
+ // assertTrue(task1.isActive());
+ //
+ // taskView.getPreviousTaskAction().run();
+ // assertTrue(task1.isActive());
+
+ // taskView.getNextTaskAction().run();
+ // assertTrue(task2.isActive());
+ //
+ // taskView.getNextTaskAction().run();
+ // assertTrue(task3.isActive());
+ //
+ // taskView.getNextTaskAction().run();
+ // assertTrue(task3.isActive());
+ //
+ // taskView.getPreviousTaskAction().run();
+ // assertTrue(task2.isActive());
+ //
+ // taskView.getNextTaskAction().run();
+ // assertTrue(task3.isActive());
+ //
+ // TasksUi.getTaskActivityManager().activateTask(task4);
+ // history.addTask(task4); // Simulate clicking on it rather
+ // // than navigating next or previous
+ // assertTrue(task4.isActive());
+ //
+ // taskView.getNextTaskAction().run();
+ // assertTrue(task4.isActive());
+ //
+ // taskView.getPreviousTaskAction().run();
+ // assertTrue(task3.isActive());
+ //
+ // taskView.getNextTaskAction().run();
+ // assertTrue(task4.isActive());
+
+ }
+
+ /**
+ * Tests navigation to previous/next tasks that are chosen from a list rather than being sequentially navigated
+ */
+ public void testArbitraryHistoryNavigation() {
+ // Simulate activating the tasks by clicking rather than
+ // navigating previous/next
+ TasksUi.getTaskActivityManager().activateTask(task1);
+ history.addTask(task1);
+ TasksUi.getTaskActivityManager().activateTask(task2);
+ history.addTask(task2);
+ TasksUi.getTaskActivityManager().activateTask(task3);
+ history.addTask(task3);
+ TasksUi.getTaskActivityManager().activateTask(task4);
+ history.addTask(task4);
+
+ assertTrue(task4.isActive());
+ //TaskActivationHistory taskHistory = taskView.getTaskActivationHistory();
+ List<AbstractTask> prevHistoryList = history.getPreviousTasks();
+
+ // Check that the previous history list looks right
+ assertTrue(prevHistoryList.size() >= 3);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task3);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task2);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
+
+ // Get a task from the list and activate it
+ TasksUi.getTaskActivityManager().activateTask(task2);
+ assertTrue(task2.isActive());
+
+ // Now check that the next and prev lists look right
+ prevHistoryList = history.getPreviousTasks();
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task2);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task4);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task3);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
+
+ // Activation of task outside of history navigation tool
+ history.addTask(task3);
+ prevHistoryList = history.getPreviousTasks();
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task3);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task2);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task4);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
+
+ // Pick a task from drop down history
+ TasksUi.getTaskActivityManager().activateTask(task4);
+ assertTrue(task4.isActive());
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task4);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task3);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task2);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
+
+ // Hit previous task button
+ previousTaskAction.run();
+ assertTrue(task3.isActive());
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task4);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task3);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task2);
+ assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
+
+ TasksUi.getTaskActivityManager().deactivateTask(task3);
+
+ // List<ITask> nextHistoryList = taskHistory.getNextTasks();
+ // assertTrue(nextHistoryList.get(0) == task3);
+ // assertTrue(nextHistoryList.get(1) == task4);
+ //
+ // // Navigate to a next item
+ // NextTaskDropDownAction nextAction = new
+ // NextTaskDropDownAction(taskView, taskHistory);
+ // navigateAction = nextAction.new TaskNavigateAction(task4);
+ // navigateAction.run();
+ // taskHistory.navigatedToTask(task4);
+ //
+ // assertTrue(task4.isActive());
+ //
+ // // Check that the prev and next lists look right
+ // nextHistoryList = taskHistory.getNextTasks();
+ // prevHistoryList = taskHistory.getPreviousTasks();
+ // assertTrue(nextHistoryList.size() == 0);
+ // assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task3);
+ // assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task2);
+ // assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task1);
+ //
+ // // Check that a deactivated task appears first on the history list
+ // TasksUi.getTaskActivityManager().activateTask(task5);
+ // (new TaskDeactivateAction()).run(task5);
+ // taskView.addTaskToHistory(task5);
+ // prevHistoryList = taskHistory.getPreviousTasks();
+ // assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task5);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java
index cd2899704..e665caa02 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityListenerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -15,8 +15,10 @@ import junit.framework.TestCase;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
import org.eclipse.mylyn.tasks.tests.connector.MockTask;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
/**
* @author Shawn Minto
@@ -68,18 +70,21 @@ public class TaskActivityListenerTest extends TestCase {
}
+ private ITaskActivityManager taskActivityManager;
+
@Override
protected void setUp() throws Exception {
- TasksUiPlugin.getTaskListManager().deactivateAllTasks();
+ taskActivityManager = TasksUi.getTaskActivityManager();
+ taskActivityManager.deactivateActiveTask();
}
public void testTaskActivation() {
MockTask task = new MockTask("test:activation");
MockTaskActivationListener listener = new MockTaskActivationListener();
try {
- TasksUiPlugin.getTaskActivityManager().addActivationListener(listener);
+ taskActivityManager.addActivationListener(listener);
try {
- TasksUiPlugin.getTaskListManager().activateTask(task);
+ taskActivityManager.activateTask(task);
assertTrue(listener.hasPreActivated);
assertTrue(listener.hasActivated);
assertFalse(listener.hasPreDeactivated);
@@ -87,7 +92,7 @@ public class TaskActivityListenerTest extends TestCase {
listener.reset();
} finally {
- TasksUiPlugin.getTaskListManager().deactivateTask(task);
+ taskActivityManager.deactivateTask(task);
}
assertFalse(listener.hasPreActivated);
assertFalse(listener.hasActivated);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
index 3d50e950b..0cd17ce98 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityTimingTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -63,8 +63,7 @@ public class TaskActivityTimingTest extends TestCase {
@Override
protected void tearDown() throws Exception {
ContextCorePlugin.getContextManager().getActivityMetaContext().reset();
- TasksUiPlugin.getTaskListManager().resetTaskList();
- TasksUiPlugin.getTaskListManager().saveTaskList();
+ TaskTestUtil.resetTaskList();
super.tearDown();
}
@@ -708,7 +707,7 @@ public class TaskActivityTimingTest extends TestCase {
TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent1, false);
metaContext.parseEvent(activityEvent2);
TasksUiPlugin.getTaskActivityMonitor().parseInteractionEvent(activityEvent2, false);
- TasksUiPlugin.getTaskListManager().deactivateAllTasks();
+ TasksUiPlugin.getTaskActivityManager().deactivateActiveTask();
assertEquals(4, ContextCorePlugin.getContextManager().getActivityMetaContext().getInteractionHistory().size());
TasksUiPlugin.getTaskListManager().saveTaskList();
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AttachmentJobTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java
index cc7476fe5..a5081b58b 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AttachmentJobTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskAttachmentTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -17,20 +17,28 @@ import java.io.RandomAccessFile;
import junit.framework.TestCase;
import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.deprecated.DownloadAttachmentJob;
+import org.eclipse.mylyn.internal.tasks.ui.util.CopyAttachmentToClipboardJob;
+import org.eclipse.mylyn.internal.tasks.ui.util.DownloadAttachmentJob;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.tests.connector.MockAttachmentHandler;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.connector.MockTask;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.ui.PlatformUI;
/**
* Test task attachment jobs.
*
* @author Steffen Pingel
*/
-public class AttachmentJobTest extends TestCase {
+public class TaskAttachmentTest extends TestCase {
private TaskRepositoryManager manager;
@@ -57,7 +65,9 @@ public class AttachmentJobTest extends TestCase {
connector.setAttachmentHandler(attachmentHandler);
manager.addRepositoryConnector(connector);
-// attachment = new TaskAttachment(repository, task, attribute);
+ TaskData taskData = new TaskData(new TaskAttributeMapper(repository), MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL, "1");
+ attachment = new TaskAttachment(repository, new MockTask("1"), taskData.getRoot().createAttribute("attachment"));
}
@Override
@@ -65,18 +75,17 @@ public class AttachmentJobTest extends TestCase {
manager.removeRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
}
-// TODO: refactor 3.0
-// public void testCopyToClipboardAction() throws Exception {
-// String expected = "attachment content";
-// attachmentHandler.setAttachmentData(expected.getBytes());
-//
-// CopyAttachmentToClipboardJob job = new CopyAttachmentToClipboardJob(attachment);
-// job.schedule();
-// job.join();
-//
-// Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
-// assertEquals(expected, clipboard.getContents(TextTransfer.getInstance()));
-// }
+ public void testCopyToClipboardAction() throws Exception {
+ String expected = "attachment content";
+ attachmentHandler.setAttachmentData(expected.getBytes());
+
+ CopyAttachmentToClipboardJob job = new CopyAttachmentToClipboardJob(attachment);
+ job.schedule();
+ job.join();
+
+ Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
+ assertEquals(expected, clipboard.getContents(TextTransfer.getInstance()));
+ }
public void testDownloadAttachmentJob() throws Exception {
File file = File.createTempFile("mylyn", null);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AbstractTaskContainerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskContainerTest.java
index 0e4c1ca87..e65783e0c 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AbstractTaskContainerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskContainerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -15,7 +15,10 @@ import junit.framework.TestCase;
import org.eclipse.mylyn.tasks.tests.connector.MockTask;
-public class AbstractTaskContainerTest extends TestCase {
+/**
+ * @author Steffen Pingel
+ */
+public class TaskContainerTest extends TestCase {
public void testGetChildren() {
MockTask task1 = new MockTask("1");
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStorageManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStorageManagerTest.java
deleted file mode 100644
index b3052bd59..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStorageManagerTest.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2008 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.tasks.tests;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.mylyn.internal.tasks.core.TaskDataStorageManager;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.tasks.tests.connector.MockAttributeFactory;
-import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
-
-/**
- * @author Rob Elves
- */
-public class TaskDataStorageManagerTest extends TestCase {
-
- TaskDataStorageManager offlineTaskDataManager;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- offlineTaskDataManager = TasksUiPlugin.getTaskDataStorageManager();
- offlineTaskDataManager.clear();
- offlineTaskDataManager.saveNow();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- if (offlineTaskDataManager != null) {
- offlineTaskDataManager.clear();
- offlineTaskDataManager.saveNow();
- }
- }
-
- public void testAdd() throws CoreException {
- RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
- offlineTaskDataManager.setNewTaskData(taskData);
- assertNotNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1"));
- }
-
- public void testSave() throws CoreException, IOException, ClassNotFoundException {
- RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
-
- RepositoryTaskAttribute attrib1 = new RepositoryTaskAttribute("key", "name", false);
- attrib1.putMetaDataValue("key1", "value1");
- attrib1.putMetaDataValue("key2", "value2");
- taskData.addAttribute("key", attrib1);
-
- assertNotNull(taskData.getAttribute("key"));
-
- offlineTaskDataManager.setNewTaskData(taskData);
-
- taskData = new RepositoryTaskData(new MockAttributeFactory(), MockRepositoryConnector.REPOSITORY_KIND,
- MockRepositoryConnector.REPOSITORY_URL, "2");
-
- RepositoryTaskAttribute attrib2 = new RepositoryTaskAttribute("key", "name", false);
- attrib2.putMetaDataValue("key3", "value3");
- attrib2.putMetaDataValue("key4", "value4");
- taskData.addAttribute("key", attrib2);
-
- assertNotNull(taskData.getAttribute("key"));
-
- offlineTaskDataManager.setNewTaskData(taskData);
-
- RepositoryTaskData loaded = offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1");
- assertNotNull(loaded);
- RepositoryTaskAttribute atr = loaded.getAttribute("key");
- assertNotNull(atr);
- assertEquals("value1", atr.getMetaDataValue("key1"));
- assertEquals("value2", atr.getMetaDataValue("key2"));
-
- loaded = offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "2");
- assertNotNull(loaded);
- atr = loaded.getAttribute("key");
- assertNotNull(atr);
-
- assertEquals("value3", atr.getMetaDataValue("key3"));
- assertEquals("value4", atr.getMetaDataValue("key4"));
-
- offlineTaskDataManager.saveNow();
- offlineTaskDataManager.remove(MockRepositoryConnector.REPOSITORY_URL, "1");
- offlineTaskDataManager.remove(MockRepositoryConnector.REPOSITORY_URL, "2");
-
- assertNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1"));
- assertNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "2"));
-
- }
-
- public void testGetNextOfflineBugId() throws IOException, ClassNotFoundException {
- assertEquals("1", offlineTaskDataManager.getNewRepositoryTaskId());
- assertEquals("2", offlineTaskDataManager.getNewRepositoryTaskId());
- offlineTaskDataManager.saveNow();
- offlineTaskDataManager.clear(); // currently resets new task id
- assertEquals("1", offlineTaskDataManager.getNewRepositoryTaskId());
- }
-
-// public void testGetTaskData() throws CoreException, IOException, ClassNotFoundException {
-// RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(),
-// MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
-// taskData.setNewComment("version 1");
-// offlineTaskDataManager.setNewTaskData(RepositoryTaskHandleUtil.getHandle(MockRepositoryConnector.REPOSITORY_URL, "1"),
-// taskData);
-// offlineTaskDataManager.setOldTaskData(RepositoryTaskHandleUtil.getHandle(MockRepositoryConnector.REPOSITORY_URL, "1"),
-// taskData);
-// assertNotNull(offlineTaskDataManager.getNewTaskData(RepositoryTaskHandleUtil.getHandle(
-// MockRepositoryConnector.REPOSITORY_URL, "1")));
-// taskData = new RepositoryTaskData(new MockAttributeFactory(), MockRepositoryConnector.REPOSITORY_KIND,
-// MockRepositoryConnector.REPOSITORY_URL, "1");
-// taskData.setNewComment("version 2");
-// offlineTaskDataManager.setNewTaskData(RepositoryTaskHandleUtil.getHandle(MockRepositoryConnector.REPOSITORY_URL, "1"),
-// taskData);
-//
-// offlineTaskDataManager.saveNow();
-// offlineTaskDataManager.clear();
-// offlineTaskDataManager.readOfflineData();
-// assertEquals("version 2", offlineTaskDataManager.getNewTaskData(
-// RepositoryTaskHandleUtil.getHandle(MockRepositoryConnector.REPOSITORY_URL, "1")).getNewComment());
-// assertEquals("version 1", offlineTaskDataManager.getOldTaskData(MockRepositoryConnector.REPOSITORY_URL, "1").getNewComment());
-// }
-
- public void testUniqueCopy() throws Exception {
- RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
- offlineTaskDataManager.setNewTaskData(taskData);
- RepositoryTaskData taskData2 = offlineTaskDataManager.getEditableCopy(MockRepositoryConnector.REPOSITORY_URL,
- "1");
- assertNotNull(taskData2);
- taskData2.setNewComment("test");
- taskData = null;
- taskData = offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1");
- assertFalse(taskData.getNewComment().equals("test"));
-// taskData = null;
-// taskData = offlineTaskDataManager.getOldTaskData(RepositoryTaskHandleUtil.getHandle(
-// MockRepositoryConnector.REPOSITORY_URL, "1"));
-// assertFalse(taskData.getNewComment().equals("test"));
- }
-
- public void testRemoveRepositoryTaskData() throws CoreException, IOException, ClassNotFoundException {
- RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
- offlineTaskDataManager.setNewTaskData(taskData);
- taskData = new RepositoryTaskData(new MockAttributeFactory(), MockRepositoryConnector.REPOSITORY_KIND,
- MockRepositoryConnector.REPOSITORY_URL, "2");
- offlineTaskDataManager.setNewTaskData(taskData);
- offlineTaskDataManager.saveNow();
- assertNotNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1"));
- assertNotNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "2"));
- offlineTaskDataManager.remove(MockRepositoryConnector.REPOSITORY_URL, "2");
- assertNotNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1"));
- assertNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "2"));
- offlineTaskDataManager.saveNow();
- offlineTaskDataManager.clear();
- assertNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1"));
- assertNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "2"));
- }
-
- public void testEditing() {
- RepositoryTaskData taskData = new RepositoryTaskData(new MockAttributeFactory(),
- MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, "1");
- offlineTaskDataManager.setNewTaskData(taskData);
-
- assertNotNull(offlineTaskDataManager.getNewTaskData(MockRepositoryConnector.REPOSITORY_URL, "1"));
-// assertNotNull(offlineTaskDataManager.getOldTaskData(RepositoryTaskHandleUtil.getHandle(
-// MockRepositoryConnector.REPOSITORY_URL, "1")));
-
- RepositoryTaskData editData = offlineTaskDataManager.getEditableCopy(MockRepositoryConnector.REPOSITORY_URL,
- "1");
- assertNotNull(editData);
- editData.setAttributeFactory(new MockAttributeFactory());
- editData.refresh();
- editData.setAttributeValue(RepositoryTaskAttribute.COMMENT_NEW, "new comment");
- // for (RepositoryTaskAttribute attribute: editData.getAttributes()) {
- // assertTrue(taskData.getAttribute(attribute.getID()).equals(attribute));
- // }
-
- Set<RepositoryTaskAttribute> attSave = new HashSet<RepositoryTaskAttribute>();
- attSave.add(editData.getAttribute(RepositoryTaskAttribute.COMMENT_NEW));
- offlineTaskDataManager.saveEdits(MockRepositoryConnector.REPOSITORY_URL, "1", attSave);
-
- editData = null;
- editData = offlineTaskDataManager.getEditableCopy(MockRepositoryConnector.REPOSITORY_URL, "1");
- assertNotNull(editData);
- assertEquals("new comment", editData.getAttributeValue(RepositoryTaskAttribute.COMMENT_NEW));
-
- }
-
- // /** DND
- // * As is will write 81481326 bytes.
- // *
- // * @throws Exception
- // */
- // public void testLargeDataSet() throws Exception {
- // RepositoryTaskData taskData;
- // for (int x = 1; x < 500; x++) {
- // taskData = new RepositoryTaskData(new MockAttributeFactory(),
- // MockRepositoryConnector.REPOSITORY_KIND,
- // MockRepositoryConnector.REPOSITORY_URL, "" + x);
- //
- // for (int y = 1; y < 60; y++) {
- // RepositoryTaskAttribute attribute = new RepositoryTaskAttribute("" + y,
- // "" + y, false);
- // for (int z = 1; z < 10; z++) {
- // attribute.addOption("" + z, "" + z);
- // attribute.addValue("" + z);
- // }
- // taskData.addAttribute("" + y, attribute);
- // }
- //
- // for (int y = 1; y < 5; y++) {
- // RepositoryOperation op = new RepositoryOperation("" + y, "" + y);
- // taskData.addOperation(op);
- // }
- //
- // try {
- // for (int y = 1; y < 1000; y++) {
- // TaskComment comment = new TaskComment(new MockAttributeFactory(), y);
- // comment.setAttributeValue(RepositoryTaskAttribute.COMMENT_TEXT, "Testing
- // \u05D0");
- // taskData.addComment(comment);
- // }
- // } catch (StackOverflowError e) {
- // e.printStackTrace();
- // }
- //
- // // for(int y = 1; y < 1000; y++) {
- // // RepositoryAttachment attachment = new
- // // RepositoryAttachment(repository, new MockAttributeFactory());
- // // taskData.addAttachment(attachment);
- // // }
- //
- // offlineTaskDataManager.put(taskData);
- // offlineTaskDataManager.put(taskData);
- // }
- // offlineTaskDataManager.save();
- // File file =
- // TasksUiPlugin.getDefault().getOfflineReportsFilePath().toFile();
- // offlineTaskDataManager.clear();
- // offlineTaskDataManager.readOfflineData();
- // assertNotNull(offlineTaskDataManager.getOldTaskData(AbstractTask.getHandle(
- // MockRepositoryConnector.REPOSITORY_URL, 400)));
- // }
-}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java
new file mode 100644
index 000000000..3e41040af
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDataStoreTest.java
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 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.tasks.tests;
+
+import java.io.File;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
+import org.eclipse.mylyn.internal.tasks.core.data.TaskDataState;
+import org.eclipse.mylyn.internal.tasks.core.data.TaskDataStore;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskOperation;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+
+/**
+ * @author Robert Elves
+ * @author Steffen Pingel
+ */
+public class TaskDataStoreTest extends TestCase {
+
+ private static final String MOCK_ID = "1";
+
+ private TaskDataStore storage;
+
+ private TaskRepository taskRepository;
+
+ private File file;
+
+ private TaskData data;
+
+ private TaskDataState state;
+
+ @Override
+ protected void setUp() throws Exception {
+ TaskRepositoryManager taskRepositoryManager = new TaskRepositoryManager();
+ storage = new TaskDataStore(taskRepositoryManager);
+ taskRepository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL);
+ file = File.createTempFile("mylyn", null);
+ file.deleteOnExit();
+
+ taskRepositoryManager.addRepositoryConnector(new MockRepositoryConnector());
+ taskRepositoryManager.addRepository(taskRepository);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ file.delete();
+ }
+
+ public void testPutAndGet() throws Exception {
+ TaskDataState state = new TaskDataState(MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
+
+ TaskData data = new TaskData(new TaskAttributeMapper(taskRepository), MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
+ TaskMapper mapper = new TaskMapper(data, true);
+ mapper.getTaskData().getRoot().createAttribute("attributeKey1").setValue("attValue!");
+ mapper.setDescription("description");
+ mapper.setSummary("summary");
+ mapper.setTaskKind("task kind");
+
+ TaskData oldData = new TaskData(new TaskAttributeMapper(taskRepository),
+ MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
+
+ state.setRepositoryData(data);
+ state.setLastReadData(oldData);
+ state.setEditsData(null);
+
+ storage.putTaskData(file, state);
+
+ TaskDataState retrieved = storage.getTaskDataState(file);
+ assertNotNull(retrieved);
+ TaskData newTaskData = retrieved.getRepositoryData();
+ assertNotNull(newTaskData);
+ assertEquals(MockRepositoryConnector.REPOSITORY_KIND, newTaskData.getConnectorKind());
+ mapper = new TaskMapper(newTaskData);
+ assertEquals("description", mapper.getDescription());
+ assertEquals("summary", mapper.getSummary());
+ assertEquals("task kind", mapper.getTaskKind());
+ }
+
+ public void testDelete() throws Exception {
+ TaskData data = new TaskData(new TaskAttributeMapper(taskRepository), MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
+ TaskDataState state = new TaskDataState(MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
+ state.setRepositoryData(data);
+ storage.putTaskData(file, state);
+ storage.deleteTaskData(file);
+ assertFalse(file.exists());
+ assertNull(storage.getTaskDataState(file));
+ }
+
+ private void setupData() {
+ data = new TaskData(new TaskAttributeMapper(taskRepository), MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL, MOCK_ID);
+ state = new TaskDataState(MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL,
+ MOCK_ID);
+ state.setRepositoryData(data);
+ }
+
+ public void testAttributes() throws Exception {
+ setupData();
+
+ TaskAttribute attribute = data.getRoot().createAttribute("testId");
+ attribute.getMetaData().setLabel("testName").setReadOnly(true);
+ attribute.putOption("Option Name 1", "Option Value 1");
+ attribute.putOption("Option Name 2", "Option Value 2");
+ attribute.addValue("Value 1");
+ attribute.addValue("Value 2");
+ attribute.addValue("Value 3");
+ attribute.getMetaData().putValue("MetaKey1", "MetaValue1");
+ attribute.getMetaData().putValue("MetaKey2", "MetaValue2");
+ attribute.getMetaData().putValue("MetaKey3", "MetaValue3");
+ attribute.getMetaData().putValue("MetaKey4", "MetaValue4");
+
+ assertData(1);
+ }
+
+ private void assertData(int attributeCount) throws CoreException {
+ storage.putTaskData(file, state);
+ state = storage.getTaskDataState(file);
+
+ assertNotNull(state);
+ assertNotNull(state.getRepositoryData());
+ assertEquals(data.getRoot().toString(), state.getRepositoryData().getRoot().toString());
+ assertEquals(attributeCount, state.getRepositoryData().getRoot().getAttributes().size());
+ }
+
+ public void testOperations() throws Exception {
+ setupData();
+
+ TaskOperation.applyTo(data.getRoot().createAttribute("op1"), "op1 id", "op1 label");
+ TaskOperation.applyTo(data.getRoot().createAttribute("op2"), "op2 id", "op2 label");
+
+ assertData(2);
+ }
+
+ public void testComments() throws Exception {
+ setupData();
+
+ TaskCommentMapper comment1 = new TaskCommentMapper();
+ comment1.setCommentId("attachmentId1");
+ TaskAttribute attr = data.getRoot().createAttribute("1");
+ comment1.applyTo(attr);
+ attr.createAttribute("attr1").setValue("attr1Name");
+
+ TaskCommentMapper comment2 = new TaskCommentMapper();
+ comment2.setCommentId("attachmentId2");
+ comment2.setCreationDate(new Date());
+ comment2.setNumber(100);
+ comment2.applyTo(data.getRoot().createAttribute("2"));
+
+ assertData(2);
+ }
+
+ public void testAttachments() throws Exception {
+ setupData();
+
+ TaskAttachmentMapper attachment1 = new TaskAttachmentMapper();
+ attachment1.setAuthor(taskRepository.createPerson("thecreator"));
+ attachment1.setDeprecated(false);
+ attachment1.setPatch(true);
+ TaskAttribute attr = data.getRoot().createAttribute("1");
+ attachment1.applyTo(attr);
+ attr.createAttribute("attr1").setValue("attr1Name");
+ attr.createAttribute("attr2").setValue("attr1Name");
+
+ TaskAttachmentMapper attachment2 = new TaskAttachmentMapper();
+ attachment2.setAuthor(taskRepository.createPerson("thecreator2"));
+ attachment2.setDeprecated(true);
+ attachment2.setPatch(false);
+ attachment2.applyTo(data.getRoot().createAttribute("2"));
+
+ assertData(2);
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskHistoryTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskHistoryTest.java
deleted file mode 100644
index 177206190..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskHistoryTest.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2008 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.tasks.tests;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
-import org.eclipse.mylyn.internal.tasks.core.TaskActivationHistory;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListManager;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.actions.ActivateTaskHistoryDropDownAction;
-import org.eclipse.mylyn.internal.tasks.ui.actions.TaskActivateAction;
-import org.eclipse.mylyn.internal.tasks.ui.actions.TaskDeactivateAction;
-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
-
-/**
- * @author Wesley Coelho
- * @author Rob Elves
- */
-public class TaskHistoryTest extends TestCase {
-
- private final TaskListManager manager = TasksUiPlugin.getTaskListManager();
-
- private TaskActivationHistory history;
-
- private AbstractTask task1;
-
- private AbstractTask task2;
-
- private AbstractTask task3;
-
- private AbstractTask task4;
-
- private AbstractTask task5;
-
- private ActivateTaskHistoryDropDownAction previousTaskAction;
-
- @Override
- protected void setUp() throws Exception {
- resetHistory();
-
- task1 = TasksUiInternal.createNewLocalTask("task 1");
- manager.getTaskList().addTask(task1);
-
- task2 = TasksUiInternal.createNewLocalTask("task 2");
- manager.getTaskList().addTask(task2);
-
- task3 = TasksUiInternal.createNewLocalTask("task 3");
- manager.getTaskList().addTask(task3);
-
- task4 = TasksUiInternal.createNewLocalTask("task 4");
- manager.getTaskList().addTask(task4);
-
- task5 = TasksUiInternal.createNewLocalTask("task 5");
- manager.getTaskList().addTask(task5);
-
- history = TasksUiPlugin.getTaskActivityManager().getTaskActivationHistory();
-
- previousTaskAction = new ActivateTaskHistoryDropDownAction();
- }
-
- private void resetHistory() {
- manager.deactivateAllTasks();
- TasksUiPlugin.getTaskActivityManager().clear();
- ContextCorePlugin.getContextManager().resetActivityMetaContext();
- }
-
- /**
- * Tests the next task and previous task navigation.
- */
- public void testBasicHistoryNavigation() {
- // NOTE: legacy test
- (new TaskActivateAction()).run(task1);
- history.addTask(task1);
- (new TaskActivateAction()).run(task2);
- history.addTask(task2);
- (new TaskActivateAction()).run(task3);
- history.addTask(task3);
-
- assertTrue(task3.isActive());
- assertFalse(task2.isActive());
- assertFalse(task1.isActive());
-
- previousTaskAction.run();
- assertTrue(task2.isActive());
-
- previousTaskAction.run();
- assertTrue(task1.isActive());
-
- previousTaskAction.run();
- assertTrue(task1.isActive());
-
- // taskView.getPreviousTaskAction().run();
- // assertTrue(task1.isActive());
- //
- // taskView.getPreviousTaskAction().run();
- // assertTrue(task1.isActive());
-
- // taskView.getNextTaskAction().run();
- // assertTrue(task2.isActive());
- //
- // taskView.getNextTaskAction().run();
- // assertTrue(task3.isActive());
- //
- // taskView.getNextTaskAction().run();
- // assertTrue(task3.isActive());
- //
- // taskView.getPreviousTaskAction().run();
- // assertTrue(task2.isActive());
- //
- // taskView.getNextTaskAction().run();
- // assertTrue(task3.isActive());
- //
- // (new TaskActivateAction()).run(task4);
- // history.addTask(task4); // Simulate clicking on it rather
- // // than navigating next or previous
- // assertTrue(task4.isActive());
- //
- // taskView.getNextTaskAction().run();
- // assertTrue(task4.isActive());
- //
- // taskView.getPreviousTaskAction().run();
- // assertTrue(task3.isActive());
- //
- // taskView.getNextTaskAction().run();
- // assertTrue(task4.isActive());
-
- }
-
- /**
- * Tests navigation to previous/next tasks that are chosen from a list rather than being sequentially navigated
- */
- public void testArbitraryHistoryNavigation() {
-
- resetHistory();
-
- // Simulate activating the tasks by clicking rather than
- // navigating previous/next
- (new TaskActivateAction()).run(task1);
- history.addTask(task1);
- (new TaskActivateAction()).run(task2);
- history.addTask(task2);
- (new TaskActivateAction()).run(task3);
- history.addTask(task3);
- (new TaskActivateAction()).run(task4);
- history.addTask(task4);
-
- assertTrue(task4.isActive());
- //TaskActivationHistory taskHistory = taskView.getTaskActivationHistory();
- List<AbstractTask> prevHistoryList = history.getPreviousTasks();
-
- // Check that the previous history list looks right
- assertTrue(prevHistoryList.size() >= 3);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task3);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task2);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
-
- // Get a task from the list and activate it
- (new TaskActivateAction()).run(task2);
- assertTrue(task2.isActive());
-
- // Now check that the next and prev lists look right
- prevHistoryList = history.getPreviousTasks();
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task2);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task4);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task3);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
-
- // Activation of task outside of history navigation tool
- history.addTask(task3);
- prevHistoryList = history.getPreviousTasks();
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task3);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task2);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task4);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
-
- // Pick a task from drop down history
- (new TaskActivateAction()).run(task4);
- assertTrue(task4.isActive());
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task4);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task3);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task2);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
-
- // Hit previous task button
- previousTaskAction.run();
- assertTrue(task3.isActive());
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task4);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task3);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task2);
- assertTrue(prevHistoryList.get(prevHistoryList.size() - 4) == task1);
-
- (new TaskDeactivateAction()).run(task3);
-
- // List<ITask> nextHistoryList = taskHistory.getNextTasks();
- // assertTrue(nextHistoryList.get(0) == task3);
- // assertTrue(nextHistoryList.get(1) == task4);
- //
- // // Navigate to a next item
- // NextTaskDropDownAction nextAction = new
- // NextTaskDropDownAction(taskView, taskHistory);
- // navigateAction = nextAction.new TaskNavigateAction(task4);
- // navigateAction.run();
- // taskHistory.navigatedToTask(task4);
- //
- // assertTrue(task4.isActive());
- //
- // // Check that the prev and next lists look right
- // nextHistoryList = taskHistory.getNextTasks();
- // prevHistoryList = taskHistory.getPreviousTasks();
- // assertTrue(nextHistoryList.size() == 0);
- // assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task3);
- // assertTrue(prevHistoryList.get(prevHistoryList.size() - 2) == task2);
- // assertTrue(prevHistoryList.get(prevHistoryList.size() - 3) == task1);
- //
- // // Check that a deactivated task appears first on the history list
- // (new TaskActivateAction()).run(task5);
- // (new TaskDeactivateAction()).run(task5);
- // taskView.addTaskToHistory(task5);
- // prevHistoryList = taskHistory.getPreviousTasks();
- // assertTrue(prevHistoryList.get(prevHistoryList.size() - 1) == task5);
-
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDnDTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java
index 73a83e791..11f05c69c 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDnDTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListDropAdapterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -16,7 +16,7 @@ import java.util.Collection;
import junit.framework.TestCase;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.mylyn.internal.tasks.ui.TaskListManager;
+import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListDropAdapter;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
@@ -26,30 +26,26 @@ import org.eclipse.mylyn.tasks.core.ITask;
* @author Rob Elves
* @author Mik Kersten
*/
-public class TaskListDnDTest extends TestCase {
+public class TaskListDropAdapterTest extends TestCase {
private TaskListDropAdapter dropAdapter;
- private TaskListManager manager;
+ private TaskList taskList;
@Override
protected void setUp() throws Exception {
- manager = TasksUiPlugin.getTaskListManager();
- manager.resetTaskList();
+ TaskTestUtil.resetTaskList();
+ TasksUiPlugin.getDefault().getLocalTaskRepository();
TreeViewer viewer = TaskListView.getFromActivePerspective().getViewer();
assertNotNull(viewer);
dropAdapter = new TaskListDropAdapter(viewer);
-
- TasksUiPlugin.getDefault().getLocalTaskRepository();
+ taskList = TasksUiPlugin.getTaskList();
}
@Override
protected void tearDown() throws Exception {
- super.tearDown();
- manager.resetTaskList();
- manager.saveTaskList();
- assertNull(manager.getActiveTask());
+ TaskTestUtil.resetTaskList();
}
public void testisUrl() {
@@ -62,13 +58,13 @@ public class TaskListDnDTest extends TestCase {
}
public void testUrlDrop() {
- assertEquals(0, manager.getTaskList().getDefaultCategory().getChildren().size());
+ assertEquals(0, taskList.getDefaultCategory().getChildren().size());
String url = "http://eclipse.org/mylyn";
String title = "Mylar Technology Project";
String urlData = url + "\n" + title;
dropAdapter.performDrop(urlData);
- Collection<ITask> tasks = manager.getTaskList().getDefaultCategory().getChildren();
+ Collection<ITask> tasks = taskList.getDefaultCategory().getChildren();
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertEquals(url, tasks.iterator().next().getUrl());
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListExternalizationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListExternalizationTest.java
index 4b2bfcd29..ddbbdea7a 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListExternalizationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListExternalizationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -22,6 +22,9 @@ import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+/**
+ * @author Steffen Pingel
+ */
public class TaskListExternalizationTest extends TestCase {
private TaskList taskList;
@@ -39,7 +42,7 @@ public class TaskListExternalizationTest extends TestCase {
super.setUp();
TasksUiPlugin.getDefault().getPreferenceStore().setValue(
ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, false);
- TasksUiPlugin.getTaskListManager().resetTaskList();
+ TaskTestUtil.resetTaskList();
repository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND, MockRepositoryConnector.REPOSITORY_URL);
TasksUiPlugin.getRepositoryManager().addRepository(repository);
@@ -49,7 +52,7 @@ public class TaskListExternalizationTest extends TestCase {
@Override
protected void tearDown() throws Exception {
- TasksUiPlugin.getTaskListManager().resetTaskList();
+ TaskTestUtil.resetTaskList();
}
public void testTaskAttributes() throws CoreException {
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMappingTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMapperTest.java
index 56dfe2344..e42b4abe3 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMappingTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMapperTest.java
@@ -27,7 +27,7 @@ import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
/**
* @author Steffen Pingel
*/
-public class TaskMappingTest extends TestCase {
+public class TaskMapperTest extends TestCase {
private StubTaskAttributeMapper mapper;
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java
index 2440c2952..2bdc330b3 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskTestUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -20,6 +20,7 @@ import java.io.OutputStream;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
/**
* @author Mik Kersten
@@ -62,4 +63,16 @@ public class TaskTestUtil {
out.close();
}
+ @SuppressWarnings("deprecation")
+ public static void resetTaskList() {
+ TasksUiPlugin.getTaskListManager().resetTaskList();
+ }
+
+ @SuppressWarnings("deprecation")
+ public static void saveAndReadTasklist() {
+ TasksUiPlugin.getTaskListManager().saveTaskList();
+ TasksUiPlugin.getTaskListManager().resetTaskList();
+ TasksUiPlugin.getTaskListManager().readExistingOrCreateNewList();
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java
index a1388c4ec..37eed63d7 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2008 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
@@ -39,6 +39,7 @@ import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
*/
public class MockRepositoryConnector extends AbstractLegacyRepositoryConnector {
+ // TODO 3.1 rename to CONNECTOR_KIND
public static final String REPOSITORY_KIND = "mock";
public static final String REPOSITORY_URL = "http://mockrepository.test";

Back to the top