Search in sources :

Example 86 with DefaultIssue

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);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 87 with DefaultIssue

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");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 88 with DefaultIssue

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");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset) Test(org.junit.Test)

Example 89 with DefaultIssue

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");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 90 with DefaultIssue

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();
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Aggregations

DefaultIssue (org.sonar.core.issue.DefaultIssue)140 Test (org.junit.Test)120 Date (java.util.Date)27 ActiveRule (org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule)15 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)14 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)8 IssueDto (org.sonar.db.issue.IssueDto)8 DbSession (org.sonar.db.DbSession)6 ComponentDto (org.sonar.db.component.ComponentDto)5 Issue (org.sonar.api.issue.Issue)4 FieldDiffs (org.sonar.core.issue.FieldDiffs)4 ArrayList (java.util.ArrayList)3 RuleKey (org.sonar.api.rule.RuleKey)3 User (org.sonar.api.user.User)3 IssueChangeMapper (org.sonar.db.issue.IssueChangeMapper)3 IssueMapper (org.sonar.db.issue.IssueMapper)3 RuleDto (org.sonar.db.rule.RuleDto)3 IssueChangeNotification (org.sonar.server.issue.notification.IssueChangeNotification)3 DefaultUser (org.sonar.core.user.DefaultUser)2 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)2