From: Nolwenn Cadic <98824442+Nolwenn-cadic-sonarsource@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:30:36 +0000 (+0200) Subject: SONAR-20787 Add telemetry about quality gate conditions and sonar way (#9743) X-Git-Tag: 10.3.0.82913~85 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2eaf4da9b14cc5bfa73719b660c5db706672d182;p=sonarqube.git SONAR-20787 Add telemetry about quality gate conditions and sonar way (#9743) --- diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/qualitygate/QualityGateConditionDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/qualitygate/QualityGateConditionDaoIT.java index 6a46ce044d4..aa5e1c27a5e 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/qualitygate/QualityGateConditionDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/qualitygate/QualityGateConditionDaoIT.java @@ -33,6 +33,7 @@ import org.sonar.db.metric.MetricDto; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.tuple; public class QualityGateConditionDaoIT { @@ -81,6 +82,20 @@ public class QualityGateConditionDaoIT { assertThat(underTest.selectForQualityGate(dbSession, "5")).isEmpty(); } + @Test + public void selectAll() { + MetricDto metric = dbTester.measures().insertMetric(t -> t.setEnabled(true)); + QualityGateConditionDto condition1 = insertQGCondition("uuid1", metric.getUuid()); + QualityGateConditionDto condition2 = insertQGCondition("uuid2", metric.getUuid()); + QualityGateConditionDto condition3 = insertQGCondition("uuid3", metric.getUuid()); + + assertThat(underTest.selectAll(dbSession)) + .extracting(QualityGateConditionDto::getUuid, QualityGateConditionDto::getMetricUuid) + .containsOnly(tuple(condition1.getUuid(), condition1.getMetricUuid()), + tuple(condition2.getUuid(), condition2.getMetricUuid()), + tuple(condition3.getUuid(), condition3.getMetricUuid())); + } + @Test public void testSelectByUuid() { QualityGateConditionDto condition = insertQGCondition("1", "2", "GT", "20"); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java index 7187d444538..2c412ff9bb3 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java @@ -34,6 +34,10 @@ public class QualityGateConditionDao implements Dao { return mapper(session).selectForQualityGate(qGateUuid); } + public Collection selectAll(DbSession session) { + return mapper(session).selectAll(); + } + public QualityGateConditionDto selectByUuid(String uuid, DbSession session) { return mapper(session).selectByUuid(uuid); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionMapper.java index 723bd22e96d..8b9efc7fc93 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateConditionMapper.java @@ -27,6 +27,8 @@ public interface QualityGateConditionMapper { List selectForQualityGate(String qGateUuid); + List selectAll(); + void update(QualityGateConditionDto newCondition); QualityGateConditionDto selectByUuid(String uuid); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateConditionMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateConditionMapper.xml index 2c57a73d936..0efc2c5d5b5 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateConditionMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualitygate/QualityGateConditionMapper.xml @@ -20,6 +20,13 @@ order by created_at asc + +