use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultIssueTest method default_issue_has_no_quickfix.
@Test
public void default_issue_has_no_quickfix() {
SensorStorage storage = mock(SensorStorage.class);
DefaultIssue issue = new DefaultIssue(project, storage);
assertThat(issue.isQuickFixAvailable()).isFalse();
}
use of org.sonar.api.batch.sensor.internal.SensorStorage in project sonarqube by SonarSource.
the class DefaultIssueTest method issue_can_have_quickfix.
@Test
public void issue_can_have_quickfix() {
SensorStorage storage = mock(SensorStorage.class);
DefaultIssue issue = new DefaultIssue(project, storage).setQuickFixAvailable(true);
assertThat(issue.isQuickFixAvailable()).isTrue();
}
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 DefaultMeasureTest method build_file_measure.
@Test
public void build_file_measure() {
SensorStorage storage = Mockito.mock(SensorStorage.class);
DefaultMeasure<Integer> newMeasure = new DefaultMeasure<Integer>(storage).forMetric(CoreMetrics.LINES).on(new TestInputFileBuilder("foo", "src/Foo.php").build()).withValue(3);
Assertions.assertThat(newMeasure.inputComponent()).isEqualTo(new TestInputFileBuilder("foo", "src/Foo.php").build());
Assertions.assertThat(newMeasure.metric()).isEqualTo(CoreMetrics.LINES);
Assertions.assertThat(newMeasure.value()).isEqualTo(3);
newMeasure.save();
Mockito.verify(storage).store(newMeasure);
}
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