aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>2023-04-27 10:24:44 +0200
committersonartech <sonartech@sonarsource.com>2023-04-28 20:02:58 +0000
commit04039ecb04d210143d247e01a75afbeab7b324ee (patch)
tree776abd848fbf7d36f1259fd82bdf0a7eb74bf7ad /sonar-plugin-api-impl
parent23063324622502be596ce9bb613eaa3d993aca19 (diff)
downloadsonarqube-04039ecb04d210143d247e01a75afbeab7b324ee.tar.gz
sonarqube-04039ecb04d210143d247e01a75afbeab7b324ee.zip
SONAR-19050 Add tests to fix coverage
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java9
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java10
2 files changed, 18 insertions, 1 deletions
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
index 25cb562857d..0a71d62ef34 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultExternalIssueTest.java
@@ -30,6 +30,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.batch.sensor.internal.SensorStorage;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
@@ -164,4 +165,12 @@ public class DefaultExternalIssueTest {
.hasMessageContaining("Severity is mandatory");
}
+ @Test
+ public void characteristic_shouldThrowIllegalStateException() {
+ SensorStorage storage = mock(SensorStorage.class);
+ DefaultExternalIssue issue = new DefaultExternalIssue(project, storage);
+ assertThatThrownBy(issue::characteristic).isInstanceOf(IllegalStateException.class);
+ assertThatThrownBy(() -> issue.characteristic(CodeCharacteristic.CLEAR)).isInstanceOf(IllegalStateException.class);
+ }
+
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java
index 945b145fedf..2e8036cc336 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/rule/internal/DefaultAdHocRuleTest.java
@@ -23,6 +23,7 @@ import org.junit.Test;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.sensor.rule.NewAdHocRule;
+import org.sonar.api.code.CodeCharacteristic;
import org.sonar.api.rules.RuleType;
import static org.assertj.core.api.Assertions.assertThat;
@@ -43,7 +44,7 @@ public class DefaultAdHocRuleTest {
.description("desc")
.severity(Severity.BLOCKER)
.type(RuleType.CODE_SMELL);
- rule.save();
+ rule.save();
assertThat(rule.engineId()).isEqualTo("engine");
assertThat(rule.ruleId()).isEqualTo("ruleId");
@@ -149,4 +150,11 @@ public class DefaultAdHocRuleTest {
.hasMessageContaining("Type is mandatory");
}
+ @Test
+ public void characteristic_shouldThrowIllegalStateException() {
+ SensorStorage storage = mock(SensorStorage.class);
+ DefaultAdHocRule rule = new DefaultAdHocRule(storage);
+ assertThatThrownBy(() -> rule.characteristic(CodeCharacteristic.CLEAR)).isInstanceOf(IllegalStateException.class);
+ assertThatThrownBy(() -> rule.characteristic()).isInstanceOf(IllegalStateException.class);
+ }
}