Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2013-04-13 15:19:04 -0400
committerGerrit Code Review @ Eclipse.org2013-04-17 12:57:57 -0400
commit2349cefaf3c46f66a5b0e79771405d907a7bcec5 (patch)
treee155b13cf5b9681b8d21ba4bfc967c1bec1d7757 /org.eclipse.mylyn.bugzilla.tests/src
parent98134ce70bb091dce62d2bc647401912818819d2 (diff)
downloadorg.eclipse.mylyn.tasks-2349cefaf3c46f66a5b0e79771405d907a7bcec5.tar.gz
org.eclipse.mylyn.tasks-2349cefaf3c46f66a5b0e79771405d907a7bcec5.tar.xz
org.eclipse.mylyn.tasks-2349cefaf3c46f66a5b0e79771405d907a7bcec5.zip
405656: speed up BugzillaRepositoryConnectorTest.testMissingHits()
Change-Id: Ib54e3af39a9b4a6ef3eb5604457b23185fb79b07 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=405656
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests/src')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java115
2 files changed, 124 insertions, 1 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 bb5a88b3d..7a66d6f21 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
@@ -15,6 +15,7 @@ import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
@@ -934,7 +935,14 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
}
public void testMissingHits() throws Exception {
- String queryString = "http://mylyn.eclipse.org/bugs323/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&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=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
+ ArrayList<String> taskId = harness.taskMissingHitsExists();
+ if (taskId == null || taskId.isEmpty()) {
+ harness.createMissingHitsTask();
+ }
+
+ String queryString = BugzillaFixture.current().getRepositoryUrl() + "/buglist.cgi?"
+ + "short_desc=test%20Missing%20Hits&resolution=---&query_format=advanced"
+ + "&short_desc_type=casesubstring&component=ManualC2&product=ManualTest";
RepositoryQuery query = new RepositoryQuery(BugzillaCorePlugin.CONNECTOR_KIND, "test");
query.setRepositoryUrl(repository.getRepositoryUrl());
query.setUrl(queryString);
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 92a609cb7..815b4f0eb 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
@@ -18,6 +18,7 @@ import static org.junit.Assert.fail;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -598,4 +599,118 @@ public class BugzillaHarness {
return taskId;
}
+ public ArrayList<String> taskMissingHitsExists() {
+ ArrayList<String> taskIDs = new ArrayList<String>();
+
+ String queryUrlString = abstractBugzillaTest.getRepository().getRepositoryUrl() + "/buglist.cgi?"
+ + "short_desc=test%20Missing%20Hits&resolution=---&query_format=advanced"
+ + "&short_desc_type=casesubstring&component=ManualC2&product=ManualTest";
+ 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);
+ for (Integer integer : sks) {
+ taskIDs.add("" + integer);
+ }
+ }
+ return taskIDs;
+ }
+
+ public void createMissingHitsTask() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+
+ @Override
+ public String getProduct() {
+ return "ManualTest";
+ }
+ };
+ final TaskMapping taskMappingSelect1 = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "ManualC2";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test Missing Hits 1";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the test Missing Hits 1";
+ }
+ };
+ final TaskMapping taskMappingSelect2 = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "ManualC2";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test Missing Hits 2";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the test Missing Hits 2";
+ }
+ };
+ final TaskMapping taskMappingSelect3 = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "ManualC2";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test Missing Hits 3";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the test Missing Hits 3";
+ }
+ };
+ createTask(taskMappingInit, taskMappingSelect1);
+ createTask(taskMappingInit, taskMappingSelect2);
+ createTask(taskMappingInit, taskMappingSelect3);
+ }
+
+ private String createTask(TaskMapping taskMappingInit, TaskMapping taskMappingSelect) throws Exception {
+ 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