コード例 #1
0
  @Test
  public void shouldNotSendEmailWhenValidationFailed() {
    // given
    final ShareService.ValidateShareIssueResult validationResult =
        getShareIssueValidationResult(user, shareBean, issue);

    final NotificationRecipient userRecipient = recipientFromUserName("username");
    final NotificationRecipient mailRecipient = recipientFromEmail("*****@*****.**");
    final List<NotificationRecipient> notificationRecipients =
        Lists.newArrayList(userRecipient, mailRecipient);
    when(notificationRecipientUtil.getRecipients(shareBean)).thenReturn(notificationRecipients);

    final AdhocNotificationService.ValidateNotificationResult userNotification =
        expectNotificationToRecipient(userRecipient);
    addSomeErrors(userNotification);

    final AdhocNotificationService.ValidateNotificationResult mailNotification =
        expectNotificationToRecipient(mailRecipient);
    addSomeErrors(mailNotification);

    // when
    shareIssueService.shareIssue(validationResult);

    // then
    verify(notificationService, times(0))
        .sendNotification(any(AdhocNotificationService.ValidateNotificationResult.class));
  }
コード例 #2
0
  @Test
  public void shouldPublishEventWhenShareIssueSent() throws Exception {
    // given
    final ShareService.ValidateShareIssueResult validationResult =
        getShareIssueValidationResult(user, shareBean, issue);

    // when
    shareIssueService.shareIssue(validationResult);

    // then
    verify(eventPublisher).publish(any(ShareIssueEvent.class));
  }
コード例 #3
0
  @Test
  public void shouldSendMailToUsersAndEmailAddresses() {
    // given
    final ShareService.ValidateShareIssueResult validationResult =
        getShareIssueValidationResult(user, shareBean, issue);

    final NotificationRecipient userRecipient = recipientFromUserName("username");
    final NotificationRecipient mailRecipient = recipientFromEmail("*****@*****.**");
    final List<NotificationRecipient> notificationRecipients =
        Lists.newArrayList(userRecipient, mailRecipient);
    when(notificationRecipientUtil.getRecipients(shareBean)).thenReturn(notificationRecipients);

    final AdhocNotificationService.ValidateNotificationResult userNotification =
        expectNotificationToRecipient(userRecipient);
    final AdhocNotificationService.ValidateNotificationResult mailNotification =
        expectNotificationToRecipient(mailRecipient);

    // when
    shareIssueService.shareIssue(validationResult);

    // then
    verify(notificationService).sendNotification(userNotification);
    verify(notificationService).sendNotification(mailNotification);
  }