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();
}
Aggregations