Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 320697
Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java (-8 / +14 lines)
Lines 47-55 Link Here
47
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
47
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
48
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
48
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
49
import org.eclipse.mylyn.tasks.core.ITask;
49
import org.eclipse.mylyn.tasks.core.ITask;
50
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
50
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
51
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
51
import org.eclipse.mylyn.tasks.core.TaskRepository;
52
import org.eclipse.mylyn.tasks.core.TaskRepository;
52
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
53
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
53
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
54
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
54
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
55
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
55
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
Lines 665-673 Link Here
665
				if (bugzillaVersion.compareTo(BugzillaVersion.BUGZILLA_3_6) >= 0) {
665
				if (bugzillaVersion.compareTo(BugzillaVersion.BUGZILLA_3_6) >= 0) {
666
					BugzillaPriorityLevel bugzillaPriorityLevel = BugzillaPriorityLevel.fromPriority(getPriority());
666
					BugzillaPriorityLevel bugzillaPriorityLevel = BugzillaPriorityLevel.fromPriority(getPriority());
667
					if (bugzillaPriorityLevel != null) {
667
					if (bugzillaPriorityLevel != null) {
668
						return BugzillaPriorityLevel.fromPriority(getPriority()).toPriorityLevel();
668
						return bugzillaPriorityLevel.toPriorityLevel();
669
					} else {
670
						PriorityLevel.getDefault();
671
					}
669
					}
672
				}
670
				}
673
				return super.getPriorityLevel();
671
				return super.getPriorityLevel();
Lines 981-991 Link Here
981
	}
979
	}
982
980
983
	public enum BugzillaPriorityLevel {
981
	public enum BugzillaPriorityLevel {
984
		HIGHEST, HIGH, NORMAL, LOW, LOWEST, NOSELECT;
982
		HIGHEST, HIGH, NORMAL, LOW, LOWEST, NONE;
985
983
986
		public static BugzillaPriorityLevel fromPriority(String priority) {
984
		public static BugzillaPriorityLevel fromPriority(String priority) {
987
			if (priority == null) {
985
			if (priority == null) {
988
				return NOSELECT;
986
				return null;
989
			}
987
			}
990
			if (priority.equals("Highest")) { //$NON-NLS-1$
988
			if (priority.equals("Highest")) { //$NON-NLS-1$
991
				return HIGHEST;
989
				return HIGHEST;
Lines 1002-1008 Link Here
1002
			if (priority.equals("Lowest")) { //$NON-NLS-1$
1000
			if (priority.equals("Lowest")) { //$NON-NLS-1$
1003
				return LOWEST;
1001
				return LOWEST;
1004
			}
1002
			}
1005
			return NOSELECT;
1003
			if (priority.equals("Lowest")) { //$NON-NLS-1$
1004
				return LOWEST;
1005
			}
1006
			if (priority.equals("---")) { //$NON-NLS-1$
1007
				return NONE;
1008
			}
1009
			return null;
1006
		}
1010
		}
1007
1011
1008
		public PriorityLevel toPriorityLevel() {
1012
		public PriorityLevel toPriorityLevel() {
Lines 1017-1022 Link Here
1017
				return PriorityLevel.P4;
1021
				return PriorityLevel.P4;
1018
			case LOWEST:
1022
			case LOWEST:
1019
				return PriorityLevel.P5;
1023
				return PriorityLevel.P5;
1024
			case NONE:
1025
				return PriorityLevel.P3;
1020
			default:
1026
			default:
1021
				return null;
1027
				return null;
1022
			}
1028
			}
Lines 1035-1041 Link Here
1035
				return "Low"; //$NON-NLS-1$
1041
				return "Low"; //$NON-NLS-1$
1036
			case LOWEST:
1042
			case LOWEST:
1037
				return "Lowest"; //$NON-NLS-1$
1043
				return "Lowest"; //$NON-NLS-1$
1038
			case NOSELECT:
1044
			case NONE:
1039
				return "---"; //$NON-NLS-1$
1045
				return "---"; //$NON-NLS-1$
1040
			default:
1046
			default:
1041
				return null;
1047
				return null;
(-)src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java (-2 lines)
Lines 14-20 Link Here
14
import junit.framework.Test;
14
import junit.framework.Test;
15
import junit.framework.TestSuite;
15
import junit.framework.TestSuite;
16
16
17
import org.eclipse.mylyn.bugzilla.tests.core.BugzillaPriorityTest;
18
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
17
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
19
import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaHyperlinkDetectorTest;
18
import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaHyperlinkDetectorTest;
20
import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaRepositorySettingsPageTest;
19
import org.eclipse.mylyn.bugzilla.tests.ui.BugzillaRepositorySettingsPageTest;
Lines 50-56 Link Here
50
			fixture.add(BugzillaTaskDataHandlerTest.class);
49
			fixture.add(BugzillaTaskDataHandlerTest.class);
51
			fixture.add(BugzillaSearchTest.class);
50
			fixture.add(BugzillaSearchTest.class);
52
			fixture.add(EncodingTest.class);
51
			fixture.add(EncodingTest.class);
53
			fixture.add(BugzillaPriorityTest.class);
54
52
55
			// Move any tests here that are resulting in spurious failures
53
			// Move any tests here that are resulting in spurious failures
56
			// due to recent changes in Bugzilla Server head.
54
			// due to recent changes in Bugzilla Server head.
(-)src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaPriorityTest.java (-80 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.bugzilla.tests.core;
13
14
import junit.framework.TestCase;
15
16
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
17
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
18
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
19
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
20
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
21
import org.eclipse.mylyn.tasks.core.ITaskMapping;
22
import org.eclipse.mylyn.tasks.core.TaskRepository;
23
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
24
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
25
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
26
import org.eclipse.mylyn.tasks.core.data.TaskData;
27
import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel;
28
29
public class BugzillaPriorityTest extends TestCase {
30
31
	private TaskRepository repository;
32
33
	private BugzillaRepositoryConnector connector;
34
35
	@Override
36
	public void setUp() throws Exception {
37
		BugzillaFixture.current().client(PrivilegeLevel.USER);
38
		repository = BugzillaFixture.current().repository();
39
		connector = BugzillaFixture.current().connector();
40
	}
41
42
	public void testPriority() throws Exception {
43
		BugzillaVersion version = new BugzillaVersion(BugzillaFixture.current().getVersion());
44
		boolean useOldWay = version.isSmaller(BugzillaVersion.BUGZILLA_3_6);
45
46
		AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
47
		TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
48
		TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
49
		ITaskMapping mapping = connector.getTaskMapping(taskData);
50
		taskDataHandler.initializeTaskData(repository, taskData, null, null);
51
		String value;
52
		PriorityLevel level;
53
54
		level = PriorityLevel.P1;
55
		value = useOldWay ? level.toString() : "Highest";
56
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
57
		assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
58
		assertEquals(level, mapping.getPriorityLevel());
59
		level = PriorityLevel.P2;
60
		value = useOldWay ? level.toString() : "High";
61
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
62
		assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
63
		assertEquals(level, mapping.getPriorityLevel());
64
		level = PriorityLevel.P3;
65
		value = useOldWay ? level.toString() : "Normal";
66
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
67
		assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
68
		assertEquals(level, mapping.getPriorityLevel());
69
		level = PriorityLevel.P4;
70
		value = useOldWay ? level.toString() : "Low";
71
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
72
		assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
73
		assertEquals(level, mapping.getPriorityLevel());
74
		level = PriorityLevel.P5;
75
		value = useOldWay ? level.toString() : "Lowest";
76
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(value);
77
		assertEquals(value, taskData.getRoot().getMappedAttribute(TaskAttribute.PRIORITY).getValue());
78
		assertEquals(level, mapping.getPriorityLevel());
79
	}
80
}
(-)src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java (-8 / +61 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Nathan Hapke - initial API and implementation
9
 *     Nathan Hapke - initial API and implementation
10
 *     Tasktop Technologies - improvements
10
 *     Tasktop Technologies - improvements
11
 *     Frank Becker - improvements
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.mylyn.bugzilla.tests.core;
14
package org.eclipse.mylyn.bugzilla.tests.core;
Lines 26-37 Link Here
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
29
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
30
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
29
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
31
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
30
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
32
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
31
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
33
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
34
import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
35
import org.eclipse.mylyn.tasks.core.ITaskMapping;
32
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
36
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
33
import org.eclipse.mylyn.tasks.core.TaskRepository;
37
import org.eclipse.mylyn.tasks.core.TaskRepository;
38
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
34
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
39
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
40
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
35
import org.eclipse.mylyn.tasks.core.data.TaskData;
41
import org.eclipse.mylyn.tasks.core.data.TaskData;
36
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
42
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
37
import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel;
43
import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel;
Lines 41-46 Link Here
41
 * @author Rob Elves
47
 * @author Rob Elves
42
 * @author Thomas Ehrnhoefer
48
 * @author Thomas Ehrnhoefer
43
 * @author Steffen Pingel
49
 * @author Steffen Pingel
50
 * @author Frank Becker
44
 */
51
 */
45
public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
52
public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
46
53
Lines 220-229 Link Here
220
				+ email + "&type0-0-0=notequals&field0-0-1=reporter&value0-0-0=UNCONFIRMED&emailtype1=exact";
227
				+ email + "&type0-0-0=notequals&field0-0-1=reporter&value0-0-0=UNCONFIRMED&emailtype1=exact";
221
228
222
		// make sure initial task is not P1/trivial
229
		// make sure initial task is not P1/trivial
223
		assertFalse(taskData.getRoot().getMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).getValue().equals(
230
		assertFalse(taskData.getRoot()
224
				priority));
231
				.getMappedAttribute(BugzillaAttribute.PRIORITY.getKey())
225
		assertFalse(taskData.getRoot().getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey()).getValue().equals(
232
				.getValue()
226
				severity));
233
				.equals(priority));
234
		assertFalse(taskData.getRoot()
235
				.getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey())
236
				.getValue()
237
				.equals(severity));
227
238
228
		// run query
239
		// run query
229
		RepositoryQuery query = new RepositoryQuery(repository.getConnectorKind(), "handle-testQueryViaConnector");
240
		RepositoryQuery query = new RepositoryQuery(repository.getConnectorKind(), "handle-testQueryViaConnector");
Lines 238-245 Link Here
238
		connector.performQuery(repository, query, collector, null, new NullProgressMonitor());
249
		connector.performQuery(repository, query, collector, null, new NullProgressMonitor());
239
250
240
		// set priority and severity on task
251
		// set priority and severity on task
241
		taskData.getRoot().getMappedAttribute(BugzillaAttribute.SHORT_DESC.getKey()).setValue(
252
		taskData.getRoot()
242
				System.currentTimeMillis() + "");
253
				.getMappedAttribute(BugzillaAttribute.SHORT_DESC.getKey())
254
				.setValue(System.currentTimeMillis() + "");
243
		taskData.getRoot().getMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(priority);
255
		taskData.getRoot().getMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(priority);
244
		taskData.getRoot().getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey()).setValue(severity);
256
		taskData.getRoot().getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey()).setValue(severity);
245
		RepositoryResponse response = BugzillaFixture.current().submitTask(taskData, client);
257
		RepositoryResponse response = BugzillaFixture.current().submitTask(taskData, client);
Lines 261-268 Link Here
261
		assertEquals(1, changedTaskData2.size());
273
		assertEquals(1, changedTaskData2.size());
262
		taskData = changedTaskData2.get(taskData.getTaskId());
274
		taskData = changedTaskData2.get(taskData.getTaskId());
263
		assertNotNull(taskData);
275
		assertNotNull(taskData);
264
		assertTrue(taskData.getRoot().getAttribute(BugzillaAttribute.SHORT_DESC.getKey()).getValue().equals(
276
		assertTrue(taskData.getRoot()
265
				taskDataNew.getRoot().getAttribute(BugzillaAttribute.SHORT_DESC.getKey()).getValue()));
277
				.getAttribute(BugzillaAttribute.SHORT_DESC.getKey())
278
				.getValue()
279
				.equals(taskDataNew.getRoot().getAttribute(BugzillaAttribute.SHORT_DESC.getKey()).getValue()));
266
	}
280
	}
267
281
282
	public void testGetTaskMappingPriority() throws Exception {
283
		BugzillaVersion version = new BugzillaVersion(BugzillaFixture.current().getVersion());
284
285
		AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
286
		TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
287
		TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
288
		ITaskMapping mapping = connector.getTaskMapping(taskData);
289
		taskDataHandler.initializeTaskData(repository, taskData, null, null);
290
291
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P1");
292
		assertEquals(PriorityLevel.P1, mapping.getPriorityLevel());
293
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P2");
294
		assertEquals(PriorityLevel.P2, mapping.getPriorityLevel());
295
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P3");
296
		assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
297
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P4");
298
		assertEquals(PriorityLevel.P4, mapping.getPriorityLevel());
299
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("P5");
300
		assertEquals(PriorityLevel.P5, mapping.getPriorityLevel());
301
		taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("abc");
302
		assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
303
		if (!version.isSmaller(BugzillaVersion.BUGZILLA_3_6)) {
304
			// fresh bugzilla 3.6 databases have a new schema for priorities
305
			taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Highest");
306
			assertEquals(PriorityLevel.P1, mapping.getPriorityLevel());
307
			taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("High");
308
			assertEquals(PriorityLevel.P2, mapping.getPriorityLevel());
309
			taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Normal");
310
			assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
311
			taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Low");
312
			assertEquals(PriorityLevel.P4, mapping.getPriorityLevel());
313
			taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("Lowest");
314
			assertEquals(PriorityLevel.P5, mapping.getPriorityLevel());
315
			taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("---");
316
			assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
317
			taskData.getRoot().createMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue("abc");
318
			assertEquals(PriorityLevel.P3, mapping.getPriorityLevel());
319
		}
320
	}
268
}
321
}

Return to bug 320697