use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class FpOrWontFixEmailTemplateTest method format_sets_from_to_login_of_author_change_when_name_is_not_available.
@Test
public void format_sets_from_to_login_of_author_change_when_name_is_not_available() {
UserChange change = new UserChange(new Random().nextLong(), new User(randomAlphabetic(5), randomAlphabetic(6), null));
EmailMessage emailMessage = underTest.format(new FPOrWontFixNotification(change, Collections.emptySet(), WONT_FIX));
assertThat(emailMessage.getFrom()).isEqualTo(change.getUser().getLogin());
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class ChangesOnMyIssueNotificationHandlerTest method deliver_checks_by_projectKey_if_notifications_have_subscribed_assignee_to_ChangesOnMyIssues_notifications.
@Test
public void deliver_checks_by_projectKey_if_notifications_have_subscribed_assignee_to_ChangesOnMyIssues_notifications() {
when(emailNotificationChannel.isActivated()).thenReturn(true);
Project project = newProject();
Set<ChangedIssue> issues = IntStream.range(0, 1 + new Random().nextInt(2)).mapToObj(i -> new ChangedIssue.Builder("issue_key_" + i).setNewStatus("foo").setAssignee(newUser("assignee_" + i)).setRule(newRule()).setProject(project).build()).collect(toSet());
IssuesChangesNotificationBuilder builder = new IssuesChangesNotificationBuilder(issues, new UserChange(new Random().nextLong(), new User("user_uuid", "user_login", null)));
int deliver = underTest.deliver(ImmutableSet.of(serializer.serialize(builder)));
assertThat(deliver).isZero();
Set<String> assigneeLogins = issues.stream().map(i -> i.getAssignee().get().getLogin()).collect(toSet());
verify(notificationManager).findSubscribedEmailRecipients(CHANGE_ON_MY_ISSUES_DISPATCHER_KEY, project.getKey(), assigneeLogins, ALL_MUST_HAVE_ROLE_USER);
verifyNoMoreInteractions(notificationManager);
verify(emailNotificationChannel).isActivated();
verifyNoMoreInteractions(emailNotificationChannel);
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class ChangesOnMyIssueNotificationHandlerTest method deliver_checks_by_projectKeys_if_notifications_have_subscribed_assignee_to_ChangesOnMyIssues_notifications.
@Test
public void deliver_checks_by_projectKeys_if_notifications_have_subscribed_assignee_to_ChangesOnMyIssues_notifications() {
when(emailNotificationChannel.isActivated()).thenReturn(true);
Set<ChangedIssue> issues = IntStream.range(0, 1 + new Random().nextInt(2)).mapToObj(i -> new ChangedIssue.Builder("issue_key_" + i).setNewStatus("foo").setAssignee(newUser("" + i)).setRule(newRule()).setProject(newProject(i + "")).build()).collect(toSet());
IssuesChangesNotificationBuilder builder = new IssuesChangesNotificationBuilder(issues, new UserChange(new Random().nextLong(), new User("user_uuid", "user_login", null)));
int deliver = underTest.deliver(ImmutableSet.of(serializer.serialize(builder)));
assertThat(deliver).isZero();
issues.stream().collect(MoreCollectors.index(ChangedIssue::getProject)).asMap().forEach((key, value) -> {
String projectKey = key.getKey();
Set<String> assigneeLogins = value.stream().map(i -> i.getAssignee().get().getLogin()).collect(toSet());
verify(notificationManager).findSubscribedEmailRecipients(CHANGE_ON_MY_ISSUES_DISPATCHER_KEY, projectKey, assigneeLogins, ALL_MUST_HAVE_ROLE_USER);
});
verifyNoMoreInteractions(notificationManager);
verify(emailNotificationChannel).isActivated();
verifyNoMoreInteractions(emailNotificationChannel);
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class ChangesOnMyIssuesNotificationTest method key_is_ChangesOnMyIssues.
@Test
public void key_is_ChangesOnMyIssues() {
ChangesOnMyIssuesNotification underTest = new ChangesOnMyIssuesNotification(new UserChange(new Random().nextLong(), new User(randomAlphabetic(2), randomAlphabetic(3), randomAlphabetic(4))), ImmutableSet.of());
assertThat(underTest.getType()).isEqualTo("ChangesOnMyIssues");
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class BulkChangeAction method sendNotification.
private void sendNotification(Collection<DefaultIssue> issues, BulkChangeData bulkChangeData, Map<String, UserDto> userDtoByUuid, UserDto author) {
if (!bulkChangeData.sendNotification) {
return;
}
Set<ChangedIssue> changedIssues = issues.stream().filter(issue -> issue.updateDate() != null).map(issue -> toNotification(bulkChangeData, userDtoByUuid, issue)).filter(Objects::nonNull).collect(toSet(issues.size()));
if (changedIssues.isEmpty()) {
return;
}
IssuesChangesNotificationBuilder builder = new IssuesChangesNotificationBuilder(changedIssues, new UserChange(oldestUpdateDate(issues), new User(author.getUuid(), author.getLogin(), author.getName())));
notificationService.scheduleForSending(notificationSerializer.serialize(builder));
}
Aggregations