Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-09-17 01:31:07 -0400
committerspingel2008-09-17 01:31:07 -0400
commited73ce722ef60a020b5a18277f3013243e3e9d33 (patch)
tree7063b8acb7a28cefb27d76fe519332f4c375de26
parentfd57425b86b3050ac0be83174c009db15e874532 (diff)
downloadorg.eclipse.mylyn.tasks-ed73ce722ef60a020b5a18277f3013243e3e9d33.tar.gz
org.eclipse.mylyn.tasks-ed73ce722ef60a020b5a18277f3013243e3e9d33.tar.xz
org.eclipse.mylyn.tasks-ed73ce722ef60a020b5a18277f3013243e3e9d33.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.tests/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AbstractTaskDataHandlerTest.java226
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMappingTest.java186
4 files changed, 190 insertions, 230 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn.tasks.tests/.settings/org.eclipse.jdt.core.prefs
index fda3897b7..a68eec4df 100644
--- a/org.eclipse.mylyn.tasks.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.mylyn.tasks.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Tue May 20 10:54:29 PDT 2008
+#Sat Sep 13 19:26:36 PDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -18,7 +18,7 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AbstractTaskDataHandlerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AbstractTaskDataHandlerTest.java
deleted file mode 100644
index 3888612eb..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AbstractTaskDataHandlerTest.java
+++ /dev/null
@@ -1,226 +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.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractAttributeFactory;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractTaskDataHandler;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-
-/**
- * @author Steffen Pingel
- */
-public class AbstractTaskDataHandlerTest extends TestCase {
-
- private StubTaskDataHandler handler;
-
- private StubAttributeFactory factory;
-
- private RepositoryTaskData source;
-
- private RepositoryTaskData target;
-
- @Override
- protected void setUp() throws Exception {
- handler = new StubTaskDataHandler();
-
- factory = new StubAttributeFactory();
- source = new RepositoryTaskData(factory, "kind", "http://url", "1");
- target = new RepositoryTaskData(factory, "kind", "http://url", "2");
- }
-
- public void testCloneTaskCloneCommonAttributes() {
- source.setDescription("sourceDescription");
- handler.cloneTaskData(source, target);
- assertEquals("sourceDescription", target.getDescription());
- assertEquals("", target.getSummary());
-
- source.setSummary("sourceSummary");
- handler.cloneTaskData(source, target);
- assertEquals("sourceSummary", target.getSummary());
- }
-
- public void testCloneTaskDataAttributeWithValues() {
- source.addAttributeValue("key1", "value1");
- handler.cloneTaskData(source, target);
- assertEquals(null, target.getAttribute("key1"));
-
- target.setAttributeValue("key1", "value2");
- handler.cloneTaskData(source, target);
- assertEquals("value1", target.getAttributeValue("key1"));
-
- target.addAttributeValue("multi", "v1");
- target.addAttributeValue("multi", "v2");
- handler.cloneTaskData(source, target);
- assertEquals("value1", target.getAttributeValue("key1"));
- List<String> values = target.getAttributeValues("multi");
- assertEquals(2, values.size());
- assertEquals("v1", values.get(0));
- assertEquals("v2", values.get(1));
- }
-
- public void testCloneTaskDataAttributeWithOptions() {
- source.addAttributeValue("key", "o2");
- RepositoryTaskAttribute sourceAttribute = source.getAttribute("key");
- sourceAttribute.addOption("o1", "");
- sourceAttribute.addOption("o2", "");
- target.setAttributeValue("key", "");
- handler.cloneTaskData(source, target);
- assertEquals("o2", target.getAttributeValue("key"));
-
- // test target with options that don't contain
- RepositoryTaskAttribute targetAttribute = target.getAttribute("key");
- targetAttribute.addOption("o3", "");
- handler.cloneTaskData(source, target);
- assertEquals("", target.getAttributeValue("key"));
-
- // test target with options that contain value
- targetAttribute.addOption("o2", "");
- handler.cloneTaskData(source, target);
- assertEquals("o2", target.getAttributeValue("key"));
-
- // test multiple values
- sourceAttribute.addValue("o3");
- handler.cloneTaskData(source, target);
- List<String> values = targetAttribute.getValues();
- assertEquals(2, values.size());
- assertEquals("o2", values.get(0));
- assertEquals("o3", values.get(1));
- }
-
- public void testCloneTaskDifferentRepositoryTypesCloneCommonAttributes() {
- StubAttributeFactory targetFactory = new StubAttributeFactory();
- target = new RepositoryTaskData(targetFactory, "otherkind", "http://url", "2");
-
- source.setDescription("sourceDescription");
- handler.cloneTaskData(source, target);
- assertEquals("sourceDescription", target.getDescription());
- assertEquals("", target.getSummary());
-
- source.setSummary("sourceSummary");
- handler.cloneTaskData(source, target);
- assertEquals("sourceSummary", target.getSummary());
- }
-
- public void testCloneTaskDifferentRepositoryTypesCloneMappedAttribues() {
- StubAttributeFactory targetFactory = new StubAttributeFactory();
- target = new RepositoryTaskData(targetFactory, "otherkind", "http://url", "2");
-
- // key is not part of common schema
- source.setAttributeValue("key", "source");
- target.setAttributeValue("key", "target");
- handler.cloneTaskData(source, target);
- assertEquals("target", target.getAttributeValue("key"));
-
- // map key in source factory only
- factory.attributeMap.put(RepositoryTaskAttribute.PRIORITY, "key");
- handler.cloneTaskData(source, target);
- assertEquals("target", target.getAttributeValue("key"));
-
- // map key in target factory to different key
- targetFactory.attributeMap.put(RepositoryTaskAttribute.PRODUCT, "key");
- handler.cloneTaskData(source, target);
- assertEquals("target", target.getAttributeValue("key"));
-
- // map key in both factories
- targetFactory.attributeMap.put(RepositoryTaskAttribute.PRIORITY, "key");
- handler.cloneTaskData(source, target);
- assertEquals("source", target.getAttributeValue("key"));
-
- }
-
- 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;
- }
-
- }
-
- private class StubTaskDataHandler extends AbstractTaskDataHandler {
-
- @Override
- public AbstractAttributeFactory getAttributeFactory(String repositoryUrl, String repositoryKind, String taskKind) {
- // ignore
- return null;
- }
-
- @Override
- public AbstractAttributeFactory getAttributeFactory(RepositoryTaskData taskData) {
- // ignore
- return null;
- }
-
- @Override
- public RepositoryTaskData getTaskData(TaskRepository repository, String taskId, IProgressMonitor monitor)
- throws CoreException {
- // ignore
- return null;
- }
-
- @Override
- public boolean initializeTaskData(TaskRepository repository, RepositoryTaskData data, IProgressMonitor monitor)
- throws CoreException {
- // ignore
- return false;
- }
-
- @Override
- public String postTaskData(TaskRepository repository, RepositoryTaskData taskData, IProgressMonitor monitor)
- throws CoreException {
- // ignore
- return null;
- }
-
- }
-
-}
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 6997a4205..fbd12801b 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
@@ -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
@@ -65,7 +65,7 @@ public class AllTasksTests {
suite.addTestSuite(PersonProposalProviderTest.class);
suite.addTestSuite(TaskRepositoryLocationTest.class);
suite.addTestSuite(AttachmentSizeFormatterTest.class);
- suite.addTestSuite(AbstractTaskDataHandlerTest.class);
+ suite.addTestSuite(TaskMappingTest.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/TaskMappingTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMappingTest.java
new file mode 100644
index 000000000..56dfe2344
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskMappingTest.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskMapper;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskMappingTest extends TestCase {
+
+ private StubTaskAttributeMapper mapper;
+
+ private TaskMapper source;
+
+ private TaskMapper target;
+
+ private TaskRepository taskRepository;
+
+ @Override
+ protected void setUp() throws Exception {
+ taskRepository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND,
+ MockRepositoryConnector.REPOSITORY_URL);
+ mapper = new StubTaskAttributeMapper(taskRepository);
+ source = new TaskMapper(new TaskData(mapper, "kind", "http://url", "1"), true);
+ target = new TaskMapper(new TaskData(mapper, "kind", "http://url", "2"), true);
+ }
+
+ public void testCloneTaskCloneCommonAttributes() {
+ source.setDescription("sourceDescription");
+ target.setDescription("");
+ // TODO 3.1 remove (bug 247595)
+ target.getTaskData().getRoot().getAttribute(TaskAttribute.DESCRIPTION).getMetaData().setReadOnly(false);
+ target.merge(source);
+ assertEquals("sourceDescription", target.getDescription());
+ assertEquals(null, target.getSummary());
+
+ source.setSummary("sourceSummary");
+ target.setSummary("");
+ // TODO 3.1 remove (bug 247595)
+ target.getTaskData().getRoot().getAttribute(TaskAttribute.SUMMARY).getMetaData().setReadOnly(false);
+ target.merge(source);
+ assertEquals("sourceSummary", target.getSummary());
+ }
+
+ public void testCloneTaskDataAttributeWithValues() {
+ source.getTaskData().getRoot().createAttribute("key1").addValue("value1");
+ target.merge(source);
+ assertEquals(null, target.getTaskData().getRoot().getAttribute("key1"));
+
+ target.getTaskData().getRoot().createAttribute("key1").addValue("value2");
+ target.merge(source);
+ assertEquals("value1", target.getTaskData().getRoot().getAttribute("key1").getValue());
+
+ TaskAttribute attribute = source.getTaskData().getRoot().createAttribute("multi");
+ attribute.addValue("v1");
+ attribute.addValue("v2");
+ target.getTaskData().getRoot().createAttribute("multi");
+ target.merge(source);
+ assertEquals("value1", target.getTaskData().getRoot().getAttribute("key1").getValue());
+ List<String> values = target.getTaskData().getRoot().getAttribute("multi").getValues();
+ assertEquals(2, values.size());
+ assertEquals("v1", values.get(0));
+ assertEquals("v2", values.get(1));
+ }
+
+ public void testCloneTaskDataAttributeWithOptions() {
+ TaskAttribute sourceAttribute = source.getTaskData().getRoot().createAttribute("key");
+ sourceAttribute.setValue("o2");
+ sourceAttribute.putOption("o1", "");
+ sourceAttribute.putOption("o2", "");
+ target.getTaskData().getRoot().createAttribute("key");
+ target.merge(source);
+ assertEquals("o2", target.getTaskData().getRoot().getAttribute("key").getValue());
+
+ // test target with options that don't contain value
+ TaskAttribute targetAttribute = target.getTaskData().getRoot().getAttribute("key");
+ targetAttribute.putOption("o3", "");
+ target.merge(source);
+ assertEquals("", target.getTaskData().getRoot().getAttribute("key").getValue());
+
+ // test target with options that contain value
+ targetAttribute.putOption("o2", "");
+ target.merge(source);
+ assertEquals("o2", target.getTaskData().getRoot().getAttribute("key").getValue());
+
+ // test multiple values
+ sourceAttribute.addValue("o3");
+ target.merge(source);
+ List<String> values = targetAttribute.getValues();
+ assertEquals(2, values.size());
+ assertEquals("o2", values.get(0));
+ assertEquals("o3", values.get(1));
+ }
+
+ public void testCloneTaskDifferentRepositoryTypesCloneCommonAttributes() {
+ target = new TaskMapper(new TaskData(mapper, "otherkind", "http://url", "2"), true);
+
+ source.setDescription("sourceDescription");
+ target.setDescription("");
+ // TODO 3.1 remove (bug 247595)
+ target.getTaskData().getRoot().getAttribute(TaskAttribute.DESCRIPTION).getMetaData().setReadOnly(false);
+ target.merge(source);
+ assertEquals("sourceDescription", target.getDescription());
+ assertEquals(null, target.getSummary());
+
+ source.setSummary("sourceSummary");
+ target.merge(source);
+ assertEquals("sourceSummary", target.getSummary());
+ }
+
+ public void testCloneTaskDifferentRepositoryTypesCloneMappedAttribues() {
+ StubTaskAttributeMapper targetMapper = new StubTaskAttributeMapper(taskRepository);
+ target = new TaskMapper(new TaskData(targetMapper, "otherkind", "http://url", "2"), true);
+
+ // key is not part of common schema
+ source.getTaskData().getRoot().createAttribute("key").setValue("source");
+ target.getTaskData().getRoot().createAttribute("key").setValue("target");
+ target.merge(source);
+ assertEquals("target", target.getTaskData().getRoot().getAttribute("key").getValue());
+
+ // map key in source factory only
+ mapper.attributeMap.put(TaskAttribute.COMPONENT, "key");
+ target.merge(source);
+ assertEquals("target", target.getTaskData().getRoot().getAttribute("key").getValue());
+
+ // map key in target factory to different key
+ targetMapper.attributeMap.put(TaskAttribute.PRODUCT, "key");
+ target.merge(source);
+ assertEquals("target", target.getTaskData().getRoot().getAttribute("key").getValue());
+
+ // map key in both factories
+ targetMapper.attributeMap.put(TaskAttribute.COMPONENT, "key");
+ target.merge(source);
+ assertEquals("source", target.getTaskData().getRoot().getAttribute("key").getValue());
+ }
+
+ public void testNoCreationOfAttributes() {
+ target = new TaskMapper(new TaskData(mapper, "otherkind", "http://url", "2"));
+ target.setDescription("abc");
+ assertNull(target.getTaskData().getRoot().getAttribute(TaskAttribute.DESCRIPTION));
+ assertEquals(0, target.getTaskData().getRoot().getAttributes().size());
+
+ target = new TaskMapper(new TaskData(mapper, "otherkind", "http://url", "2"), false);
+ target.setDescription("abc");
+ assertNull(target.getTaskData().getRoot().getAttribute(TaskAttribute.DESCRIPTION));
+ assertEquals(0, target.getTaskData().getRoot().getAttributes().size());
+ }
+
+ private class StubTaskAttributeMapper extends TaskAttributeMapper {
+
+ public StubTaskAttributeMapper(TaskRepository taskRepository) {
+ super(taskRepository);
+ }
+
+ private final Map<String, String> attributeMap = new HashMap<String, String>();
+
+ @Override
+ public String mapToRepositoryKey(TaskAttribute parent, String key) {
+ String mappedKey = attributeMap.get(key);
+ return (mappedKey != null) ? mappedKey : key;
+ }
+
+ }
+
+}

Back to the top