use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueAssignerTest method set_default_assignee_if_author_not_found.
@Test
public void set_default_assignee_if_author_not_found() throws Exception {
addScmUser("john", null);
setSingleChangeset("john", 123456789L, "rev-1");
when(defaultAssignee.getLogin()).thenReturn("John C");
DefaultIssue issue = new DefaultIssue().setLine(1);
underTest.onIssue(FILE, issue);
assertThat(issue.assignee()).isEqualTo("John C");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueAssignerTest method nothing_to_do_if_no_changeset.
@Test
public void nothing_to_do_if_no_changeset() throws Exception {
DefaultIssue issue = new DefaultIssue().setLine(1);
underTest.onIssue(FILE, issue);
assertThat(issue.authorLogin()).isNull();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueLifecycleTest method mergeExistingOpenIssue.
@Test
public void mergeExistingOpenIssue() throws Exception {
DefaultIssue raw = new DefaultIssue().setNew(true).setKey("RAW_KEY").setCreationDate(parseDate("2015-10-01")).setUpdateDate(parseDate("2015-10-02")).setCloseDate(parseDate("2015-10-03"));
DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder().setTextRange(DbCommons.TextRange.newBuilder().setStartLine(10).setEndLine(12).build()).build();
DefaultIssue base = new DefaultIssue().setKey("BASE_KEY").setCreationDate(parseDate("2015-01-01")).setUpdateDate(parseDate("2015-01-02")).setCloseDate(parseDate("2015-01-03")).setResolution(RESOLUTION_FIXED).setStatus(STATUS_CLOSED).setSeverity(BLOCKER).setAssignee("base assignee").setAuthorLogin("base author").setTags(newArrayList("base tag")).setOnDisabledRule(true).setSelectedAt(1000L).setLine(10).setMessage("message").setGap(15d).setEffort(Duration.create(15L)).setManualSeverity(false).setLocations(issueLocations);
when(debtCalculator.calculate(raw)).thenReturn(DEFAULT_DURATION);
underTest.mergeExistingOpenIssue(raw, base);
assertThat(raw.isNew()).isFalse();
assertThat(raw.key()).isEqualTo("BASE_KEY");
assertThat(raw.creationDate()).isEqualTo(base.creationDate());
assertThat(raw.updateDate()).isEqualTo(base.updateDate());
assertThat(raw.closeDate()).isEqualTo(base.closeDate());
assertThat(raw.resolution()).isEqualTo(RESOLUTION_FIXED);
assertThat(raw.status()).isEqualTo(STATUS_CLOSED);
assertThat(raw.assignee()).isEqualTo("base assignee");
assertThat(raw.authorLogin()).isEqualTo("base author");
assertThat(raw.tags()).containsOnly("base tag");
assertThat(raw.debt()).isEqualTo(DEFAULT_DURATION);
assertThat(raw.isOnDisabledRule()).isTrue();
assertThat(raw.selectedAt()).isEqualTo(1000L);
verify(updater).setPastSeverity(raw, BLOCKER, issueChangeContext);
verify(updater).setPastLine(raw, 10);
verify(updater).setPastMessage(raw, "message", issueChangeContext);
verify(updater).setPastEffort(raw, Duration.create(15L), issueChangeContext);
verify(updater).setPastLocations(raw, issueLocations);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueLifecycleTest method mergeExistingOpenIssue_with_attributes.
@Test
public void mergeExistingOpenIssue_with_attributes() throws Exception {
DefaultIssue raw = new DefaultIssue().setNew(true).setKey("RAW_KEY");
DefaultIssue base = new DefaultIssue().setKey("BASE_KEY").setResolution(RESOLUTION_FIXED).setStatus(STATUS_CLOSED).setSeverity(BLOCKER).setAttributes(ImmutableMap.of("JIRA", "SONAR-01"));
underTest.mergeExistingOpenIssue(raw, base);
assertThat(raw.attributes()).containsEntry("JIRA", "SONAR-01");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class EffortAggregatorTest method sum_reliability_effort_of_unresolved_issues.
@Test
public void sum_reliability_effort_of_unresolved_issues() {
DefaultIssue unresolved1 = newBugIssue(10);
DefaultIssue unresolved2 = newBugIssue(30);
DefaultIssue unresolvedWithoutEffort = newBugIssueWithoutEffort();
DefaultIssue resolved = newBugIssue(50).setResolution(RESOLUTION_FIXED);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, unresolved1);
underTest.onIssue(FILE, unresolved2);
underTest.onIssue(FILE, unresolvedWithoutEffort);
underTest.onIssue(FILE, resolved);
underTest.afterComponent(FILE);
assertMeasure(FILE, RELIABILITY_REMEDIATION_EFFORT_KEY, 10L + 30L);
}
Aggregations