@@ -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); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |