summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-02-12 07:22:01 (EST)
committer Steffen Pingel2012-02-12 07:22:01 (EST)
commit23afd2a8112c4fb5d77f961aa1814a57c1840f93 (patch)
tree81ac50bf7f46ca6df3429e07c5ae062bf9d3af5e
parenta73ad6d430c3fcbcfbd0ef75765f1d6397ddc46e (diff)
downloadorg.eclipse.mylyn.tasks-23afd2a8112c4fb5d77f961aa1814a57c1840f93.zip
org.eclipse.mylyn.tasks-23afd2a8112c4fb5d77f961aa1814a57c1840f93.tar.gz
org.eclipse.mylyn.tasks-23afd2a8112c4fb5d77f961aa1814a57c1840f93.tar.bz2
NEW - bug 371323: [regression] all comments are shown as incoming
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371323 Change-Id: I20bd34a248dbfbd2e157ffdfda183aaa0fd30b00
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java4
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java19
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeMapperTest.java99
4 files changed, 124 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
index 315fc6a..8337968 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java
@@ -317,6 +317,10 @@ public class BugzillaAttributeMapper extends TaskAttributeMapper {
@Override
public boolean equals(TaskAttribute newAttribute, TaskAttribute oldAttribute) {
+ if (TaskAttribute.TYPE_COMMENT.equals(newAttribute.getMetaData().getType())) {
+ // the ID mapping for Bugzilla changed in Mylyn 3.7, always consider existing comments equal
+ return true;
+ }
if (oldAttribute.getId().startsWith(TaskAttribute.PREFIX_ATTACHMENT)) {
TaskAttachmentMapper oldAttachment;
oldAttachment = TaskAttachmentMapper.createFrom(oldAttribute);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
index 2c76878..2b7d17f 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
@@ -47,6 +47,25 @@ public class TaskAttributeMapper {
}
public boolean equals(TaskAttribute newAttribute, TaskAttribute oldAttribute) {
+ if (TaskAttribute.TYPE_COMMENT.equals(newAttribute.getMetaData().getType())) {
+ if (newAttribute.getValues().equals(oldAttribute.getValues())) {
+ return true;
+ }
+ // the comment mapping accidentally changed throughout the Mylyn 3.7 cycle therefore some
+ // cases need to be considered equal even though attribute values differ
+ if (oldAttribute != null) {
+ TaskAttribute commentIdAttribute = oldAttribute.getAttribute("task.common.comment.id"); //$NON-NLS-1$
+ // ID not present
+ if ((commentIdAttribute == null || commentIdAttribute.getValue().equals("")) //$NON-NLS-1$
+ && newAttribute.getValue().equals("")) { //$NON-NLS-1$
+ return true;
+ }
+ // ID previously stored in a sub attribute
+ if (commentIdAttribute != null && commentIdAttribute.getValue().equals(newAttribute.getValue())) {
+ return true;
+ }
+ }
+ }
return newAttribute.getValues().equals(oldAttribute.getValues());
}
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 abc4bd7..fc10dc0 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
@@ -19,6 +19,7 @@ import org.eclipse.mylyn.tasks.tests.core.ITasksCoreConstantsTest;
import org.eclipse.mylyn.tasks.tests.core.PriorityLevelTest;
import org.eclipse.mylyn.tasks.tests.core.TaskListUnmatchedContainerTest;
import org.eclipse.mylyn.tasks.tests.core.TaskRepositoryLocationTest;
+import org.eclipse.mylyn.tasks.tests.data.TaskAttributeMapperTest;
import org.eclipse.mylyn.tasks.tests.data.TaskDataExternalizerTest;
import org.eclipse.mylyn.tasks.tests.data.Xml11InputStreamTest;
import org.eclipse.mylyn.tasks.tests.ui.MultipleTaskHyperlinkDetectorTest;
@@ -120,6 +121,7 @@ public class AllTasksTests {
suite.addTestSuite(MultipleTaskHyperlinkDetectorTest.class);
suite.addTestSuite(RegionComparatorTest.class);
suite.addTestSuite(PriorityLevelTest.class);
+ suite.addTestSuite(TaskAttributeMapperTest.class);
return suite;
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeMapperTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeMapperTest.java
new file mode 100644
index 0000000..76b6a93
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/data/TaskAttributeMapperTest.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.data;
+
+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.TaskCommentMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskAttributeMapperTest extends TestCase {
+
+ TaskRepository taskRepository = new TaskRepository("kind", "repository");
+
+ TaskAttributeMapper mapper = new TaskAttributeMapper(taskRepository);
+
+ TaskData data = new TaskData(mapper, "kind", "repository", "id");
+
+ public void testEqualsCommentId() {
+ TaskCommentMapper comment = new TaskCommentMapper();
+ comment.setCommentId("commentid");
+ comment.setNumber(1);
+
+ TaskAttribute attributeOld = data.getRoot().createAttribute("1");
+ comment.applyTo(attributeOld);
+
+ TaskAttribute attributeNew = data.getRoot().createAttribute("2");
+ comment.applyTo(attributeNew);
+ assertTrue(mapper.equals(attributeNew, attributeOld));
+
+ comment.setCommentId("commentid2");
+ comment.applyTo(attributeOld);
+ assertFalse("Expected not equals:\n" + attributeOld + "\n" + attributeNew,
+ mapper.equals(attributeNew, attributeOld));
+ }
+
+ public void testEqualsCommentMylyn37() {
+ TaskCommentMapper comment = new TaskCommentMapper();
+ comment.setNumber(1);
+
+ // Mylyn 3.7 before release
+ TaskAttribute attributeOld = data.getRoot().createAttribute("1");
+ comment.applyTo(attributeOld);
+ attributeOld.setValue("1");
+
+ // Mylyn 3.7 release
+ TaskAttribute attributeNew = data.getRoot().createAttribute("2");
+ comment.applyTo(attributeNew);
+ assertEquals("", attributeNew.getValue());
+
+ assertTrue("Expected equals:\n" + attributeOld + "\n" + attributeNew, mapper.equals(attributeNew, attributeOld));
+ assertFalse("Expected not equals:\n" + attributeOld + "\n" + attributeNew,
+ mapper.equals(attributeOld, attributeNew));
+ }
+
+ public void testEqualsCommentMylyn37CommentId() {
+ TaskCommentMapper comment = new TaskCommentMapper();
+ comment.setNumber(1);
+ comment.setCommentId("2");
+
+ // Mylyn 3.7 before release, but missing sub-attribute
+ TaskAttribute attributeOld = data.getRoot().createAttribute("1");
+ comment.applyTo(attributeOld);
+ attributeOld.setValue("1");
+
+ // Mylyn 3.7 release
+ TaskAttribute attributeNew = data.getRoot().createAttribute("2");
+ comment.applyTo(attributeNew);
+ assertEquals("2", attributeNew.getValue());
+
+ assertFalse("Expected not equals:\n" + attributeOld + "\n" + attributeNew,
+ mapper.equals(attributeNew, attributeOld));
+
+ // Mylyn 3.7 before release with ID sub-attribute
+ TaskAttribute idAttribute = attributeOld.createAttribute("task.common.comment.id");
+ idAttribute.setValue("2");
+ assertTrue("Expected equals:\n" + attributeOld + "\n" + attributeNew, mapper.equals(attributeNew, attributeOld));
+
+ // IDs should now be unequal
+ idAttribute.setValue("3");
+ assertFalse("Expected not equals:\n" + attributeOld + "\n" + attributeNew,
+ mapper.equals(attributeNew, attributeOld));
+ }
+
+}