Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-02-11 13:41:58 +0000
committerSteffen Pingel2012-02-11 13:41:58 +0000
commitfa6a5fb9967a08f54e5800a1b239c03bfb4850ba (patch)
treedcbc5b4518cc80209932a12944612dd29519d863 /org.eclipse.mylyn.tasks.tests
parenta7f0e7fc780376a7ec5b21dd4a8a15d2ca015090 (diff)
downloadorg.eclipse.mylyn.tasks-fa6a5fb9967a08f54e5800a1b239c03bfb4850ba.tar.gz
org.eclipse.mylyn.tasks-fa6a5fb9967a08f54e5800a1b239c03bfb4850ba.tar.xz
org.eclipse.mylyn.tasks-fa6a5fb9967a08f54e5800a1b239c03bfb4850ba.zip
NEW - bug 371010: [api] provide abstracted priority mapping
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371010 Change-Id: I858678eac8c4803811553e18e65775244f61c78c
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-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/core/PriorityLevelTest.java100
2 files changed, 102 insertions, 0 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 7f36e0835..abc4bd7a7 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
@@ -16,6 +16,7 @@ import junit.framework.TestSuite;
import org.eclipse.mylyn.tasks.tests.core.FileTaskAttachmentSourceTest;
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.TaskDataExternalizerTest;
@@ -118,6 +119,7 @@ public class AllTasksTests {
//suite.addTestSuite(BackgroundSaveTest.class);
suite.addTestSuite(MultipleTaskHyperlinkDetectorTest.class);
suite.addTestSuite(RegionComparatorTest.class);
+ suite.addTestSuite(PriorityLevelTest.class);
return suite;
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/PriorityLevelTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/PriorityLevelTest.java
new file mode 100644
index 000000000..9b9213d47
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/PriorityLevelTest.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.core;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.tasks.core.ITask.IPriorityValue;
+import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
+
+/**
+ * @author Steffen Pingel
+ */
+public class PriorityLevelTest extends TestCase {
+
+ private static class Priority implements IPriorityValue {
+
+ private final int value;
+
+ public Priority(int value) {
+ this.value = value;
+ }
+
+ public int getPriorityValue() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + value;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Priority other = (Priority) obj;
+ if (value != other.value) {
+ return false;
+ }
+ return true;
+ }
+
+ }
+
+ public void testFromValueThreePriorities() {
+ Priority p1 = new Priority(1);
+ Priority p2 = new Priority(2);
+ Priority p3 = new Priority(3);
+ Priority[] priorities = new Priority[] { p1, p2, p3 };
+ assertEquals("P1", PriorityLevel.fromValue(priorities, new Priority(1)).toString());
+ assertEquals("P3", PriorityLevel.fromValue(priorities, new Priority(2)).toString());
+ assertEquals("P5", PriorityLevel.fromValue(priorities, new Priority(3)).toString());
+ assertEquals("P3", PriorityLevel.fromValue(priorities, new Priority(10)).toString());
+ assertEquals("P3", PriorityLevel.fromValue(priorities, null).toString());
+ }
+
+ public void testFromValueSinglePriority() {
+ Priority p1 = new Priority(10);
+ Priority[] priorities = new Priority[] { p1 };
+ assertEquals("P1", PriorityLevel.fromValue(priorities, new Priority(10)).toString());
+ assertEquals("P3", PriorityLevel.fromValue(priorities, new Priority(11)).toString());
+ assertEquals("P3", PriorityLevel.fromValue(priorities, null).toString());
+ }
+
+ public void testFromValueSixPriorites() {
+ Priority p1 = new Priority(10);
+ Priority p2 = new Priority(20);
+ Priority p3 = new Priority(30);
+ Priority p4 = new Priority(40);
+ Priority p5 = new Priority(70);
+ Priority p6 = new Priority(100);
+ Priority[] priorities = new Priority[] { p1, p2, p3, p4, p5, p6 };
+ assertEquals("P1", PriorityLevel.fromValue(priorities, new Priority(10)).toString());
+ assertEquals("P1", PriorityLevel.fromValue(priorities, new Priority(20)).toString());
+ assertEquals("P2", PriorityLevel.fromValue(priorities, new Priority(30)).toString());
+ assertEquals("P2", PriorityLevel.fromValue(priorities, new Priority(40)).toString());
+ assertEquals("P4", PriorityLevel.fromValue(priorities, new Priority(70)).toString());
+ assertEquals("P5", PriorityLevel.fromValue(priorities, new Priority(100)).toString());
+ }
+
+}

Back to the top