Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2008-12-02 01:11:21 +0000
committerrelves2008-12-02 01:11:21 +0000
commit3804cc123639952a89b8143e2f2c37c907bcd0c7 (patch)
tree8a28cdc2b6527b0a07780bc1e97835904b046b85 /org.eclipse.mylyn.bugzilla.tests
parent4a77b58c9e8cd7dd0189c9546fa51d5ac5fc481c (diff)
downloadorg.eclipse.mylyn.tasks-3804cc123639952a89b8143e2f2c37c907bcd0c7.tar.gz
org.eclipse.mylyn.tasks-3804cc123639952a89b8143e2f2c37c907bcd0c7.tar.xz
org.eclipse.mylyn.tasks-3804cc123639952a89b8143e2f2c37c907bcd0c7.zip
ASSIGNED - bug 242480: [patch] port Bugzilla tests to Myly 3.0 framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=242480
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java574
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest2.java333
2 files changed, 331 insertions, 576 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index 9843008d0..11753cac5 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -23,343 +23,6 @@ import org.eclipse.mylyn.tasks.tests.connector.MockTask;
public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// TODO: refactor
//
-// int counter = 0;
-//
-//// public void testMissingHits() throws Exception {
-//// // query for all mylyn bugzilla tasks.
-//// // reset sync date
-//// // mark stale tasks should equal number of tasks
-//// TasksUiPlugin.getSynchronizationManager().setForceSyncExec(true);
-//// init(IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
-//// repository.setAuthenticationCredentials("username", "password");
-//// String queryString = "https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&classification=Tools&product=Mylyn&component=Bugzilla&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=NEW&priority=P1&priority=P2&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
-//// //String queryString = "https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&classification=Tools&product=Mylyn&component=Bugzilla&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&priority=P1&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
-//// //String queryString = "https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&classification=Tools&product=Mylyn&component=Bugzilla&component=Tasks&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
-//// BugzillaRepositoryQuery query = new BugzillaRepositoryQuery(IBugzillaConstants.ECLIPSE_BUGZILLA_URL, queryString, "test" );
-//// //TasksUiPlugin.getTaskList().addQuery(query);
-//// AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(BugzillaCorePlugin.REPOSITORY_KIND);
-////// QueryHitCollector collector = new QueryHitCollector(new TaskFactory(repository, false, false));
-////// connector.performQuery(query, repository, new NullProgressMonitor(), collector);
-////// for (AbstractTask task : collector.getTasks()) {
-////// TasksUiPlugin.getTaskList().addTask(task);
-////// }
-////
-//// TasksUiPlugin.getSynchronizationManager().synchronize(connector, query, null, true);
-//// for (AbstractTask task : query.getChildren()) {
-//// assertTrue(task.getSynchronizationState() == SynchronizationState.INCOMING);
-//// TasksUiPlugin.getSynchronizationManager().setTaskRead(task, true);
-//// task.setLastReadTimeStamp("1970-01-01");
-//// assertTrue(task.getSynchronizationState() == SynchronizationState.SYNCHRONIZED);
-//// }
-////
-//// for (AbstractTask task : query.getChildren()) {
-//// assertTrue(task.getSynchronizationState() == SynchronizationState.SYNCHRONIZED);
-//// }
-////
-//// repository.setSynchronizationTimeStamp("1970-01-01");//getSynchronizationTimeStamp();
-//// //connector.markStaleTasks(repository, query.getChildren(), new NullProgressMonitor());
-//// TasksUiPlugin.getSynchronizationManager().synchronize(connector, query, null, true);
-//// for (AbstractTask task : query.getChildren()) {
-//// assertTrue(task.getSynchronizationState() == SynchronizationState.INCOMING);
-//// }
-//// }
-//
-// ITask fruitTask;
-//
-// TaskData fruitTaskData;
-//
-// private void setFruitValueTo(String newValue) throws CoreException {
-// Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
-// TaskAttribute att = fruitTaskData.getRoot().createAttribute("cf_fruit");
-// att.setValue(newValue);
-// assertEquals(newValue, fruitTaskData.getRoot().getAttribute("cf_fruit").getValue());
-// changed.add(fruitTaskData.getRoot().getAttribute("cf_fruit"));
-// submit(fruitTask, fruitTaskData, changed);
-// TasksUiInternal.synchronizeTask(connector, fruitTask, true, null);
-// fruitTaskData = TasksUiPlugin.getTaskDataManager().getTaskData(repository, fruitTask.getTaskId());
-// assertEquals(newValue, fruitTaskData.getRoot().getAttribute("cf_fruit").getValue());
-//
-// }
-//
-// public void testCustomFields() throws Exception {
-// init(IBugzillaConstants.TEST_BUGZILLA_303_URL);
-//
-// String taskNumber = "1";
-// TasksUiPlugin.getTaskDataStorageManager().clear();
-//
-// // Get the task
-// fruitTask = generateLocalTaskAndDownload(taskNumber);
-//
-// ITaskDataWorkingCopy working = TasksUiPlugin.getTaskDataManager().getWorkingCopy(fruitTask);
-// assertNotNull(working);
-//
-// if (fruitTaskData.getRoot().getAttribute("cf_fruit").getValue().equals("---")) {
-// setFruitValueTo("apple");
-// setFruitValueTo("orange");
-// setFruitValueTo("---");
-// } else if (fruitTaskData.getRoot().getAttribute("cf_fruit").getValue().equals("apple")) {
-// setFruitValueTo("orange");
-// setFruitValueTo("apple");
-// setFruitValueTo("---");
-// } else if (fruitTaskData.getRoot().getAttribute("cf_fruit").getValue().equals("orange")) {
-// setFruitValueTo("apple");
-// setFruitValueTo("orange");
-// setFruitValueTo("---");
-// }
-// if (fruitTask != null) {
-// fruitTask = null;
-// }
-// if (fruitTaskData != null) {
-// fruitTaskData = null;
-// }
-// }
-//
-//// public void testMidAirCollision() throws Exception {
-//// init30();
-//// String taskNumber = "5";
-////
-//// TasksUiPlugin.getTaskDataStorageManager().clear();
-////
-//// // Get the task
-//// ITask task = generateLocalTaskAndDownload(taskNumber);
-////
-//// TaskData taskData = TasksUiPlugin.getTaskDataManager().getTaskData(task);
-//// assertNotNull(taskData);
-////
-//// TasksUiPlugin.getTaskList().addTask(task);
-////
-//// String newCommentText = "BugzillaRepositoryClientTest.testMidAirCollision(): test " + (new Date()).toString();
-//// taskData.setNewComment(newCommentText);
-//// Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
-//// changed.add(taskData.getAttribute(TaskAttribute.COMMENT_NEW));
-//// taskData.setAttributeValue("delta_ts", "2007-01-01 00:00:00");
-//// changed.add(taskData.getAttribute("delta_ts"));
-////
-//// TasksUiPlugin.getTaskDataStorageManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), changed);
-////
-//// try {
-//// // Submit changes
-//// submit(task, taskData, changed);
-//// fail("Mid-air collision expected");
-//// } catch (CoreException e) {
-//// assertTrue(e.getStatus().getMessage().indexOf("Mid-air collision occurred while submitting") != -1);
-//// }
-//// }
-//
-//// public void testAuthenticationCredentials() throws Exception {
-//// init218();
-//// BugzillaTask task = this.generateLocalTaskAndDownload("3");
-//// assertNotNull(task);
-//// assertNotNull(TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId()));
-//// TasksUiPlugin.getTaskListManager().activateTask(task);
-//// File sourceContextFile = ContextCorePlugin.getContextStore().getFileForContext(task.getHandleIdentifier());
-//// assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
-//// sourceContextFile.createNewFile();
-//// sourceContextFile.deleteOnExit();
-////
-//// repository.setAuthenticationCredentials("wrong", "wrong");
-//// TasksUiPlugin.getRepositoryManager().notifyRepositorySettingsChanged(repository);
-//// try {
-//// AttachmentUtil.attachContext(connector.getAttachmentHandler(), repository, task, "",
-//// new NullProgressMonitor());
-//// } catch (CoreException e) {
-//// assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
-//// assertTrue(e.getStatus().getMessage().indexOf("Invalid repository credentials.") != -1);
-//// return;
-//// }
-//// fail("Should have failed due to invalid userid and password.");
-//// }
-//
-//// testReassign Bugs
-//// Version BugNr assigned reporter
-//// 2.22 92 user@mylar.eclipse.org tests@mylar.eclipse.org
-//// 3.0 5 tests@mylar.eclipse.org tests2@mylar.eclipse.org
-//// 3.1 1 rob.elves@eclipse.org tests@mylar.eclipse.org
-//
-//// XXX: restore
-//// public void testReassign222() throws CoreException {
-//// init222();
-//// String taskNumber = "92";
-//// doReassignOld(taskNumber, "user@mylar.eclipse.org");
-//// }
-////
-//// public void testReassign30() throws CoreException {
-//// init30();
-//// String taskNumber = "5";
-//// doReassignOld(taskNumber, "tests@mylyn.eclipse.org");
-//// }
-////
-//// public void testReassign31() throws CoreException {
-//// init31();
-//// String taskNumber = "1";
-////
-//// TasksUiPlugin.getTaskDataStorageManager().clear();
-////
-//// // Get the task
-//// ITask task = generateLocalTaskAndDownload(taskNumber);
-////
-//// ITaskDataWorkingCopy workingCopy = TasksUiPlugin.getTaskDataManager().getWorkingCopy(task,
-//// task.getConnectorKind());
-////
-//// TaskData taskData = workingCopy.getLocalData();
-//// assertNotNull(taskData);
-////
-//// TaskMapper mapper = new TaskMapper(taskData);
-////
-//// TasksUiPlugin.getTaskList().addTask(task);
-//// if (taskData.getAssignedTo().equals("rob.elves@eclipse.org")) {
-//// assertEquals("rob.elves@eclipse.org", taskData.getAssignedTo());
-//// reassingToUser31(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals("tests2@mylyn.eclipse.org", taskData.getAssignedTo());
-////
-//// reassignToDefault31(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals("rob.elves@eclipse.org", taskData.getAssignedTo());
-//// } else if (taskData.getAssignedTo().equals("tests2@mylyn.eclipse.org")) {
-//// assertEquals("tests2@mylyn.eclipse.org", taskData.getAssignedTo());
-//// reassignToDefault31(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals("rob.elves@eclipse.org", taskData.getAssignedTo());
-////
-//// reassingToUser31(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals("tests2@mylyn.eclipse.org", taskData.getAssignedTo());
-//// } else {
-//// fail("Bug with unexpected user assigned");
-//// }
-////
-//// }
-////
-//// private void reassignToDefault31(BugzillaTask task, RepositoryTaskData taskData) throws CoreException {
-//// // Modify it (reassignbycomponent)
-//// String newCommentText = "BugzillaRepositoryClientTest.testReassign31(): reassignbycomponent "
-//// + (new Date()).toString();
-//// taskData.setNewComment(newCommentText);
-//// Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
-//// changed.add(taskData.getAttribute(TaskAttribute.COMMENT_NEW));
-////
-//// taskData.setAttributeValue(BugzillaReportElement.SET_DEFAULT_ASSIGNEE.getKey(), "1");
-//// changed.add(taskData.getAttribute(BugzillaReportElement.SET_DEFAULT_ASSIGNEE.getKey()));
-////
-//// TasksUiPlugin.getTaskDataStorageManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), changed);
-////
-//// // Submit changes
-//// submit(task, taskData, changed);
-//// }
-////
-//// private void reassingToUser31(BugzillaTask task, RepositoryTaskData taskData) throws CoreException {
-//// // Modify it (reassign to tests2@mylyn.eclipse.org)
-//// String newCommentText = "BugzillaRepositoryClientTest.testReassign31(): reassign " + (new Date()).toString();
-//// taskData.setNewComment(newCommentText);
-//// Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
-//// changed.add(taskData.getAttribute(TaskAttribute.COMMENT_NEW));
-////
-//// taskData.setAttributeValue(TaskAttribute.USER_ASSIGNED, "tests2@mylyn.eclipse.org");
-//// changed.add(taskData.getAttribute(TaskAttribute.USER_ASSIGNED));
-//// TasksUiPlugin.getTaskDataStorageManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), changed);
-////
-//// // Submit changes
-//// submit(task, taskData, null);
-//// }
-////
-//// private void doReassignOld(String taskNumber, String defaultAssignee) throws CoreException {
-//// TasksUiPlugin.getTaskDataStorageManager().clear();
-////
-//// // Get the task
-//// BugzillaTask task = generateLocalTaskAndDownload(taskNumber);
-////
-//// RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getEditableCopy(
-//// task.getRepositoryUrl(), task.getTaskId());
-//// assertNotNull(taskData);
-////
-//// TasksUiPlugin.getTaskList().addTask(task, TasksUiPlugin.getTaskList().getDefaultCategory());
-////
-//// if (taskData.getAssignedTo().equals(defaultAssignee)) {
-//// assertEquals(defaultAssignee, taskData.getAssignedTo());
-//// reassingToUserOld(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals("tests2@mylyn.eclipse.org", taskData.getAssignedTo());
-////
-//// reassignToDefaultOld(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals(defaultAssignee, taskData.getAssignedTo());
-//// } else if (taskData.getAssignedTo().equals("tests2@mylyn.eclipse.org")) {
-//// assertEquals("tests2@mylyn.eclipse.org", taskData.getAssignedTo());
-//// reassignToDefaultOld(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals(defaultAssignee, taskData.getAssignedTo());
-////
-//// reassingToUserOld(task, taskData);
-//// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-//// task.getTaskId());
-//// assertEquals("tests2@mylyn.eclipse.org", taskData.getAssignedTo());
-//// } else {
-//// fail("Bug with unexpected user assigned");
-//// }
-//// }
-////
-//// private void reassignToDefaultOld(BugzillaTask task, RepositoryTaskData taskData) throws CoreException {
-//// // Modify it (reassignbycomponent)
-//// String newCommentText = "BugzillaRepositoryClientTest.testReassignOld(): reassignbycomponent "
-//// + (new Date()).toString();
-//// taskData.setNewComment(newCommentText);
-//// Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
-//// changed.add(taskData.getAttribute(TaskAttribute.COMMENT_NEW));
-//// for (RepositoryOperation o : taskData.getOperations()) {
-//// if (o.isChecked()) {
-//// o.setChecked(false);
-//// }
-//// if (o.getKnobName().compareTo("reassignbycomponent") == 0) {
-//// o.setChecked(true);
-//// taskData.setSelectedOperation(o);
-//// }
-//// }
-//// TasksUiPlugin.getTaskDataStorageManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), changed);
-////
-//// // Submit changes
-//// submit(task, taskData, null);
-//// }
-////
-//// private void reassingToUserOld(BugzillaTask task, RepositoryTaskData taskData) throws CoreException {
-//// // Modify it (reassign to tests2@mylyn.eclipse.org)
-//// String newCommentText = "BugzillaRepositoryClientTest.testReassignOld(): reassign " + (new Date()).toString();
-//// taskData.setNewComment(newCommentText);
-//// Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
-//// changed.add(taskData.getAttribute(TaskAttribute.COMMENT_NEW));
-//// for (RepositoryOperation o : taskData.getOperations()) {
-//// if (o.isChecked()) {
-//// o.setChecked(false);
-//// }
-//// if (o.getKnobName().compareTo("reassign") == 0) {
-//// o.setInputValue("tests2@mylyn.eclipse.org");
-//// o.setChecked(true);
-//// taskData.setSelectedOperation(o);
-//// }
-//// }
-//// TasksUiPlugin.getTaskDataStorageManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), changed);
-////
-//// // Submit changes
-//// submit(task, taskData, null);
-////
-//// }
-//
// public void testSubTaskHasIncoming() throws CoreException {
// init30();
// String taskNumber = "6";
@@ -415,62 +78,6 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// assertEquals(task.getHandleIdentifier(), retrievedTask.getHandleIdentifier());
// }
//
-// public void testAnonymousRepositoryAccess() throws Exception {
-// init218();
-// assertNotNull(repository);
-// repository.setAuthenticationCredentials("", "");
-// // test anonymous task retrieval
-// ITask task = this.generateLocalTaskAndDownload("2");
-// assertNotNull(task);
-//
-// // // test anonymous query (note that this demonstrates query via
-// // eclipse search (ui)
-// // SearchHitCollector collector = new SearchHitCollector(taskList);
-// // collector.setProgressMonitor(new NullProgressMonitor());
-// // BugzillaSearchOperation operation = new BugzillaSearchOperation(
-// // repository,
-// // "http://mylyn.eclipse.org/bugs218/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=search-match-test&product=TestProduct&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&deadlinefrom=&deadlineto=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=",
-// // null, collector, "-1");
-// //
-// String queryUrl = "http://mylyn.eclipse.org/bugs218/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=search-match-test&product=TestProduct&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&deadlinefrom=&deadlineto=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
-// BugzillaRepositoryQuery bugzillaQuery = new BugzillaRepositoryQuery(repository.getRepositoryUrl(), queryUrl,
-// "search");
-//
-// SearchHitCollector collector = new SearchHitCollector(taskList, repository, bugzillaQuery);
-// RepositorySearchResult result = (RepositorySearchResult) collector.getSearchResult();
-//
-// // operation.run(new NullProgressMonitor());
-// // BugzillaSearchQuery searchQuery = new BugzillaSearchQuery(collector);
-// collector.run(new NullProgressMonitor());
-// assertEquals(2, result.getElements().length);
-//
-// for (ITask hit : collector.getTasks()) {
-// assertTrue(hit.getSummary().contains("search-match-test"));
-// }
-//
-// // test anonymous update of configuration
-// RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null);
-// assertNotNull(config);
-// assertTrue(config.getComponents().size() > 0);
-// }
-//
-// public void testUpdate() throws Exception {
-// init222();
-// String taskNumber = "3";
-// TasksUiPlugin.getTaskDataStorageManager().clear();
-// assertEquals(0, TasksUiPlugin.getTaskList().getAllTasks().size());
-// ITask task = this.generateLocalTaskAndDownload(taskNumber);
-// assertEquals("search-match-test 2", task.getSummary());
-// assertEquals("TestProduct", task.getAttribute(TaskAttribute.PRODUCT));
-// assertEquals("P1", task.getPriority());
-// assertEquals("blocker", task.getAttribute(BugzillaReportElement.BUG_SEVERITY.getKey()));
-// assertEquals("nhapke@cs.ubc.ca", task.getOwner());
-// // assertEquals("2007-04-18 14:21:40",
-// // task.getCompletionDate().toString());
-// assertFalse(task.isCompleted());
-// assertEquals("http://mylyn.eclipse.org/bugs222/show_bug.cgi?id=3", task.getUrl());
-// }
-//
// public void testUpdateWithSubTasks() throws Exception {
// init222();
// String taskNumber = "23";
@@ -503,65 +110,6 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// fail("Should have failed due to invalid userid and password.");
// }
//
-// public void testSynchronize() throws CoreException {
-// init222();
-//
-// TasksUiPlugin.getTaskDataStorageManager().clear();
-//
-// // Get the task
-// BugzillaTask task = generateLocalTaskAndDownload("3");
-//
-// RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getEditableCopy(
-// task.getRepositoryUrl(), task.getTaskId());
-// assertNotNull(taskData);
-//
-// TasksUiPlugin.getTaskList().addTask(task);
-// int numComments = taskData.getComments().size();
-//
-// // Modify it
-// String newCommentText = "BugzillaRepositoryClientTest.testSynchronize(): " + (new Date()).toString();
-// taskData.setNewComment(newCommentText);
-// Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
-// changed.add(taskData.getAttribute(TaskAttribute.COMMENT_NEW));
-// TasksUiPlugin.getTaskDataStorageManager().saveEdits(task.getRepositoryUrl(), task.getTaskId(), changed);
-//
-// // Submit changes
-// submit(task, taskData);
-//
-// TasksUiInternal.synchronizeTask(connector, task, true, null);
-// // After submit task should be in SYNCHRONIZED state
-// assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
-// RepositoryTaskData taskData2 = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(
-// task.getRepositoryUrl(), task.getTaskId());
-// assertFalse(taskData2.getLastModified().equals(taskData.getLastModified()));
-// // Still not read
-// assertFalse(taskData2.getLastModified().equals(task.getLastReadTimeStamp()));
-// TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
-// assertEquals(taskData2.getLastModified(), task.getLastReadTimeStamp());
-// assertTrue(taskData2.getComments().size() > numComments);
-//
-// // Has no outgoing changes or conflicts yet needs synch
-// // because task doesn't have bug report (new query hit)
-// // Result: retrieved with no incoming status
-// // task.setSyncState(SynchronizationState.SYNCHRONIZED);
-// TasksUiPlugin.getTaskDataStorageManager().remove(task.getRepositoryUrl(), task.getTaskId());
-// TasksUiInternal.synchronizeTask(connector, task, false, null);
-// assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
-// RepositoryTaskData bugReport2 = null;
-// bugReport2 = TasksUiPlugin.getTaskDataStorageManager()
-// .getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
-// assertNotNull(bugReport2);
-// assertEquals(task.getTaskId(), bugReport2.getTaskId());
-//
-// assertEquals(newCommentText, bugReport2.getComments().get(numComments).getText());
-// // TODO: Test that comment was appended
-// // ArrayList<Comment> comments = task.getTaskData().getComments();
-// // assertNotNull(comments);
-// // assertTrue(comments.size() > 0);
-// // Comment lastComment = comments.get(comments.size() - 1);
-// // assertEquals(newCommentText, lastComment.getText());
-//
-// }
//
// public void testUniqueQueryHitObjects() {
// init222();
@@ -590,96 +138,6 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// assertEquals(1, taskList.getAllTasks().size());
// }
//
-// public void testAttachToExistingReport() throws Exception {
-// init222();
-// String taskNumber = "33";
-// BugzillaTask task = generateLocalTaskAndDownload(taskNumber);
-// RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-// task.getTaskId());
-//
-// assertNotNull(task);
-// assertNotNull(taskData);
-// TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
-// assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
-// assertEquals(taskNumber, taskData.getTaskId());
-// int numAttached = taskData.getAttachments().size();
-// String fileName = "test-attach-" + System.currentTimeMillis() + ".txt";
-//
-// assertNotNull(repository.getUserName());
-// assertNotNull(repository.getPassword());
-//
-// /* Initialize a local attachment */
-// LocalAttachment attachment = new LocalAttachment();
-// attachment.setDescription("Test attachment " + new Date());
-// attachment.setContentType("text/plain");
-// attachment.setPatch(false);
-// attachment.setReport(taskData);
-// attachment.setComment("Automated JUnit attachment test"); // optional
-//
-// /* Test attempt to upload a non-existent file */
-// attachment.setFilePath("/this/is/not/a/real-file");
-// attachment.setFile(new File(attachment.getFilePath()));
-// attachment.setFilename("real-file");
-// // IAttachmentHandler attachmentHandler =
-// // connector.getAttachmentHandler();
-// BugzillaClient client = connector.getClientManager().getClient(repository, new NullProgressMonitor());
-// try {
-// client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment, null);
-// fail();
-// } catch (Exception e) {
-// }
-// // attachmentHandler.uploadAttachment(repository, task, comment,
-// // summary, file, contentType, isPatch, proxySettings)
-// // assertFalse(attachmentHandler.uploadAttachment(attachment,
-// // repository.getUserName(), repository.getPassword(),
-// // Proxy.NO_PROXY));
-// assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState());
-// task = (BugzillaTask) TasksUiInternal.createTask(repository, taskNumber, new NullProgressMonitor());
-// TasksUiInternal.synchronizeTask(connector, task, true, null);
-//
-// assertEquals(numAttached, taskData.getAttachments().size());
-//
-// /* Test attempt to upload an empty file */
-// File attachFile = new File(fileName);
-// attachment.setFilePath(attachFile.getAbsolutePath());
-// BufferedWriter write = new BufferedWriter(new FileWriter(attachFile));
-// attachFile = new File(attachment.getFilePath());
-// attachment.setFile(attachFile);
-// attachment.setFilename(attachFile.getName());
-// // assertFalse(attachmentHandler.uploadAttachment(attachment,
-// // repository.getUserName(), repository.getPassword(),
-// // Proxy.NO_PROXY));
-// try {
-// client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment, null);
-// fail();
-// } catch (Exception e) {
-// }
-// task = (BugzillaTask) TasksUiInternal.createTask(repository, taskNumber, new NullProgressMonitor());
-// TasksUiInternal.synchronizeTask(connector, task, true, null);
-// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
-// assertEquals(numAttached, taskData.getAttachments().size());
-//
-// /* Test uploading a proper file */
-// write.write("test file");
-// write.close();
-// attachment.setFilePath(attachFile.getAbsolutePath());
-// // assertTrue(attachmentHandler.uploadAttachment(attachment,
-// // repository.getUserName(), repository.getPassword(),
-// // Proxy.NO_PROXY));
-// File fileToAttach = new File(attachment.getFilePath());
-// assertTrue(fileToAttach.exists());
-// attachment.setFile(fileToAttach);
-// attachment.setFilename(fileToAttach.getName());
-// client.postAttachment(attachment.getReport().getTaskId(), attachment.getComment(), attachment, null);
-//
-// task = (BugzillaTask) TasksUiInternal.createTask(repository, taskNumber, new NullProgressMonitor());
-// TasksUiInternal.synchronizeTask(connector, task, true, null);
-// taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
-// assertEquals(numAttached + 1, taskData.getAttachments().size());
-//
-// // use assertion to track clean-up
-// assertTrue(attachFile.delete());
-// }
//
// public void testSynchChangedReports() throws Exception {
//
@@ -924,38 +382,6 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// return "" + year + "-" + ((month <= 9) ? "0" : "") + month + "-" + ((day <= 9) ? "0" : "") + day;
// }
//
-// /**
-// * Ensure obsoletes and patches are marked as such by the parser.
-// */
-// public void testAttachmentAttributes() throws Exception {
-// init222();
-// int bugId = 19;
-// String taskNumber = "" + bugId;
-// BugzillaTask task = generateLocalTaskAndDownload(taskNumber);
-//
-// // TasksUiPlugin.getSynchronizationManager().synchronize(connector,
-// // task, true, null);
-//
-// assertNotNull(task);
-//
-// boolean isPatch[] = { false, true, false, false, false, false, false, true, false, false };
-// boolean isObsolete[] = { false, true, false, true, false, false, false, false, false, false };
-//
-// RepositoryTaskData taskData = TasksUiPlugin.getTaskDataStorageManager().getNewTaskData(task.getRepositoryUrl(),
-// task.getTaskId());
-//
-// Iterator<RepositoryAttachment> iter = taskData.getAttachments().iterator();
-//
-// int index = 0;
-// while (iter.hasNext()) {
-// assertTrue(validateAttachmentAttributes(iter.next(), isPatch[index], isObsolete[index]));
-// index++;
-// }
-// }
-//
-// private boolean validateAttachmentAttributes(RepositoryAttachment att, boolean isPatch, boolean isObsolete) {
-// return (att.isPatch() == isPatch) && (att.isObsolete() == isObsolete);
-// }
//
//// public void testSimpleLoad() throws Exception {
//// repository = new TaskRepository(DEFAULT_KIND,
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest2.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest2.java
index e46b7360d..40dbcf270 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest2.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest2.java
@@ -28,12 +28,17 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaOperation;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
+import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
import org.eclipse.mylyn.internal.tasks.core.data.FileTaskAttachmentSource;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.search.RepositorySearchResult;
+import org.eclipse.mylyn.internal.tasks.ui.search.SearchHitCollector;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.TaskMapping;
@@ -54,6 +59,199 @@ import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
public class BugzillaRepositoryConnectorTest2 extends AbstractBugzillaTest {
+//testReassign Bugs
+//Version BugNr assigned reporter
+//2.22 92 user@mylar.eclipse.org tests@mylar.eclipse.org
+//3.0 5 tests@mylar.eclipse.org tests2@mylar.eclipse.org
+//3.1 1 rob.elves@eclipse.org tests@mylar.eclipse.org
+
+//XXX: restore
+ public void testReassign222() throws CoreException {
+ init222();
+ String taskNumber = "92";
+ doReassignOld(taskNumber, "user@mylar.eclipse.org");
+ }
+
+ public void testReassign30() throws CoreException {
+ init30();
+ String taskNumber = "5";
+ doReassignOld(taskNumber, "tests@mylyn.eclipse.org");
+ }
+
+ public void testReassign31() throws CoreException {
+ init31();
+ String taskNumber = "1";
+
+ // Get the task
+ ITask task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ TaskDataModel model = createModel(task);
+ TaskData taskData = model.getTaskData();
+ assertNotNull(taskData);
+ TaskMapper mapper = new TaskMapper(taskData);
+
+ if (mapper.getOwner().equals("rob.elves@eclipse.org")) {
+ assertEquals("rob.elves@eclipse.org", mapper.getOwner());
+ reassingToUser31(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals("tests2@mylyn.eclipse.org", mapper.getOwner());
+
+ reassignToDefault31(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals("rob.elves@eclipse.org", mapper.getOwner());
+ } else if (mapper.getOwner().equals("tests2@mylyn.eclipse.org")) {
+ assertEquals("tests2@mylyn.eclipse.org", mapper.getOwner());
+ reassignToDefault31(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals("rob.elves@eclipse.org", mapper.getOwner());
+
+ reassingToUser31(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals("tests2@mylyn.eclipse.org", mapper.getOwner());
+ } else {
+ fail("Bug with unexpected user assigned");
+ }
+ }
+
+ private void reassignToDefault31(ITask task, TaskData taskData) throws CoreException {
+ // Modify it (reassignbycomponent)
+ String newCommentText = "BugzillaRepositoryClientTest.testReassign31(): reassignbycomponent "
+ + (new Date()).toString();
+ TaskAttribute comment = taskData.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW);
+ comment.setValue(newCommentText);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ changed.add(comment);
+
+ TaskAttribute assignee = taskData.getRoot().getAttribute(BugzillaAttribute.SET_DEFAULT_ASSIGNEE.getKey());
+ assignee.setValue("1");
+ changed.add(assignee);
+ // Submit changes
+ submit(task, taskData, changed);
+ }
+
+ private void reassingToUser31(ITask task, TaskData taskData) throws CoreException {
+ // Modify it (reassign to tests2@mylyn.eclipse.org)
+ String newCommentText = "BugzillaRepositoryClientTest.testReassign31(): reassign " + (new Date()).toString();
+ TaskAttribute comment = taskData.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW);
+ comment.setValue(newCommentText);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ changed.add(comment);
+
+ TaskAttribute assignedAttribute = taskData.getRoot().getAttribute(BugzillaAttribute.ASSIGNED_TO.getKey());
+ assignedAttribute.setValue("tests2@mylyn.eclipse.org");
+ changed.add(assignedAttribute);
+
+ // Submit changes
+ submit(task, taskData, null);
+ }
+
+ private void doReassignOld(String taskNumber, String defaultAssignee) throws CoreException {
+ // Get the task
+ ITask task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ TaskDataModel model = createModel(task);
+ TaskData taskData = model.getTaskData();
+ assertNotNull(taskData);
+ TaskMapper mapper = new TaskMapper(taskData);
+
+ if (mapper.getOwner().equals(defaultAssignee)) {
+ assertEquals(defaultAssignee, mapper.getOwner());
+ reassingToUserOld(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals("tests2@mylyn.eclipse.org", mapper.getOwner());
+
+ reassignToDefaultOld(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals(defaultAssignee, mapper.getOwner());
+ } else if (mapper.getOwner().equals("tests2@mylyn.eclipse.org")) {
+ assertEquals("tests2@mylyn.eclipse.org", mapper.getOwner());
+ reassignToDefaultOld(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals(defaultAssignee, mapper.getOwner());
+
+ reassingToUserOld(task, taskData);
+ task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ mapper = new TaskMapper(taskData);
+ assertEquals("tests2@mylyn.eclipse.org", mapper.getOwner());
+ } else {
+ fail("Bug with unexpected user assigned");
+ }
+ }
+
+ private void reassignToDefaultOld(ITask task, TaskData taskData) throws CoreException {
+ // Modify it (reassignbycomponent)
+ String newCommentText = "BugzillaRepositoryClientTest.testReassignOld(): reassignbycomponent "
+ + (new Date()).toString();
+ TaskAttribute comment = taskData.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW);
+ comment.setValue(newCommentText);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ changed.add(comment);
+ TaskAttribute selectedOperationAttribute = taskData.getRoot().getMappedAttribute(TaskAttribute.OPERATION);
+ TaskOperation.applyTo(selectedOperationAttribute, BugzillaOperation.reassignbycomponent.toString(),
+ BugzillaOperation.reassignbycomponent.getLabel());
+ changed.add(selectedOperationAttribute);
+
+ // Submit changes
+ submit(task, taskData, null);
+ }
+
+ private void reassingToUserOld(ITask task, TaskData taskData) throws CoreException {
+ // Modify it (reassign to tests2@mylyn.eclipse.org)
+ String newCommentText = "BugzillaRepositoryClientTest.testReassignOld(): reassign " + (new Date()).toString();
+ TaskAttribute comment = taskData.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW);
+ comment.setValue(newCommentText);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ changed.add(comment);
+ TaskAttribute selectedOperationAttribute = taskData.getRoot().getMappedAttribute(TaskAttribute.OPERATION);
+ TaskOperation.applyTo(selectedOperationAttribute, BugzillaOperation.reassign.toString(),
+ BugzillaOperation.reassign.getLabel());
+ TaskAttribute assignedAttribute = taskData.getRoot().getAttribute("reassignInput");
+ assignedAttribute.setValue("tests2@mylyn.eclipse.org");
+ changed.add(selectedOperationAttribute);
+ changed.add(assignedAttribute);
+
+ // Submit changes
+ submit(task, taskData, null);
+ }
/*
* Test for the following State transformation
@@ -391,8 +589,6 @@ public class BugzillaRepositoryConnectorTest2 extends AbstractBugzillaTest {
TaskData taskData = workingCopy.getLocalData();
assertNotNull(taskData);
-// TasksUiPlugin.getTaskList().addTask(task);
-
String newCommentText = "BugzillaRepositoryClientTest.testMidAirCollision(): test " + (new Date()).toString();
TaskAttribute attrNewComment = taskData.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW);
attrNewComment.setValue(newCommentText);
@@ -524,4 +720,137 @@ public class BugzillaRepositoryConnectorTest2 extends AbstractBugzillaTest {
assertTrue(task.getSynchronizationState() == SynchronizationState.INCOMING);
}
}
+
+ ITask fruitTask;
+
+ TaskData fruitTaskData;
+
+ private void setFruitValueTo(String newValue) throws CoreException {
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ TaskAttribute cf_fruit = fruitTaskData.getRoot().getAttribute("cf_fruit");
+ cf_fruit.setValue(newValue);
+ assertEquals(newValue, fruitTaskData.getRoot().getAttribute("cf_fruit").getValue());
+ changed.add(cf_fruit);
+ submit(fruitTask, fruitTaskData, changed);
+ TasksUiInternal.synchronizeTask(connector, fruitTask, true, null);
+ fruitTaskData = TasksUiPlugin.getTaskDataManager().getTaskData(repository, fruitTask.getTaskId());
+ assertEquals(newValue, fruitTaskData.getRoot().getAttribute("cf_fruit").getValue());
+
+ }
+
+ public void testCustomFields() throws Exception {
+ init(IBugzillaConstants.TEST_BUGZILLA_303_URL);
+
+ String taskNumber = "1";
+
+ // Get the task
+ fruitTask = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(fruitTask);
+ TaskDataModel model = createModel(fruitTask);
+ fruitTaskData = model.getTaskData();
+ assertNotNull(fruitTaskData);
+
+ if (fruitTaskData.getRoot().getAttribute("cf_fruit").getValue().equals("---")) {
+ setFruitValueTo("apple");
+ setFruitValueTo("orange");
+ setFruitValueTo("---");
+ } else if (fruitTaskData.getRoot().getAttribute("cf_fruit").getValue().equals("apple")) {
+ setFruitValueTo("orange");
+ setFruitValueTo("apple");
+ setFruitValueTo("---");
+ } else if (fruitTaskData.getRoot().getAttribute("cf_fruit").getValue().equals("orange")) {
+ setFruitValueTo("apple");
+ setFruitValueTo("orange");
+ setFruitValueTo("---");
+ }
+ if (fruitTask != null) {
+ fruitTask = null;
+ }
+ if (fruitTaskData != null) {
+ fruitTaskData = null;
+ }
+ }
+
+ public void testAnonymousRepositoryAccess() throws Exception {
+ init218();
+ assertNotNull(repository);
+ AuthenticationCredentials anonymousCreds = new AuthenticationCredentials("", "");
+ repository.setCredentials(AuthenticationType.REPOSITORY, anonymousCreds, false);
+ TasksUiPlugin.getRepositoryManager().notifyRepositorySettingsChanged(repository);
+ // test anonymous task retrieval
+ ITask task = this.generateLocalTaskAndDownload("2");
+ assertNotNull(task);
+
+ // // test anonymous query (note that this demonstrates query via
+ // eclipse search (ui)
+
+ String queryUrl = "http://mylyn.eclipse.org/bugs218/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=search-match-test&product=TestProduct&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&deadlinefrom=&deadlineto=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
+ IRepositoryQuery bugzillaQuery = TasksUi.getRepositoryModel().createRepositoryQuery(repository);
+ bugzillaQuery.setUrl(queryUrl);
+ SearchHitCollector collector = new SearchHitCollector(taskList, repository, bugzillaQuery);
+ RepositorySearchResult result = (RepositorySearchResult) collector.getSearchResult();
+
+ collector.run(new NullProgressMonitor());
+ assertEquals(2, result.getElements().length);
+
+ for (Object element : result.getElements()) {
+ assertEquals(true, element instanceof ITask);
+ ITask hit = (ITask) element;
+ assertTrue(hit.getSummary().contains("search-match-test"));
+ }
+
+ // test anonymous update of configuration
+ RepositoryConfiguration config = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, null);
+ assertNotNull(config);
+ assertTrue(config.getComponents().size() > 0);
+ }
+
+ public void testUpdate() throws Exception {
+ init222();
+ String taskNumber = "3";
+ ITask task = generateLocalTaskAndDownload(taskNumber);
+ TasksUi.getTaskDataManager().discardEdits(task);
+ TaskDataModel model = createModel(task);
+ TaskData taskData = model.getTaskData();
+ assertNotNull(taskData);
+
+ assertEquals("search-match-test 2", task.getSummary());
+ assertEquals("TestProduct", task.getAttribute(TaskAttribute.PRODUCT));
+ assertEquals("P1", task.getPriority());
+ assertEquals("blocker", task.getAttribute(BugzillaAttribute.BUG_SEVERITY.getKey()));
+ assertEquals("nhapke@cs.ubc.ca", task.getOwner());
+ assertFalse(task.isCompleted());
+ assertEquals("http://mylyn.eclipse.org/bugs222/show_bug.cgi?id=3", task.getUrl());
+ }
+
+ /**
+ * Ensure obsoletes and patches are marked as such by the parser.
+ */
+ public void testAttachmentAttributes() throws Exception {
+ init222();
+ String taskNumber = "19";
+ ITask task = generateLocalTaskAndDownload(taskNumber);
+ assertNotNull(task);
+ TaskDataModel model = createModel(task);
+ TaskData taskData = model.getTaskData();
+ assertNotNull(taskData);
+
+ boolean isPatch[] = { false, true, false, false, false, false, false, true, false, false, false };
+ boolean isObsolete[] = { false, true, false, true, false, false, false, false, false, false, false };
+
+ int index = 0;
+ for (TaskAttribute attribute : taskData.getAttributeMapper().getAttributesByType(taskData,
+ TaskAttribute.TYPE_ATTACHMENT)) {
+ assertTrue(validateAttachmentAttributes(model, attribute, isPatch[index], isObsolete[index]));
+ index++;
+ }
+ }
+
+ private boolean validateAttachmentAttributes(TaskDataModel model, TaskAttribute taskAttribute, boolean isPatch,
+ boolean isObsolete) {
+ TaskAttachment taskAttachment = new TaskAttachment(model.getTaskRepository(), model.getTask(), taskAttribute);
+ model.getTaskData().getAttributeMapper().updateTaskAttachment(taskAttachment, taskAttribute);
+ return (taskAttachment.isPatch() == isPatch) && (taskAttachment.isDeprecated() == isObsolete);
+ }
+
}

Back to the top