Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-07-29 00:34:12 -0400
committerspingel2010-07-29 00:34:12 -0400
commit96444fe1f23996dedd18cd10519e110b66762141 (patch)
tree88d25157a5db6064b313dcc48848363898ff52c9
parent055961cd9fbea5b8a0fd862d971d1c267d613129 (diff)
downloadorg.eclipse.mylyn.tasks-96444fe1f23996dedd18cd10519e110b66762141.tar.gz
org.eclipse.mylyn.tasks-96444fe1f23996dedd18cd10519e110b66762141.tar.xz
org.eclipse.mylyn.tasks-96444fe1f23996dedd18cd10519e110b66762141.zip
RESOLVED - bug 320697: [regression] priorities mapped to P3 when migrating from Bugzilla 3.4 or earlier
https://bugs.eclipse.org/bugs/show_bug.cgi?id=320697
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java22
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaPriorityTest.java80
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java69
4 files changed, 75 insertions, 98 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 8d99fcb55..5baf68e78 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
@@ -47,9 +47,9 @@ import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
@@ -665,9 +665,7 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
if (bugzillaVersion.compareTo(BugzillaVersion.BUGZILLA_3_6) >= 0) {
BugzillaPriorityLevel bugzillaPriorityLevel = BugzillaPriorityLevel.fromPriority(getPriority());
if (bugzillaPriorityLevel != null) {
- return BugzillaPriorityLevel.fromPriority(getPriority()).toPriorityLevel();
- } else {
- PriorityLevel.getDefault();
+ return bugzillaPriorityLevel.toPriorityLevel();
}
}
return super.getPriorityLevel();
@@ -981,11 +979,11 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
}
public enum BugzillaPriorityLevel {
- HIGHEST, HIGH, NORMAL, LOW, LOWEST, NOSELECT;
+ HIGHEST, HIGH, NORMAL, LOW, LOWEST, NONE;
public static BugzillaPriorityLevel fromPriority(String priority) {
if (priority == null) {
- return NOSELECT;
+ return null;
}
if (priority.equals("Highest")) { //$NON-NLS-1$
return HIGHEST;
@@ -1002,7 +1000,13 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
if (priority.equals("Lowest")) { //$NON-NLS-1$
return LOWEST;
}
- return NOSELECT;
+ if (priority.equals("Lowest")) { //$NON-NLS-1$
+ return LOWEST;
+ }
+ if (priority.equals("---")) { //$NON-NLS-1$
+ return NONE;
+ }
+ return null;
}
public PriorityLevel toPriorityLevel() {
@@ -1017,6 +1021,8 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
return PriorityLevel.P4;
case LOWEST:
return PriorityLevel.P5;
+ case NONE:
+ return PriorityLevel.P3;
default:
return null;
}
@@ -1035,7 +1041,7 @@ public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {
return "Low"; //$NON-NLS-1$
case LOWEST:
return "Lowest"; //$NON-NLS-1$
- case NOSELECT:
+ case NONE:
return "---"; //$NON-NLS-1$
default:
return null;
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
index b66d03d1f..c956debb4 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java
@@ -14,7 +14,6 @@ package org.eclipse.mylyn.bugzilla.tests;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.mylyn.bugzilla.tests.core.BugzillaPriorityTest;
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaHyperlinkDetectorTest;
import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaRepositorySettingsPageTest;
@@ -50,7 +49,6 @@ public class AllBugzillaTests {
fixture.add(BugzillaTaskDataHandlerTest.class);
fixture.add(BugzillaSearchTest.class);
fixture.add(EncodingTest.class);
- fixture.add(BugzillaPriorityTest.class);
// Move any tests here that are resulting in spurious failures
// due to recent changes in Bugzilla Server head.
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaPriorityTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaPriorityTest.java
deleted file mode 100644
index 3c5e86ec3..000000000
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaPriorityTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Frank Becker 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:
- * Frank Becker - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.bugzilla.tests.core;
-
-import junit.framework.TestCase;
-
-import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
-import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
-import org.eclipse.mylyn.tasks.core.ITaskMapping;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
-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.tests.util.TestUtil.PrivilegeLevel;
-
-public class BugzillaPriorityTest extends TestCase {
-
- private TaskRepository repository;
-
- private BugzillaRepositoryConnector connector;
-
- @Override
- public void setUp() throws Exception {
- BugzillaFixture.current().client(PrivilegeLevel.USER);
- repository = BugzillaFixture.current().repository();
- connector = BugzillaFixture.current().connector();
- }
-
- public void testPriority() throws Exception {
- BugzillaVersion version = new BugzillaVersion(BugzillaFixture.current().getVersion());
- boolean useOldWay = version.isSmaller(BugzillaVersion.BUGZILLA_3_6);
-
- AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
- TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
- TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
- ITaskMapping mapping = connector.getTaskMapping(taskData);
- taskDataHandler.initializeTaskData(repository, taskData, null, null);
- String value;
- PriorityLevel level;
-
- level = PriorityLevel.P1;
- value = useOldWay ? level.toString() : "Highest";
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
- assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
- assertEquals(level, mapping.getPriorityLevel());
- level = PriorityLevel.P2;
- value = useOldWay ? level.toString() : "High";
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
- assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
- assertEquals(level, mapping.getPriorityLevel());
- level = PriorityLevel.P3;
- value = useOldWay ? level.toString() : "Normal";
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
- assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
- assertEquals(level, mapping.getPriorityLevel());
- level = PriorityLevel.P4;
- value = useOldWay ? level.toString() : "Low";
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
- assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
- assertEquals(level, mapping.getPriorityLevel());
- level = PriorityLevel.P5;
- value = useOldWay ? level.toString() : "Lowest";
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
- assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
- assertEquals(level, mapping.getPriorityLevel());
- }
-}
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 d8348e6f9..42a2766b2 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
@@ -8,6 +8,7 @@
* Contributors:
* Nathan Hapke - initial API and implementation
* Tasktop Technologies - improvements
+ * Frank Becker - improvements
*******************************************************************************/
package org.eclipse.mylyn.bugzilla.tests.core;
@@ -26,12 +27,17 @@ import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
+import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
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.TaskDataCollector;
import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel;
@@ -41,6 +47,7 @@ import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel;
* @author Rob Elves
* @author Thomas Ehrnhoefer
* @author Steffen Pingel
+ * @author Frank Becker
*/
public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
@@ -220,10 +227,14 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
+ email + "&type0-0-0=notequals&field0-0-1=reporter&value0-0-0=UNCONFIRMED&emailtype1=exact";
// make sure initial task is not P1/trivial
- assertFalse(taskData.getRoot().getMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).getValue().equals(
- priority));
- assertFalse(taskData.getRoot().getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey()).getValue().equals(
- severity));
+ assertFalse(taskData.getRoot()
+ .getMappedAttribute(BugzillaAttribute.PRIORITY.getKey())
+ .getValue()
+ .equals(priority));
+ assertFalse(taskData.getRoot()
+ .getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey())
+ .getValue()
+ .equals(severity));
// run query
RepositoryQuery query = new RepositoryQuery(repository.getConnectorKind(), "handle-testQueryViaConnector");
@@ -238,8 +249,9 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
connector.performQuery(repository, query, collector, null, new NullProgressMonitor());
// set priority and severity on task
- taskData.getRoot().getMappedAttribute(BugzillaAttribute.SHORT_DESC.getKey()).setValue(
- System.currentTimeMillis() + "");
+ taskData.getRoot()
+ .getMappedAttribute(BugzillaAttribute.SHORT_DESC.getKey())
+ .setValue(System.currentTimeMillis() + "");
taskData.getRoot().getMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(priority);
taskData.getRoot().getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey()).setValue(severity);
RepositoryResponse response = BugzillaFixture.current().submitTask(taskData, client);
@@ -261,8 +273,49 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
assertEquals(1, changedTaskData2.size());
taskData = changedTaskData2.get(taskData.getTaskId());
assertNotNull(taskData);
- assertTrue(taskData.getRoot().getAttribute(BugzillaAttribute.SHORT_DESC.getKey()).getValue().equals(
- taskDataNew.getRoot().getAttribute(BugzillaAttribute.SHORT_DESC.getKey()).getValue()));
+ assertTrue(taskData.getRoot()
+ .getAttribute(BugzillaAttribute.SHORT_DESC.getKey())
+ .getValue()
+ .equals(taskDataNew.getRoot().getAttribute(BugzillaAttribute.SHORT_DESC.getKey()).getValue()));
}
+ public void testGetTaskMappingPriority() throws Exception {
+ BugzillaVersion version = new BugzillaVersion(BugzillaFixture.current().getVersion());
+
+ AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
+ TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
+ TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
+ ITaskMapping mapping = connector.getTaskMapping(taskData);
+ taskDataHandler.initializeTaskData(repository, taskData, null, null);
+
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P1");
+ assertEquals(PriorityLevel.P1, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P2");
+ assertEquals(PriorityLevel.P2, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P3");
+ assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P4");
+ assertEquals(PriorityLevel.P4, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P5");
+ assertEquals(PriorityLevel.P5, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("abc");
+ assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
+ if (!version.isSmaller(BugzillaVersion.BUGZILLA_3_6)) {
+ // fresh bugzilla 3.6 databases have a new schema for priorities
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Highest");
+ assertEquals(PriorityLevel.P1, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("High");
+ assertEquals(PriorityLevel.P2, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Normal");
+ assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Low");
+ assertEquals(PriorityLevel.P4, mapping.getPriorityLevel());
+ 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());
+ taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("abc");
+ assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
+ }
+ }
} \ No newline at end of file

Back to the top