]> source.dussan.org Git - sonarqube.git/commitdiff
[SONAR-19509] Update the response example of the QG endpoints show and list with...
authorMatteo Mara <matteo.mara@sonarsource.com>
Tue, 6 Jun 2023 13:33:03 +0000 (15:33 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 7 Jun 2023 20:02:43 +0000 (20:02 +0000)
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/main/resources/org/sonar/server/qualitygate/ws/list-example.json
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json

index a09f872cf8a87729919757efc8392970185ab7eb..94eededce332ac7b0d50065b4b2aa2b5348c4873 100644 (file)
@@ -209,8 +209,10 @@ public class ListActionIT {
   public void json_example() {
     userSession.logIn("admin").addPermission(ADMINISTER_QUALITY_GATES);
     QualityGateDto defaultQualityGate = db.qualityGates().insertQualityGate(qualityGate -> qualityGate.setName("Sonar way").setBuiltIn(true));
-    db.qualityGates().insertQualityGate(qualityGate -> qualityGate.setName("Sonar way - Without Coverage").setBuiltIn(false));
+    QualityGateDto otherQualityGate = db.qualityGates().insertQualityGate(qualityGate -> qualityGate.setName("Sonar way - Without Coverage").setBuiltIn(false));
     db.qualityGates().setDefaultQualityGate(defaultQualityGate);
+    when(qualityGateCaycChecker.checkCaycCompliant(any(), eq(defaultQualityGate.getUuid()))).thenReturn(COMPLIANT);
+    when(qualityGateCaycChecker.checkCaycCompliant(any(), eq(otherQualityGate.getUuid()))).thenReturn(NON_COMPLIANT);
 
     String response = ws.newRequest().execute().getInput();
 
index b28d10f96f9a5f44da8f7b9b9912492130606ba2..eedca4b3f2efa99a15066cb347e1c72f77352c55 100644 (file)
@@ -52,6 +52,7 @@ import static org.mockito.Mockito.when;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER_QUALITY_GATES;
 import static org.sonar.db.permission.GlobalPermission.ADMINISTER_QUALITY_PROFILES;
 import static org.sonar.server.qualitygate.QualityGateCaycStatus.COMPLIANT;
+import static org.sonar.server.qualitygate.QualityGateCaycStatus.NON_COMPLIANT;
 import static org.sonar.test.JsonAssert.assertJson;
 import static org.sonarqube.ws.Qualitygates.Actions;
 
@@ -303,6 +304,7 @@ public class ShowActionIT {
     MetricDto criticalViolationsMetric = db.measures().insertMetric(m -> m.setKey("tests"));
     db.qualityGates().addCondition(qualityGate, blockerViolationsMetric, c -> c.setOperator("GT").setErrorThreshold("0"));
     db.qualityGates().addCondition(qualityGate, criticalViolationsMetric, c -> c.setOperator("LT").setErrorThreshold("10"));
+    when(qualityGateCaycChecker.checkCaycCompliant(any(), any())).thenReturn(NON_COMPLIANT);
 
     String response = ws.newRequest()
       .setParam("name", qualityGate.getName())
index 683855bfbf89a51e9021c8aa48d24fc460de1c77..1c07d960016e465ea9f015f2c4db1911b6958309 100644 (file)
@@ -12,7 +12,8 @@
         "delete": false,
         "manageConditions": false,
         "delegate": false
-      }
+      },
+      "caycStatus": "compliant"
     },
     {
       "name": "Sonar way - Without Coverage",
@@ -26,7 +27,8 @@
         "delete": true,
         "manageConditions": true,
         "delegate": true
-      }
+      },
+      "caycStatus": "non-compliant"
     }
   ],
   "actions": {
index d27e328bf9442de3ba32cfa08117dfee628ecf22..c960640c619821d4ab4e1acfe82c8d7b7426390b 100644 (file)
@@ -23,5 +23,6 @@
     "delete": true,
     "manageConditions": true,
     "delegate": true
-  }
+  },
+  "caycStatus": "non-compliant"
 }