@Test public void testSendMail() throws Exception { CompositeEvent event1 = mock(CompositeEvent.class); when(this.wikiDescriptorManager.getCurrentWikiId()).thenReturn("xwiki"); when(this.notificationUserIteratorProvider.get()).thenReturn(Mockito.mock(NotificationUserIterator.class)); when(this.liveMimeMessageIteratorProvider.get()).thenReturn(Mockito.mock(LiveMimeMessageIterator.class)); when(this.sessionFactory.create(ArgumentMatchers.any())).thenReturn(null); when(this.mailListenerProvider.get()).thenReturn(Mockito.mock(MailListener.class)); this.mocker.getComponentUnderTest().sendEmails(event1); verify(this.mailSender, times(1)).sendAsynchronously( any(LiveMimeMessageIterator.class), any(), any(MailListener.class)); }
public void sendEmails(CompositeEvent event) { DocumentReference templateReference = new DocumentReference(this.wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications"), "MailTemplate"); NotificationUserIterator notificationUserIterator = this.notificationUserIteratorProvider.get(); notificationUserIterator.initialize(NotificationEmailInterval.LIVE); LiveMimeMessageIterator liveNotificationMessageIterator = this.liveMimeMessageIteratorProvider.get(); liveNotificationMessageIterator.initialize(notificationUserIterator, new HashMap<>(), event, templateReference); Session session = this.sessionFactory.create(Collections.emptyMap()); MailListener mailListener = this.mailListenerProvider.get(); this.mailSender.sendAsynchronously(liveNotificationMessageIterator, session, mailListener); }
LiveNotificationEmailSender { public void sendEmails(CompositeEvent event) { DocumentReference templateReference = new DocumentReference(this.wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications"), "MailTemplate"); NotificationUserIterator notificationUserIterator = this.notificationUserIteratorProvider.get(); notificationUserIterator.initialize(NotificationEmailInterval.LIVE); LiveMimeMessageIterator liveNotificationMessageIterator = this.liveMimeMessageIteratorProvider.get(); liveNotificationMessageIterator.initialize(notificationUserIterator, new HashMap<>(), event, templateReference); Session session = this.sessionFactory.create(Collections.emptyMap()); MailListener mailListener = this.mailListenerProvider.get(); this.mailSender.sendAsynchronously(liveNotificationMessageIterator, session, mailListener); } }
LiveNotificationEmailSender { public void sendEmails(CompositeEvent event) { DocumentReference templateReference = new DocumentReference(this.wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications"), "MailTemplate"); NotificationUserIterator notificationUserIterator = this.notificationUserIteratorProvider.get(); notificationUserIterator.initialize(NotificationEmailInterval.LIVE); LiveMimeMessageIterator liveNotificationMessageIterator = this.liveMimeMessageIteratorProvider.get(); liveNotificationMessageIterator.initialize(notificationUserIterator, new HashMap<>(), event, templateReference); Session session = this.sessionFactory.create(Collections.emptyMap()); MailListener mailListener = this.mailListenerProvider.get(); this.mailSender.sendAsynchronously(liveNotificationMessageIterator, session, mailListener); }  }
LiveNotificationEmailSender { public void sendEmails(CompositeEvent event) { DocumentReference templateReference = new DocumentReference(this.wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications"), "MailTemplate"); NotificationUserIterator notificationUserIterator = this.notificationUserIteratorProvider.get(); notificationUserIterator.initialize(NotificationEmailInterval.LIVE); LiveMimeMessageIterator liveNotificationMessageIterator = this.liveMimeMessageIteratorProvider.get(); liveNotificationMessageIterator.initialize(notificationUserIterator, new HashMap<>(), event, templateReference); Session session = this.sessionFactory.create(Collections.emptyMap()); MailListener mailListener = this.mailListenerProvider.get(); this.mailSender.sendAsynchronously(liveNotificationMessageIterator, session, mailListener); }  void sendEmails(CompositeEvent event); }
LiveNotificationEmailSender { public void sendEmails(CompositeEvent event) { DocumentReference templateReference = new DocumentReference(this.wikiDescriptorManager.getCurrentWikiId(), Arrays.asList("XWiki", "Notifications"), "MailTemplate"); NotificationUserIterator notificationUserIterator = this.notificationUserIteratorProvider.get(); notificationUserIterator.initialize(NotificationEmailInterval.LIVE); LiveMimeMessageIterator liveNotificationMessageIterator = this.liveMimeMessageIteratorProvider.get(); liveNotificationMessageIterator.initialize(notificationUserIterator, new HashMap<>(), event, templateReference); Session session = this.sessionFactory.create(Collections.emptyMap()); MailListener mailListener = this.mailListenerProvider.get(); this.mailSender.sendAsynchronously(liveNotificationMessageIterator, session, mailListener); }  void sendEmails(CompositeEvent event);  }