diff options
Diffstat (limited to 'sonar-plugin-api-impl')
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); + } } |