Search in sources :

Example 1 with PostJobIssue

use of org.sonar.api.batch.postjob.issue.PostJobIssue in project sonarqube by SonarSource.

the class DefaultPostJobContextTest method testIssues.

@Test
public void testIssues() throws IOException {
    when(analysisMode.isIssues()).thenReturn(true);
    assertThat(context.settings()).isSameAs(settings);
    TrackedIssue defaultIssue = new TrackedIssue();
    defaultIssue.setComponentKey("foo:src/Foo.php");
    defaultIssue.setGap(2.0);
    defaultIssue.setNew(true);
    defaultIssue.setKey("xyz");
    defaultIssue.setStartLine(1);
    defaultIssue.setMessage("msg");
    defaultIssue.setSeverity("BLOCKER");
    when(issueCache.all()).thenReturn(Arrays.asList(defaultIssue));
    PostJobIssue issue = context.issues().iterator().next();
    assertThat(issue.componentKey()).isEqualTo("foo:src/Foo.php");
    assertThat(issue.isNew()).isTrue();
    assertThat(issue.key()).isEqualTo("xyz");
    assertThat(issue.line()).isEqualTo(1);
    assertThat(issue.message()).isEqualTo("msg");
    assertThat(issue.severity()).isEqualTo(Severity.BLOCKER);
    assertThat(issue.inputComponent()).isNull();
    String moduleKey = "foo";
    componentStore.put(TestInputFileBuilder.newDefaultInputModule("foo", temp.newFolder()));
    componentStore.put(new TestInputFileBuilder(moduleKey, "src/Foo.php").build());
    assertThat(issue.inputComponent()).isNotNull();
}
Also used : TrackedIssue(org.sonar.scanner.issue.tracking.TrackedIssue) TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) PostJobIssue(org.sonar.api.batch.postjob.issue.PostJobIssue) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)1 PostJobIssue (org.sonar.api.batch.postjob.issue.PostJobIssue)1 TrackedIssue (org.sonar.scanner.issue.tracking.TrackedIssue)1