aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-11-18 09:43:44 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-11-18 09:43:48 +0100
commit760d4ab222c40e06b1b4217ebcfe5789596b4044 (patch)
tree516f7f86b5a23d6dfec31e33b973c6b6c2dfd2b6 /sonar-ws
parentd2494dcd38af169e65436b1ba0b8f5ebb27d12e4 (diff)
downloadsonarqube-760d4ab222c40e06b1b4217ebcfe5789596b4044.tar.gz
sonarqube-760d4ab222c40e06b1b4217ebcfe5789596b4044.zip
Fix quality flaws
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java5
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/WsRequestTest.java80
2 files changed, 82 insertions, 3 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java
index 7ab7cea2e7c..8fe92d8820f 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java
@@ -25,8 +25,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import java.util.List;
-import static com.google.common.collect.Lists.newArrayList;
-
/**
* @since 3.7
*/
@@ -80,7 +78,8 @@ public class IssueFilterParameters {
public static final List<String> ALL = ImmutableList.of(ISSUES, SEVERITIES, STATUSES, RESOLUTIONS, RESOLVED, COMPONENTS, COMPONENT_ROOTS, RULES, ACTION_PLANS, REPORTERS, TAGS,
ASSIGNEES, LANGUAGES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, CREATED_IN_LAST, COMPONENT_UUIDS, COMPONENT_ROOT_UUIDS, FACET_MODE,
PROJECTS, PROJECT_UUIDS, PROJECT_KEYS, COMPONENT_KEYS, MODULE_UUIDS, DIRECTORIES, FILE_UUIDS, AUTHORS, HIDE_COMMENTS, PAGE_SIZE, PAGE_INDEX, SORT, ASC);
- public static final List<String> ALL_WITHOUT_PAGINATION = newArrayList(Iterables.filter(ALL, new Predicate<String>() {
+
+ public static final List<String> ALL_WITHOUT_PAGINATION = ImmutableList.copyOf(Iterables.filter(ALL, new Predicate<String>() {
@Override
public boolean apply(String input) {
return !PAGE_INDEX.equals(input) && !PAGE_SIZE.equals(input);
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/WsRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/WsRequestTest.java
new file mode 100644
index 00000000000..28b5c04aede
--- /dev/null
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/WsRequestTest.java
@@ -0,0 +1,80 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonarqube.ws.client;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonarqube.ws.client.WsRequest.Method;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonarqube.ws.client.WsRequest.newGetRequest;
+import static org.sonarqube.ws.client.WsRequest.newPostRequest;
+
+public class WsRequestTest {
+
+ static final String ENDPOINT = "api/issues/search";
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ WsRequest underTest;
+
+ @Test
+ public void get_request() {
+ underTest = newGetRequest("api/issues/search");
+
+ assertThat(underTest.getMethod()).isEqualTo(Method.GET);
+ }
+
+ @Test
+ public void post_request() {
+ underTest = newPostRequest("api/issues/search");
+
+ assertThat(underTest.getMethod()).isEqualTo(Method.POST);
+ }
+
+ @Test
+ public void set_non_null_param() {
+ underTest = newGetRequest("api/issues/search")
+ .setParam("key", "value");
+
+ assertThat(underTest.getParams().get("key")).isEqualTo("value");
+ }
+
+ @Test
+ public void set_null_param_remove_existing_param() {
+ underTest = newGetRequest(ENDPOINT)
+ .setParam("key", "value")
+ .setParam("key", null);
+
+ assertThat(underTest.getParams().get("key")).isNull();
+ }
+
+ @Test
+ public void fail_if_key_is_null() {
+ expectedException.expect(NullPointerException.class);
+ expectedException.expectMessage("a WS parameter key cannot be null");
+
+ underTest = newGetRequest(ENDPOINT)
+ .setParam(null, "value");
+ }
+}