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);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class NewIssuesNotificationDispatcherTest method shouldDispatchToUsersWhoHaveSubscribedAndFlaggedProjectAsFavourite.
@Test
public void shouldDispatchToUsersWhoHaveSubscribedAndFlaggedProjectAsFavourite() {
Multimap<String, NotificationChannel> recipients = HashMultimap.create();
recipients.put("user1", emailChannel);
recipients.put("user2", twitterChannel);
when(notifications.findNotificationSubscribers(dispatcher, "struts")).thenReturn(recipients);
Notification notification = new Notification(NewIssuesNotification.TYPE).setFieldValue("projectKey", "struts");
dispatcher.performDispatch(notification, context);
verify(context).addUser("user1", emailChannel);
verify(context).addUser("user2", twitterChannel);
verifyNoMoreInteractions(context);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class AddActionTest method setUp.
@Before
public void setUp() {
NotificationDispatcherMetadata metadata1 = NotificationDispatcherMetadata.create(NOTIF_MY_NEW_ISSUES).setProperty(GLOBAL_NOTIFICATION, "true").setProperty(PER_PROJECT_NOTIFICATION, "true");
NotificationDispatcherMetadata metadata2 = NotificationDispatcherMetadata.create(NOTIF_NEW_ISSUES).setProperty(GLOBAL_NOTIFICATION, "true");
NotificationDispatcherMetadata metadata3 = NotificationDispatcherMetadata.create(NOTIF_NEW_QUALITY_GATE_STATUS).setProperty(GLOBAL_NOTIFICATION, "true").setProperty(PER_PROJECT_NOTIFICATION, "true");
notificationCenter = new NotificationCenter(new NotificationDispatcherMetadata[] { metadata1, metadata2, metadata3 }, new NotificationChannel[] { emailChannel, twitterChannel, defaultChannel });
underTest = new AddAction(notificationCenter, new NotificationUpdater(userSession, dbClient), dbClient, new ComponentFinder(dbClient), userSession);
ws = new WsActionTester(underTest);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class DefaultNotificationManager method findSubscribedRecipientsForDispatcher.
/**
* {@inheritDoc}
*/
@Override
public Multimap<String, NotificationChannel> findSubscribedRecipientsForDispatcher(NotificationDispatcher dispatcher, @Nullable String projectUuid) {
String dispatcherKey = dispatcher.getKey();
SetMultimap<String, NotificationChannel> recipients = HashMultimap.create();
for (NotificationChannel channel : notificationChannels) {
String channelKey = channel.getKey();
// Find users subscribed globally to the dispatcher (i.e. not on a specific project)
addUsersToRecipientListForChannel(propertiesDao.selectUsersForNotification(dispatcherKey, channelKey, null), recipients, channel);
if (projectUuid != null) {
// Find users subscribed to the dispatcher specifically for the project
addUsersToRecipientListForChannel(propertiesDao.selectUsersForNotification(dispatcherKey, channelKey, projectUuid), recipients, channel);
}
}
return recipients;
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class NewAlertsTest method should_dispatch_to_users_who_have_subscribed.
@Test
public void should_dispatch_to_users_who_have_subscribed() {
Multimap<String, NotificationChannel> recipients = HashMultimap.create();
recipients.put("user1", emailChannel);
recipients.put("user2", twitterChannel);
when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, "uuid_34")).thenReturn(recipients);
Notification notification = new Notification("alerts").setFieldValue("projectUuid", "uuid_34");
dispatcher.performDispatch(notification, context);
verify(context).addUser("user1", emailChannel);
verify(context).addUser("user2", twitterChannel);
verifyNoMoreInteractions(context);
}
Aggregations