use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class NewAlertsTest method should_not_dispatch_if_missing_project_id.
@Test
public void should_not_dispatch_if_missing_project_id() {
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");
dispatcher.performDispatch(notification, context);
verifyNoMoreInteractions(context);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class ChangesOnMyIssueNotificationDispatcherTest method should_dispatch_to_assignee.
@Test
public void should_dispatch_to_assignee() {
Multimap<String, NotificationChannel> recipients = HashMultimap.create();
recipients.put("simon", emailChannel);
recipients.put("freddy", twitterChannel);
recipients.put("godin", twitterChannel);
when(notifications.findNotificationSubscribers(dispatcher, "struts")).thenReturn(recipients);
Notification notification = new IssueChangeNotification().setFieldValue("projectKey", "struts").setFieldValue("changeAuthor", "olivier").setFieldValue("assignee", "freddy");
dispatcher.performDispatch(notification, context);
verify(context).addUser("freddy", twitterChannel);
verify(context, never()).addUser("godin", twitterChannel);
verifyNoMoreInteractions(context);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class NotificationChannelTest method defaultMethods.
@Test
public void defaultMethods() {
NotificationChannel channel = new FakeNotificationChannel();
assertThat(channel.getKey()).isEqualTo("FakeNotificationChannel");
assertThat(channel.toString()).isEqualTo("FakeNotificationChannel");
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class RemoveActionTest 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 });
notificationUpdater = new NotificationUpdater(userSession, dbClient);
underTest = new RemoveAction(notificationCenter, notificationUpdater, dbClient, new ComponentFinder(dbClient), userSession);
ws = new WsActionTester(underTest);
}
use of org.sonar.api.notifications.NotificationChannel in project sonarqube by SonarSource.
the class NewIssuesNotificationDispatcher method dispatch.
@Override
public void dispatch(Notification notification, Context context) {
String projectKey = notification.getFieldValue("projectKey");
Multimap<String, NotificationChannel> subscribedRecipients = manager.findNotificationSubscribers(this, projectKey);
for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) {
String userLogin = channelsByRecipients.getKey();
for (NotificationChannel channel : channelsByRecipients.getValue()) {
context.addUser(userLogin, channel);
}
}
}
Aggregations