Search in sources :

Example 1 with DefaultExternalIssue

use of org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue in project sonarqube by SonarSource.

the class IssuePublisherTest method add_external_issue_to_cache.

@Test
public void add_external_issue_to_cache() {
    ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
    initModuleIssues();
    DefaultExternalIssue issue = new DefaultExternalIssue(project).at(new DefaultIssueLocation().on(file).at(file.selectLine(3)).message("Foo")).type(RuleType.BUG).forRule(SQUID_RULE_KEY).severity(org.sonar.api.batch.rule.Severity.CRITICAL);
    moduleIssues.initAndAddExternalIssue(issue);
    ArgumentCaptor<ScannerReport.ExternalIssue> argument = ArgumentCaptor.forClass(ScannerReport.ExternalIssue.class);
    verify(reportPublisher.getWriter()).appendComponentExternalIssue(eq(file.scannerId()), argument.capture());
    assertThat(argument.getValue().getSeverity()).isEqualTo(org.sonar.scanner.protocol.Constants.Severity.CRITICAL);
}
Also used : DefaultExternalIssue(org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue) DefaultIssueLocation(org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation) DefaultExternalIssue(org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue) ScannerReport(org.sonar.scanner.protocol.output.ScannerReport) Test(org.junit.Test)

Example 2 with DefaultExternalIssue

use of org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue in project sonarqube by SonarSource.

the class DefaultSensorStorageTest method should_save_external_issue.

@Test
public void should_save_external_issue() {
    InputFile file = new TestInputFileBuilder("foo", "src/Foo.php").build();
    DefaultExternalIssue externalIssue = new DefaultExternalIssue(project).at(new DefaultIssueLocation().on(file));
    underTest.store(externalIssue);
    ArgumentCaptor<ExternalIssue> argumentCaptor = ArgumentCaptor.forClass(ExternalIssue.class);
    verify(moduleIssues).initAndAddExternalIssue(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue()).isEqualTo(externalIssue);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultExternalIssue(org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue) ExternalIssue(org.sonar.api.batch.sensor.issue.ExternalIssue) DefaultIssueLocation(org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation) DefaultExternalIssue(org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DefaultExternalIssue (org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue)2 DefaultIssueLocation (org.sonar.api.batch.sensor.issue.internal.DefaultIssueLocation)2 InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)1 ExternalIssue (org.sonar.api.batch.sensor.issue.ExternalIssue)1 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)1