use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class IssueUpdaterTest method verify_notification_without_resolution.
@Test
public void verify_notification_without_resolution() {
UserDto assignee = db.users().insertUser();
RuleDefinitionDto rule = db.rules().insertIssueRule();
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
DefaultIssue issue = db.issues().insertIssue(rule, project, file, t -> t.setSeverity(MAJOR).setAssigneeUuid(assignee.getUuid())).toDefaultIssue();
UserDto changeAuthor = db.users().insertUser();
IssueChangeContext context = IssueChangeContext.createUser(new Date(), changeAuthor.getUuid());
issueFieldsSetter.setSeverity(issue, BLOCKER, context);
underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, false);
verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
IssuesChangesNotification issueChangeNotification = notificationArgumentCaptor.getValue();
IssuesChangesNotificationBuilder builder = issuesChangesSerializer.from(issueChangeNotification);
assertThat(builder.getIssues()).hasSize(1);
ChangedIssue changedIssue = builder.getIssues().iterator().next();
assertThat(changedIssue.getKey()).isEqualTo(issue.key());
assertThat(changedIssue.getNewStatus()).isEqualTo(issue.status());
assertThat(changedIssue.getNewResolution()).isEmpty();
assertThat(changedIssue.getAssignee()).contains(userOf(assignee));
assertThat(changedIssue.getRule()).isEqualTo(ruleOf(rule));
assertThat(changedIssue.getProject()).isEqualTo(projectOf(project));
assertThat(builder.getChange()).isEqualTo(new UserChange(issue.updateDate().getTime(), userOf(changeAuthor)));
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class IssueUpdaterTest method verify_notification_when_issue_is_linked_on_removed_rule.
@Test
public void verify_notification_when_issue_is_linked_on_removed_rule() {
RuleDefinitionDto rule = db.rules().insertIssueRule(r -> r.setStatus(RuleStatus.REMOVED));
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
DefaultIssue issue = db.issues().insertIssue(rule, project, file, t -> t.setSeverity(MAJOR)).toDefaultIssue();
IssueChangeContext context = IssueChangeContext.createUser(new Date(), "user_uuid");
issueFieldsSetter.setSeverity(issue, BLOCKER, context);
underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, false);
verifyZeroInteractions(notificationManager);
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class IssueUpdaterTest method verify_notification_when_assignee_has_changed.
@Test
public void verify_notification_when_assignee_has_changed() {
UserDto oldAssignee = db.users().insertUser();
RuleDefinitionDto rule = db.rules().insertIssueRule();
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
DefaultIssue issue = db.issues().insertIssue(rule, project, file, t -> t.setAssigneeUuid(oldAssignee.getUuid())).toDefaultIssue();
UserDto changeAuthor = db.users().insertUser();
IssueChangeContext context = IssueChangeContext.createUser(new Date(), changeAuthor.getUuid());
UserDto newAssignee = db.users().insertUser();
issueFieldsSetter.assign(issue, newAssignee, context);
underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, false);
verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
IssuesChangesNotification issueChangeNotification = notificationArgumentCaptor.getValue();
IssuesChangesNotificationBuilder builder = issuesChangesSerializer.from(issueChangeNotification);
assertThat(builder.getIssues()).hasSize(1);
ChangedIssue changedIssue = builder.getIssues().iterator().next();
assertThat(changedIssue.getKey()).isEqualTo(issue.key());
assertThat(changedIssue.getNewStatus()).isEqualTo(issue.status());
assertThat(changedIssue.getNewResolution()).isEmpty();
assertThat(changedIssue.getAssignee()).contains(userOf(newAssignee));
assertThat(changedIssue.getRule()).isEqualTo(ruleOf(rule));
assertThat(changedIssue.getProject()).isEqualTo(projectOf(project));
assertThat(builder.getChange()).isEqualTo(new UserChange(issue.updateDate().getTime(), userOf(changeAuthor)));
}
use of org.sonar.core.issue.IssueChangeContext in project sonarqube by SonarSource.
the class IssueUpdaterTest method update_issue.
@Test
public void update_issue() {
DefaultIssue issue = db.issues().insertIssue(i -> i.setSeverity(MAJOR)).toDefaultIssue();
UserDto user = db.users().insertUser();
IssueChangeContext context = IssueChangeContext.createUser(new Date(), user.getUuid());
issueFieldsSetter.setSeverity(issue, BLOCKER, context);
underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, false);
IssueDto issueReloaded = dbClient.issueDao().selectByKey(db.getSession(), issue.key()).get();
assertThat(issueReloaded.getSeverity()).isEqualTo(BLOCKER);
}
Aggregations