diff options
author | Frank Becker | 2011-10-08 17:19:21 +0000 |
---|---|---|
committer | Frank Becker | 2011-10-08 17:19:21 +0000 |
commit | b9bf134a859194af22e2e3bdaa4413a3d4a69003 (patch) | |
tree | 384390367c56df49446547e105d12c354f00e744 | |
parent | cefccfdb23394c0aa77027837dda1dd67133ff84 (diff) | |
download | org.eclipse.mylyn.tasks-b9bf134a859194af22e2e3bdaa4413a3d4a69003.tar.gz org.eclipse.mylyn.tasks-b9bf134a859194af22e2e3bdaa4413a3d4a69003.tar.xz org.eclipse.mylyn.tasks-b9bf134a859194af22e2e3bdaa4413a3d4a69003.zip |
ASSIGNED - bug 242739: add support for custom priority levels (ie. if
not using P1-P5)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=242739
4 files changed, 17 insertions, 15 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java index 41e42ade3..91237081f 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java @@ -1091,27 +1091,27 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector { return history; } - public static PriorityLevel getTaskPriority(String tracPriority) { - if (tracPriority != null) { - BugzillaPriorityLevel priority = BugzillaPriorityLevel.fromPriority(tracPriority); + public static PriorityLevel getTaskPriority(String bugzillaPriority) { + if (bugzillaPriority != null) { + BugzillaPriorityLevel priority = BugzillaPriorityLevel.fromPriority(bugzillaPriority); if (priority != null) { return priority.toPriorityLevel(); } } - return PriorityLevel.getDefault(); + return PriorityLevel.fromString(bugzillaPriority); } public static PriorityLevel getTaskPriority(String priority, List<String> priorities) { if (priority != null && priorities != null && priorities.size() > 0) { - int size = priorities.size(); + int size = priorities.size() - 1; int index = 0; for (String priority2test : priorities) { - index++; if (priority.equals(priority2test)) { float relativeValue = (float) index / size; int value = (int) (relativeValue * 5) + 1; return PriorityLevel.fromLevel(value); } + index++; } } return getTaskPriority(priority); diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java index e3bbdb9c5..854ec4eb0 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java @@ -308,6 +308,7 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase { assertEquals(PriorityLevel.P3, mapping.getPriorityLevel()); if (!version.isSmaller(BugzillaVersion.BUGZILLA_3_6)) { // fresh bugzilla 3.6 databases have a new schema for priorities + // the value "---" maybe present (as default) so we get P5 or P3 (if not present) as the level taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Highest"); assertEquals(PriorityLevel.P1, mapping.getPriorityLevel()); taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("High"); @@ -319,7 +320,8 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase { taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Lowest"); assertEquals(PriorityLevel.P5, mapping.getPriorityLevel()); taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("---"); - assertEquals(PriorityLevel.P3, mapping.getPriorityLevel()); + PriorityLevel pl = mapping.getPriorityLevel(); + assertTrue("P3 or P5 expected! but got " + pl.toString(), pl == PriorityLevel.P3 || pl == PriorityLevel.P5); taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("abc"); assertEquals(PriorityLevel.P3, mapping.getPriorityLevel()); } diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaTaskCompletionTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaTaskCompletionTest.java index fcbd9504b..865c96245 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaTaskCompletionTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaTaskCompletionTest.java @@ -54,10 +54,11 @@ public class BugzillaTaskCompletionTest extends TestCase { } public void testCompletionDate() throws Exception { - TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaFixture.TEST_BUGZILLA_LATEST_URL, "1"); + TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaFixture.current().getRepositoryUrl(), + "1"); TaskAttributeMapper mapper = connector.getTaskDataHandler().getAttributeMapper(repository); - TaskData taskData = new TaskData(mapper, BugzillaCorePlugin.CONNECTOR_KIND, - BugzillaFixture.TEST_BUGZILLA_LATEST_URL, "1"); + TaskData taskData = new TaskData(mapper, BugzillaCorePlugin.CONNECTOR_KIND, BugzillaFixture.current() + .getRepositoryUrl(), "1"); taskData.getRoot() .createAttribute(BugzillaAttribute.BUG_STATUS.getKey()) .setValue(IBugzillaConstants.VALUE_STATUS_RESOLVED); @@ -75,10 +76,11 @@ public class BugzillaTaskCompletionTest extends TestCase { } public void testCompletionDateForStates() throws Exception { - TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaFixture.TEST_BUGZILLA_LATEST_URL, "1"); + TaskTask task = new TaskTask(BugzillaCorePlugin.CONNECTOR_KIND, BugzillaFixture.current().getRepositoryUrl(), + "1"); TaskAttributeMapper mapper = connector.getTaskDataHandler().getAttributeMapper(repository); - TaskData taskData = new TaskData(mapper, BugzillaCorePlugin.CONNECTOR_KIND, - BugzillaFixture.TEST_BUGZILLA_LATEST_URL, "1"); + TaskData taskData = new TaskData(mapper, BugzillaCorePlugin.CONNECTOR_KIND, BugzillaFixture.current() + .getRepositoryUrl(), "1"); TaskAttribute status = taskData.getRoot().createAttribute(BugzillaAttribute.BUG_STATUS.getKey()); status.setValue("REOPENED"); TaskAttribute attrComment = taskData.getRoot().createAttribute(BugzillaAttribute.COMMENTID.getKey()); diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java index e44cb4212..6593b8098 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java @@ -58,8 +58,6 @@ public class BugzillaFixture extends TestFixture { public static final String TEST_BUGZILLA_HEAD_URL = getServerUrl("bugshead"); - public static final String TEST_BUGZILLA_LATEST_URL = TEST_BUGZILLA_36_URL; - private static final String getServerUrl(String version) { return TestConfiguration.getRepositoryUrl(version); } |