use of org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation in project sonarqube by SonarSource.
the class ModuleIssuesTest method use_severity_from_active_rule_if_no_severity_on_issue.
@Test
public void use_severity_from_active_rule_if_no_severity_on_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("Foo")).forRule(SQUID_RULE_KEY);
when(filters.accept(anyString(), any(ScannerReport.Issue.class))).thenReturn(true);
moduleIssues.initAndAddIssue(issue);
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.INFO);
}
use of org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation in project sonarqube by SonarSource.
the class ModuleIssuesTest method fail_on_unknown_rule.
@Test
public void fail_on_unknown_rule() {
initModuleIssues();
DefaultIssue issue = new DefaultIssue().at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("Foo")).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 use_rule_name_if_no_message.
@Test
public void use_rule_name_if_no_message() {
ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
activeRulesBuilder.create(SQUID_RULE_KEY).setSeverity(Severity.INFO).setName(SQUID_RULE_NAME).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(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().getMsg()).isEqualTo("Avoid Cycle");
}
Aggregations