aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar/scanner
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-10-18 16:27:20 +0200
committersonartech <sonartech@sonarsource.com>2024-10-21 20:03:59 +0000
commitdd9ebd6a6f4b59c38ce1f1ca494f1d4231291513 (patch)
treea1a42bbd4e9d1f65a4b84b072be0ebd2e721d2ba /sonar-scanner-engine/src/test/java/org/sonar/scanner
parent691fe9681e59a01bca5e6079e74c2d3995ba3667 (diff)
downloadsonarqube-dd9ebd6a6f4b59c38ce1f1ca494f1d4231291513.tar.gz
sonarqube-dd9ebd6a6f4b59c38ce1f1ca494f1d4231291513.zip
SONAR-23250 Revert changes made in the plugin API for ActiveRule
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java8
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/LoadedActiveRuleTest.java38
3 files changed, 43 insertions, 5 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
index 14a5036e254..4072d462f92 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
@@ -31,7 +31,7 @@ import org.assertj.core.groups.Tuple;
import org.junit.Test;
import org.sonar.api.batch.rule.ActiveRule;
import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.batch.rule.LoadedActiveRule;
+import org.sonar.api.batch.rule.internal.DefaultActiveRule;
import org.sonar.api.batch.rule.internal.DefaultActiveRules;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
@@ -73,11 +73,11 @@ public class ActiveRulesProviderTest {
RuleKey.of("rule1", "rule1"), RuleKey.of("rule2", "rule2"), RuleKey.of("rule3", "rule3"));
Map<String, ActiveRule> activeRuleByKey = activeRules.findAll().stream().collect(Collectors.toMap(e -> e.ruleKey().rule(), e -> e));
- assertThat(activeRuleByKey.get("rule1").impacts())
+ assertThat(((DefaultActiveRule) activeRuleByKey.get("rule1")).impacts())
.containsExactlyInAnyOrderEntriesOf(Map.of(SoftwareQuality.MAINTAINABILITY, Severity.HIGH));
- assertThat(activeRuleByKey.get("rule2").impacts()).isEmpty();
- assertThat(activeRuleByKey.get("rule3").impacts()).isEmpty();
+ assertThat(((DefaultActiveRule) activeRuleByKey.get("rule2")).impacts()).isEmpty();
+ assertThat(((DefaultActiveRule) activeRuleByKey.get("rule3")).impacts()).isEmpty();
verify(loader).load("qp1");
verify(loader).load("qp2");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
index ad70dd74d47..59a49084742 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.stream.IntStream;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.api.batch.rule.LoadedActiveRule;
+import org.sonar.scanner.rule.LoadedActiveRule;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/LoadedActiveRuleTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/LoadedActiveRuleTest.java
new file mode 100644
index 00000000000..735e48e9473
--- /dev/null
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/LoadedActiveRuleTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.scanner.rule;
+
+import java.util.Map;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.sonar.api.issue.impact.Severity;
+import org.sonar.api.issue.impact.SoftwareQuality;
+
+class LoadedActiveRuleTest {
+
+ @Test
+ void should_return_expected_field() {
+ LoadedActiveRule loadedActiveRule = new LoadedActiveRule();
+ loadedActiveRule.setImpacts(Map.of(SoftwareQuality.MAINTAINABILITY, Severity.MEDIUM));
+
+ Assertions.assertThat(loadedActiveRule.getImpacts())
+ .containsExactlyInAnyOrderEntriesOf(Map.of(SoftwareQuality.MAINTAINABILITY, Severity.MEDIUM));
+ }
+}