]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-18746 Remove the field periods from the response of api/qualitygates/project_status
authorMatteo Mara <matteo.mara@sonarsource.com>
Tue, 28 Mar 2023 15:31:37 +0000 (17:31 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 29 Mar 2023 20:03:02 +0000 (20:03 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatter.java
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/project_status-example.json
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatterTest.java
sonar-ws/src/main/protobuf/ws-qualitygates.proto

index 54fc1d9db3227315e1a75c725fe15dee45b571ad..456ae51975c251e498bc29ae8610e8b12b4a1bcd 100644 (file)
@@ -96,6 +96,7 @@ public class ProjectStatusAction implements QualityGatesWsAction {
       .setSince("5.3")
       .setHandler(this)
       .setChangelog(
+        new Change("10.0", "The field 'periods' in the response is removed"),
         new Change("9.9", "'caycStatus' field is added to the response"),
         new Change("9.5", "The 'Execute Analysis' permission also allows to access the endpoint"),
         new Change("8.5", "The field 'periods' in the response is deprecated. Use 'period' instead"),
index e32b433b4826b8a1d65d2d7b6ebf585f4a6fb81f..b8715debe222b4f092b2ab0b8a5f0c7489336fb7 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.db.component.SnapshotDto;
 import org.sonar.server.qualitygate.QualityGateCaycStatus;
 import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
 import org.sonarqube.ws.Qualitygates.ProjectStatusResponse.NewCodePeriod;
-import org.sonarqube.ws.Qualitygates.ProjectStatusResponse.Period;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
@@ -81,7 +80,6 @@ public class QualityGateDetailsFormatter {
       return;
     }
 
-    Period.Builder periodsBuilder = Period.newBuilder();
     NewCodePeriod.Builder periodBuilder = NewCodePeriod.newBuilder();
 
     SnapshotDto snapshot = this.optionalSnapshot.get();
@@ -89,21 +87,19 @@ public class QualityGateDetailsFormatter {
     if (isNullOrEmpty(snapshot.getPeriodMode())) {
       return;
     }
-    periodsBuilder.setIndex(1);
-    periodsBuilder.setMode(snapshot.getPeriodMode());
+
     periodBuilder.setMode(snapshot.getPeriodMode());
     Long periodDate = snapshot.getPeriodDate();
     if (periodDate != null) {
       String formattedDateTime = formatDateTime(periodDate);
-      periodsBuilder.setDate(formattedDateTime);
       periodBuilder.setDate(formattedDateTime);
     }
     String periodModeParameter = snapshot.getPeriodModeParameter();
     if (!isNullOrEmpty(periodModeParameter)) {
-      periodsBuilder.setParameter(periodModeParameter);
+
       periodBuilder.setParameter(periodModeParameter);
     }
-    projectStatusBuilder.addPeriods(periodsBuilder);
+
     projectStatusBuilder.setPeriod(periodBuilder);
   }
 
index b17e84c2c7662a07af20dfac0c6ffb019755abc5..686493327cf7155c97b739a12a91209391e81f0a 100644 (file)
         "actualValue": "0"
       }
     ],
-    "periods": [
-      {
-        "index": 1,
-        "mode": "last_version",
-        "date": "2000-04-27T00:45:23+0200",
-        "parameter": "2015-12-07"
-      }
-    ],
     "period": {
         "mode": "last_version",
         "date": "2000-04-27T00:45:23+0200",
index ebf394c06d3a45ea7c10138e88c50101023acb78..ca7fec90ce62b90dd46879982b0a6e7b458997f2 100644 (file)
@@ -39,7 +39,7 @@ public class QualityGateDetailsFormatterTest {
   private QualityGateDetailsFormatter underTest;
 
   @Test
-  public void map_level_conditions_and_periods() throws IOException {
+  public void map_level_conditions_and_period() throws IOException {
     String measureData = IOUtils.toString(getClass().getResource("QualityGateDetailsFormatterTest/quality_gate_details.json"));
     SnapshotDto snapshot = new SnapshotDto()
       .setPeriodMode("last_version")
@@ -68,13 +68,11 @@ public class QualityGateDetailsFormatterTest {
     assertThat(conditions).extracting("errorThreshold").containsOnly("85", "0", "0");
     assertThat(conditions).extracting("actualValue").containsExactly("82.2985024398452", "1", "0");
 
-    // check periods
-    assertThat(result.getPeriodsCount()).isOne();
-    List<ProjectStatusResponse.Period> periods = result.getPeriodsList();
-    assertThat(periods).extracting("index").containsExactly(1);
-    assertThat(periods).extracting("mode").containsExactly("last_version");
-    assertThat(periods).extracting("parameter").containsExactly("2015-12-07");
-    assertThat(periods.get(0).getDate()).isEqualTo(formatDateTime(snapshot.getPeriodDate()));
+    // check period
+    ProjectStatusResponse.NewCodePeriod period = result.getPeriod();
+    assertThat(period).extracting("mode").isEqualTo("last_version");
+    assertThat(period).extracting("parameter").isEqualTo("2015-12-07");
+    assertThat(period.getDate()).isEqualTo(formatDateTime(snapshot.getPeriodDate()));
   }
 
   @Test
index 8d137726d1ccff4acefa63808f55debd0ddd99fc..8c9d4fbf96286ed43ba46da8c379234f875bd817 100644 (file)
@@ -33,7 +33,7 @@ message ProjectStatusResponse {
   message ProjectStatus {
     optional Status status = 1;
     repeated Condition conditions = 2;
-    repeated Period periods = 3;
+    reserved 3; //drop periods
     optional bool ignoredConditions = 4;
     optional NewCodePeriod period = 5;
     optional string caycStatus = 6;
@@ -55,13 +55,6 @@ message ProjectStatusResponse {
       optional string parameter = 3;
     }
 
-  message Period {
-    optional int32 index = 1;
-    optional string mode = 2;
-    optional string date = 3;
-    optional string parameter = 4;
-  }
-
   enum Status {
     OK = 1;
     WARN = 2;