use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class DefaultProjectIssuesTest method toTrackedIssue.
private TrackedIssue toTrackedIssue(DefaultIssue issue) {
TrackedIssue trackedIssue = new TrackedIssue();
trackedIssue.setKey(issue.key());
trackedIssue.setRuleKey(issue.ruleKey());
trackedIssue.setComponentKey(issue.componentKey());
trackedIssue.setSeverity(issue.severity());
trackedIssue.setResolution(issue.resolution());
return trackedIssue;
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class IssueCacheTest method createIssue.
private TrackedIssue createIssue(String key, String componentKey, String severity) {
TrackedIssue issue = new TrackedIssue();
issue.setKey(key);
issue.setComponentKey(componentKey);
issue.setSeverity(severity);
return issue;
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class IssueCacheTest method should_get_all_issues.
@Test
public void should_get_all_issues() {
IssueCache cache = new IssueCache(caches);
TrackedIssue issue1 = createIssue("111", "org.struts.Action", Severity.BLOCKER);
TrackedIssue issue2 = createIssue("222", "org.struts.Filter", Severity.INFO);
cache.put(issue1).put(issue2);
List<TrackedIssue> issues = ImmutableList.copyOf(cache.all());
assertThat(issues).containsOnly(issue1, issue2);
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class IssueModeAndReportsMediumTest method testIssueTracking.
@Test
public void testIssueTracking() throws Exception {
File projectDir = copyProject("/mediumtest/xoo/sample");
TaskResult result = tester.newScanTask(new File(projectDir, "sonar-project.properties")).start();
int newIssues = 0;
int openIssues = 0;
int resolvedIssue = 0;
for (TrackedIssue issue : result.trackedIssues()) {
System.out.println(issue.getMessage() + " " + issue.key() + " " + issue.getRuleKey() + " " + issue.isNew() + " " + issue.resolution() + " " + issue.componentKey() + " " + issue.startLine());
if (issue.isNew()) {
newIssues++;
} else if (issue.resolution() != null) {
resolvedIssue++;
} else {
openIssues++;
}
}
System.out.println("new: " + newIssues + " open: " + openIssues + " resolved " + resolvedIssue);
assertThat(newIssues).isEqualTo(16);
assertThat(openIssues).isEqualTo(2);
assertThat(resolvedIssue).isEqualTo(1);
// progress report
String logs = StringUtils.join(logTester.logs(LoggerLevel.INFO), "\n");
assertThat(logs).contains("Performing issue tracking");
assertThat(logs).contains("6/6 components tracked");
// assert that original fields of a matched issue are kept
assertThat(result.trackedIssues()).haveExactly(1, new Condition<TrackedIssue>() {
@Override
public boolean matches(TrackedIssue value) {
return value.isNew() == false && "resolved-on-project".equals(value.key()) && "OPEN".equals(value.status()) && new Date(date("14/03/2004")).equals(value.creationDate());
}
});
}
use of org.sonar.scanner.issue.tracking.TrackedIssue 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