aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/test
diff options
context:
space:
mode:
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>2024-10-04 11:38:02 +0200
committersonartech <sonartech@sonarsource.com>2024-10-16 20:03:00 +0000
commita0b64b247f0cc23c837ba09961c27dcafed1cca8 (patch)
tree9f614a4faf4ce2adc3032d5d817c3e516c25c64f /server/sonar-db-dao/src/test
parent108a542c3248cb24a1c7417dfad693f51e7d4b50 (diff)
downloadsonarqube-a0b64b247f0cc23c837ba09961c27dcafed1cca8.tar.gz
sonarqube-a0b64b247f0cc23c837ba09961c27dcafed1cca8.zip
SONAR-23250 Add facilitator method for impacts
Diffstat (limited to 'server/sonar-db-dao/src/test')
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDtoTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDtoTest.java
new file mode 100644
index 00000000000..aa652fbd18d
--- /dev/null
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDtoTest.java
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.qualityprofile;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.sonar.api.issue.impact.Severity;
+import org.sonar.api.issue.impact.SoftwareQuality;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class ActiveRuleDtoTest {
+
+ @Test
+ void setImpacts_shouldStoreAsString() {
+ ActiveRuleDto activeRuleDto = new ActiveRuleDto();
+ Map<SoftwareQuality, Severity> map = new LinkedHashMap<>();
+ map.put(SoftwareQuality.MAINTAINABILITY, Severity.INFO);
+ map.put(SoftwareQuality.RELIABILITY, Severity.INFO);
+
+ activeRuleDto.setImpacts(map);
+
+ assertThat(activeRuleDto.getImpactsString()).isEqualTo("{\"MAINTAINABILITY\":\"INFO\",\"RELIABILITY\":\"INFO\"}");
+ assertThat(activeRuleDto.getImpacts()).containsEntry(SoftwareQuality.MAINTAINABILITY, Severity.INFO)
+ .containsEntry(SoftwareQuality.RELIABILITY, Severity.INFO);
+ }
+
+ @Test
+ void setImpacts_shouldReturnEmpty() {
+ ActiveRuleDto activeRuleDto = new ActiveRuleDto();
+ Map<SoftwareQuality, Severity> map = new LinkedHashMap<>();
+ activeRuleDto.setImpacts(map);
+
+ assertThat(activeRuleDto.getImpactsString()).isNull();
+ assertThat(activeRuleDto.getImpacts()).isEmpty();
+ }
+
+}