@Test public void should_not_dispatch_if_other_notification_type() { Notification notification = new Notification("other-notif"); underTest.performDispatch(notification, context); verify(context, never()).addUser(any(String.class), any(NotificationChannel.class)); }
@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.findSubscribedRecipientsForDispatcher(underTest, "struts", new NotificationManager.SubscriberPermissionsOnProject(UserRole.USER))).thenReturn(recipients); Notification notification = new IssueChangeNotification() .setFieldValue("projectKey", "struts") .setFieldValue("changeAuthor", "olivier") .setFieldValue("assignee", "freddy"); underTest.performDispatch(notification, context); verify(context).addUser("freddy", twitterChannel); verify(context, never()).addUser("godin", twitterChannel); verifyNoMoreInteractions(context); }
@Test public void should_not_dispatch_to_author_of_changes() { Multimap<String, NotificationChannel> recipients = HashMultimap.create(); recipients.put("simon", emailChannel); recipients.put("freddy", twitterChannel); recipients.put("godin", twitterChannel); when(notifications.findSubscribedRecipientsForDispatcher(underTest, "uuid1", new NotificationManager.SubscriberPermissionsOnProject(UserRole.USER))).thenReturn(recipients); // change author is the assignee underTest.performDispatch( new IssueChangeNotification() .setFieldValue("projectKey", "struts") .setFieldValue("projectUuid", "uuid1") .setFieldValue("changeAuthor", "simon") .setFieldValue("assignee", "simon"), context); // no change author underTest.performDispatch(new IssueChangeNotification().setFieldValue("projectKey", "struts") .setFieldValue("new.resolution", "FIXED"), context); verifyNoMoreInteractions(context); } }