コード例 #1
0
  @Test
  public void should_not_dispatch_if_other_notification_type() {
    Notification notification = new Notification("other");
    underTest.performDispatch(notification, context);

    verify(context, never()).addUser(any(String.class), any(NotificationChannel.class));
  }
コード例 #2
0
  /** 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);
  }
コード例 #3
0
  @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);
  }