aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java12
-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
3 files changed, 29 insertions, 2 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java
index 763be4b20ad..80d15a5257a 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java
@@ -25,9 +25,11 @@ import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -70,7 +72,8 @@ public class DefaultIssueTest {
.setUpdateDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-20"))
.setCloseDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-21"))
.setSelectedAt(1400000000000L)
- .setRuleDescriptionContextKey(TEST_CONTEXT_KEY);
+ .setRuleDescriptionContextKey(TEST_CONTEXT_KEY)
+ .setType(RuleType.BUG);
assertThat((Object) issue.getLocations()).isEqualTo("loc");
assertThat(issue.locationsChanged()).isTrue();
@@ -105,6 +108,7 @@ public class DefaultIssueTest {
assertThat(issue.closeDate()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-21"));
assertThat(issue.selectedAt()).isEqualTo(1400000000000L);
assertThat(issue.getRuleDescriptionContextKey()).contains(TEST_CONTEXT_KEY);
+ assertThat(issue.type()).isEqualTo(RuleType.BUG);
}
@Test
@@ -298,4 +302,10 @@ public class DefaultIssueTest {
assertThat(defaultIssue.isQuickFixAvailable()).isFalse();
}
+
+ @Test
+ public void characteristic_shouldThrowIllegalStateException() {
+ DefaultIssue defaultIssue = new DefaultIssue();
+ assertThatThrownBy(() -> defaultIssue.characteristic()).isInstanceOf(IllegalStateException.class);
+ }
}
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);
+ }
}