aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java5
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java7
2 files changed, 9 insertions, 3 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java
index aae35d9f2e0..8648524329c 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java
@@ -75,9 +75,8 @@ public class ResourceSearchQuery extends Query<ResourceSearchResult> {
@Override
public String getUrl() {
StringBuilder url = new StringBuilder();
- url.append("/api/resources/search?s=");
- url.append(text);
- url.append("&");
+ url.append("/api/resources/search?");
+ appendUrlParameter(url, "s", text);
if (page > 0) {
appendUrlParameter(url, "p", page);
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java
index f789d361819..717c321c702 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java
@@ -34,6 +34,13 @@ public class ResourceSearchQueryTest extends QueryTestCase {
}
@Test
+ public void test_encode_url_search_param() {
+ ResourceSearchQuery query = ResourceSearchQuery.create("commons logging");
+ assertThat(query.getUrl(), is("/api/resources/search?s=commons+logging&"));
+ assertThat(query.getModelClass().getName(), is(ResourceSearchResult.class.getName()));
+ }
+
+ @Test
public void test_optional_parameters() {
ResourceSearchQuery query = ResourceSearchQuery.create("commons");
query.setPage(5);