From 6cae1ea47191bd94d85bb1b6f6596ce6121eed65 Mon Sep 17 00:00:00 2001 From: Matteo Mara Date: Tue, 6 Jun 2023 15:33:03 +0200 Subject: [PATCH] [SONAR-19509] Update the response example of the QG endpoints show and list with the caycStatus field --- .../java/org/sonar/server/qualitygate/ws/ListActionIT.java | 4 +++- .../java/org/sonar/server/qualitygate/ws/ShowActionIT.java | 2 ++ .../org/sonar/server/qualitygate/ws/list-example.json | 6 ++++-- .../org/sonar/server/qualitygate/ws/show-example.json | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ListActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ListActionIT.java index a09f872cf8a..94eededce33 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ListActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ListActionIT.java @@ -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(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ShowActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ShowActionIT.java index b28d10f96f9..eedca4b3f2e 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ShowActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/ShowActionIT.java @@ -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()) diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json index 683855bfbf8..1c07d960016 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/list-example.json @@ -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": { diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json index d27e328bf94..c960640c619 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/qualitygate/ws/show-example.json @@ -23,5 +23,6 @@ "delete": true, "manageConditions": true, "delegate": true - } + }, + "caycStatus": "non-compliant" } -- 2.39.5