Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2013-06-17 14:43:59 -0400
committerGerrit Code Review @ Eclipse.org2013-10-11 10:21:53 -0400
commitd9afc005a7ff99e8e4599d05ae31153b22be3c15 (patch)
tree8a959a255e5a5285a48fdf59134899d0061295d1 /org.eclipse.mylyn.bugzilla.tests/src
parentf6fef9e7c49d951ac5d15ff30b664ef6d031d9ea (diff)
downloadorg.eclipse.mylyn.tasks-d9afc005a7ff99e8e4599d05ae31153b22be3c15.tar.gz
org.eclipse.mylyn.tasks-d9afc005a7ff99e8e4599d05ae31153b22be3c15.tar.xz
org.eclipse.mylyn.tasks-d9afc005a7ff99e8e4599d05ae31153b22be3c15.zip
410279: scoping down queries
Change-Id: I771052d650bd71876d31588ef900918e2fd019c0 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=410279
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.tests/src')
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java22
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java43
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java34
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaHarness.java82
4 files changed, 140 insertions, 41 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java
index d3a9f3725..202b35a26 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java
@@ -16,10 +16,9 @@ import java.net.Proxy;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.mylyn.bugzilla.tests.AbstractBugzillaTest;
import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
@@ -49,17 +48,7 @@ import org.eclipse.mylyn.tests.util.UrlBuilder;
* @author Frank Becker
* @author David Green
*/
-public class BugzillaClientTest extends TestCase {
-
- private BugzillaClient client;
-
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- repository = BugzillaFixture.current().repository();
- client = BugzillaFixture.current().client();
- }
+public class BugzillaClientTest extends AbstractBugzillaTest {
public void testRDFProductConfig() throws Exception {
if (BugzillaVersion.BUGZILLA_4_4.compareTo(BugzillaFixture.current().getBugzillaVersion()) == 0
@@ -234,11 +223,16 @@ public class BugzillaClientTest extends TestCase {
* test for bug 335278: enhance search result handler to handle additional attributes
*/
public void testQueryRealName_Bug335278() throws Exception {
+ String taskId = harness.enhanceSearchTaskExists();
+ if (taskId == null) {
+ taskId = harness.createEnhanceSearchTask();
+ }
+
IRepositoryQuery query = new RepositoryQuery(BugzillaFixture.current().getConnectorKind(), "query");
UrlBuilder urlBuilder = UrlBuilder.build(BugzillaFixture.current().repository()).append("/buglist.cgi");
urlBuilder.parameter(
- "columnlist",
+ "short_desc=test%20Bug%20335278&columnlist",
"bug_severity,priority,assigned_to,bug_status,resolution,short_desc,changeddate,reporter,assigned_to_realname,reporter_realname,product,component");
query.setUrl(urlBuilder.toString());
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java
index 97f50cb72..3113b426b 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java
@@ -13,6 +13,7 @@
package org.eclipse.mylyn.bugzilla.tests.core;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -214,14 +215,39 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
}
public void testPerformQuery() throws Exception {
- TaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, null, null);
-
- // queries for bugs assigned to tests@mylyn.eclipse.org, updated in the last hour, trivial with P1
RepositoryConfiguration repositoryConfiguration = connector.getRepositoryConfiguration(repository.getRepositoryUrl());
List<String> priorities = repositoryConfiguration.getOptionValues(BugzillaAttribute.PRIORITY);
- String priority = priorities.get(0);
- String severity = "trivial";
+ final String priority = priorities.get(0);
+ final String severity = "trivial";
String email = "tests%40mylyn.eclipse.org";
+
+ final String summaryNotNull = "Summary for testPerformQuery " + new Date();
+ final String descriptionNotNull = "Description for testPerformQuery " + new Date();
+ // create a Task so we not have on for the query
+ BugzillaFixture.current().createTask(PrivilegeLevel.USER, new HashMap<String, String>() {
+ private static final long serialVersionUID = 1L;
+ {
+ put(TaskAttribute.SUMMARY, summaryNotNull);
+ put(TaskAttribute.DESCRIPTION, descriptionNotNull);
+ put(BugzillaAttribute.OP_SYS.getKey(), "All");
+ put(BugzillaAttribute.REP_PLATFORM.getKey(), "All");
+ put(BugzillaAttribute.VERSION.getKey(), "unspecified");
+ put(TaskAttribute.PRIORITY, priority);
+ put(TaskAttribute.SEVERITY, severity);
+ }
+ });
+ // create the test Task
+ TaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, new HashMap<String, String>() {
+ private static final long serialVersionUID = 1L;
+ {
+ put(TaskAttribute.SUMMARY, summaryNotNull);
+ put(TaskAttribute.DESCRIPTION, descriptionNotNull);
+ put(BugzillaAttribute.OP_SYS.getKey(), "All");
+ put(BugzillaAttribute.REP_PLATFORM.getKey(), "All");
+ put(BugzillaAttribute.VERSION.getKey(), "unspecified");
+ }
+ });
+
String bug_status = BugzillaFixture.current()
.getBugzillaVersion()
.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_0) < 0
@@ -230,7 +256,8 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
String queryUrlString = repository.getRepositoryUrl() + "/buglist.cgi?priority=" + priority
+ "&emailassigned_to1=1&query_format=advanced&emailreporter1=1&field0-0-0=bug_status&bug_severity="
+ severity + bug_status + "&type0-0-1=equals&value0-0-1=tests%40mylyn.eclipse.org&email1=" + email
- + "&type0-0-0=notequals&field0-0-1=reporter&value0-0-0=UNCONFIRMED&emailtype1=exact";
+ + "&type0-0-0=notequals&field0-0-1=reporter&value0-0-0=UNCONFIRMED&emailtype1=exact&longdesc="
+ + descriptionNotNull + "&longdesc_type=casesubstring";
// make sure initial task is not P1/trivial
assertFalse(taskData.getRoot()
@@ -253,6 +280,7 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
}
};
connector.performQuery(repository, query, collector, null, new NullProgressMonitor());
+ assertEquals(1, changedTaskData.size());
// set priority and severity on task
taskData.getRoot()
@@ -260,6 +288,7 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
.setValue(System.currentTimeMillis() + "");
taskData.getRoot().getMappedAttribute(BugzillaAttribute.PRIORITY.getKey()).setValue(priority);
taskData.getRoot().getMappedAttribute(BugzillaAttribute.BUG_SEVERITY.getKey()).setValue(severity);
+ taskData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION).setValue(descriptionNotNull);
RepositoryResponse response = BugzillaFixture.current().submitTask(taskData, client);
assertFalse(response.getTaskId().equals(""));
TaskData taskDataNew = BugzillaFixture.current().getTask(response.getTaskId(), client);
@@ -273,7 +302,7 @@ public class BugzillaRepositoryConnectorStandaloneTest extends TestCase {
}
};
connector.performQuery(repository, query, collector2, null, new NullProgressMonitor());
-
+ assertEquals(2, changedTaskData2.size());
// compare query results
changedTaskData2.keySet().removeAll(changedTaskData.keySet());
assertEquals(1, changedTaskData2.size());
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
index 77d136958..1f9144779 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
@@ -20,6 +20,7 @@ import java.util.Map;
import junit.framework.AssertionFailedError;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
@@ -194,12 +195,23 @@ public class BugzillaFixture extends TestFixture {
* @return The taskData retrieved from updating the task
*/
public TaskData createTask(PrivilegeLevel level, String summary, String description) throws Exception {
- if (summary == null) {
- summary = "summary";
- }
- if (description == null) {
- description = "description";
- }
+ final String summaryNotNull = summary != null ? summary : "summary";
+ final String descriptionNotNull = description != null ? description : "description";
+ return createTask(level, new HashMap<String, String>() {
+ private static final long serialVersionUID = 1L;
+ {
+ put(TaskAttribute.SUMMARY, summaryNotNull);
+ put(TaskAttribute.DESCRIPTION, descriptionNotNull);
+ put(BugzillaAttribute.OP_SYS.getKey(), "All");
+ put(BugzillaAttribute.REP_PLATFORM.getKey(), "All");
+ put(BugzillaAttribute.VERSION.getKey(), "unspecified");
+ }
+ });
+ }
+
+ public TaskData createTask(PrivilegeLevel level, Map<String, String> additionalAttributeValues) throws Exception {
+ Assert.isLegal(additionalAttributeValues.containsKey(TaskAttribute.SUMMARY), "need value for Summary");
+ Assert.isLegal(additionalAttributeValues.containsKey(TaskAttribute.DESCRIPTION), "need value for Description");
ITaskMapping initializationData = new TaskMapping() {
@Override
@@ -219,11 +231,11 @@ public class BugzillaFixture extends TestFixture {
TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository());
TaskData taskData = new TaskData(mapper, repository().getConnectorKind(), repository().getRepositoryUrl(), "");
taskDataHandler.initializeTaskData(repository(), taskData, initializationData, null);
- taskData.getRoot().createMappedAttribute(TaskAttribute.SUMMARY).setValue(summary);
- taskData.getRoot().createMappedAttribute(TaskAttribute.DESCRIPTION).setValue(description);
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.OP_SYS.getKey()).setValue("All");
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.REP_PLATFORM.getKey()).setValue("All");
- taskData.getRoot().createMappedAttribute(BugzillaAttribute.VERSION.getKey()).setValue("unspecified");
+ for (String attributeKey : additionalAttributeValues.keySet()) {
+ taskData.getRoot()
+ .createMappedAttribute(attributeKey)
+ .setValue(additionalAttributeValues.get(attributeKey));
+ }
RepositoryResponse response = submitTask(taskData, client);
String bugId = response.getTaskId();
return getTask(bugId, client);
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 db5a8f191..193047ab7 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
@@ -21,6 +21,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
@@ -35,9 +36,11 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.data.FileTaskAttachmentSource;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
@@ -45,6 +48,7 @@ import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind;
import org.eclipse.mylyn.tasks.core.TaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
+import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
@@ -52,6 +56,7 @@ import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
public class BugzillaHarness {
@@ -672,9 +677,7 @@ public class BugzillaHarness {
RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
- String taskId = response.getTaskId();
-
- return taskId;
+ return response.getTaskId();
}
public String taskAliasExists() {
@@ -733,8 +736,7 @@ public class BugzillaHarness {
RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
- String taskId = response.getTaskId();
- return taskId;
+ return response.getTaskId();
}
public String taskAlias2Exists() {
@@ -790,8 +792,7 @@ public class BugzillaHarness {
RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
- String taskId = response.getTaskId();
- return taskId;
+ return response.getTaskId();
}
public String taskCfBugIdExists() {
@@ -845,8 +846,71 @@ public class BugzillaHarness {
RepositoryResponse response = createNewTask(taskDataNew);
assertNotNull(response);
assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
- String taskId = response.getTaskId();
- return taskId;
+ return response.getTaskId();
+ }
+
+ public String enhanceSearchTaskExists() {
+ String taskID = null;
+ String queryUrlString = repository().getRepositoryUrl() + "/buglist.cgi?"
+ + "short_desc=test%20EnhanceSearch&resolution=---&query_format=advanced"
+ + "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
+ RepositoryQuery query = new RepositoryQuery(repository().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);
+ }
+ };
+ connector().performQuery(repository(), 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 createEnhanceSearchTask() 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 EnhanceSearch";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the Bug 335278";
+ }
+ };
+ final TaskData[] taskDataNew = new TaskData[1];
+
+ // create Task
+ taskDataNew[0] = TasksUiInternal.createTaskData(repository(), 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], priviledgedClient());
+ ((AbstractTask) taskNew).setSubmitting(true);
+ assertNotNull(response);
+ assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
+ return response.getTaskId();
}
}

Back to the top