use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method new_maintainability_effort_is_only_computed_using_code_smell_issues.
@Test
public void new_maintainability_effort_is_only_computed_using_code_smell_issues() {
periodsHolder.setPeriod(PERIOD);
DefaultIssue codeSmellIssue = newCodeSmellIssue(10);
// Issues of type BUG and VULNERABILITY should be ignored
DefaultIssue bugIssue = newBugIssue(15);
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(12);
when(calculator.calculate(same(codeSmellIssue), anyList(), same(PERIOD))).thenReturn(4L);
when(calculator.calculate(same(bugIssue), anyList(), same(PERIOD))).thenReturn(3L);
when(calculator.calculate(same(vulnerabilityIssue), anyList(), same(PERIOD))).thenReturn(5L);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, codeSmellIssue);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.afterComponent(FILE);
// Only effort of CODE SMELL issue is used
assertVariation(FILE, NEW_TECHNICAL_DEBT_KEY, 4);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueAssignerTest method set_assignee_to_issue.
@Test
public void set_assignee_to_issue() throws Exception {
addScmUser("john", "John C");
setSingleChangeset("john", 123456789L, "rev-1");
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 set_last_committer_when_line_is_null.
@Test
public void set_last_committer_when_line_is_null() throws Exception {
addScmUser("henry", "Henry V");
Changeset changeset1 = Changeset.newChangesetBuilder().setAuthor("john").setDate(123456789L).setRevision("rev-1").build();
// Latest changeset
Changeset changeset2 = Changeset.newChangesetBuilder().setAuthor("henry").setDate(1234567810L).setRevision("rev-2").build();
scmInfoRepository.setScmInfo(FILE_REF, changeset1, changeset2, changeset1);
DefaultIssue issue = new DefaultIssue().setLine(null);
underTest.onIssue(FILE, issue);
assertThat(issue.assignee()).isEqualTo("Henry V");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueAssignerTest method set_author_to_issue.
@Test
public void set_author_to_issue() throws Exception {
setSingleChangeset("john", 123456789L, "rev-1");
DefaultIssue issue = new DefaultIssue().setLine(1);
underTest.onIssue(FILE, issue);
assertThat(issue.authorLogin()).isEqualTo("john");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueAssignerTest method doest_not_set_assignee_if_no_author.
@Test
public void doest_not_set_assignee_if_no_author() throws Exception {
addScmUser("john", "John C");
setSingleChangeset(null, 123456789L, "rev-1");
DefaultIssue issue = new DefaultIssue().setLine(1);
underTest.onIssue(FILE, issue);
assertThat(issue.authorLogin()).isNull();
assertThat(issue.assignee()).isNull();
}
Aggregations