]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-18752 Drop the id field in the response of multiple endpoints
authorMatteo Mara <matteo.mara@sonarsource.com>
Thu, 30 Mar 2023 06:20:41 +0000 (08:20 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 30 Mar 2023 20:03:06 +0000 (20:03 +0000)
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/GetByProjectActionIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ListActionIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ShowActionIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/SearchActionIT.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/GetByProjectAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ListAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/usergroups/ws/search-example.json

index d1027c778ea0dc7abbbc9f2c6454aecf6ae7db44..ed2702f76b6d2f9c2d496538b8720ee300edf58e 100644 (file)
@@ -38,7 +38,6 @@ import org.sonar.server.ws.WsActionTester;
 import org.sonarqube.ws.Qualitygates;
 import org.sonarqube.ws.Qualitygates.GetByProjectResponse;
 
-import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.assertj.core.api.Assertions.tuple;
@@ -97,7 +96,6 @@ public class GetByProjectActionIT {
       .executeProtobuf(GetByProjectResponse.class);
 
     Qualitygates.QualityGate qualityGate = result.getQualityGate();
-    assertThat(qualityGate.getId()).isEqualTo(dbQualityGate.getUuid());
     assertThat(qualityGate.getName()).isEqualTo(dbQualityGate.getName());
     assertThat(qualityGate.getDefault()).isTrue();
   }
index 446ba750b74295be8836bcf6f3b92434b38f6a8c..b5f66629aeeb614a60f46ad96f5663ca0aa0c331 100644 (file)
@@ -80,10 +80,10 @@ public class ListActionIT {
       .executeProtobuf(ListWsResponse.class);
 
     assertThat(response.getQualitygatesList())
-      .extracting(QualityGate::getId, QualityGate::getName, QualityGate::getIsDefault)
+      .extracting(QualityGate::getName, QualityGate::getIsDefault)
       .containsExactlyInAnyOrder(
-        tuple(defaultQualityGate.getUuid(), defaultQualityGate.getName(), true),
-        tuple(otherQualityGate.getUuid(), otherQualityGate.getName(), false));
+        tuple(defaultQualityGate.getName(), true),
+        tuple(otherQualityGate.getName(), false));
   }
 
   @Test
@@ -96,10 +96,10 @@ public class ListActionIT {
       .executeProtobuf(ListWsResponse.class);
 
     assertThat(response.getQualitygatesList())
-      .extracting(QualityGate::getId, QualityGate::getIsBuiltIn)
+      .extracting(QualityGate::getName, QualityGate::getIsBuiltIn)
       .containsExactlyInAnyOrder(
-        tuple(qualityGate1.getUuid(), true),
-        tuple(qualityGate2.getUuid(), false));
+        tuple(qualityGate1.getName(), true),
+        tuple(qualityGate2.getName(), false));
   }
 
   @Test
@@ -117,11 +117,11 @@ public class ListActionIT {
       .executeProtobuf(ListWsResponse.class);
 
     assertThat(response.getQualitygatesList())
-      .extracting(QualityGate::getId, QualityGate::getCaycStatus)
+      .extracting(QualityGate::getName, QualityGate::getCaycStatus)
       .containsExactlyInAnyOrder(
-        tuple(qualityGate1.getUuid(), COMPLIANT.toString()),
-        tuple(qualityGate2.getUuid(), NON_COMPLIANT.toString()),
-        tuple(qualityGate3.getUuid(), OVER_COMPLIANT.toString()));
+        tuple(qualityGate1.getName(), COMPLIANT.toString()),
+        tuple(qualityGate2.getName(), NON_COMPLIANT.toString()),
+        tuple(qualityGate3.getName(), OVER_COMPLIANT.toString()));
   }
 
   @Test
index 01c45c7ff3d646c7e30efd519c9b7677f1c61688..b28d10f96f9a5f44da8f7b9b9912492130606ba2 100644 (file)
@@ -85,7 +85,6 @@ public class ShowActionIT {
       .setParam("name", qualityGate.getName())
       .executeProtobuf(ShowWsResponse.class);
 
-    assertThat(response.getId()).isEqualTo(qualityGate.getUuid());
     assertThat(response.getName()).isEqualTo(qualityGate.getName());
     assertThat(response.getIsBuiltIn()).isFalse();
     assertThat(response.getConditionsList()).hasSize(2);
@@ -122,7 +121,7 @@ public class ShowActionIT {
   }
 
   @Test
-  public void show_by_id() {
+  public void show_by_name() {
     QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
     db.qualityGates().setDefaultQualityGate(qualityGate);
 
@@ -130,7 +129,6 @@ public class ShowActionIT {
       .setParam("name", qualityGate.getName())
       .executeProtobuf(ShowWsResponse.class);
 
-    assertThat(response.getId()).isEqualTo(qualityGate.getUuid());
     assertThat(response.getName()).isEqualTo(qualityGate.getName());
   }
 
@@ -143,7 +141,6 @@ public class ShowActionIT {
       .setParam("name", qualityGate.getName())
       .executeProtobuf(ShowWsResponse.class);
 
-    assertThat(response.getId()).isEqualTo(qualityGate.getUuid());
     assertThat(response.getName()).isEqualTo(qualityGate.getName());
     assertThat(response.getConditionsList()).isEmpty();
   }
index 93ebda9a07cfb0b2ee17a46d0ef533db1cd7d7d5..c8951c475cbcfa9d15666b525a5bd9384269d9cf 100644 (file)
@@ -83,6 +83,7 @@ public class SearchActionIT {
     assertThat(action.responseExampleAsString()).isNotEmpty();
     assertThat(action.params()).hasSize(5);
     assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
+      tuple("10.0", "Field 'id' in the response has been removed"),
       tuple("10.0", "New parameter 'managed' to optionally search by managed status"),
       tuple("10.0", "Response includes 'managed' field."),
       tuple("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
@@ -246,23 +247,23 @@ public class SearchActionIT {
     loginAsAdmin();
 
     assertThat(call(ws.newRequest()).getGroupsList())
-      .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
-      .containsOnly(tuple(true, true, true, true, true));
+      .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+      .containsOnly(tuple(true, true, true, true));
     assertThat(call(ws.newRequest().setParam(FIELDS, "")).getGroupsList())
-      .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
-      .containsOnly(tuple(true, true, true, true, true));
+      .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+      .containsOnly(tuple(true, true, true, true));
     assertThat(call(ws.newRequest().setParam(FIELDS, "name")).getGroupsList())
-      .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
-      .containsOnly(tuple(true, true, false, false, false));
+      .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+      .containsOnly(tuple(true, false, false, false));
     assertThat(call(ws.newRequest().setParam(FIELDS, "description")).getGroupsList())
-      .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
-      .containsOnly(tuple(true, false, true, false, false));
+      .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+      .containsOnly(tuple(false, true, false, false));
     assertThat(call(ws.newRequest().setParam(FIELDS, "membersCount")).getGroupsList())
-      .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
-      .containsOnly(tuple(true, false, false, true, false));
+      .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+      .containsOnly(tuple(false, false, true, false));
     assertThat(call(ws.newRequest().setParam(FIELDS, "managed")).getGroupsList())
-      .extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
-      .containsOnly(tuple(true, false, false, false, true));
+      .extracting(Group::hasName, Group::hasDescription, Group::hasMembersCount, Group::hasManaged)
+      .containsOnly(tuple(false, false, false, true));
   }
 
   @Test
index 4ae6c5dd037a0020c27b9bbe3edcac1e4837c947..3b3f53c96bf0b7f2c126a9b97404043c02a1de24 100644 (file)
@@ -69,6 +69,7 @@ public class GetByProjectAction implements QualityGatesWsAction {
       .setResponseExample(getClass().getResource("get_by_project-example.json"))
       .setHandler(this)
       .setChangelog(
+        new Change("10.0", "Field 'id' in the response has been removed"),
         new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
         new Change("6.6", "The parameter 'projectId' has been removed"),
         new Change("6.6", "The parameter 'projectKey' has been renamed to 'project'"),
@@ -100,7 +101,6 @@ public class GetByProjectAction implements QualityGatesWsAction {
     GetByProjectResponse.Builder response = GetByProjectResponse.newBuilder();
 
     response.getQualityGateBuilder()
-      .setId(qg.getUuid())
       .setName(qg.getName())
       .setDefault(qg.isDefault());
 
index 8a6362d1686f0d507bd6f541432977611f091519..4841361bb546bc79ddc4bd052ad6a64e07772590 100644 (file)
@@ -59,6 +59,7 @@ public class ListAction implements QualityGatesWsAction {
       .setSince("4.3")
       .setResponseExample(Resources.getResource(this.getClass(), "list-example.json"))
       .setChangelog(
+        new Change("10.0", "Field 'id' in the response has been removed"),
         new Change("9.9", "'caycStatus' field is added on quality gate"),
         new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
         new Change("7.0", "'isDefault' field is added on quality gate"),
@@ -84,7 +85,6 @@ public class ListAction implements QualityGatesWsAction {
       .setActions(ListWsResponse.RootActions.newBuilder().setCreate(wsSupport.isQualityGateAdmin()))
       .addAllQualitygates(qualityGates.stream()
         .map(qualityGate -> QualityGate.newBuilder()
-          .setId(qualityGate.getUuid())
           .setName(qualityGate.getName())
           .setIsDefault(qualityGate.getUuid().equals(defaultUuid))
           .setIsBuiltIn(qualityGate.isBuiltIn())
index 361b793ad1ed96e48efd2f9d5b03ab706c017cb6..3920cb3c2ac4b9303f24eb8ed9df274f55df9498 100644 (file)
@@ -68,6 +68,7 @@ public class ShowAction implements QualityGatesWsAction {
       .setSince("4.3")
       .setResponseExample(Resources.getResource(this.getClass(), "show-example.json"))
       .setChangelog(
+        new Change("10.0", "Field 'id' in the response has been removed"),
         new Change("10.0", "Parameter 'id' is removed. Use 'name' instead."),
         new Change("9.9", "'caycStatus' field is added to the response"),
         new Change("8.4", "Parameter 'id' is deprecated. Format changes from integer to string. Use 'name' instead."),
@@ -109,7 +110,6 @@ public class ShowAction implements QualityGatesWsAction {
   private ShowWsResponse buildResponse(DbSession dbSession, QualityGateDto qualityGate, QualityGateDto defaultQualityGate, Collection<QualityGateConditionDto> conditions,
     Map<String, MetricDto> metricsByUuid, QualityGateCaycStatus caycStatus) {
     return ShowWsResponse.newBuilder()
-      .setId(qualityGate.getUuid())
       .setName(qualityGate.getName())
       .setIsBuiltIn(qualityGate.isBuiltIn())
       .setCaycStatus(caycStatus.toString())
index f34b123314acd1ebf2eeb762f6d5e284a7f8c54c..5cc43f25ef70010cedb97e661eba052017b9bcf6 100644 (file)
@@ -85,6 +85,7 @@ public class SearchAction implements UserGroupsWsAction {
       .addPagingParams(100, MAX_PAGE_SIZE)
       .addSearchQuery("sonar-users", "names")
       .setChangelog(
+        new Change("10.0", "Field 'id' in the response has been removed"),
         new Change("10.0", "New parameter 'managed' to optionally search by managed status"),
         new Change("10.0", "Response includes 'managed' field."),
         new Change("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
@@ -176,7 +177,6 @@ public class SearchAction implements UserGroupsWsAction {
 
   private static Group toWsGroup(GroupDto group, Integer memberCount, Boolean isManaged, Set<String> fields, boolean isDefault) {
     Group.Builder groupBuilder = Group.newBuilder()
-      .setId(group.getUuid())
       .setDefault(isDefault);
     if (fields.contains(FIELD_NAME)) {
       groupBuilder.setName(group.getName());
index a2bd06211c48689c078549f345939bac3b2d484b..b33f9f15fe839e0f31d65793b4e322baf6ff5dfa 100644 (file)
@@ -6,7 +6,6 @@
   },
   "groups": [
     {
-      "id": "AU-Tpxb--iU5OvuD2FLy",
       "name": "sonar-users",
       "description": "Users",
       "membersCount": 17,
@@ -14,7 +13,6 @@
       "managed": false
     },
     {
-      "id": "AU-Tpxb--iU5OvuD2FLz",
       "name": "administrators",
       "description": "Administrators",
       "membersCount": 2,