Search in sources :

Example 56 with DefaultIssue

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

the class SetSeverityActionTest method set_severity.

@Test
public void set_severity() {
    DefaultIssue issue = newIssue().setSeverity(MAJOR).toDefaultIssue();
    setUserWithBrowseAndAdministerIssuePermission(issue.projectUuid());
    BulkChangeAction.ActionContext context = new BulkChangeAction.ActionContext(issue, IssueChangeContext.createUser(NOW, userSession.getLogin()));
    action.execute(ImmutableMap.of("severity", MINOR), context);
    assertThat(issue.severity()).isEqualTo(MINOR);
    assertThat(issue.isChanged()).isTrue();
    assertThat(issue.manualSeverity()).isTrue();
    assertThat(issue.updateDate()).isEqualTo(NOW);
    assertThat(issue.mustSendNotifications()).isTrue();
    Map<String, FieldDiffs.Diff> change = issue.currentChange().diffs();
    assertThat(change.get("severity").newValue()).isEqualTo(MINOR);
    assertThat(change.get("severity").oldValue()).isEqualTo(MAJOR);
}
Also used : BulkChangeAction(org.sonar.server.issue.ws.BulkChangeAction) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 57 with DefaultIssue

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

the class IssueChangeNotificationTest method set_issue_with_current_change_having_no_old_value.

@Test
public void set_issue_with_current_change_having_no_old_value() {
    DefaultIssue issue = new DefaultIssue().setKey("ABCD").setAssignee("simon").setMessage("Remove this useless method").setComponentKey("MyService");
    IssueChangeNotification result = notification.setIssue(issue.setCurrentChange(new FieldDiffs().setDiff("resolution", null, "FIXED")));
    assertThat(result.getFieldValue("old.resolution")).isNull();
    assertThat(result.getFieldValue("new.resolution")).isEqualTo("FIXED");
    result = notification.setIssue(issue.setCurrentChange(new FieldDiffs().setDiff("resolution", "", "FIXED")));
    assertThat(result.getFieldValue("old.resolution")).isNull();
    assertThat(result.getFieldValue("new.resolution")).isEqualTo("FIXED");
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 58 with DefaultIssue

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

the class IssueChangeNotificationTest method set_issue.

@Test
public void set_issue() {
    DefaultIssue issue = new DefaultIssue().setKey("ABCD").setAssignee("simon").setMessage("Remove this useless method").setComponentKey("MyService").setCurrentChange(new FieldDiffs().setDiff("resolution", "FALSE-POSITIVE", "FIXED"));
    IssueChangeNotification result = notification.setIssue(issue);
    assertThat(result.getFieldValue("key")).isEqualTo("ABCD");
    assertThat(result.getFieldValue("assignee")).isEqualTo("simon");
    assertThat(result.getFieldValue("message")).isEqualTo("Remove this useless method");
    assertThat(result.getFieldValue("componentKey")).isEqualTo("MyService");
    assertThat(result.getFieldValue("old.resolution")).isEqualTo("FALSE-POSITIVE");
    assertThat(result.getFieldValue("new.resolution")).isEqualTo("FIXED");
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 59 with DefaultIssue

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

the class IssueWorkflowTest method fail_if_unknown_status_when_listing_transitions.

@Test
public void fail_if_unknown_status_when_listing_transitions() {
    workflow.start();
    DefaultIssue issue = new DefaultIssue().setStatus("xxx");
    try {
        workflow.outTransitions(issue);
        fail();
    } catch (IllegalArgumentException e) {
        assertThat(e).hasMessage("Unknown status: xxx");
    }
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 60 with DefaultIssue

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

the class IssueWorkflowTest method list_out_transitions_from_status_open.

@Test
public void list_out_transitions_from_status_open() {
    workflow.start();
    DefaultIssue issue = new DefaultIssue().setStatus(STATUS_OPEN);
    List<Transition> transitions = workflow.outTransitions(issue);
    assertThat(keys(transitions)).containsOnly("confirm", "falsepositive", "resolve", "wontfix");
}
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