aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-08-04 06:09:24 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-09-12 10:55:10 +0200
commita307775b34efbbc4641b01c55aa1aa9465f7f004 (patch)
tree645578a6a5bcba25f8187ca4ee21e379b91e3223 /sonar-ws
parent682128592478eff93567b11bcc7d083bf23f56b4 (diff)
downloadsonarqube-a307775b34efbbc4641b01c55aa1aa9465f7f004.tar.gz
sonarqube-a307775b34efbbc4641b01c55aa1aa9465f7f004.zip
SONAR-9682 Clean component parameters in api/measures/component_tree
- deprecate baseComponentId - rename baseComponentKey to component - deprecate id in response
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeWsRequest.java32
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java9
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java4
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java10
4 files changed, 43 insertions, 12 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeWsRequest.java
index cb985375b6e..d6c550eae92 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeWsRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeWsRequest.java
@@ -27,6 +27,7 @@ public class ComponentTreeWsRequest {
private String baseComponentId;
private String baseComponentKey;
+ private String component;
private String strategy;
private List<String> qualifiers;
private List<String> additionalFields;
@@ -42,27 +43,53 @@ public class ComponentTreeWsRequest {
private String developerId;
private String developerKey;
+ /**
+ * @deprecated since 6.6, please use {@link #getComponent()} instead
+ */
+ @Deprecated
@CheckForNull
public String getBaseComponentId() {
return baseComponentId;
}
+ /**
+ * @deprecated since 6.6, please use {@link #setComponent(String)} instead
+ */
+ @Deprecated
public ComponentTreeWsRequest setBaseComponentId(@Nullable String baseComponentId) {
this.baseComponentId = baseComponentId;
return this;
}
+ /**
+ * @deprecated since 6.6, please use {@link #getComponent()} instead
+ */
+ @Deprecated
@CheckForNull
public String getBaseComponentKey() {
return baseComponentKey;
}
+ /**
+ * @deprecated since 6.6, please use {@link #setComponent(String)} instead
+ */
+ @Deprecated
public ComponentTreeWsRequest setBaseComponentKey(@Nullable String baseComponentKey) {
this.baseComponentKey = baseComponentKey;
return this;
}
@CheckForNull
+ public String getComponent() {
+ return component;
+ }
+
+ public ComponentTreeWsRequest setComponent(@Nullable String component) {
+ this.component = component;
+ return this;
+ }
+
+ @CheckForNull
public String getStrategy() {
return strategy;
}
@@ -102,11 +129,12 @@ public class ComponentTreeWsRequest {
return this;
}
+ @CheckForNull
public List<String> getSort() {
return sort;
}
- public ComponentTreeWsRequest setSort(List<String> sort) {
+ public ComponentTreeWsRequest setSort(@Nullable List<String> sort) {
this.sort = sort;
return this;
}
@@ -146,7 +174,7 @@ public class ComponentTreeWsRequest {
return asc;
}
- public ComponentTreeWsRequest setAsc(boolean asc) {
+ public ComponentTreeWsRequest setAsc(@Nullable Boolean asc) {
this.asc = asc;
return this;
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
index f81d8b9a72b..dca24806339 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java
@@ -32,11 +32,11 @@ import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPON
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT_TREE;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_SEARCH_HISTORY;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.CONTROLLER_MEASURES;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_ID;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_KEY;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_ID;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_KEY;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS;
-import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_ID;
-import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_KEY;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID;
@@ -58,8 +58,9 @@ public class MeasuresService extends BaseService {
public ComponentTreeWsResponse componentTree(ComponentTreeWsRequest request) {
GetRequest getRequest = new GetRequest(path(ACTION_COMPONENT_TREE))
- .setParam(PARAM_BASE_COMPONENT_ID, request.getBaseComponentId())
- .setParam(PARAM_BASE_COMPONENT_KEY, request.getBaseComponentKey())
+ .setParam(DEPRECATED_PARAM_BASE_COMPONENT_ID, request.getBaseComponentId())
+ .setParam(DEPRECATED_PARAM_BASE_COMPONENT_KEY, request.getBaseComponentKey())
+ .setParam(PARAM_COMPONENT, request.getComponent())
.setParam(PARAM_STRATEGY, request.getStrategy())
.setParam(PARAM_QUALIFIERS, inlineMultipleParamValue(request.getQualifiers()))
.setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys()))
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
index 70b7c27496d..519ec102d41 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java
@@ -31,8 +31,8 @@ public class MeasuresWsParameters {
public static final String ACTION_SEARCH_HISTORY = "search_history";
// parameters
- public static final String PARAM_BASE_COMPONENT_ID = "baseComponentId";
- public static final String PARAM_BASE_COMPONENT_KEY = "baseComponentKey";
+ public static final String DEPRECATED_PARAM_BASE_COMPONENT_ID = "baseComponentId";
+ public static final String DEPRECATED_PARAM_BASE_COMPONENT_KEY = "baseComponentKey";
public static final String PARAM_COMPONENT = "component";
public static final String PARAM_BRANCH = "branch";
public static final String PARAM_STRATEGY = "strategy";
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java
index c0b0d0c1967..b83ac53ce90 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java
@@ -33,9 +33,9 @@ import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_ID;
+import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_KEY;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS;
-import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_ID;
-import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BASE_COMPONENT_KEY;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID;
@@ -81,6 +81,7 @@ public class MeasuresServiceTest {
ComponentTreeWsRequest componentTreeRequest = new ComponentTreeWsRequest()
.setBaseComponentId(VALUE_BASE_COMPONENT_ID)
.setBaseComponentKey(VALUE_BASE_COMPONENT_KEY)
+ .setComponent(VALUE_BASE_COMPONENT_KEY)
.setMetricKeys(VALUE_METRIC_KEYS)
.setStrategy(VALUE_STRATEGY)
.setQualifiers(VALUE_QUALIFIERS)
@@ -100,8 +101,9 @@ public class MeasuresServiceTest {
assertThat(serviceTester.getGetParser()).isSameAs(ComponentTreeWsResponse.parser());
serviceTester.assertThat(getRequest)
- .hasParam(PARAM_BASE_COMPONENT_ID, VALUE_BASE_COMPONENT_ID)
- .hasParam(PARAM_BASE_COMPONENT_KEY, VALUE_BASE_COMPONENT_KEY)
+ .hasParam(DEPRECATED_PARAM_BASE_COMPONENT_ID, VALUE_BASE_COMPONENT_ID)
+ .hasParam(DEPRECATED_PARAM_BASE_COMPONENT_KEY, VALUE_BASE_COMPONENT_KEY)
+ .hasParam(PARAM_COMPONENT, VALUE_BASE_COMPONENT_KEY)
.hasParam(PARAM_METRIC_KEYS, "ncloc,complexity")
.hasParam(PARAM_STRATEGY, VALUE_STRATEGY)
.hasParam(PARAM_QUALIFIERS, "FIL,PRJ")