use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class IssueCacheTest method should_add_new_issue.
@Test
public void should_add_new_issue() {
IssueCache cache = new IssueCache(caches);
TrackedIssue issue1 = createIssue("111", "org.struts.Action", null);
TrackedIssue issue2 = createIssue("222", "org.struts.Action", null);
TrackedIssue issue3 = createIssue("333", "org.struts.Filter", null);
issue3.setAssignee("foo");
cache.put(issue1).put(issue2).put(issue3);
assertThat(issueKeys(cache.byComponent("org.struts.Action"))).containsOnly("111", "222");
assertThat(issueKeys(cache.byComponent("org.struts.Filter"))).containsOnly("333");
assertThat(cache.byComponent("org.struts.Filter").iterator().next().assignee()).isEqualTo("foo");
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class IssueCacheTest method should_update_existing_issue.
@Test
public void should_update_existing_issue() {
IssueCache cache = new IssueCache(caches);
TrackedIssue issue = createIssue("111", "org.struts.Action", Severity.BLOCKER);
cache.put(issue);
issue.setSeverity(Severity.MINOR);
cache.put(issue);
List<TrackedIssue> issues = ImmutableList.copyOf(cache.byComponent("org.struts.Action"));
assertThat(issues).hasSize(1);
TrackedIssue reloaded = issues.iterator().next();
assertThat(reloaded.key()).isEqualTo("111");
assertThat(reloaded.severity()).isEqualTo(Severity.MINOR);
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class TrackedIssueAdapterTest method improve_coverage.
@Test
public void improve_coverage() {
Date creationDate = new Date();
TrackedIssue trackedIssue = new TrackedIssue().setKey("XYZ123").setComponentKey("foo").setRuleKey(RuleKey.of("repo", "rule")).setSeverity("MAJOR").setMessage("msg").setStartLine(1).setGap(2.0).setStatus("RESOLVED").setResolution("FIXED").setAssignee("tata").setNew(true).setCreationDate(creationDate);
Issue issue = new TrackedIssueAdapter(trackedIssue);
assertThat(issue.key()).isEqualTo("XYZ123");
assertThat(issue.componentKey()).isEqualTo("foo");
assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule"));
assertThat(issue.severity()).isEqualTo("MAJOR");
assertThat(issue.message()).isEqualTo("msg");
assertThat(issue.line()).isEqualTo(1);
assertThat(issue.gap()).isEqualTo(2.0);
assertThat(issue.status()).isEqualTo("RESOLVED");
assertThat(issue.resolution()).isEqualTo("FIXED");
assertThat(issue.assignee()).isEqualTo("tata");
assertThat(issue.isNew()).isTrue();
assertThat(issue.attribute("foo")).isNull();
assertThat(issue.creationDate()).isEqualTo(creationDate);
assertThat(issue.language()).isNull();
assertThat(issue.updateDate()).isNull();
assertThat(issue.closeDate()).isNull();
assertThat(issue.authorLogin()).isNull();
assertThat(issue.comments()).isEmpty();
assertThat(issue.effort()).isNull();
assertThat(issue.projectKey()).isNull();
assertThat(issue.projectUuid()).isNull();
assertThat(issue.componentUuid()).isNull();
assertThat(issue.tags()).isEmpty();
assertThat(issue).isNotEqualTo(null);
assertThat(issue).isNotEqualTo("Foo");
assertThat(issue).isEqualTo(new TrackedIssueAdapter(trackedIssue));
assertThat(issue.hashCode()).isEqualTo(trackedIssue.key().hashCode());
assertThat(issue).isNotEqualTo(new TrackedIssueAdapter(new TrackedIssue().setKey("another")));
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class ScanOnlyChangedTest method assertNumberIssues.
private static void assertNumberIssues(TaskResult result, int expectedNew, int expectedOpen, int expectedResolved) {
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(expectedNew);
assertThat(openIssues).isEqualTo(expectedOpen);
assertThat(resolvedIssue).isEqualTo(expectedResolved);
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class EmptyFileTest method testIssueTrackingWithIssueOnEmptyFile.
@Test
public void testIssueTrackingWithIssueOnEmptyFile() throws Exception {
File projectDir = copyProject("/mediumtest/xoo/sample-with-empty-file");
TaskResult result = tester.newScanTask(new File(projectDir, "sonar-project.properties")).property("sonar.xoo.internalKey", "my/internal/key").start();
for (TrackedIssue i : result.trackedIssues()) {
System.out.println(i.startLine() + " " + i.getMessage());
}
assertThat(result.trackedIssues()).hasSize(11);
}
Aggregations