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);
}
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");
}
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");
}
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");
}
}
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");
}
Aggregations