use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultIssueTest method move_directory_issue_to_project_root.
@Test
public void move_directory_issue_to_project_root() {
SensorStorage storage = mock(SensorStorage.class);
DefaultIssue issue = new DefaultIssue(project, storage).at(new DefaultIssueLocation().on(new DefaultInputDir("foo", "src/main").setModuleBaseDir(project.getBaseDir())).message("Wrong way!")).forRule(RuleKey.of("repo", "rule")).overrideSeverity(Severity.BLOCKER);
assertThat(issue.primaryLocation().inputComponent()).isEqualTo(project);
assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule"));
assertThat(issue.primaryLocation().textRange()).isNull();
assertThat(issue.primaryLocation().message()).isEqualTo("[src/main] Wrong way!");
assertThat(issue.overriddenSeverity()).isEqualTo(Severity.BLOCKER);
issue.save();
verify(storage).store(issue);
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultAdHocRuleTest method fail_to_store_if_no_rule_id.
@Test
public void fail_to_store_if_no_rule_id() {
SensorStorage storage = mock(SensorStorage.class);
NewAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId(" ").name("name").description("desc").severity(Severity.BLOCKER).type(RuleType.CODE_SMELL);
assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Rule id is mandatory");
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultAdHocRuleTest method store.
@Test
public void store() {
SensorStorage storage = mock(SensorStorage.class);
DefaultAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId("ruleId").name("name").description("desc").severity(Severity.BLOCKER).type(RuleType.CODE_SMELL);
rule.save();
assertThat(rule.engineId()).isEqualTo("engine");
assertThat(rule.ruleId()).isEqualTo("ruleId");
assertThat(rule.name()).isEqualTo("name");
assertThat(rule.description()).isEqualTo("desc");
assertThat(rule.severity()).isEqualTo(Severity.BLOCKER);
assertThat(rule.type()).isEqualTo(RuleType.CODE_SMELL);
verify(storage).store(any(DefaultAdHocRule.class));
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultAdHocRuleTest method fail_to_store_if_no_type.
@Test
public void fail_to_store_if_no_type() {
SensorStorage storage = mock(SensorStorage.class);
NewAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId("ruleId").name("name").description("desc").severity(Severity.BLOCKER);
assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Type is mandatory");
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultAdHocRuleTest method fail_to_store_if_no_severity.
@Test
public void fail_to_store_if_no_severity() {
SensorStorage storage = mock(SensorStorage.class);
NewAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId("ruleId").name("name").description("desc").type(RuleType.CODE_SMELL);
assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Severity is mandatory");
}
Aggregations