Search in sources :

Example 1 with IssueLocation

use of org.sonar.scanner.protocol.output.ScannerReport.IssueLocation in project sonarqube by SonarSource.

the class MultilineIssuesMediumTest method testFlowWithSingleLocation.

@Test
public void testFlowWithSingleLocation() throws Exception {
    List<Issue> issues = result.issuesFor(result.inputFile("xources/hello/Multiple.xoo"));
    assertThat(issues).hasSize(1);
    Issue issue = issues.get(0);
    assertThat(issue.getMsg()).isEqualTo("Primary location");
    assertThat(issue.getTextRange().getStartLine()).isEqualTo(6);
    assertThat(issue.getTextRange().getStartOffset()).isEqualTo(23);
    assertThat(issue.getTextRange().getEndLine()).isEqualTo(6);
    assertThat(issue.getTextRange().getEndOffset()).isEqualTo(50);
    assertThat(issue.getFlowList()).hasSize(1);
    Flow flow = issue.getFlow(0);
    assertThat(flow.getLocationList()).hasSize(1);
    IssueLocation additionalLocation = flow.getLocation(0);
    assertThat(additionalLocation.getMsg()).isEqualTo("Flow step #1");
    assertThat(additionalLocation.getTextRange().getStartLine()).isEqualTo(7);
    assertThat(additionalLocation.getTextRange().getStartOffset()).isEqualTo(26);
    assertThat(additionalLocation.getTextRange().getEndLine()).isEqualTo(7);
    assertThat(additionalLocation.getTextRange().getEndOffset()).isEqualTo(53);
}
Also used : Issue(org.sonar.scanner.protocol.output.ScannerReport.Issue) IssueLocation(org.sonar.scanner.protocol.output.ScannerReport.IssueLocation) Flow(org.sonar.scanner.protocol.output.ScannerReport.Flow) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Flow (org.sonar.scanner.protocol.output.ScannerReport.Flow)1 Issue (org.sonar.scanner.protocol.output.ScannerReport.Issue)1 IssueLocation (org.sonar.scanner.protocol.output.ScannerReport.IssueLocation)1