Search in sources :

Example 91 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class IssueLifecycleTest method doAutomaticTransition.

@Test
public void doAutomaticTransition() throws Exception {
    DefaultIssue issue = new DefaultIssue();
    underTest.doAutomaticTransition(issue);
    verify(workflow).doAutomaticTransition(issue, issueChangeContext);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 92 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class IssueLifecycleTest method initNewOpenIssue.

@Test
public void initNewOpenIssue() throws Exception {
    DefaultIssue issue = new DefaultIssue();
    when(debtCalculator.calculate(issue)).thenReturn(DEFAULT_DURATION);
    underTest.initNewOpenIssue(issue);
    assertThat(issue.key()).isNotNull();
    assertThat(issue.creationDate()).isNotNull();
    assertThat(issue.updateDate()).isNotNull();
    assertThat(issue.status()).isEqualTo(STATUS_OPEN);
    assertThat(issue.debt()).isEqualTo(DEFAULT_DURATION);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 93 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class IssueLifecycleTest method mergeExistingOpenIssue_with_manual_severity.

@Test
public void mergeExistingOpenIssue_with_manual_severity() 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).setManualSeverity(true);
    underTest.mergeExistingOpenIssue(raw, base);
    assertThat(raw.manualSeverity()).isTrue();
    assertThat(raw.severity()).isEqualTo(BLOCKER);
    verify(updater, never()).setPastSeverity(raw, BLOCKER, issueChangeContext);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 94 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class MovedIssueVisitorTest method onIssue_does_not_alter_issue_if_component_is_not_a_file.

@Test
public void onIssue_does_not_alter_issue_if_component_is_not_a_file() {
    DefaultIssue issue = mock(DefaultIssue.class);
    underTest.onIssue(ReportComponent.builder(Component.Type.DIRECTORY, 1).build(), issue);
    verifyZeroInteractions(issue);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 95 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class CommonRuleEngineImplTest method process_files_with_known_language.

@Test
public void process_files_with_known_language() throws Exception {
    ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setKey("FILE_KEY").setUuid("FILE_UUID").setFileAttributes(new FileAttributes(false, "java", 1)).build();
    DefaultIssue issue = new DefaultIssue();
    when(rule1.processFile(file, "java")).thenReturn(issue);
    when(rule2.processFile(file, "java")).thenReturn(null);
    Collection<DefaultIssue> issues = underTest.process(file);
    assertThat(issues).containsOnly(issue);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) FileAttributes(org.sonar.server.computation.task.projectanalysis.component.FileAttributes) 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