Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2013-05-01 11:25:33 -0400
committerGerrit Code Review @ Eclipse.org2013-05-09 08:59:07 -0400
commit20e8aaf07ff15718cd47180630614e240b687a83 (patch)
tree66eac10b68a4c8ebcc1df83bf3e8e38036b3f822 /org.eclipse.mylyn.bugzilla.tests/src
parentec1c6c9dfe7c3c63c0a55e0b278c57695772eef7 (diff)
downloadorg.eclipse.mylyn.tasks-20e8aaf07ff15718cd47180630614e240b687a83.tar.gz
org.eclipse.mylyn.tasks-20e8aaf07ff15718cd47180630614e240b687a83.tar.xz
org.eclipse.mylyn.tasks-20e8aaf07ff15718cd47180630614e240b687a83.zip
398239: Bugzilla should return RepositoryStatus (ERROR_INTERNAL) on
invalid taskID in getMultiTaskData Change-Id: Ia31e03314e1a43d3f22596f3dd7d8ff96d8c6ed2 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398239
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests/src')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaCustomRepositoryTest.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java92
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java219
3 files changed, 313 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaCustomRepositoryTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaCustomRepositoryTest.java
index 08349ee69..52e02d8bf 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaCustomRepositoryTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaCustomRepositoryTest.java
@@ -36,7 +36,11 @@ import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
public class BugzillaCustomRepositoryTest extends AbstractBugzillaTest {
public void testWorkflow() throws Exception {
- doCustomWorkflow("3");
+ String taskId = harness.taskCfBugIdExists();
+ if (taskId == null) {
+ taskId = harness.createCfBugIdTask();
+ }
+ doCustomWorkflow(taskId);
}
private void doCustomWorkflow(String DupBugID) throws Exception {
@@ -281,6 +285,6 @@ public class BugzillaCustomRepositoryTest extends AbstractBugzillaTest {
assertEquals("CLOSED", statusAttribute.getValue());
resolution = taskData.getRoot().getMappedAttribute(TaskAttribute.RESOLUTION);
assertEquals("FIXED", resolution.getValue());
-
}
+
}
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 91c986c73..24af59b67 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
@@ -18,11 +18,14 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
@@ -57,6 +60,7 @@ import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
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.tasks.core.data.TaskDataModel;
import org.eclipse.mylyn.tasks.core.data.TaskOperation;
import org.eclipse.mylyn.tasks.ui.TasksUi;
@@ -73,11 +77,89 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
connector.getTaskData(repository, "99999", new NullProgressMonitor());
fail("Invalid id error should have resulted");
} catch (CoreException e) {
+ if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_4) > 0) {
+ assertTrue(e.getStatus().getMessage().contains(IBugzillaConstants.ERROR_MSG_INVALID_BUG_ID));
+ } else {
+ assertTrue(e.getStatus().getMessage().contains(IBugzillaConstants.ERROR_MSG_NOT_FOUND_BUG_ID));
+ }
+ }
+
+ }
+
+ public void testAliasRetrievalFailure() throws CoreException {
+ try {
+ connector.getTaskData(repository, "Hugo", new NullProgressMonitor());
+ fail("Invalid id error should have resulted");
+ } catch (CoreException e) {
assertTrue(e.getStatus().getMessage().contains(IBugzillaConstants.ERROR_MSG_INVALID_BUG_ID));
}
}
+ public void testAliasRetrieval() throws Exception {
+ String taskId = harness.taskAliasExists();
+ if (taskId == null) {
+ taskId = harness.createAliasTask();
+ }
+ String usebugaliases = BugzillaFixture.current().getProperty("usebugaliases");
+ boolean bugAliases = Boolean.parseBoolean(usebugaliases);
+ try {
+ TaskData td = connector.getTaskData(repository, "Fritz", new NullProgressMonitor());
+ if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_4) >= 0
+ || bugAliases) {
+ assertNotNull(td);
+ } else {
+ fail("testAliasRetrieval: never reach this! CoreException expected");
+ }
+ } catch (CoreException e) {
+ if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_4) < 0
+ && !bugAliases) {
+ assertTrue(e.getStatus().getMessage().contains(IBugzillaConstants.ERROR_MSG_INVALID_BUG_ID));
+ } else {
+ fail("testAliasRetrieval: never reach this! no CoreException expected");
+ }
+ }
+ }
+
+ public void testAliasMultiRetrieval() throws Exception {
+ String taskId = harness.taskAliasExists();
+ if (taskId == null) {
+ taskId = harness.createAliasTask();
+ }
+ taskId = harness.taskAlias2Exists();
+ if (taskId == null) {
+ taskId = harness.createAliasTask2();
+ }
+ Set<String> taskIds = new HashSet<String>();
+ taskIds.add("Hugo");
+ taskIds.add("Fritz");
+ taskIds.add(taskId);
+ final Map<String, TaskData> results = new HashMap<String, TaskData>();
+ final Map<String, IStatus> failed = new HashMap<String, IStatus>();
+ TaskDataCollector collector = new TaskDataCollector() {
+ @Override
+ public void accept(TaskData taskData) {
+ results.put(taskData.getTaskId(), taskData);
+ }
+
+ @Override
+ public void failed(String taskId, IStatus status) {
+ failed.put(taskId, status);
+ }
+
+ };
+ connector.getTaskDataHandler().getMultiTaskData(repository, taskIds, collector, new NullProgressMonitor());
+ String usebugaliases = BugzillaFixture.current().getProperty("usebugaliases");
+ if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_4) >= 0
+ || Boolean.parseBoolean(usebugaliases)) {
+ assertEquals(2, results.size());
+ assertEquals(1, failed.size());
+ } else {
+ assertEquals(1, results.size());
+ assertEquals(2, failed.size());
+ }
+ }
+
public void testMultiRetrievalFailure() throws Exception {
TaskData taskData1 = BugzillaFixture.current().createTask(PrivilegeLevel.USER, null, null);
@@ -348,13 +430,17 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
// }
//
public void testStdWorkflow() throws Exception {
+ String taskId = harness.taskCfBugIdExists();
+ if (taskId == null) {
+ taskId = harness.createCfBugIdTask();
+ }
if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_0) < 0) {
if (!BugzillaFixture.current().isCustomWorkflow() && !BugzillaFixture.current().isCustomWorkflowAndStatus()) {
- doStdWorkflow32("3");
+ doStdWorkflow32(taskId);
}
} else {
- doStdWorkflow40_1("3");
- doStdWorkflow40_2("3");
+ doStdWorkflow40_1(taskId);
+ doStdWorkflow40_2(taskId);
}
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java
index 815b4f0eb..e5efca926 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java
@@ -257,7 +257,11 @@ public class BugzillaHarness {
cf_largetextbox.setValue("large text box");
cf_multiselect.setValue("Blue");
cf_datetime.setValue("2012-01-01 00:00:00");
- cf_bugid.setValue("3");
+ String cf_bugidValue = taskCfBugIdExists();
+ if (cf_bugidValue == null) {
+ cf_bugidValue = createCfBugIdTask();
+ }
+ cf_bugid.setValue(cf_bugidValue);
model.attributeChanged(cf_freetext);
model.attributeChanged(cf_dropdown);
@@ -713,4 +717,217 @@ public class BugzillaHarness {
return taskId;
}
+ public String taskAliasExists() {
+ String taskID = null;
+ String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ + "short_desc=test%20Alias%20Bug&resolution=---&query_format=advanced"
+ + "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
+ RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
+ "handle-testQueryViaConnector");
+ query.setUrl(queryUrlString);
+ final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
+ TaskDataCollector collector = new TaskDataCollector() {
+ @Override
+ public void accept(TaskData taskData) {
+ changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
+ }
+ };
+ abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
+ new NullProgressMonitor());
+ if (changedTaskData.size() > 0) {
+ Set<Integer> ks = changedTaskData.keySet();
+ SortedSet<Integer> sks = new TreeSet<Integer>(ks);
+ taskID = sks.last().toString();
+ }
+ return taskID;
+ }
+
+ public String createAliasTask() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "TestComponent";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test Alias Bug";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the Alias Bug";
+ }
+ };
+ final TaskData[] taskDataNew = new TaskData[1];
+
+ // create Task
+ taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
+ taskMappingSelect, null);
+ ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
+ taskDataNew[0].getRepositoryUrl());
+
+ ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ TaskAttribute alias = taskDataNew[0].getRoot().getAttribute("alias");
+ if (alias == null) {
+ alias = taskDataNew[0].getRoot().createAttribute("alias");
+ }
+ alias.setValue("Fritz");
+ changed.add(alias);
+ workingCopy.save(changed, null);
+ RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
+ abstractBugzillaTest.getClient());
+ ((AbstractTask) taskNew).setSubmitting(true);
+ assertNotNull(response);
+ assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
+ String taskId = response.getTaskId();
+ return taskId;
+ }
+
+ public String taskAlias2Exists() {
+ String taskID = null;
+ String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ + "short_desc=test%20Alias%20Bug2&resolution=---&query_format=advanced"
+ + "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
+ RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
+ "handle-testQueryViaConnector");
+ query.setUrl(queryUrlString);
+ final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
+ TaskDataCollector collector = new TaskDataCollector() {
+ @Override
+ public void accept(TaskData taskData) {
+ changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
+ }
+ };
+ abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
+ new NullProgressMonitor());
+ if (changedTaskData.size() > 0) {
+ Set<Integer> ks = changedTaskData.keySet();
+ SortedSet<Integer> sks = new TreeSet<Integer>(ks);
+ taskID = sks.last().toString();
+ }
+ return taskID;
+ }
+
+ public String createAliasTask2() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "TestComponent";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test Alias Bug2";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the Alias Bug";
+ }
+ };
+ final TaskData[] taskDataNew = new TaskData[1];
+
+ // create Task
+ taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
+ taskMappingSelect, null);
+ ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
+ taskDataNew[0].getRepositoryUrl());
+
+ ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ workingCopy.save(changed, null);
+ RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
+ abstractBugzillaTest.getClient());
+ ((AbstractTask) taskNew).setSubmitting(true);
+ assertNotNull(response);
+ assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
+ String taskId = response.getTaskId();
+ return taskId;
+ }
+
+ public String taskCfBugIdExists() {
+ String taskID = null;
+ String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ + "short_desc=test%20CF%20Bug%20ID%20Bug&resolution=---&query_format=advanced"
+ + "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
+ RepositoryQuery query = new RepositoryQuery(abstractBugzillaTest.getRepository().getConnectorKind(),
+ "handle-testQueryViaConnector");
+ query.setUrl(queryUrlString);
+ final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
+ TaskDataCollector collector = new TaskDataCollector() {
+ @Override
+ public void accept(TaskData taskData) {
+ changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
+ }
+ };
+ abstractBugzillaTest.getConnector().performQuery(abstractBugzillaTest.getRepository(), query, collector, null,
+ new NullProgressMonitor());
+ if (changedTaskData.size() > 0) {
+ Set<Integer> ks = changedTaskData.keySet();
+ SortedSet<Integer> sks = new TreeSet<Integer>(ks);
+ taskID = sks.last().toString();
+ }
+ return taskID;
+ }
+
+ public String createCfBugIdTask() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "TestComponent";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test CF Bug ID Bug";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the CF Bug ID Bug";
+ }
+ };
+ final TaskData[] taskDataNew = new TaskData[1];
+
+ // create Task
+ taskDataNew[0] = TasksUiInternal.createTaskData(abstractBugzillaTest.getRepository(), taskMappingInit,
+ taskMappingSelect, null);
+ ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
+ taskDataNew[0].getRepositoryUrl());
+
+ ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ workingCopy.save(changed, null);
+ RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0],
+ abstractBugzillaTest.getClient());
+ ((AbstractTask) taskNew).setSubmitting(true);
+ assertNotNull(response);
+ assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
+ String taskId = response.getTaskId();
+ return taskId;
+ }
+
}

Back to the top