Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaClientTest.java46
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/UrlBuilder.java76
2 files changed, 122 insertions, 0 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 222146808..f494ae913 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
@@ -32,18 +32,22 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion;
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryLocation;
+import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
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.tests.util.TestUtil.PrivilegeLevel;
+import org.eclipse.mylyn.tests.util.UrlBuilder;
/**
* @author Robert Elves
* @author Thomas Ehrnhoefer
* @author Frank Becker
+ * @author David Green
*/
public class BugzillaClientTest extends TestCase {
@@ -202,6 +206,48 @@ public class BugzillaClientTest extends TestCase {
assertEquals(bugid, returnedData.iterator().next().getTaskId());
}
+ /**
+ * test for bug 335278: enhance search result handler to handle additional attributes
+ */
+ public void testQueryRealName_Bug335278() throws Exception {
+ IRepositoryQuery query = new RepositoryQuery(BugzillaFixture.current().getConnectorKind(), "query");
+ UrlBuilder urlBuilder = UrlBuilder.build(BugzillaFixture.current().repository()).append("/buglist.cgi");
+
+ urlBuilder.parameter(
+ "columnlist",
+ "bug_severity,priority,assigned_to,bug_status,resolution,short_desc,changeddate,reporter,assigned_to_realname,reporter_realname,product,component");
+ query.setUrl(urlBuilder.toString());
+
+ final Set<TaskData> returnedData = new HashSet<TaskData>();
+ TaskDataCollector collector = new TaskDataCollector() {
+
+ @Override
+ public void accept(TaskData taskData) {
+ returnedData.add(taskData);
+ }
+ };
+ TaskAttributeMapper mapper = BugzillaFixture.current()
+ .connector()
+ .getTaskDataHandler()
+ .getAttributeMapper(BugzillaFixture.current().repository());
+
+ client.getSearchHits(query, collector, mapper, new NullProgressMonitor());
+
+ assertTrue(returnedData.size() > 0);
+ for (TaskData taskData : returnedData) {
+ TaskAttribute reporterName = taskData.getRoot().getAttribute(BugzillaAttribute.REPORTER_NAME.getKey());
+ TaskAttribute assignedToName = taskData.getRoot().getAttribute(BugzillaAttribute.ASSIGNED_TO_NAME.getKey());
+ assertHasValue(reporterName);
+ assertHasValue(assignedToName);
+ }
+ }
+
+ private void assertHasValue(TaskAttribute attribute) {
+ assertNotNull(attribute);
+ assertNotNull(attribute.getValue());
+ assertTrue(attribute.getValue().trim().length() > 0);
+ }
+
public void testLeadingZeros() throws Exception {
String taskNumber = "0002";
TaskData taskData = BugzillaFixture.current().getTask(taskNumber, client);
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/UrlBuilder.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/UrlBuilder.java
new file mode 100644
index 000000000..f0698abf1
--- /dev/null
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/UrlBuilder.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.tests.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * A builder class for constructing {@link TaskRepository task repository} URLs.
+ *
+ * @author David Green
+ * @since 3.5
+ */
+public class UrlBuilder {
+ private final StringBuilder buf = new StringBuilder(512);
+
+ private UrlBuilder() {
+ }
+
+ public static UrlBuilder build(TaskRepository repository) {
+ UrlBuilder builder = new UrlBuilder();
+ String url = repository.getRepositoryUrl();
+ if (url.endsWith("/")) {
+ url = url.substring(0, url.length() - 1);
+ }
+ return builder.append(url);
+ }
+
+ public UrlBuilder append(String urlSegment) {
+ buf.append(urlSegment);
+ return this;
+ }
+
+ public UrlBuilder parameter(String name, Object value) {
+ return parameter(name, value == null ? null : value.toString());
+ }
+
+ public UrlBuilder parameter(String name, String value) {
+ int indexOfQ = buf.indexOf("?");
+ if (indexOfQ == -1) {
+ buf.append("?");
+ } else {
+ buf.append("&");
+ }
+ buf.append(name);
+ buf.append('=');
+ if (value != null) {
+ buf.append(encode(value));
+ }
+ return this;
+ }
+
+ private String encode(String value) {
+ try {
+ return URLEncoder.encode(value, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return buf.toString();
+ }
+
+}

Back to the top