Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-03-01 09:50:20 +0000
committerspingel2011-03-01 09:50:20 +0000
commitd51e695c7bf4a837cdf31005773858c478fc2768 (patch)
treec86a35089e38f4122e426e5661028ffc2dd51925 /org.eclipse.mylyn.tasks.tests/src
parent641bae63d3bcc1df5ee5173007128f8b6e57eca9 (diff)
downloadorg.eclipse.mylyn.tasks-d51e695c7bf4a837cdf31005773858c478fc2768.tar.gz
org.eclipse.mylyn.tasks-d51e695c7bf4a837cdf31005773858c478fc2768.tar.xz
org.eclipse.mylyn.tasks-d51e695c7bf4a837cdf31005773858c478fc2768.zip
NEW - bug 286963: [api] add support for ignoring incoming notification on specified fields
https://bugs.eclipse.org/bugs/show_bug.cgi?id=286963
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java3
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDiffUtilTest.java66
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskAttributeDiffTest.java90
3 files changed, 67 insertions, 92 deletions
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 bff563b35..896c9c720 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
@@ -23,7 +23,6 @@ import org.eclipse.mylyn.tasks.tests.data.Xml11InputStreamTest;
import org.eclipse.mylyn.tasks.tests.ui.ContextPerspectiveManagerTest;
import org.eclipse.mylyn.tasks.tests.ui.RetrieveTitleFromUrlTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskAttachmentPropertyTesterTest;
-import org.eclipse.mylyn.tasks.tests.ui.TaskAttributeDiffTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskHyperlinkDetectorTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskListSynchronizationSchedulerTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskListViewTest;
@@ -106,7 +105,7 @@ public class AllTasksTests {
suite.addTestSuite(TaskListSynchronizationSchedulerTest.class);
suite.addTestSuite(PlanningPartTest.class);
suite.addTestSuite(RepositoryCompletionProcessorTest.class);
- suite.addTestSuite(TaskAttributeDiffTest.class);
+ suite.addTestSuite(TaskDiffUtilTest.class);
// XXX re-enable
//suite.addTestSuite(ServiceMessageManagerTest.class);
suite.addTestSuite(TaskMigratorTest.class);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDiffUtilTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDiffUtilTest.java
index 9d8fdf320..91e5fcf14 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDiffUtilTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskDiffUtilTest.java
@@ -12,13 +12,27 @@
package org.eclipse.mylyn.tasks.tests;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+
import junit.framework.TestCase;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryModel;
+import org.eclipse.mylyn.internal.tasks.core.TaskList;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
+import org.eclipse.mylyn.internal.tasks.core.data.TaskDataDiff;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskDiffUtil;
+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;
/**
* @author Eugene Kuleshov
* @author Steffen Pingel
+ * @author Robert Elves
*/
public class TaskDiffUtilTest extends TestCase {
@@ -53,4 +67,56 @@ public class TaskDiffUtilTest extends TestCase {
+ "> loren ipsum\n" + "> loren ipsum\n" + "other comment\n")));
}
+ public void testDateDiff() {
+ TaskData dataA = new TaskData(new MyTaskAttributeMapper(new TaskRepository("mock", "url")), "mock", "url",
+ "1123");
+ TaskAttribute attributeA = new TaskAttribute(dataA.getRoot(), "attributeA");
+ attributeA.getMetaData()
+ .setKind(TaskAttribute.KIND_DEFAULT)
+ .setType(TaskAttribute.TYPE_DATE)
+ .setLabel("someDate:");
+ attributeA.setValue("1275068800000");
+
+ TaskData dataB = new TaskData(new MyTaskAttributeMapper(new TaskRepository("mock", "url")), "mock", "url",
+ "1123");
+ TaskAttribute attributeB = new TaskAttribute(dataB.getRoot(), "attributeA");
+ attributeB.getMetaData()
+ .setKind(TaskAttribute.KIND_DEFAULT)
+ .setType(TaskAttribute.TYPE_DATE)
+ .setLabel("mydate");
+ attributeB.setValue("1265068800000");
+
+ TaskDataDiff diff = new TaskDataDiff(new RepositoryModel(new TaskList(), new TaskRepositoryManager()), dataA,
+ dataB);
+ assertEquals(" someDate: 2010/02/01 -> 2010/05/28", TaskDiffUtil.toString(diff));
+ }
+
+ static class MyTaskAttributeMapper extends TaskAttributeMapper {
+
+ public MyTaskAttributeMapper(TaskRepository taskRepository) {
+ super(taskRepository);
+ }
+
+ @Override
+ public String getValueLabel(TaskAttribute taskAttribute) {
+ if (taskAttribute.getMetaData().getType() == TaskAttribute.TYPE_DATE) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(Long.parseLong(taskAttribute.getValue()));
+ return new SimpleDateFormat("yyyy/MM/dd").format(cal.getTime());
+ }
+ return super.getValueLabel(taskAttribute);
+ }
+
+ @Override
+ public List<String> getValueLabels(TaskAttribute taskAttribute) {
+ if (taskAttribute.getMetaData().getType() == TaskAttribute.TYPE_DATE) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(Long.parseLong(taskAttribute.getValue()));
+ return Collections.singletonList(new SimpleDateFormat("yyyy/MM/dd").format(cal.getTime()));
+ }
+ return super.getValueLabels(taskAttribute);
+ }
+
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskAttributeDiffTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskAttributeDiffTest.java
deleted file mode 100644
index 1d8f1457e..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskAttributeDiffTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.ui;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.internal.tasks.core.RepositoryModel;
-import org.eclipse.mylyn.internal.tasks.core.TaskList;
-import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.internal.tasks.core.data.TaskDataDiff;
-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;
-
-/**
- * @author Robert Elves
- */
-public class TaskAttributeDiffTest extends TestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- public void testDateDiff() {
- TaskData dataA = new TaskData(new MyTaskAttributeMapper(new TaskRepository("mock", "url")), "mock", "url",
- "1123");
- TaskAttribute attributeA = new TaskAttribute(dataA.getRoot(), "attributeA");
- attributeA.getMetaData().setKind(TaskAttribute.KIND_DEFAULT).setType(TaskAttribute.TYPE_DATE).setLabel(
- "someDate:");
- attributeA.setValue("1275068800000");
-
- TaskData dataB = new TaskData(new MyTaskAttributeMapper(new TaskRepository("mock", "url")), "mock", "url",
- "1123");
- TaskAttribute attributeB = new TaskAttribute(dataB.getRoot(), "attributeA");
- attributeB.getMetaData()
- .setKind(TaskAttribute.KIND_DEFAULT)
- .setType(TaskAttribute.TYPE_DATE)
- .setLabel("mydate");
- attributeB.setValue("1265068800000");
-
- TaskDataDiff diff = new TaskDataDiff(new RepositoryModel(new TaskList(), new TaskRepositoryManager()), dataA,
- dataB);
- assertEquals(" someDate: 2010/02/01 -> 2010/05/28", diff.toString());
-
- }
-
- static class MyTaskAttributeMapper extends TaskAttributeMapper {
-
- public MyTaskAttributeMapper(TaskRepository taskRepository) {
- super(taskRepository);
- }
-
- @Override
- public String getValueLabel(TaskAttribute taskAttribute) {
- if (taskAttribute.getMetaData().getType() == TaskAttribute.TYPE_DATE) {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(Long.parseLong(taskAttribute.getValue()));
- return new SimpleDateFormat("yyyy/MM/dd").format(cal.getTime());
- }
- return super.getValueLabel(taskAttribute);
- }
-
- @Override
- public List<String> getValueLabels(TaskAttribute taskAttribute) {
- if (taskAttribute.getMetaData().getType() == TaskAttribute.TYPE_DATE) {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(Long.parseLong(taskAttribute.getValue()));
- return Collections.singletonList(new SimpleDateFormat("yyyy/MM/dd").format(cal.getTime()));
- }
- return super.getValueLabels(taskAttribute);
- }
-
- }
-}

Back to the top