aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-01-03 16:03:28 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-01-05 13:09:46 +0100
commit58b2a0961fc705d7f65736535d70916c5b8d46f3 (patch)
tree338262fec471f382a7c77c65e5eb0f14b6e62ae6 /sonar-ws/src
parente23046ef19a3baa4484320e13a3ac0eaa60195b7 (diff)
downloadsonarqube-58b2a0961fc705d7f65736535d70916c5b8d46f3.tar.gz
sonarqube-58b2a0961fc705d7f65736535d70916c5b8d46f3.zip
SONAR-8575 Set api/settings WS as public and keep only one parameter for component
Diffstat (limited to 'sonar-ws/src')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java27
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ResetRequest.java27
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SetRequest.java27
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java15
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsWsParameters.java3
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ValuesRequest.java27
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java16
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SetRequestTest.java18
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java23
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java22
10 files changed, 55 insertions, 150 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java
index 7aee9357e7f..776c4acf0b3 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ListDefinitionsRequest.java
@@ -27,22 +27,15 @@ import javax.annotation.concurrent.Immutable;
@Immutable
public class ListDefinitionsRequest {
- private final String componentId;
- private final String componentKey;
+ private final String component;
private ListDefinitionsRequest(Builder builder) {
- this.componentId = builder.componentId;
- this.componentKey = builder.componentKey;
+ this.component = builder.component;
}
@CheckForNull
- public String getComponentId() {
- return componentId;
- }
-
- @CheckForNull
- public String getComponentKey() {
- return componentKey;
+ public String getComponent() {
+ return component;
}
public static Builder builder() {
@@ -50,20 +43,14 @@ public class ListDefinitionsRequest {
}
public static class Builder {
- private String componentId;
- private String componentKey;
+ private String component;
private Builder() {
// enforce factory method use
}
- public Builder setComponentId(@Nullable String componentId) {
- this.componentId = componentId;
- return this;
- }
-
- public Builder setComponentKey(@Nullable String componentKey) {
- this.componentKey = componentKey;
+ public Builder setComponent(@Nullable String component) {
+ this.component = component;
return this;
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ResetRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ResetRequest.java
index 451491f0971..142b58c6867 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ResetRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ResetRequest.java
@@ -29,13 +29,11 @@ import static java.util.Arrays.asList;
public class ResetRequest {
private final List<String> keys;
- private final String componentId;
- private final String componentKey;
+ private final String component;
private ResetRequest(Builder builder) {
this.keys = builder.keys;
- this.componentId = builder.componentId;
- this.componentKey = builder.componentKey;
+ this.component = builder.component;
}
public List<String> getKeys() {
@@ -43,13 +41,8 @@ public class ResetRequest {
}
@CheckForNull
- public String getComponentId() {
- return componentId;
- }
-
- @CheckForNull
- public String getComponentKey() {
- return componentKey;
+ public String getComponent() {
+ return component;
}
public static Builder builder() {
@@ -58,8 +51,7 @@ public class ResetRequest {
public static class Builder {
private List<String> keys;
- private String componentId;
- private String componentKey;
+ private String component;
private Builder() {
// enforce factory method use
@@ -75,13 +67,8 @@ public class ResetRequest {
return this;
}
- public Builder setComponentId(@Nullable String componentId) {
- this.componentId = componentId;
- return this;
- }
-
- public Builder setComponentKey(@Nullable String componentKey) {
- this.componentKey = componentKey;
+ public Builder setComponent(@Nullable String component) {
+ this.component = component;
return this;
}
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 d8c91fe2d64..fcd3b217431 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
@@ -32,16 +32,14 @@ public class SetRequest {
private final String value;
private final List<String> values;
private final List<String> fieldValues;
- private final String componentId;
- private final String componentKey;
+ private final String component;
private SetRequest(Builder builder) {
this.key = builder.key;
this.value = builder.value;
this.values = builder.values;
this.fieldValues = builder.fieldValues;
- this.componentId = builder.componentId;
- this.componentKey = builder.componentKey;
+ this.component = builder.component;
}
public String getKey() {
@@ -62,13 +60,8 @@ public class SetRequest {
}
@CheckForNull
- public String getComponentId() {
- return componentId;
- }
-
- @CheckForNull
- public String getComponentKey() {
- return componentKey;
+ public String getComponent() {
+ return component;
}
public static Builder builder() {
@@ -80,8 +73,7 @@ public class SetRequest {
private String value;
private List<String> values = emptyList();
private List<String> fieldValues = emptyList();
- private String componentId;
- private String componentKey;
+ private String component;
private Builder() {
// enforce factory method use
@@ -107,13 +99,8 @@ public class SetRequest {
return this;
}
- public Builder setComponentId(@Nullable String componentId) {
- this.componentId = componentId;
- return this;
- }
-
- public Builder setComponentKey(@Nullable String componentKey) {
- this.componentKey = componentKey;
+ public Builder setComponent(@Nullable String component) {
+ this.component = component;
return this;
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java
index bdc9453aba1..19a031844ae 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/SettingsService.java
@@ -26,13 +26,12 @@ import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
-import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT_ID;
-import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT_KEY;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.ACTION_LIST_DEFINITIONS;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.ACTION_RESET;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.ACTION_SET;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.ACTION_VALUES;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.CONTROLLER_SETTINGS;
+import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_COMPONENT;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_FIELD_VALUES;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_KEYS;
@@ -46,16 +45,14 @@ public class SettingsService extends BaseService {
public ListDefinitionsWsResponse listDefinitions(ListDefinitionsRequest request) {
GetRequest getRequest = new GetRequest(path(ACTION_LIST_DEFINITIONS))
- .setParam(PARAM_COMPONENT_ID, request.getComponentId())
- .setParam(PARAM_COMPONENT_KEY, request.getComponentKey());
+ .setParam(PARAM_COMPONENT, request.getComponent());
return call(getRequest, ListDefinitionsWsResponse.parser());
}
public ValuesWsResponse values(ValuesRequest request) {
GetRequest getRequest = new GetRequest(path(ACTION_VALUES))
.setParam(PARAM_KEYS, inlineMultipleParamValue(request.getKeys()))
- .setParam(PARAM_COMPONENT_ID, request.getComponentId())
- .setParam(PARAM_COMPONENT_KEY, request.getComponentKey());
+ .setParam(PARAM_COMPONENT, request.getComponent());
return call(getRequest, ValuesWsResponse.parser());
}
@@ -65,15 +62,13 @@ public class SettingsService extends BaseService {
.setParam(PARAM_VALUE, request.getValue())
.setParam(PARAM_VALUES, request.getValues())
.setParam(PARAM_FIELD_VALUES, request.getFieldValues())
- .setParam(PARAM_COMPONENT_ID, request.getComponentId())
- .setParam(PARAM_COMPONENT_KEY, request.getComponentKey()));
+ .setParam(PARAM_COMPONENT, request.getComponent()));
}
public void reset(ResetRequest request) {
call(new PostRequest(path(ACTION_RESET))
.setParam(PARAM_KEYS, inlineMultipleParamValue(request.getKeys()))
- .setParam(PARAM_COMPONENT_ID, request.getComponentId())
- .setParam(PARAM_COMPONENT_KEY, request.getComponentKey()));
+ .setParam(PARAM_COMPONENT, request.getComponent()));
}
}
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 85e4da4e300..0c552413367 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
@@ -28,8 +28,7 @@ public class SettingsWsParameters {
public static final String ACTION_SET = "set";
public static final String ACTION_RESET = "reset";
- public static final String PARAM_COMPONENT_ID = "componentId";
- public static final String PARAM_COMPONENT_KEY = "componentKey";
+ public static final String PARAM_COMPONENT = "component";
public static final String PARAM_KEYS = "keys";
public static final String PARAM_KEY = "key";
public static final String PARAM_VALUE = "value";
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ValuesRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ValuesRequest.java
index 06ac411ddf6..8c587cfcee8 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ValuesRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/setting/ValuesRequest.java
@@ -30,24 +30,17 @@ import static java.util.Objects.requireNonNull;
public class ValuesRequest {
- private final String componentId;
- private final String componentKey;
+ private final String component;
private final List<String> keys;
private ValuesRequest(Builder builder) {
- this.componentId = builder.componentId;
- this.componentKey = builder.componentKey;
+ this.component = builder.component;
this.keys = builder.keys;
}
@CheckForNull
- public String getComponentId() {
- return componentId;
- }
-
- @CheckForNull
- public String getComponentKey() {
- return componentKey;
+ public String getComponent() {
+ return component;
}
public List<String> getKeys() {
@@ -59,21 +52,15 @@ public class ValuesRequest {
}
public static class Builder {
- private String componentId;
- private String componentKey;
+ private String component;
private List<String> keys = new ArrayList<>();
private Builder() {
// enforce factory method use
}
- public Builder setComponentId(@Nullable String componentId) {
- this.componentId = componentId;
- return this;
- }
-
- public Builder setComponentKey(@Nullable String componentKey) {
- this.componentKey = componentKey;
+ public Builder setComponent(@Nullable String component) {
+ this.component = component;
return this;
}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java
index 66eb07952f7..c17751cad77 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ListDefinitionsRequestTest.java
@@ -37,24 +37,14 @@ public class ListDefinitionsRequestTest {
public void create_request_with_no_component() {
ListDefinitionsRequest result = underTest.build();
- assertThat(result.getComponentId()).isNull();
- assertThat(result.getComponentKey()).isNull();
- }
-
- @Test
- public void create_request_with_component_id() {
- ListDefinitionsRequest result = underTest.setComponentId("projectId").build();
-
- assertThat(result.getComponentId()).isEqualTo("projectId");
- assertThat(result.getComponentKey()).isNull();
+ assertThat(result.getComponent()).isNull();
}
@Test
public void create_request_with_component_key() {
- ListDefinitionsRequest result = underTest.setComponentKey("projectKey").build();
+ ListDefinitionsRequest result = underTest.setComponent("projectKey").build();
- assertThat(result.getComponentId()).isNull();
- assertThat(result.getComponentKey()).isEqualTo("projectKey");
+ assertThat(result.getComponent()).isEqualTo("projectKey");
}
}
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 461daa1d29f..d0f714d754c 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
@@ -40,28 +40,16 @@ 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();
- }
-
- @Test
- public void create_request_with_component_id() {
- SetRequest result = underTest.setKey("my.key").setValue("my value").setComponentId("projectId").build();
-
- assertThat(result.getKey()).isEqualTo("my.key");
- assertThat(result.getValue()).isEqualTo("my value");
- assertThat(result.getComponentId()).isEqualTo("projectId");
- assertThat(result.getComponentKey()).isNull();
+ assertThat(result.getComponent()).isNull();
}
@Test
public void create_request_with_component_key() {
- SetRequest result = underTest.setKey("my.key").setValue("my value").setComponentKey("projectKey").build();
+ SetRequest result = underTest.setKey("my.key").setValue("my value").setComponent("projectKey").build();
assertThat(result.getKey()).isEqualTo("my.key");
assertThat(result.getValue()).isEqualTo("my value");
- assertThat(result.getComponentId()).isNull();
- assertThat(result.getComponentKey()).isEqualTo("projectKey");
+ assertThat(result.getComponent()).isEqualTo("projectKey");
}
@Test
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java
index 1faf51ef43d..66cfbf94c91 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/SettingsServiceTest.java
@@ -31,8 +31,7 @@ import org.sonarqube.ws.client.WsConnector;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_COMPONENT_ID;
-import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_COMPONENT_KEY;
+import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_COMPONENT;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_FIELD_VALUES;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.setting.SettingsWsParameters.PARAM_KEYS;
@@ -49,13 +48,13 @@ public class SettingsServiceTest {
@Test
public void list_definitions() {
underTest.listDefinitions(ListDefinitionsRequest.builder()
- .setComponentKey("KEY")
+ .setComponent("KEY")
.build());
GetRequest getRequest = serviceTester.getGetRequest();
assertThat(serviceTester.getGetParser()).isSameAs(ListDefinitionsWsResponse.parser());
serviceTester.assertThat(getRequest)
- .hasParam(PARAM_COMPONENT_KEY, "KEY")
+ .hasParam(PARAM_COMPONENT, "KEY")
.andNoOtherParam();
}
@@ -63,14 +62,14 @@ public class SettingsServiceTest {
public void values() {
underTest.values(ValuesRequest.builder()
.setKeys("sonar.debt,sonar.issue")
- .setComponentKey("KEY")
+ .setComponent("KEY")
.build());
GetRequest getRequest = serviceTester.getGetRequest();
assertThat(serviceTester.getGetParser()).isSameAs(ValuesWsResponse.parser());
serviceTester.assertThat(getRequest)
.hasParam(PARAM_KEYS, "sonar.debt,sonar.issue")
- .hasParam(PARAM_COMPONENT_KEY, "KEY")
+ .hasParam(PARAM_COMPONENT, "KEY")
.andNoOtherParam();
}
@@ -80,9 +79,8 @@ public class SettingsServiceTest {
.setKey("sonar.debt")
.setValue("8h")
.setValues(newArrayList("v1", "v2", "v3"))
- .setFieldValues(newArrayList("json1","json2","json3"))
- .setComponentId("UUID")
- .setComponentKey("KEY")
+ .setFieldValues(newArrayList("json1", "json2", "json3"))
+ .setComponent("KEY")
.build());
serviceTester.assertThat(serviceTester.getPostRequest())
@@ -90,8 +88,7 @@ public class SettingsServiceTest {
.hasParam(PARAM_VALUE, "8h")
.hasParam(PARAM_VALUES, newArrayList("v1", "v2", "v3"))
.hasParam(PARAM_FIELD_VALUES, newArrayList("json1", "json2", "json3"))
- .hasParam(PARAM_COMPONENT_ID, "UUID")
- .hasParam(PARAM_COMPONENT_KEY, "KEY")
+ .hasParam(PARAM_COMPONENT, "KEY")
.andNoOtherParam();
}
@@ -99,12 +96,12 @@ public class SettingsServiceTest {
public void reset() {
underTest.reset(ResetRequest.builder()
.setKeys("sonar.debt")
- .setComponentKey("KEY")
+ .setComponent("KEY")
.build());
serviceTester.assertThat(serviceTester.getPostRequest())
.hasParam(PARAM_KEYS, "sonar.debt")
- .hasParam(PARAM_COMPONENT_KEY, "KEY")
+ .hasParam(PARAM_COMPONENT, "KEY")
.andNoOtherParam();
}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java
index 3c08fd7142f..bbf78709a25 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/setting/ValuesRequestTest.java
@@ -37,8 +37,7 @@ public class ValuesRequestTest {
public void create_request_with_no_component() {
ValuesRequest result = underTest.setKeys("sonar.debt").build();
- assertThat(result.getComponentId()).isNull();
- assertThat(result.getComponentKey()).isNull();
+ assertThat(result.getComponent()).isNull();
assertThat(result.getKeys()).containsOnly("sonar.debt");
}
@@ -46,26 +45,15 @@ public class ValuesRequestTest {
public void create_request_with_no_keys() {
ValuesRequest result = underTest.build();
- assertThat(result.getComponentId()).isNull();
- assertThat(result.getComponentKey()).isNull();
+ assertThat(result.getComponent()).isNull();
assertThat(result.getKeys()).isEmpty();
}
@Test
- public void create_request_with_component_id() {
- ValuesRequest result = underTest.setKeys("sonar.debt").setComponentId("projectId").build();
+ public void create_request_with_component() {
+ ValuesRequest result = underTest.setKeys("sonar.debt").setComponent("projectKey").build();
- assertThat(result.getComponentId()).isEqualTo("projectId");
- assertThat(result.getComponentKey()).isNull();
- assertThat(result.getKeys()).containsOnly("sonar.debt");
- }
-
- @Test
- public void create_request_with_component_key() {
- ValuesRequest result = underTest.setKeys("sonar.debt").setComponentKey("projectKey").build();
-
- assertThat(result.getComponentId()).isNull();
- assertThat(result.getComponentKey()).isEqualTo("projectKey");
+ assertThat(result.getComponent()).isEqualTo("projectKey");
assertThat(result.getKeys()).containsOnly("sonar.debt");
}