]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13848 remove deprecations from api/measure/* WS
authorMichal Duda <michal.duda@sonarsource.com>
Wed, 24 Feb 2021 14:24:31 +0000 (15:24 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 26 Feb 2021 20:07:40 +0000 (20:07 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/MeasuresWsParameters.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentDtoToWsComponent.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeRequest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
sonar-ws/src/main/protobuf/ws-measures.proto

index 7f9e57d7a3424c66269fa231aca7e7c60c983140..d00bd5adf6cfd13b3d58a0c81d80adb9b80e5ffa 100644 (file)
@@ -31,8 +31,6 @@ public class MeasuresWsParameters {
   public static final String ACTION_SEARCH_HISTORY = "search_history";
 
   // parameters
-  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_PULL_REQUEST = "pullRequest";
index 56fb4b43c33c316d925f3431d9d5ca1a8c734d6a..383de3a2800c9a210893b2c24485cda3f82d5f72 100644 (file)
@@ -96,11 +96,13 @@ public class ComponentAction implements MeasuresWsAction {
       .setResponseExample(getClass().getResource("component-example.json"))
       .setSince("5.4")
       .setChangelog(
+        new Change("8.8", "deprecated response field 'id' has been removed"),
+        new Change("8.8", "deprecated response field 'refId' has been removed."),
         new Change("8.1", "the response field periods under measures field is deprecated. Use period instead."),
         new Change("8.1", "the response field periods is deprecated. Use period instead."),
         new Change("7.6", format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
-        new Change("6.6", "the response field id is deprecated. Use key instead."),
-        new Change("6.6", "the response field refId is deprecated. Use refKey instead."))
+        new Change("6.6", "the response field 'id' is deprecated. Use 'key' instead."),
+        new Change("6.6", "the response field 'refId' is deprecated. Use 'refKey' instead."))
       .setHandler(this);
 
     action.createParam(PARAM_COMPONENT)
@@ -237,7 +239,7 @@ public class ComponentAction implements MeasuresWsAction {
   }
 
   private static ComponentWsResponse buildResponse(ComponentRequest request, ComponentDto component, Optional<ComponentDto> refComponent,
-    Map<MetricDto, LiveMeasureDto> measuresByMetric, Collection<MetricDto> metrics, Optional<Measures.Period> period) {
+                                                   Map<MetricDto, LiveMeasureDto> measuresByMetric, Collection<MetricDto> metrics, Optional<Measures.Period> period) {
     ComponentWsResponse.Builder response = ComponentWsResponse.newBuilder();
 
     if (refComponent.isPresent()) {
index 19d6095c7410cb8b21d7d63838b9b959b8ae2104..c2df3e2d68a0800b6a5491d8b91abdf38f6eefc0 100644 (file)
@@ -34,12 +34,11 @@ class ComponentDtoToWsComponent {
   }
 
   static Component.Builder componentDtoToWsComponent(ComponentDto component, Map<MetricDto, LiveMeasureDto> measuresByMetric,
-    Map<String, ComponentDto> referenceComponentsByUuid) {
+                                                     Map<String, ComponentDto> referenceComponentsByUuid) {
     Component.Builder wsComponent = componentDtoToWsComponent(component);
 
     ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid());
     if (referenceComponent != null) {
-      wsComponent.setRefId(referenceComponent.uuid());
       wsComponent.setRefKey(referenceComponent.getDbKey());
     }
 
@@ -55,7 +54,6 @@ class ComponentDtoToWsComponent {
 
   static Component.Builder componentDtoToWsComponent(ComponentDto component) {
     Component.Builder wsComponent = Component.newBuilder()
-      .setId(component.uuid())
       .setKey(component.getKey())
       .setName(component.name())
       .setQualifier(component.qualifier());
index bee959acf915a4cf9c0f711e7d4d8f590fb87fc4..cbd139a13b70b20609b4b04b5784c74848acb71e 100644 (file)
@@ -79,16 +79,12 @@ import static java.util.Collections.emptyMap;
 import static org.sonar.api.measures.Metric.ValueType.DATA;
 import static org.sonar.api.measures.Metric.ValueType.DISTRIB;
 import static org.sonar.api.utils.Paging.offset;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
 import static org.sonar.db.component.ComponentTreeQuery.Strategy.CHILDREN;
 import static org.sonar.db.component.ComponentTreeQuery.Strategy.LEAVES;
-import static org.sonar.server.component.ComponentFinder.ParamNames.BASE_COMPONENT_ID_AND_KEY;
 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_PERIOD;
 import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_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;
@@ -109,8 +105,8 @@ import static org.sonar.server.measure.ws.SnapshotDtoToWsPeriod.snapshotToWsPeri
 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.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001;
-import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
 import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
+import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
 /**
@@ -162,7 +158,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   private final ResourceTypes resourceTypes;
 
   public ComponentTreeAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, I18n i18n,
-    ResourceTypes resourceTypes) {
+                             ResourceTypes resourceTypes) {
     this.dbClient = dbClient;
     this.componentFinder = componentFinder;
     this.userSession = userSession;
@@ -173,22 +169,26 @@ public class ComponentTreeAction implements MeasuresWsAction {
   @Override
   public void define(WebService.NewController context) {
     WebService.NewAction action = context.createAction(ACTION_COMPONENT_TREE)
-      .setDescription(format("Navigate through components based on the chosen strategy with specified measures. The %s or the %s parameter must be provided.<br>" +
+      .setDescription(format("Navigate through components based on the chosen strategy with specified measures.<br>" +
         "Requires the following permission: 'Browse' on the specified project.<br>" +
-        "When limiting search with the %s parameter, directories are not returned.",
-        DEPRECATED_PARAM_BASE_COMPONENT_ID, PARAM_COMPONENT, Param.TEXT_QUERY))
+        "When limiting search with the %s parameter, directories are not returned.", Param.TEXT_QUERY))
       .setResponseExample(getClass().getResource("component_tree-example.json"))
       .setSince("5.4")
       .setHandler(this)
       .addPagingParams(100, MAX_SIZE)
       .setChangelog(
+        new Change("8.8", "parameter 'component' is now required"),
+        new Change("8.8", "deprecated parameter 'baseComponentId' has been removed"),
+        new Change("8.8", "deprecated parameter 'baseComponentKey' has been removed."),
+        new Change("8.8", "deprecated response field 'id' has been removed"),
+        new Change("8.8", "deprecated response field 'refId' has been removed."),
         new Change("8.1", "the response field periods under measures field is deprecated. Use period instead."),
         new Change("8.1", "the response field periods is deprecated. Use period instead."),
         new Change("7.6", format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
         new Change("7.2", "field 'bestValue' is added to the response"),
         new Change("6.3", format("Number of metric keys is limited to %s", MAX_METRIC_KEYS)),
-        new Change("6.6", "the response field id is deprecated. Use key instead."),
-        new Change("6.6", "the response field refId is deprecated. Use refKey instead."));
+        new Change("6.6", "the response field 'id' is deprecated. Use 'key' instead."),
+        new Change("6.6", "the response field 'refId' is deprecated. Use 'refKey' instead."));
 
     action.createSortParams(SORTS, NAME_SORT, true)
       .setDescription("Comma-separated list of sort fields")
@@ -202,15 +202,10 @@ public class ComponentTreeAction implements MeasuresWsAction {
       .setMinimumLength(QUERY_MINIMUM_LENGTH)
       .setExampleValue("FILE_NAM");
 
-    action.createParam(DEPRECATED_PARAM_BASE_COMPONENT_ID)
-      .setDescription("Base component id. The search is based on this component.")
-      .setExampleValue(UUID_EXAMPLE_02)
-      .setDeprecatedSince("6.6");
-
     action.createParam(PARAM_COMPONENT)
+      .setRequired(true)
       .setDescription("Component key. The search is based on this component.")
-      .setExampleValue(KEY_PROJECT_EXAMPLE_001)
-      .setDeprecatedKey(DEPRECATED_PARAM_BASE_COMPONENT_KEY, "6.6");
+      .setExampleValue(KEY_PROJECT_EXAMPLE_001);
 
     action.createParam(PARAM_BRANCH)
       .setDescription("Branch key. Not available in the community edition.")
@@ -342,8 +337,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
     List<String> metricKeys = request.mandatoryParamAsStrings(PARAM_METRIC_KEYS);
     checkArgument(metricKeys.size() <= MAX_METRIC_KEYS, "Number of metrics keys is limited to %s, got %s", MAX_METRIC_KEYS, metricKeys.size());
     ComponentTreeRequest componentTreeRequest = new ComponentTreeRequest()
-      .setBaseComponentId(request.param(DEPRECATED_PARAM_BASE_COMPONENT_ID))
-      .setComponent(request.param(PARAM_COMPONENT))
+      .setComponent(request.mandatoryParam(PARAM_COMPONENT))
       .setBranch(request.param(PARAM_BRANCH))
       .setPullRequest(request.param(PARAM_PULL_REQUEST))
       .setMetricKeys(metricKeys)
@@ -375,11 +369,10 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private static Measures.Component.Builder toWsComponent(ComponentDto component, Map<MetricDto, ComponentTreeData.Measure> measures,
-    Map<String, ComponentDto> referenceComponentsByUuid) {
+                                                          Map<String, ComponentDto> referenceComponentsByUuid) {
     Measures.Component.Builder wsComponent = componentDtoToWsComponent(component);
     ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid());
     if (referenceComponent != null) {
-      wsComponent.setRefId(referenceComponent.uuid());
       wsComponent.setRefKey(referenceComponent.getKey());
     }
     Measures.Measure.Builder measureBuilder = Measures.Measure.newBuilder();
@@ -447,16 +440,12 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private ComponentDto loadComponent(DbSession dbSession, ComponentTreeRequest request) {
-    String componentId = request.getBaseComponentId();
     String componentKey = request.getComponent();
     String branch = request.getBranch();
     String pullRequest = request.getPullRequest();
-    checkArgument(componentId == null || (branch == null && pullRequest == null), "Parameter '%s' cannot be used at the same time as '%s' or '%s'",
-      DEPRECATED_PARAM_BASE_COMPONENT_ID, PARAM_BRANCH, PARAM_PULL_REQUEST);
     if (branch == null && pullRequest == null) {
-      return componentFinder.getByUuidOrKey(dbSession, componentId, componentKey, BASE_COMPONENT_ID_AND_KEY);
+      return componentFinder.getByKey(dbSession, componentKey);
     }
-    checkRequest(componentKey != null, "The '%s' parameter is missing", PARAM_COMPONENT);
     return componentFinder.getByKeyAndOptionalBranchOrPullRequest(dbSession, componentKey, branch, pullRequest);
   }
 
@@ -501,7 +490,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private Table<String, MetricDto, ComponentTreeData.Measure> searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent,
-    ComponentTreeQuery componentTreeQuery, List<ComponentDto> components, List<MetricDto> metrics) {
+                                                                                                     ComponentTreeQuery componentTreeQuery, List<ComponentDto> components, List<MetricDto> metrics) {
 
     Map<String, MetricDto> metricsByUuid = Maps.uniqueIndex(metrics, MetricDto::getUuid);
     MeasureTreeQuery measureQuery = MeasureTreeQuery.builder()
@@ -533,7 +522,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
    * </ul>
    */
   private static void addBestValuesToMeasures(Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric, List<ComponentDto> components,
-    List<MetricDto> metrics) {
+                                              List<MetricDto> metrics) {
     List<MetricDtoWithBestValue> metricDtosWithBestValueMeasure = metrics.stream()
       .filter(MetricDtoFunctions.isOptimizedForBestValue())
       .map(new MetricDtoToMetricDtoWithBestValue())
@@ -554,7 +543,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private static List<ComponentDto> filterComponents(List<ComponentDto> components,
-    Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric, List<MetricDto> metrics, ComponentTreeRequest wsRequest) {
+                                                     Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric, List<MetricDto> metrics, ComponentTreeRequest wsRequest) {
     if (!componentWithMeasuresOnly(wsRequest)) {
       return components;
     }
@@ -574,7 +563,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private static List<ComponentDto> sortComponents(List<ComponentDto> components, ComponentTreeRequest wsRequest, List<MetricDto> metrics,
-    Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) {
+                                                   Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) {
     return ComponentTreeSort.sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric);
   }
 
index 07a4445baa403141ee495f27f6fe2ded9484e854..7a6cdecd4ae1dc5bc04cba03a4eb3615f9897e24 100644 (file)
@@ -24,8 +24,6 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
 class ComponentTreeRequest {
-
-  private String baseComponentId;
   private String component;
   private String branch;
   private String pullRequest;
@@ -42,30 +40,11 @@ class ComponentTreeRequest {
   private Integer page;
   private Integer pageSize;
 
-  /**
-   * @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;
-  }
-
-  @CheckForNull
   public String getComponent() {
     return component;
   }
 
-  public ComponentTreeRequest setComponent(@Nullable String component) {
+  public ComponentTreeRequest setComponent(String component) {
     this.component = component;
     return this;
   }
index 7401d923665a0e58b5a497bfcad855dfe37c0f5c..95b01f6383c8947ee218829b1814a0a3ea6effc8 100644 (file)
@@ -225,7 +225,7 @@ public class ComponentActionTest {
   }
 
   @Test
-  public void reference_uuid_in_the_response() {
+  public void reference_key_in_the_response() {
     userSession.logIn().setRoot();
     ComponentDto project = db.components().insertPrivateProject();
     ComponentDto view = db.components().insertPrivatePortfolio();
@@ -235,22 +235,9 @@ public class ComponentActionTest {
 
     ComponentWsResponse response = newRequest(projectCopy.getKey(), metric.getKey());
 
-    assertThat(response.getComponent().getRefId()).isEqualTo(project.uuid());
     assertThat(response.getComponent().getRefKey()).isEqualTo(project.getKey());
   }
 
-  @Test
-  public void return_deprecated_id_in_the_response() {
-    ComponentDto project = db.components().insertPrivateProject();
-    userSession.addProjectPermission(UserRole.USER, project);
-    db.components().insertSnapshot(project);
-    MetricDto metric = db.measures().insertMetric(m -> m.setValueType("INT"));
-
-    ComponentWsResponse response = newRequest(project.getKey(), metric.getKey());
-
-    assertThat(response.getComponent().getId()).isEqualTo(project.uuid());
-  }
-
   @Test
   public void use_deprecated_component_id_parameter() {
     ComponentDto project = db.components().insertPrivateProject();
index 40c62df3dc4a6a92fd87bf4d69d64862359a982d..ace3cf74fec28de0a63b6dd7d8c57727f9d98921 100644 (file)
@@ -76,8 +76,6 @@ import static org.sonar.db.component.ComponentTesting.newProjectCopy;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_PERIOD;
 import static org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_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;
@@ -353,15 +351,15 @@ public class ComponentTreeActionTest {
   public void load_measures_multi_sort_with_metric_key_and_paginated() {
     ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file9 = db.components().insertComponent(newFileDto(project, null, "file-uuid-9").setName("file-1"));
-    ComponentDto file8 = db.components().insertComponent(newFileDto(project, null, "file-uuid-8").setName("file-1"));
-    ComponentDto file7 = db.components().insertComponent(newFileDto(project, null, "file-uuid-7").setName("file-1"));
-    ComponentDto file6 = db.components().insertComponent(newFileDto(project, null, "file-uuid-6").setName("file-1"));
-    ComponentDto file5 = db.components().insertComponent(newFileDto(project, null, "file-uuid-5").setName("file-1"));
-    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setName("file-1"));
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setName("file-1"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setName("file-1"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setName("file-1"));
+    ComponentDto file9 = db.components().insertComponent(newFileDto(project, null, "file-uuid-9").setName("file-1").setDbKey("file-9-key"));
+    ComponentDto file8 = db.components().insertComponent(newFileDto(project, null, "file-uuid-8").setName("file-1").setDbKey("file-8-key"));
+    ComponentDto file7 = db.components().insertComponent(newFileDto(project, null, "file-uuid-7").setName("file-1").setDbKey("file-7-key"));
+    ComponentDto file6 = db.components().insertComponent(newFileDto(project, null, "file-uuid-6").setName("file-1").setDbKey("file-6-key"));
+    ComponentDto file5 = db.components().insertComponent(newFileDto(project, null, "file-uuid-5").setName("file-1").setDbKey("file-5-key"));
+    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setName("file-1").setDbKey("file-4-key"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setName("file-1").setDbKey("file-3-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setName("file-1").setDbKey("file-2-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setName("file-1").setDbKey("file-1-key"));
     MetricDto coverage = insertCoverageMetric();
     db.commit();
     db.measures().insertLiveMeasure(file1, coverage, m -> m.setValue(1.0d));
@@ -385,7 +383,7 @@ public class ComponentTreeActionTest {
       .setParam(Param.PAGE_SIZE, "3")
       .executeProtobuf(ComponentTreeWsResponse.class);
 
-    assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-4", "file-uuid-5", "file-uuid-6");
+    assertThat(response.getComponentsList()).extracting("key").containsExactly("file-4-key", "file-5-key", "file-6-key");
     assertThat(response.getPaging().getPageIndex()).isEqualTo(2);
     assertThat(response.getPaging().getPageSize()).isEqualTo(3);
     assertThat(response.getPaging().getTotal()).isEqualTo(9);
@@ -395,10 +393,10 @@ public class ComponentTreeActionTest {
   public void sort_by_metric_value() {
     ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4"));
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2"));
+    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setDbKey("file-4-key"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key"));
     MetricDto ncloc = newMetricDto().setKey("ncloc").setValueType(INT.name()).setDirection(1);
     dbClient.metricDao().insert(dbSession, ncloc);
     db.commit();
@@ -413,7 +411,7 @@ public class ComponentTreeActionTest {
       .setParam(PARAM_METRIC_KEYS, "ncloc")
       .executeProtobuf(ComponentTreeWsResponse.class);
 
-    assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3", "file-uuid-4");
+    assertThat(response.getComponentsList()).extracting("key").containsExactly("file-1-key", "file-2-key", "file-3-key", "file-4-key");
     assertThat(response.getPaging().getTotal()).isEqualTo(4);
   }
 
@@ -421,10 +419,10 @@ public class ComponentTreeActionTest {
   public void remove_components_without_measure_on_the_metric_sort() {
     ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file1 = newFileDto(project, null, "file-uuid-1");
-    ComponentDto file2 = newFileDto(project, null, "file-uuid-2");
-    ComponentDto file3 = newFileDto(project, null, "file-uuid-3");
-    ComponentDto file4 = newFileDto(project, null, "file-uuid-4");
+    ComponentDto file1 = newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key");
+    ComponentDto file2 = newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key");
+    ComponentDto file3 = newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key");
+    ComponentDto file4 = newFileDto(project, null, "file-uuid-4").setDbKey("file-4-key");
     db.components().insertComponent(file1);
     db.components().insertComponent(file2);
     db.components().insertComponent(file3);
@@ -446,9 +444,9 @@ public class ComponentTreeActionTest {
       .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER)
       .executeProtobuf(ComponentTreeWsResponse.class);
 
-    assertThat(response.getComponentsList()).extracting("id")
-      .containsExactly(file1.uuid(), file2.uuid(), file3.uuid())
-      .doesNotContain(file4.uuid());
+    assertThat(response.getComponentsList()).extracting("key")
+      .containsExactly(file1.getKey(), file2.getKey(), file3.getKey())
+      .doesNotContain(file4.getKey());
     assertThat(response.getPaging().getTotal()).isEqualTo(3);
   }
 
@@ -456,9 +454,9 @@ public class ComponentTreeActionTest {
   public void sort_by_metric_period() {
     ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key"));
     MetricDto ncloc = newMetricDto().setKey("ncloc").setValueType(INT.name()).setDirection(1);
     dbClient.metricDao().insert(dbSession, ncloc);
     db.commit();
@@ -474,17 +472,17 @@ public class ComponentTreeActionTest {
       .setParam(PARAM_METRIC_PERIOD_SORT, "1")
       .executeProtobuf(ComponentTreeWsResponse.class);
 
-    assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3");
+    assertThat(response.getComponentsList()).extracting("key").containsExactly("file-1-key", "file-2-key", "file-3-key");
   }
 
   @Test
   public void remove_components_without_measure_on_the_metric_period_sort() {
     ComponentDto project = db.components().insertPrivateProject();
     SnapshotDto projectSnapshot = db.components().insertSnapshot(project);
-    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4"));
-    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3"));
-    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2"));
-    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1"));
+    ComponentDto file4 = db.components().insertComponent(newFileDto(project, null, "file-uuid-4").setDbKey("file-4-key"));
+    ComponentDto file3 = db.components().insertComponent(newFileDto(project, null, "file-uuid-3").setDbKey("file-3-key"));
+    ComponentDto file2 = db.components().insertComponent(newFileDto(project, null, "file-uuid-2").setDbKey("file-2-key"));
+    ComponentDto file1 = db.components().insertComponent(newFileDto(project, null, "file-uuid-1").setDbKey("file-1-key"));
     MetricDto ncloc = newMetricDto().setKey("new_ncloc").setValueType(INT.name()).setDirection(1);
     dbClient.metricDao().insert(dbSession, ncloc);
     db.measures().insertLiveMeasure(file1, ncloc, m -> m.setData((String) null).setValue(null).setVariation(1.0d));
@@ -503,9 +501,9 @@ public class ComponentTreeActionTest {
       .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER)
       .executeProtobuf(ComponentTreeWsResponse.class);
 
-    assertThat(response.getComponentsList()).extracting("id")
-      .containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3")
-      .doesNotContain("file-uuid-4");
+    assertThat(response.getComponentsList()).extracting("key")
+      .containsExactly("file-1-key", "file-2-key", "file-3-key")
+      .doesNotContain("file-4-key");
   }
 
   @Test
@@ -619,52 +617,6 @@ public class ComponentTreeActionTest {
       .isEmpty();
   }
 
-  @Test
-  public void return_deprecated_id_in_the_response() {
-    ComponentDto project = db.components().insertPrivateProject();
-    SnapshotDto analysis = db.components().insertSnapshot(project);
-    ComponentDto file = db.components().insertComponent(newFileDto(project));
-    MetricDto ncloc = insertNclocMetric();
-    db.measures().insertLiveMeasure(file, ncloc, m -> m.setValue(2d));
-
-    ComponentTreeWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT, project.getKey())
-      .setParam(PARAM_METRIC_KEYS, ncloc.getKey())
-      .executeProtobuf(ComponentTreeWsResponse.class);
-
-    assertThat(response.getBaseComponent().getId()).isEqualTo(project.uuid());
-    assertThat(response.getComponentsList()).extracting(Component::getId)
-      .containsExactlyInAnyOrder(file.uuid());
-  }
-
-  @Test
-  public void use_deprecated_base_component_id_parameter() {
-    ComponentDto project = db.components().insertPrivateProject();
-    userSession.addProjectPermission(USER, project);
-    insertNclocMetric();
-
-    ComponentTreeWsResponse response = ws.newRequest()
-      .setParam("baseComponentId", project.uuid())
-      .setParam(PARAM_METRIC_KEYS, "ncloc")
-      .executeProtobuf(ComponentTreeWsResponse.class);
-
-    assertThat(response.getBaseComponent().getKey()).isEqualTo(project.getKey());
-  }
-
-  @Test
-  public void use_deprecated_base_component_key_parameter() {
-    ComponentDto project = db.components().insertPrivateProject();
-    userSession.addProjectPermission(USER, project);
-    insertNclocMetric();
-
-    ComponentTreeWsResponse response = ws.newRequest()
-      .setParam("baseComponentKey", project.getKey())
-      .setParam(PARAM_METRIC_KEYS, "ncloc")
-      .executeProtobuf(ComponentTreeWsResponse.class);
-
-    assertThat(response.getBaseComponent().getKey()).isEqualTo(project.getKey());
-  }
-
   @Test
   public void metric_without_a_domain() {
     ComponentDto project = db.components().insertPrivateProject();
@@ -701,8 +653,8 @@ public class ComponentTreeActionTest {
       .executeProtobuf(ComponentTreeWsResponse.class);
 
     assertThat(result.getComponentsList())
-      .extracting(Component::getKey, Component::getRefId, Component::getRefKey)
-      .containsExactlyInAnyOrder(tuple(projectCopy.getKey(), project.uuid(), project.getKey()));
+      .extracting(Component::getKey, Component::getRefKey)
+      .containsExactlyInAnyOrder(tuple(projectCopy.getKey(), project.getKey()));
   }
 
   @Test
@@ -728,8 +680,8 @@ public class ComponentTreeActionTest {
       .extracting(Component::getKey, Component::getBranch)
       .containsExactlyInAnyOrder(applicationBranch.getKey(), applicationBranch.getBranch());
     assertThat(result.getComponentsList())
-      .extracting(Component::getKey, Component::getBranch, Component::getRefId, Component::getRefKey)
-      .containsExactlyInAnyOrder(tuple(techProjectBranch.getKey(), projectBranch.getBranch(), projectBranch.uuid(), project.getKey()));
+      .extracting(Component::getKey, Component::getBranch, Component::getRefKey)
+      .containsExactlyInAnyOrder(tuple(techProjectBranch.getKey(), projectBranch.getBranch(), project.getKey()));
   }
 
   @Test
@@ -933,7 +885,7 @@ public class ComponentTreeActionTest {
     expectedException.expectMessage("Component key 'project-key' not found");
 
     ws.newRequest()
-      .setParam(DEPRECATED_PARAM_BASE_COMPONENT_KEY, "project-key")
+      .setParam(PARAM_COMPONENT, "project-key")
       .setParam(PARAM_METRIC_KEYS, "ncloc")
       .execute();
   }
@@ -988,22 +940,6 @@ public class ComponentTreeActionTest {
       .execute();
   }
 
-  @Test
-  public void fail_when_using_branch_uuid() {
-    ComponentDto project = db.components().insertPrivateProject();
-    userSession.logIn().addProjectPermission(UserRole.USER, project);
-    ComponentDto branch = db.components().insertProjectBranch(project);
-    insertNclocMetric();
-
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage(format("Component id '%s' not found", branch.uuid()));
-
-    ws.newRequest()
-      .setParam(DEPRECATED_PARAM_BASE_COMPONENT_ID, branch.uuid())
-      .setParam(PARAM_METRIC_KEYS, "ncloc")
-      .execute();
-  }
-
   private static MetricDto newMetricDto() {
     return MetricTesting.newMetricDto()
       .setWorstValue(null)
index 17d7c0c866ca36f031850506028b2f981edb1f39..ebe34f594a3eabad96f4615470ad945e4b237b87 100644 (file)
@@ -68,9 +68,8 @@ message SearchHistoryResponse {
 }
 
 message Component {
-  optional string id = 1;
+  reserved 1,3;
   optional string key = 2;
-  optional string refId = 3;
   optional string refKey = 4;
   optional string projectId = 5;
   optional string name = 6;