|
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 |
} |