From 9cba9e0a34bd4b7fa24a7b9c9b8616c0c47273da Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 4 Dec 2017 15:52:09 +0100 Subject: [PATCH] Remove deprecated MeasuresService --- .../sonar/server/component/ws/AppAction.java | 2 +- .../component/ws}/MeasuresWsParameters.java | 2 +- .../sonar/server/component/ws/ShowAction.java | 2 +- .../sonar/server/component/ws/TreeAction.java | 2 +- .../server/duplication/ws/ShowAction.java | 2 +- .../server/measure/ws/ComponentAction.java | 22 +- .../measure/ws/ComponentTreeAction.java | 34 +-- .../sonar/server/measure/ws/MeasuresWs.java | 2 +- .../ws/MeasuresWsParametersBuilder.java | 12 +- .../sonar/server/measure/ws/SearchAction.java | 4 +- .../measure/ws/SearchHistoryAction.java | 12 +- .../measure/ws/ComponentActionTest.java | 12 +- .../measure/ws/ComponentTreeActionTest.java | 24 +- .../server/measure/ws/SearchActionTest.java | 4 +- .../measure/ws/SearchHistoryActionTest.java | 10 +- .../org/sonarqube/ws/client/BaseService.java | 2 +- .../sonarqube/ws/client/DefaultWsClient.java | 7 - .../org/sonarqube/ws/client/WsClient.java | 6 - .../ws/client/measure/ComponentRequest.java | 130 ---------- .../client/measure/ComponentTreeRequest.java | 242 ------------------ .../ws/client/measure/MeasuresService.java | 119 --------- .../client/measure/SearchHistoryRequest.java | 147 ----------- .../ws/client/measure/SearchRequest.java | 76 ------ .../ws/client/measure/package-info.java | 24 -- .../ws/client/measures/ComponentRequest.java | 6 +- .../client/measures/ComponentTreeRequest.java | 6 +- .../ws/client/measures/MeasuresService.java | 6 +- .../ws/client/measures/SearchRequest.java | 6 +- .../client/measure/MeasuresServiceTest.java | 200 --------------- .../measure/SearchHistoryRequestTest.java | 103 -------- .../ws/client/measure/SearchRequestTest.java | 111 -------- .../org/sonarqube/tests/lite/LiteTest.java | 12 +- .../tests/measure/MeasuresWsTest.java | 10 +- .../tests/measure/TimeMachineTest.java | 14 +- .../performance/scanner/DuplicationTest.java | 6 +- .../sonarqube/tests/upgrade/UpgradeTest.java | 30 ++- tests/src/test/java/util/ItUtils.java | 10 +- 37 files changed, 134 insertions(+), 1285 deletions(-) rename {sonar-ws/src/main/java/org/sonarqube/ws/client/measure => server/sonar-server/src/main/java/org/sonar/server/component/ws}/MeasuresWsParameters.java (98%) delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/measure/package-info.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java index 901da41760b..b19d1110941 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java @@ -59,7 +59,7 @@ import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_COMPONENT; import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; public class AppAction implements ComponentsWsAction { diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/MeasuresWsParameters.java similarity index 98% rename from sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java rename to server/sonar-server/src/main/java/org/sonar/server/component/ws/MeasuresWsParameters.java index 519ec102d41..86f91d6000d 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/MeasuresWsParameters.java @@ -17,7 +17,7 @@ * 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.measure; +package org.sonar.server.component.ws; import com.google.common.collect.ImmutableSortedSet; import java.util.Set; diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java index f7bd7a58a85..842595effb1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ShowAction.java @@ -49,7 +49,7 @@ import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SHOW; import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT; import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; public class ShowAction implements ComponentsWsAction { private final UserSession userSession; diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java index 6a6ac04d049..3ba26b161ff 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java @@ -74,7 +74,7 @@ import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COM import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT_ID; import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS; import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_STRATEGY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; public class TreeAction implements ComponentsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java index 6136a64d95f..240a5a69bfc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java @@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static org.sonar.server.component.ComponentFinder.ParamNames.UUID_AND_KEY; import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; public class ShowAction implements DuplicationsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java index 37fbe9a40f2..cf035382a7a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java @@ -69,17 +69,17 @@ import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ADDITIONAL_METRICS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ADDITIONAL_PERIODS; -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_BRANCH; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.ACTION_COMPONENT; +import static org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_METRICS; +import static org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_PERIODS; +import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_DEVELOPER_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_DEVELOPER_KEY; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; public class ComponentAction implements MeasuresWsAction { private static final Set QUALIFIERS_ELIGIBLE_FOR_BEST_VALUE = ImmutableSortedSet.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java index 4a1b94aa3e7..e66ef82f23d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java @@ -98,22 +98,22 @@ import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter; import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT_TREE; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ADDITIONAL_METRICS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ADDITIONAL_PERIODS; -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_BRANCH; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_PERIOD_SORT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_STRATEGY; +import static org.sonar.server.component.ws.MeasuresWsParameters.ACTION_COMPONENT_TREE; +import static org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_METRICS; +import static org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_PERIODS; +import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_KEY; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_DEVELOPER_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_DEVELOPER_KEY; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_PERIOD_SORT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_SORT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_QUALIFIERS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_STRATEGY; /** *

Navigate through components based on different strategy with specified measures. @@ -237,7 +237,7 @@ public class ComponentTreeAction implements MeasuresWsAction { .setPossibleValues(METRIC_SORT_FILTERS); createMetricKeysParameter(action) - .setDescription("Metric keys. Types %s are not allowed", COMMA_JOINER.join(FORBIDDEN_METRIC_TYPES)) + .setDescription("Comma-separated list of metric keys. Types %s are not allowed.", COMMA_JOINER.join(FORBIDDEN_METRIC_TYPES)) .setMaxValuesAllowed(MAX_METRIC_KEYS); createAdditionalFieldsParameter(action); createDeveloperParameters(action); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWs.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWs.java index 41d3972c49d..7bf66a383d6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWs.java @@ -20,7 +20,7 @@ package org.sonar.server.measure.ws; import org.sonar.api.server.ws.WebService; -import org.sonarqube.ws.client.measure.MeasuresWsParameters; +import org.sonar.server.component.ws.MeasuresWsParameters; public class MeasuresWs implements WebService { private final MeasuresWsAction[] actions; diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWsParametersBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWsParametersBuilder.java index 61877ece378..48a4804bf5c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWsParametersBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/MeasuresWsParametersBuilder.java @@ -22,11 +22,11 @@ package org.sonar.server.measure.ws; import org.sonar.api.server.ws.WebService.NewAction; import org.sonar.api.server.ws.WebService.NewParam; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ADDITIONAL_FIELDS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_FIELDS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_DEVELOPER_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_DEVELOPER_KEY; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; class MeasuresWsParametersBuilder { @@ -43,7 +43,7 @@ class MeasuresWsParametersBuilder { static NewParam createMetricKeysParameter(NewAction action) { return action.createParam(PARAM_METRIC_KEYS) - .setDescription("Metric keys") + .setDescription("Comma-separated list of metric keys") .setRequired(true) .setExampleValue("ncloc,complexity,violations"); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java index bdd6d5b2738..2592ebce5af 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java @@ -55,8 +55,8 @@ import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_002; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_PROJECT_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PROJECT_KEYS; public class SearchAction implements MeasuresWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java index c76decf6792..ceb039191c0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java @@ -56,12 +56,12 @@ import static org.sonar.core.util.Protobuf.setNullable; import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED; import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_SEARCH_HISTORY; -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_FROM; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRICS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_TO; +import static org.sonar.server.component.ws.MeasuresWsParameters.ACTION_SEARCH_HISTORY; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_FROM; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRICS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_TO; public class SearchHistoryAction implements MeasuresWsAction { diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java index 026a92eb616..a08abc408b1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java @@ -54,12 +54,12 @@ import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newProjectCopy; import static org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType.INT; import static org.sonar.test.JsonAssert.assertJson; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; -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; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_DEVELOPER_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; public class ComponentActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java index 8909b85dd04..6f23473e37e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java @@ -79,18 +79,18 @@ import static org.sonar.server.measure.ws.ComponentTreeAction.METRIC_SORT; import static org.sonar.server.measure.ws.ComponentTreeAction.NAME_SORT; import static org.sonar.server.measure.ws.ComponentTreeAction.WITH_MEASURES_ONLY_METRIC_SORT_FILTER; import static org.sonar.test.JsonAssert.assertJson; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ADDITIONAL_PERIODS; -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_BRANCH; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_PERIOD_SORT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_STRATEGY; +import static org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_PERIODS; +import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_ID; +import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_KEY; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_PERIOD_SORT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_SORT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_QUALIFIERS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_STRATEGY; public class ComponentTreeActionTest { @Rule diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java index 0ed7e63c25c..ecc5d3e8ae1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java @@ -56,8 +56,8 @@ import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newModuleDto; import static org.sonar.db.component.ComponentTesting.newSubView; import static org.sonar.test.JsonAssert.assertJson; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_PROJECT_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PROJECT_KEYS; public class SearchActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java index 1544e8a77b3..56a26b15b4b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java @@ -69,11 +69,11 @@ import static org.sonar.db.component.SnapshotTesting.newAnalysis; import static org.sonar.db.measure.MeasureTesting.newMeasureDto; import static org.sonar.db.metric.MetricTesting.newMetricDto; import static org.sonar.test.JsonAssert.assertJson; -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_FROM; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRICS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_TO; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_FROM; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRICS; +import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_TO; public class SearchHistoryActionTest { diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java index 4c6a0e9449e..46e07dbb804 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java @@ -52,7 +52,7 @@ public abstract class BaseService { return wsConnector.call(request).failIfNotSuccessful(); } - public T convert(WsResponse response, Parser parser) { + public static T convert(WsResponse response, Parser parser) { try (InputStream byteStream = response.contentStream()) { byte[] bytes = IOUtils.toByteArray(byteStream); // HTTP header "Content-Type" is not verified. It may be different than protobuf. diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java index 27d06ffac66..71d261c2718 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java @@ -63,7 +63,6 @@ class DefaultWsClient implements WsClient { private final UserGroupsService userGroupsService; private final UserTokensService userTokensService; private final QualitygatesService qualityGatesService; - private final org.sonarqube.ws.client.measure.MeasuresService measuresOld; private final MeasuresService measures; private final SystemService systemService; private final CeService ceService; @@ -90,7 +89,6 @@ class DefaultWsClient implements WsClient { this.userGroupsService = new UserGroupsService(wsConnector); this.userTokensService = new UserTokensService(wsConnector); this.qualityGatesService = new QualitygatesService(wsConnector); - this.measuresOld = new org.sonarqube.ws.client.measure.MeasuresService(wsConnector); this.measures = new MeasuresService(wsConnector); this.systemService = new SystemService(wsConnector); this.ceService = new CeService(wsConnector); @@ -165,11 +163,6 @@ class DefaultWsClient implements WsClient { return qualityGatesService; } - @Override - public org.sonarqube.ws.client.measure.MeasuresService measuresOld() { - return measuresOld; - } - @Override public MeasuresService measures() { return measures; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 1de94f492e4..75ac3a18e1c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -91,12 +91,6 @@ public interface WsClient { QualitygatesService qualityGates(); - /** - * @deprecated since 7.0 use {@link #measures()} instead - */ - @Deprecated - org.sonarqube.ws.client.measure.MeasuresService measuresOld(); - MeasuresService measures(); SystemService system(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentRequest.java deleted file mode 100644 index 4eb5bbcab20..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentRequest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class ComponentRequest { - private String componentId; - private String componentKey; - private String component; - private String branch; - private List metricKeys; - private List additionalFields; - private String developerId; - private String developerKey; - - /** - * @deprecated since 6.6, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getComponentId() { - return componentId; - } - - /** - * @deprecated since 6.6, please use {@link #setComponent(String)} instead - */ - @Deprecated - public ComponentRequest setComponentId(@Nullable String componentId) { - this.componentId = componentId; - return this; - } - - /** - * @deprecated since 6.6, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getComponentKey() { - return componentKey; - } - - /** - * @deprecated since 6.6, please use {@link #setComponent(String)} instead - */ - @Deprecated - public ComponentRequest setComponentKey(@Nullable String componentKey) { - this.componentKey = componentKey; - return this; - } - - @CheckForNull - public String getComponent() { - return component; - } - - public ComponentRequest setComponent(@Nullable String component) { - this.component = component; - return this; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public ComponentRequest setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - public List getMetricKeys() { - return metricKeys; - } - - public ComponentRequest setMetricKeys(@Nullable List metricKeys) { - this.metricKeys = metricKeys; - return this; - } - - @CheckForNull - public List getAdditionalFields() { - return additionalFields; - } - - public ComponentRequest setAdditionalFields(@Nullable List additionalFields) { - this.additionalFields = additionalFields; - return this; - } - - @CheckForNull - public String getDeveloperId() { - return developerId; - } - - public ComponentRequest setDeveloperId(@Nullable String developerId) { - this.developerId = developerId; - return this; - } - - @CheckForNull - public String getDeveloperKey() { - return developerKey; - } - - public ComponentRequest setDeveloperKey(@Nullable String developerKey) { - this.developerKey = developerKey; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeRequest.java deleted file mode 100644 index fa6bb474a70..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeRequest.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class ComponentTreeRequest { - - private String baseComponentId; - private String baseComponentKey; - private String component; - private String branch; - private String strategy; - private List qualifiers; - private List additionalFields; - private String query; - private List sort; - private Boolean asc; - private String metricSort; - private Integer metricPeriodSort; - private String metricSortFilter; - private List metricKeys; - private Integer page; - private Integer pageSize; - 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 ComponentTreeRequest 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 ComponentTreeRequest setBaseComponentKey(@Nullable String baseComponentKey) { - this.baseComponentKey = baseComponentKey; - return this; - } - - @CheckForNull - public String getComponent() { - return component; - } - - public ComponentTreeRequest setComponent(@Nullable String component) { - this.component = component; - return this; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public ComponentTreeRequest setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - @CheckForNull - public String getStrategy() { - return strategy; - } - - public ComponentTreeRequest setStrategy(String strategy) { - this.strategy = strategy; - return this; - } - - @CheckForNull - public List getQualifiers() { - return qualifiers; - } - - public ComponentTreeRequest setQualifiers(@Nullable List qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - @CheckForNull - public List getAdditionalFields() { - return additionalFields; - } - - public ComponentTreeRequest setAdditionalFields(@Nullable List additionalFields) { - this.additionalFields = additionalFields; - return this; - } - - @CheckForNull - public String getQuery() { - return query; - } - - public ComponentTreeRequest setQuery(@Nullable String query) { - this.query = query; - return this; - } - - @CheckForNull - public List getSort() { - return sort; - } - - public ComponentTreeRequest setSort(@Nullable List sort) { - this.sort = sort; - return this; - } - - @CheckForNull - public String getMetricSort() { - return metricSort; - } - - public ComponentTreeRequest setMetricSort(@Nullable String metricSort) { - this.metricSort = metricSort; - return this; - } - - @CheckForNull - public String getMetricSortFilter() { - return metricSortFilter; - } - - public ComponentTreeRequest setMetricSortFilter(@Nullable String metricSortFilter) { - this.metricSortFilter = metricSortFilter; - return this; - } - - @CheckForNull - public List getMetricKeys() { - return metricKeys; - } - - public ComponentTreeRequest setMetricKeys(List metricKeys) { - this.metricKeys = metricKeys; - return this; - } - - @CheckForNull - public Boolean getAsc() { - return asc; - } - - public ComponentTreeRequest setAsc(@Nullable Boolean asc) { - this.asc = asc; - return this; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - public ComponentTreeRequest setPage(int page) { - this.page = page; - return this; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - public ComponentTreeRequest setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - @CheckForNull - public Integer getMetricPeriodSort() { - return metricPeriodSort; - } - - public ComponentTreeRequest setMetricPeriodSort(@Nullable Integer metricPeriodSort) { - this.metricPeriodSort = metricPeriodSort; - return this; - } - - @CheckForNull - public String getDeveloperId() { - return developerId; - } - - public ComponentTreeRequest setDeveloperId(@Nullable String developerId) { - this.developerId = developerId; - return this; - } - - @CheckForNull - public String getDeveloperKey() { - return developerKey; - } - - public ComponentTreeRequest setDeveloperKey(@Nullable String developerKey) { - this.developerKey = developerKey; - 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 deleted file mode 100644 index e68608e655e..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import org.sonar.api.server.ws.WebService.Param; -import org.sonarqube.ws.Measures.ComponentTreeWsResponse; -import org.sonarqube.ws.Measures.ComponentWsResponse; -import org.sonarqube.ws.Measures.SearchHistoryResponse; -import org.sonarqube.ws.Measures.SearchWsResponse; -import org.sonarqube.ws.client.BaseService; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.WsConnector; - -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT; -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_BRANCH; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_FROM; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRICS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_PROJECT_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_STRATEGY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_TO; - -/** - * @deprecated since 7.0, use {@link org.sonarqube.ws.client.measures.MeasuresService} instead - */ -@Deprecated -public class MeasuresService extends BaseService { - public MeasuresService(WsConnector wsConnector) { - super(wsConnector, CONTROLLER_MEASURES); - } - - public ComponentTreeWsResponse componentTree(ComponentTreeRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_COMPONENT_TREE)) - .setParam(DEPRECATED_PARAM_BASE_COMPONENT_ID, request.getBaseComponentId()) - .setParam(DEPRECATED_PARAM_BASE_COMPONENT_KEY, request.getBaseComponentKey()) - .setParam(PARAM_COMPONENT, request.getComponent()) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(PARAM_STRATEGY, request.getStrategy()) - .setParam(PARAM_QUALIFIERS, inlineMultipleParamValue(request.getQualifiers())) - .setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys())) - .setParam(PARAM_ADDITIONAL_FIELDS, inlineMultipleParamValue(request.getAdditionalFields())) - .setParam(PARAM_DEVELOPER_ID, request.getDeveloperId()) - .setParam(PARAM_DEVELOPER_KEY, request.getDeveloperKey()) - .setParam("q", request.getQuery()) - .setParam("p", request.getPage()) - .setParam("ps", request.getPageSize()) - .setParam("s", inlineMultipleParamValue(request.getSort())) - .setParam("asc", request.getAsc()) - .setParam(PARAM_METRIC_SORT, request.getMetricSort()) - .setParam(PARAM_METRIC_SORT_FILTER, request.getMetricSortFilter()); - - return call(getRequest, ComponentTreeWsResponse.parser()); - } - - public ComponentWsResponse component(ComponentRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_COMPONENT)) - .setParam(DEPRECATED_PARAM_COMPONENT_ID, request.getComponentId()) - .setParam(DEPRECATED_PARAM_COMPONENT_KEY, request.getComponentKey()) - .setParam(PARAM_COMPONENT, request.getComponent()) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(PARAM_ADDITIONAL_FIELDS, inlineMultipleParamValue(request.getAdditionalFields())) - .setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys())) - .setParam(PARAM_DEVELOPER_ID, request.getDeveloperId()) - .setParam(PARAM_DEVELOPER_KEY, request.getDeveloperKey()); - - return call(getRequest, ComponentWsResponse.parser()); - } - - public SearchHistoryResponse searchHistory(SearchHistoryRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_SEARCH_HISTORY)) - .setParam(PARAM_COMPONENT, request.getComponent()) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(PARAM_METRICS, inlineMultipleParamValue(request.getMetrics())) - .setParam(PARAM_FROM, request.getFrom()) - .setParam(PARAM_TO, request.getTo()) - .setParam(Param.PAGE, request.getPage()) - .setParam(Param.PAGE_SIZE, request.getPageSize()); - - return call(getRequest, SearchHistoryResponse.parser()); - } - - public SearchWsResponse search(SearchRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_SEARCH_HISTORY)) - .setParam(PARAM_PROJECT_KEYS, inlineMultipleParamValue(request.getProjectKeys())) - .setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys())); - return call(getRequest, SearchWsResponse.parser()); - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java deleted file mode 100644 index b99b9b77b43..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import static java.lang.String.format; - -public class SearchHistoryRequest { - public static final int MAX_PAGE_SIZE = 1_000; - public static final int DEFAULT_PAGE_SIZE = 100; - - private final String component; - private final String branch; - private final List metrics; - private final String from; - private final String to; - private final int page; - private final int pageSize; - - public SearchHistoryRequest(Builder builder) { - this.component = builder.component; - this.branch = builder.branch; - this.metrics = builder.metrics; - this.from = builder.from; - this.to = builder.to; - this.page = builder.page; - this.pageSize = builder.pageSize; - } - - public String getComponent() { - return component; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public List getMetrics() { - return metrics; - } - - @CheckForNull - public String getFrom() { - return from; - } - - @CheckForNull - public String getTo() { - return to; - } - - public int getPage() { - return page; - } - - public int getPageSize() { - return pageSize; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String component; - private String branch; - private List metrics; - private String from; - private String to; - private int page = 1; - private int pageSize = DEFAULT_PAGE_SIZE; - - private Builder() { - // enforce build factory method - } - - public Builder setComponent(String component) { - this.component = component; - return this; - } - - public Builder setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - public Builder setMetrics(List metrics) { - this.metrics = metrics; - return this; - } - - public Builder setFrom(@Nullable String from) { - this.from = from; - return this; - } - - public Builder setTo(@Nullable String to) { - this.to = to; - return this; - } - - public Builder setPage(int page) { - this.page = page; - return this; - } - - public Builder setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public SearchHistoryRequest build() { - checkArgument(component != null && !component.isEmpty(), "Component key is required"); - checkArgument(metrics != null && !metrics.isEmpty(), "Metric keys are required"); - checkArgument(pageSize <= MAX_PAGE_SIZE, "Page size (%d) must be lower than or equal to %d", pageSize, MAX_PAGE_SIZE); - - return new SearchHistoryRequest(this); - } - - private static void checkArgument(boolean condition, String message, Object... args) { - if (!condition) { - throw new IllegalArgumentException(format(message, args)); - } - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java deleted file mode 100644 index 5c8cc2bec0e..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import java.util.List; - -import static com.google.common.base.Preconditions.checkArgument; - -public class SearchRequest { - private static final int MAX_NB_PROJECTS = 100; - - private final List metricKeys; - private final List projectKeys; - - public SearchRequest(Builder builder) { - metricKeys = builder.metricKeys; - projectKeys = builder.projectKeys; - } - - public List getMetricKeys() { - return metricKeys; - } - - public List getProjectKeys() { - return projectKeys; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private List metricKeys; - private List projectKeys; - - private Builder() { - // enforce method constructor - } - - public Builder setMetricKeys(List metricKeys) { - this.metricKeys = metricKeys; - return this; - } - - public Builder setProjectKeys(List projectKeys) { - this.projectKeys = projectKeys; - return this; - } - - public SearchRequest build() { - checkArgument(metricKeys != null && !metricKeys.isEmpty(), "Metric keys must be provided"); - checkArgument(projectKeys != null && !projectKeys.isEmpty(), "Project keys must be provided"); - int nbComponents = projectKeys.size(); - checkArgument(nbComponents <= MAX_NB_PROJECTS, - "%s projects provided, more than maximum authorized (%s)", nbComponents, MAX_NB_PROJECTS); - return new SearchRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/package-info.java deleted file mode 100644 index f4cc7064364..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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. - */ -@ParametersAreNonnullByDefault -package org.sonarqube.ws.client.measure; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java index eea21c7966c..8611025b452 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java @@ -37,7 +37,7 @@ public class ComponentRequest { private String componentId; private String developerId; private String developerKey; - private String metricKeys; + private List metricKeys; /** * Example value: "periods,metrics" @@ -125,12 +125,12 @@ public class ComponentRequest { * This is a mandatory parameter. * Example value: "ncloc,complexity,violations" */ - public ComponentRequest setMetricKeys(String metricKeys) { + public ComponentRequest setMetricKeys(List metricKeys) { this.metricKeys = metricKeys; return this; } - public String getMetricKeys() { + public List getMetricKeys() { return metricKeys; } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java index c63da756229..a7373c34f45 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java @@ -38,7 +38,7 @@ public class ComponentTreeRequest { private String component; private String developerId; private String developerKey; - private String metricKeys; + private List metricKeys; private String metricPeriodSort; private String metricSort; private String metricSortFilter; @@ -153,12 +153,12 @@ public class ComponentTreeRequest { * This is a mandatory parameter. * Example value: "ncloc,complexity,violations" */ - public ComponentTreeRequest setMetricKeys(String metricKeys) { + public ComponentTreeRequest setMetricKeys(List metricKeys) { this.metricKeys = metricKeys; return this; } - public String getMetricKeys() { + public List getMetricKeys() { return metricKeys; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java index 7422d8aae2d..bbea8ca23d9 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java @@ -57,7 +57,7 @@ public class MeasuresService extends BaseService { .setParam("componentId", request.getComponentId()) .setParam("developerId", request.getDeveloperId()) .setParam("developerKey", request.getDeveloperKey()) - .setParam("metricKeys", request.getMetricKeys()), + .setParam("metricKeys", request.getMetricKeys() == null ? null : request.getMetricKeys().stream().collect(Collectors.joining(","))), ComponentWsResponse.parser()); } @@ -78,7 +78,7 @@ public class MeasuresService extends BaseService { .setParam("component", request.getComponent()) .setParam("developerId", request.getDeveloperId()) .setParam("developerKey", request.getDeveloperKey()) - .setParam("metricKeys", request.getMetricKeys()) + .setParam("metricKeys", request.getMetricKeys() == null ? null : request.getMetricKeys().stream().collect(Collectors.joining(","))) .setParam("metricPeriodSort", request.getMetricPeriodSort()) .setParam("metricSort", request.getMetricSort()) .setParam("metricSortFilter", request.getMetricSortFilter()) @@ -101,7 +101,7 @@ public class MeasuresService extends BaseService { public SearchWsResponse search(SearchRequest request) { return call( new GetRequest(path("search")) - .setParam("metricKeys", request.getMetricKeys()) + .setParam("metricKeys", request.getMetricKeys() == null ? null : request.getMetricKeys().stream().collect(Collectors.joining(","))) .setParam("projectKeys", request.getProjectKeys() == null ? null : request.getProjectKeys().stream().collect(Collectors.joining(","))), SearchWsResponse.parser()); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java index bd7614fb216..422c6ffa977 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java @@ -31,19 +31,19 @@ import javax.annotation.Generated; @Generated("sonar-ws-generator") public class SearchRequest { - private String metricKeys; + private List metricKeys; private List projectKeys; /** * This is a mandatory parameter. * Example value: "ncloc,complexity,violations" */ - public SearchRequest setMetricKeys(String metricKeys) { + public SearchRequest setMetricKeys(List metricKeys) { this.metricKeys = metricKeys; return this; } - public String getMetricKeys() { + public List getMetricKeys() { return metricKeys; } 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 deleted file mode 100644 index cfdc00f510c..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/MeasuresServiceTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Rule; -import org.junit.Test; -import org.sonarqube.ws.Measures; -import org.sonarqube.ws.Measures.ComponentTreeWsResponse; -import org.sonarqube.ws.Measures.ComponentWsResponse; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.ServiceTester; -import org.sonarqube.ws.client.WsConnector; - -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.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_BRANCH; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_FROM; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRICS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_PROJECT_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_STRATEGY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_TO; - -public class MeasuresServiceTest { - private static final String VALUE_BASE_COMPONENT_ID = "base-component-id"; - private static final String VALUE_BASE_COMPONENT_KEY = "base-component-key"; - private static final String VALUE_COMPONENT = "component-key"; - private static final List VALUE_METRIC_KEYS = newArrayList("ncloc", "complexity"); - private static final List VALUE_METRICS = newArrayList("ncloc", "complexity"); - private static final String VALUE_STRATEGY = "all"; - private static final List VALUE_QUALIFIERS = newArrayList("FIL", "PRJ"); - private static final ArrayList VALUE_ADDITIONAL_FIELDS = newArrayList("metrics"); - private static final List VALUE_SORT = newArrayList("qualifier", "metric"); - private static final boolean VALUE_ASC = false; - private static final String VALUE_METRIC_SORT = "ncloc"; - private static final String VALUE_METRIC_SORT_FILTER = "all"; - private static final int VALUE_PAGE = 42; - private static final int VALUE_PAGE_SIZE = 1000; - private static final String VALUE_QUERY = "query-sq"; - private static final String VALUE_DEVELOPER_ID = "developer-id"; - private static final String VALUE_DEVELOPER_KEY = "developer-key"; - private static final String VALUE_FROM = "2017-10-01"; - private static final String VALUE_TO = "2017-11-01"; - - @Rule - public ServiceTester serviceTester = new ServiceTester<>(new MeasuresService(mock(WsConnector.class))); - - private MeasuresService underTest = serviceTester.getInstanceUnderTest(); - - @Test - public void component() { - ComponentRequest request = new ComponentRequest() - .setComponentId(VALUE_BASE_COMPONENT_ID) - .setComponentKey(VALUE_BASE_COMPONENT_KEY) - .setComponent(VALUE_BASE_COMPONENT_KEY) - .setBranch("my_branch") - .setMetricKeys(VALUE_METRIC_KEYS) - .setAdditionalFields(VALUE_ADDITIONAL_FIELDS) - .setMetricKeys(VALUE_METRICS) - .setDeveloperId(VALUE_DEVELOPER_ID) - .setDeveloperKey(VALUE_DEVELOPER_KEY); - - underTest.component(request); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(ComponentWsResponse.parser()); - serviceTester.assertThat(getRequest) - .hasParam(DEPRECATED_PARAM_COMPONENT_ID, VALUE_BASE_COMPONENT_ID) - .hasParam(DEPRECATED_PARAM_COMPONENT_KEY, VALUE_BASE_COMPONENT_KEY) - .hasParam(PARAM_COMPONENT, VALUE_BASE_COMPONENT_KEY) - .hasParam(PARAM_BRANCH, "my_branch") - .hasParam(PARAM_METRIC_KEYS, "ncloc,complexity") - .hasParam(PARAM_ADDITIONAL_FIELDS, "metrics") - .hasParam(PARAM_DEVELOPER_ID, VALUE_DEVELOPER_ID) - .hasParam(PARAM_DEVELOPER_KEY, VALUE_DEVELOPER_KEY) - .andNoOtherParam(); - } - - @Test - public void component_tree() { - ComponentTreeRequest componentTreeRequest = new ComponentTreeRequest() - .setBaseComponentId(VALUE_BASE_COMPONENT_ID) - .setBaseComponentKey(VALUE_BASE_COMPONENT_KEY) - .setComponent(VALUE_BASE_COMPONENT_KEY) - .setBranch("my_branch") - .setMetricKeys(VALUE_METRIC_KEYS) - .setStrategy(VALUE_STRATEGY) - .setQualifiers(VALUE_QUALIFIERS) - .setAdditionalFields(VALUE_ADDITIONAL_FIELDS) - .setSort(VALUE_SORT) - .setAsc(VALUE_ASC) - .setMetricSort(VALUE_METRIC_SORT) - .setPage(VALUE_PAGE) - .setPageSize(VALUE_PAGE_SIZE) - .setQuery(VALUE_QUERY) - .setDeveloperId(VALUE_DEVELOPER_ID) - .setDeveloperKey(VALUE_DEVELOPER_KEY) - .setMetricSortFilter(VALUE_METRIC_SORT_FILTER); - - underTest.componentTree(componentTreeRequest); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(ComponentTreeWsResponse.parser()); - serviceTester.assertThat(getRequest) - .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_BRANCH, "my_branch") - .hasParam(PARAM_METRIC_KEYS, "ncloc,complexity") - .hasParam(PARAM_STRATEGY, VALUE_STRATEGY) - .hasParam(PARAM_QUALIFIERS, "FIL,PRJ") - .hasParam(PARAM_ADDITIONAL_FIELDS, "metrics") - .hasParam("s", "qualifier,metric") - .hasParam("asc", VALUE_ASC) - .hasParam(PARAM_METRIC_SORT, VALUE_METRIC_SORT) - .hasParam("p", VALUE_PAGE) - .hasParam("ps", VALUE_PAGE_SIZE) - .hasParam("q", VALUE_QUERY) - .hasParam(PARAM_DEVELOPER_ID, VALUE_DEVELOPER_ID) - .hasParam(PARAM_DEVELOPER_KEY, VALUE_DEVELOPER_KEY) - .hasParam(PARAM_METRIC_SORT_FILTER, VALUE_METRIC_SORT_FILTER) - .andNoOtherParam(); - } - - @Test - public void search_history() { - SearchHistoryRequest request = SearchHistoryRequest.builder() - .setComponent(VALUE_COMPONENT) - .setBranch("my_branch") - .setMetrics(VALUE_METRICS) - .setFrom(VALUE_FROM) - .setTo(VALUE_TO) - .setPage(VALUE_PAGE) - .setPageSize(VALUE_PAGE_SIZE) - .build(); - - underTest.searchHistory(request); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(Measures.SearchHistoryResponse.parser()); - serviceTester.assertThat(getRequest) - .hasParam(PARAM_COMPONENT, VALUE_COMPONENT) - .hasParam(PARAM_BRANCH, "my_branch") - .hasParam(PARAM_METRICS, "ncloc,complexity") - .hasParam(PARAM_FROM, VALUE_FROM) - .hasParam(PARAM_TO, VALUE_TO) - .hasParam("p", VALUE_PAGE) - .hasParam("ps", VALUE_PAGE_SIZE) - .andNoOtherParam(); - } - - @Test - public void search() { - SearchRequest request = SearchRequest.builder() - .setProjectKeys(asList("P1", "P2")) - .setMetricKeys(asList("ncloc", "complexity")) - .build(); - - underTest.search(request); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(Measures.SearchWsResponse.parser()); - serviceTester.assertThat(getRequest) - .hasParam(PARAM_PROJECT_KEYS, "P1,P2") - .hasParam(PARAM_METRIC_KEYS, "ncloc,complexity") - .andNoOtherParam(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java deleted file mode 100644 index 85a9dab34e1..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchHistoryRequestTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonarqube.ws.client.measure.SearchHistoryRequest.DEFAULT_PAGE_SIZE; -import static org.sonarqube.ws.client.measure.SearchHistoryRequest.MAX_PAGE_SIZE; - -public class SearchHistoryRequestTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private SearchHistoryRequest.Builder underTest = SearchHistoryRequest.builder(); - - @Test - public void full_example() { - SearchHistoryRequest result = underTest - .setComponent("C1") - .setBranch("my_branch") - .setMetrics(singletonList("new_lines")) - .setFrom("2017-01-15") - .setTo("2017-01-20") - .setPage(23) - .setPageSize(42) - .build(); - - assertThat(result) - .extracting(SearchHistoryRequest::getComponent, SearchHistoryRequest::getBranch, SearchHistoryRequest::getMetrics, SearchHistoryRequest::getFrom, SearchHistoryRequest::getTo, - SearchHistoryRequest::getPage, SearchHistoryRequest::getPageSize) - .containsExactly("C1", "my_branch", singletonList("new_lines"), "2017-01-15", "2017-01-20", 23, 42); - } - - @Test - public void default_values() { - SearchHistoryRequest result = underTest.setComponent("C1").setMetrics(singletonList("new_lines")).build(); - - assertThat(result.getPage()).isEqualTo(1); - assertThat(result.getPageSize()).isEqualTo(DEFAULT_PAGE_SIZE); - } - - @Test - public void fail_if_no_component() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Component key is required"); - - underTest.setMetrics(singletonList("new_lines")).build(); - } - - @Test - public void fail_if_empty_component() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Component key is required"); - - underTest.setComponent("").setMetrics(singletonList("new_lines")).build(); - } - - @Test - public void fail_if_no_metric() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Metric keys are required"); - - underTest.setComponent("C1").build(); - } - - @Test - public void fail_if_empty_metrics() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Metric keys are required"); - - underTest.setComponent("C1").setMetrics(emptyList()).build(); - } - - @Test - public void fail_if_page_size_greater_than_max_authorized_size() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Page size (1001) must be lower than or equal to 1000"); - - underTest.setComponent("C1").setMetrics(singletonList("violations")).setPageSize(MAX_PAGE_SIZE + 1).build(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java deleted file mode 100644 index 90c36dc7ad5..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/measure/SearchRequestTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.measure; - -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; - -public class SearchRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - SearchRequest.Builder underTest = SearchRequest.builder(); - - @Test - public void create_request() { - SearchRequest result = underTest - .setMetricKeys(singletonList("metric")) - .setProjectKeys(singletonList("key")) - .build(); - - assertThat(result.getMetricKeys()).containsExactly("metric"); - assertThat(result.getProjectKeys()).containsExactly("key"); - } - - @Test - public void create_request_with_100_keys() { - SearchRequest result = underTest - .setMetricKeys(singletonList("metric")) - .setProjectKeys(IntStream.rangeClosed(1, 100).mapToObj(Integer::toString).collect(Collectors.toList())) - .build(); - - assertThat(result.getProjectKeys()).hasSize(100); - } - - @Test - public void fail_when_non_null_metric_keys() { - expectExceptionOnMetricKeys(); - - underTest.setMetricKeys(null).build(); - } - - @Test - public void fail_when_non_empty_metric_keys() { - expectExceptionOnMetricKeys(); - - underTest.setMetricKeys(emptyList()).build(); - } - - @Test - public void fail_when_unset_metric_keys() { - expectExceptionOnMetricKeys(); - - underTest.build(); - } - - @Test - public void fail_when_component_keys_is_empty() { - expectExceptionOnComponents(); - - underTest - .setMetricKeys(singletonList("metric")) - .setProjectKeys(emptyList()) - .build(); - } - - @Test - public void fail_when_component_keys_contains_more_than_100_keys() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("101 projects provided, more than maximum authorized (100)"); - - underTest - .setMetricKeys(singletonList("metric")) - .setProjectKeys(IntStream.rangeClosed(1, 101).mapToObj(Integer::toString).collect(Collectors.toList())) - .build(); - } - - private void expectExceptionOnMetricKeys() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Metric keys must be provided"); - } - - private void expectExceptionOnComponents() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Project keys must be provided"); - } -} diff --git a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java index f8230246a8e..8bf091cf72a 100644 --- a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java +++ b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java @@ -31,9 +31,9 @@ import org.sonarqube.ws.Measures; import org.sonarqube.ws.client.components.TreeRequest; import org.sonarqube.ws.client.issues.IssuesService; import org.sonarqube.ws.client.issues.SearchRequest; -import org.sonarqube.ws.client.measure.ComponentTreeRequest; -import org.sonarqube.ws.client.measure.ComponentRequest; -import org.sonarqube.ws.client.measure.MeasuresService; +import org.sonarqube.ws.client.measures.ComponentTreeRequest; +import org.sonarqube.ws.client.measures.ComponentRequest; +import org.sonarqube.ws.client.measures.MeasuresService; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -88,15 +88,15 @@ public class LiteTest { @Test public void call_measures_ws() { // project measures - MeasuresService measuresService = tester.wsClient().measuresOld(); + MeasuresService measuresService = tester.wsClient().measures(); Measures.ComponentWsResponse component = measuresService.component(new ComponentRequest() - .setComponentKey(PROJECT_KEY) + .setComponent(PROJECT_KEY) .setMetricKeys(asList("lines", "ncloc", "files"))); assertThat(component.getComponent().getMeasuresCount()).isEqualTo(3); // file measures Measures.ComponentTreeWsResponse tree = measuresService.componentTree(new ComponentTreeRequest() - .setBaseComponentKey(PROJECT_KEY) + .setComponent(PROJECT_KEY) .setQualifiers(singletonList("FIL")) .setMetricKeys(asList("lines", "ncloc"))); assertThat(tree.getComponentsCount()).isEqualTo(4); diff --git a/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java b/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java index 44a55d60c64..2515b25fec0 100644 --- a/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/measure/MeasuresWsTest.java @@ -30,8 +30,8 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Measures; import org.sonarqube.ws.Measures.ComponentTreeWsResponse; import org.sonarqube.ws.Measures.ComponentWsResponse; -import org.sonarqube.ws.client.measure.ComponentTreeRequest; -import org.sonarqube.ws.client.measure.ComponentRequest; +import org.sonarqube.ws.client.measures.ComponentTreeRequest; +import org.sonarqube.ws.client.measures.ComponentRequest; import static com.google.common.collect.Lists.newArrayList; import static java.util.Arrays.asList; @@ -59,7 +59,7 @@ public class MeasuresWsTest { public void component_tree() { scanXooSample(); - ComponentTreeWsResponse response = tester.wsClient().measuresOld().componentTree(new ComponentTreeRequest() + ComponentTreeWsResponse response = tester.wsClient().measures().componentTree(new ComponentTreeRequest() .setComponent("sample") .setMetricKeys(singletonList("ncloc")) .setAdditionalFields(asList("metrics", "periods"))); @@ -123,7 +123,7 @@ public class MeasuresWsTest { } private void verifyComponentTreeWithChildren(String baseComponentKey, String... childKeys) { - ComponentTreeWsResponse response = tester.wsClient().measuresOld().componentTree(new ComponentTreeRequest() + ComponentTreeWsResponse response = tester.wsClient().measures().componentTree(new ComponentTreeRequest() .setComponent(baseComponentKey) .setMetricKeys(singletonList("ncloc")) .setStrategy("children")); @@ -137,7 +137,7 @@ public class MeasuresWsTest { public void component() { scanXooSample(); - ComponentWsResponse response = tester.wsClient().measuresOld().component(new ComponentRequest() + ComponentWsResponse response = tester.wsClient().measures().component(new ComponentRequest() .setComponent("sample") .setMetricKeys(singletonList("ncloc")) .setAdditionalFields(newArrayList("metrics", "periods"))); diff --git a/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java b/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java index 9970b0a8470..2dc2d73b7ff 100644 --- a/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java +++ b/tests/src/test/java/org/sonarqube/tests/measure/TimeMachineTest.java @@ -21,7 +21,6 @@ package org.sonarqube.tests.measure; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import java.util.Arrays; import java.util.Date; import java.util.Map; import org.junit.BeforeClass; @@ -32,10 +31,11 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Measures.Measure; import org.sonarqube.ws.Measures.SearchHistoryResponse; import org.sonarqube.ws.Measures.SearchHistoryResponse.HistoryValue; -import org.sonarqube.ws.client.measure.SearchHistoryRequest; +import org.sonarqube.ws.client.measures.SearchHistoryRequest; import util.ItUtils; import util.ItUtils.ComponentNavigation; +import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.apache.commons.lang.time.DateUtils.addDays; import static org.assertj.core.api.Assertions.assertThat; @@ -102,12 +102,11 @@ public class TimeMachineTest { public void noDataForInterval() { Date now = new Date(); - SearchHistoryResponse response = tester.wsClient().measuresOld().searchHistory(SearchHistoryRequest.builder() + SearchHistoryResponse response = tester.wsClient().measures().searchHistory(new SearchHistoryRequest() .setComponent(PROJECT_KEY) .setMetrics(singletonList("lines")) .setFrom(formatDate(now)) - .setTo(formatDate(now)) - .build()); + .setTo(formatDate(now))); assertThat(response.getPaging().getTotal()).isEqualTo(0); assertThat(response.getMeasures(0).getHistoryList()).isEmpty(); @@ -134,10 +133,9 @@ public class TimeMachineTest { } private static SearchHistoryResponse searchHistory(String... metrics) { - return tester.wsClient().measuresOld().searchHistory(SearchHistoryRequest.builder() + return tester.wsClient().measures().searchHistory(new SearchHistoryRequest() .setComponent(PROJECT_KEY) - .setMetrics(Arrays.asList(metrics)) - .build()); + .setMetrics(asList(metrics))); } private static void assertHistory(SearchHistoryResponse response, String metric, String... expectedMeasures) { diff --git a/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java b/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java index f0e6590a6e0..80e1f718f6a 100644 --- a/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/performance/scanner/DuplicationTest.java @@ -37,7 +37,7 @@ import org.sonarqube.ws.Measures; import org.sonarqube.ws.client.HttpConnector; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; -import org.sonarqube.ws.client.measure.ComponentRequest; +import org.sonarqube.ws.client.measures.ComponentRequest; import static java.lang.Double.parseDouble; import static java.util.Arrays.asList; @@ -80,8 +80,8 @@ public class DuplicationTest extends AbstractPerfTest { } private Map getMeasures(String key) { - return newWsClient().measuresOld().component(new ComponentRequest() - .setComponentKey(key) + return newWsClient().measures().component(new ComponentRequest() + .setComponent(key) .setMetricKeys(asList("duplicated_lines", "duplicated_blocks", "duplicated_files", "duplicated_lines_density"))) .getComponent().getMeasuresList() .stream() diff --git a/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java b/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java index f929798ec84..a858de6af52 100644 --- a/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java +++ b/tests/src/test/java/org/sonarqube/tests/upgrade/UpgradeTest.java @@ -31,22 +31,26 @@ import java.io.File; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; -import java.util.Collections; import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Test; import org.sonarqube.qa.util.SelenideConfig; +import org.sonarqube.ws.Measures; import org.sonarqube.ws.Measures.Measure; +import org.sonarqube.ws.MediaTypes; +import org.sonarqube.ws.client.BaseService; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.HttpConnector; +import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.measure.ComponentRequest; +import org.sonarqube.ws.client.measures.ComponentRequest; import static com.codeborne.selenide.Condition.hasText; import static com.codeborne.selenide.Selenide.$; import static java.lang.Integer.parseInt; +import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; public class UpgradeTest { @@ -73,7 +77,7 @@ public class UpgradeTest { private void testDatabaseUpgrade(Version fromVersion) { startOldVersionServer(fromVersion, false); scanProject(); - int files = countFiles(PROJECT_KEY); + int files = countFilesOld(PROJECT_KEY); assertThat(files).isGreaterThan(0); stopServer(); @@ -83,9 +87,9 @@ public class UpgradeTest { } private void verifyAnalysis(int expectedNumberOfFiles) { - assertThat(countFiles(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles); + assertThat(countFilesNew(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles); scanProject(); - assertThat(countFiles(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles); + assertThat(countFilesNew(PROJECT_KEY)).isEqualTo(expectedNumberOfFiles); browseWebapp(); } @@ -197,8 +201,20 @@ public class UpgradeTest { orchestrator.executeBuild(build); } - private int countFiles(String key) { - Measure measure = newWsClient(orchestrator).measuresOld().component(new ComponentRequest().setComponentKey(key).setMetricKeys(Collections.singletonList("files"))) + private int countFilesOld(String key) { + PostRequest httpRequest = new PostRequest("api/measures/component") + .setParam("componentKey", key) + .setParam("metricKeys", singletonList("files")) + .setMediaType(MediaTypes.PROTOBUF); + WsResponse response = HttpConnector.newBuilder() + .url(orchestrator.getServer().getUrl()) + .build().call(httpRequest); + Measure measure = BaseService.convert(response, Measures.ComponentWsResponse.parser()).getComponent().getMeasures(0); + return parseInt(measure.getValue()); + } + + private int countFilesNew(String key) { + Measure measure = newWsClient(orchestrator).measures().component(new ComponentRequest().setComponent(key).setMetricKeys(singletonList("files"))) .getComponent().getMeasures(0); return parseInt(measure.getValue()); } diff --git a/tests/src/test/java/util/ItUtils.java b/tests/src/test/java/util/ItUtils.java index c1dfd54f86e..7700bf120f5 100644 --- a/tests/src/test/java/util/ItUtils.java +++ b/tests/src/test/java/util/ItUtils.java @@ -71,7 +71,7 @@ import org.sonarqube.ws.client.HttpConnector; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.components.ShowRequest; -import org.sonarqube.ws.client.measure.ComponentRequest; +import org.sonarqube.ws.client.measures.ComponentRequest; import org.sonarqube.ws.client.qualityprofile.RestoreRequest; import org.sonarqube.ws.client.settings.ResetRequest; import org.sonarqube.ws.client.settings.SetRequest; @@ -334,7 +334,7 @@ public class ItUtils { } private static Stream getStreamMeasures(Orchestrator orchestrator, String componentKey, String... metricKeys) { - return newWsClient(orchestrator).measuresOld().component(new ComponentRequest() + return newWsClient(orchestrator).measures().component(new ComponentRequest() .setComponent(componentKey) .setMetricKeys(asList(metricKeys))) .getComponent().getMeasuresList() @@ -343,7 +343,7 @@ public class ItUtils { @CheckForNull public static Measure getMeasureWithVariation(Orchestrator orchestrator, String componentKey, String metricKey) { - Measures.ComponentWsResponse response = newWsClient(orchestrator).measuresOld().component(new ComponentRequest() + Measures.ComponentWsResponse response = newWsClient(orchestrator).measures().component(new ComponentRequest() .setComponent(componentKey) .setMetricKeys(singletonList(metricKey)) .setAdditionalFields(singletonList("periods"))); @@ -353,8 +353,8 @@ public class ItUtils { @CheckForNull public static Map getMeasuresWithVariationsByMetricKey(Orchestrator orchestrator, String componentKey, String... metricKeys) { - return newWsClient(orchestrator).measuresOld().component(new ComponentRequest() - .setComponentKey(componentKey) + return newWsClient(orchestrator).measures().component(new ComponentRequest() + .setComponent(componentKey) .setMetricKeys(asList(metricKeys)) .setAdditionalFields(singletonList("periods"))).getComponent().getMeasuresList() .stream() -- 2.39.5