use of org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation in project sonarqube by SonarSource.
the class ModuleIssuesTest method filter_issue.
@Test
public void filter_issue() {
ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
activeRulesBuilder.create(SQUID_RULE_KEY).setSeverity(Severity.INFO).activate();
initModuleIssues();
DefaultIssue issue = new DefaultIssue().at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("")).forRule(SQUID_RULE_KEY);
when(filters.accept(anyString(), any(ScannerReport.Issue.class))).thenReturn(false);
boolean added = moduleIssues.initAndAddIssue(issue);
assertThat(added).isFalse();
verifyZeroInteractions(reportPublisher);
}
use of org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation in project sonarqube by SonarSource.
the class ModuleIssuesTest method ignore_null_rule_of_active_rule.
@Test
public void ignore_null_rule_of_active_rule() {
ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
activeRulesBuilder.create(SQUID_RULE_KEY).activate();
initModuleIssues();
DefaultIssue issue = new DefaultIssue().at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("Foo")).forRule(SQUID_RULE_KEY);
boolean added = moduleIssues.initAndAddIssue(issue);
assertThat(added).isFalse();
verifyZeroInteractions(reportPublisher);
}
use of org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation in project sonarqube by SonarSource.
the class ModuleIssuesTest method ignore_null_active_rule.
@Test
public void ignore_null_active_rule() {
ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
initModuleIssues();
DefaultIssue issue = new DefaultIssue().at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("Foo")).forRule(SQUID_RULE_KEY);
boolean added = moduleIssues.initAndAddIssue(issue);
assertThat(added).isFalse();
verifyZeroInteractions(reportPublisher);
}
use of org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation in project sonarqube by SonarSource.
the class ModuleIssuesTest method fail_if_rule_has_no_name_and_issue_has_no_message.
@Test
public void fail_if_rule_has_no_name_and_issue_has_no_message() {
ruleBuilder.add(SQUID_RULE_KEY).setInternalKey(SQUID_RULE_KEY.rule());
initModuleIssues();
DefaultIssue issue = new DefaultIssue().at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("")).forRule(SQUID_RULE_KEY);
try {
moduleIssues.initAndAddIssue(issue);
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(MessageException.class);
}
verifyZeroInteractions(reportPublisher);
}
use of org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation in project sonarqube by SonarSource.
the class ModuleIssuesTest method add_issue_to_cache.
@Test
public void add_issue_to_cache() {
ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
activeRulesBuilder.create(SQUID_RULE_KEY).setSeverity(Severity.INFO).activate();
initModuleIssues();
DefaultIssue issue = new DefaultIssue().at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("Foo")).forRule(SQUID_RULE_KEY).overrideSeverity(org.sonar.api.batch.rule.Severity.CRITICAL);
when(filters.accept(anyString(), any(ScannerReport.Issue.class))).thenReturn(true);
boolean added = moduleIssues.initAndAddIssue(issue);
assertThat(added).isTrue();
ArgumentCaptor<ScannerReport.Issue> argument = ArgumentCaptor.forClass(ScannerReport.Issue.class);
verify(reportPublisher.getWriter()).appendComponentIssue(eq(file.batchId()), argument.capture());
assertThat(argument.getValue().getSeverity()).isEqualTo(org.sonar.scanner.protocol.Constants.Severity.CRITICAL);
}
Aggregations