use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class MyNewIssuesNotificationDispatcher method dispatch.
@Override
public void dispatch(Notification notification, Context context) {
String projectKey = notification.getFieldValue("projectKey");
String assignee = notification.getFieldValue("assignee");
Multimap<String, NotificationChannel> subscribedRecipients = manager.findNotificationSubscribers(this, projectKey);
Collection<NotificationChannel> channels = subscribedRecipients.get(assignee);
for (NotificationChannel channel : channels) {
context.addUser(assignee, channel);
}
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class DefaultNotificationManager method findNotificationSubscribers.
@Override
public Multimap<String, NotificationChannel> findNotificationSubscribers(NotificationDispatcher dispatcher, @Nullable String componentKey) {
String dispatcherKey = dispatcher.getKey();
SetMultimap<String, NotificationChannel> recipients = HashMultimap.create();
for (NotificationChannel channel : notificationChannels) {
addUsersToRecipientListForChannel(propertiesDao.selectNotificationSubscribers(dispatcherKey, channel.getKey(), componentKey), recipients, channel);
}
return recipients;
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class DoNotFixNotificationDispatcherTest method ignore_other_resolutions.
/**
* Only false positive and won't fix resolutions
*/
@Test
public void ignore_other_resolutions() {
Multimap<String, NotificationChannel> recipients = HashMultimap.create();
recipients.put("simon", emailChannel);
recipients.put("freddy", twitterChannel);
when(notifications.findNotificationSubscribers(underTest, "struts")).thenReturn(recipients);
Notification fixedNotif = new IssueChangeNotification().setFieldValue("projectKey", "struts").setFieldValue("changeAuthor", "godin").setFieldValue("new.resolution", Issue.RESOLUTION_FIXED).setFieldValue("assignee", "freddy");
underTest.performDispatch(fixedNotif, context);
verifyZeroInteractions(context);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class DoNotFixNotificationDispatcherTest method should_dispatch_to_subscribers.
@Test
public void should_dispatch_to_subscribers() {
Multimap<String, NotificationChannel> recipients = HashMultimap.create();
recipients.put("simon", emailChannel);
recipients.put("freddy", twitterChannel);
recipients.put("godin", twitterChannel);
when(notifications.findNotificationSubscribers(underTest, "struts")).thenReturn(recipients);
Notification fpNotif = new IssueChangeNotification().setFieldValue("projectKey", "struts").setFieldValue("changeAuthor", "godin").setFieldValue("new.resolution", Issue.RESOLUTION_FALSE_POSITIVE).setFieldValue("assignee", "freddy");
underTest.performDispatch(fpNotif, context);
verify(context).addUser("simon", emailChannel);
verify(context).addUser("freddy", twitterChannel);
// do not notify the person who flagged the issue as false-positive
verify(context, never()).addUser("godin", twitterChannel);
verifyNoMoreInteractions(context);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class MyNewIssuesNotificationDispatcherTest method dispatch_to_users_who_have_subscribed_to_notification_and_project.
@Test
public void dispatch_to_users_who_have_subscribed_to_notification_and_project() {
Multimap<String, NotificationChannel> recipients = HashMultimap.create();
recipients.put("user1", emailChannel);
recipients.put("user2", twitterChannel);
when(notificationManager.findNotificationSubscribers(underTest, "struts")).thenReturn(recipients);
Notification notification = new Notification(MyNewIssuesNotification.MY_NEW_ISSUES_NOTIF_TYPE).setFieldValue("projectKey", "struts").setFieldValue("assignee", "user1");
underTest.performDispatch(notification, context);
verify(context).addUser("user1", emailChannel);
verifyNoMoreInteractions(context);
}
Aggregations