aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-08-26 13:43:08 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-08-26 16:04:02 +0200
commitac946d0b0e7633eb9ac9c98cf6b1adcb932abf35 (patch)
tree5b268bc8434f541df4f01986592a1d9a75ce2d3c /sonar-ws
parent5e04bd807b2b6f0ab6e213b5f786a10c35743166 (diff)
downloadsonarqube-ac946d0b0e7633eb9ac9c98cf6b1adcb932abf35.tar.gz
sonarqube-ac946d0b0e7633eb9ac9c98cf6b1adcb932abf35.zip
SONAR-8003 WS settings/set handles multi value settings
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SetRequest.java21
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsWsParameters.java1
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java11
3 files changed, 24 insertions, 9 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SetRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SetRequest.java
index ee19ef6fc1d..ab5c1bd340e 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SetRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SetRequest.java
@@ -20,20 +20,24 @@
package org.sonarqube.ws.client.setting;
+import java.util.List;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Collections.emptyList;
public class SetRequest {
private final String key;
private final String value;
+ private final List<String> values;
private final String componentId;
private final String componentKey;
public SetRequest(Builder builder) {
this.key = builder.key;
this.value = builder.value;
+ this.values = builder.values;
this.componentId = builder.componentId;
this.componentKey = builder.componentKey;
}
@@ -42,10 +46,15 @@ public class SetRequest {
return key;
}
+ @CheckForNull
public String getValue() {
return value;
}
+ public List<String> getValues() {
+ return values;
+ }
+
@CheckForNull
public String getComponentId() {
return componentId;
@@ -63,6 +72,7 @@ public class SetRequest {
public static class Builder {
private String key;
private String value;
+ private List<String> values = emptyList();
private String componentId;
private String componentKey;
@@ -75,11 +85,16 @@ public class SetRequest {
return this;
}
- public Builder setValue(String value) {
+ public Builder setValue(@Nullable String value) {
this.value = value;
return this;
}
+ public Builder setValues(List<String> values) {
+ this.values = values;
+ return this;
+ }
+
public Builder setComponentId(@Nullable String componentId) {
this.componentId = componentId;
return this;
@@ -91,8 +106,8 @@ public class SetRequest {
}
public SetRequest build() {
- checkArgument(key != null && !key.isEmpty(), "Setting key is mandatory and must not be empty.");
- checkArgument(value != null && !value.isEmpty(), "Setting value is mandatory and must not be empty.");
+ checkArgument(key != null && !key.isEmpty(), "Setting key is mandatory and must not be empty");
+ checkArgument(values != null, "Setting values must not be null");
return new SetRequest(this);
}
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsWsParameters.java
index 74daf45d569..5c6e35d243d 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsWsParameters.java
@@ -33,6 +33,7 @@ public class SettingsWsParameters {
public static final String PARAM_KEYS = "keys";
public static final String PARAM_KEY = "key";
public static final String PARAM_VALUE = "value";
+ public static final String PARAM_VALUES = "values";
private SettingsWsParameters() {
// Only static stuff
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java
index b1e48020a30..461daa1d29f 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java
@@ -39,6 +39,7 @@ public class SetRequestTest {
assertThat(result.getKey()).isEqualTo("my.key");
assertThat(result.getValue()).isEqualTo("my value");
+ assertThat(result.getValues()).isNotNull().isEmpty();
assertThat(result.getComponentKey()).isNull();
assertThat(result.getComponentId()).isNull();
}
@@ -66,6 +67,7 @@ public class SetRequestTest {
@Test
public void fail_when_empty_key() {
expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("Setting key is mandatory and must not be empty");
underTest
.setKey("")
@@ -74,13 +76,10 @@ public class SetRequestTest {
}
@Test
- public void fail_when_empty_value() {
+ public void fail_when_values_is_null() {
expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("Setting values must not be null");
- underTest
- .setKey("key")
- .setValue(null)
- .build();
+ underTest.setKey("my.key").setValues(null).build();
}
-
}