### Question:
PrefilteringLiveNotificationEmailSender { public void sendMails(Map<DocumentReference, CompositeEvent> eventsToSend) { PrefilteringMimeMessageIterator liveNotificationMessageIterator = this.liveMimeMessageIteratorProvider.get(); liveNotificationMessageIterator.initialize(eventsToSend, new HashMap<>(), TEMPLATE); Session session = this.sessionFactory.create(Collections.emptyMap()); MailListener mailListener = mailListenerProvider.get(); this.mailSender.sendAsynchronously(liveNotificationMessageIterator, session, new CompositeMailListener(mailListener, liveNotificationMessageIterator.getMailListener())); }  void sendMails(Map<DocumentReference, CompositeEvent> eventsToSend); static final LocalDocumentReference TEMPLATE; }### Answer:
@Test public void testSendMail() throws Exception { when(this.wikiDescriptorManager.getCurrentWikiId()).thenReturn("xwiki"); PrefilteringMimeMessageIterator iterator = mock(PrefilteringMimeMessageIterator.class); when(this.liveMimeMessageIteratorProvider.get()).thenReturn(iterator); when(this.sessionFactory.create(ArgumentMatchers.any())).thenReturn(null); when(this.mailListenerProvider.get()).thenReturn(Mockito.mock(MailListener.class)); CompositeEvent event1 = mock(CompositeEvent.class); DocumentReference userReference = new DocumentReference("wiki", "XWiki", "user"); Map<DocumentReference, CompositeEvent> events = new HashMap<>(); events.put(userReference, event1); this.sender.sendMails(events); verify(iterator).initialize(events, Collections.emptyMap(), PrefilteringLiveNotificationEmailSender.TEMPLATE); verify(this.mailSender).sendAsynchronously(same(iterator), any(), any(MailListener.class)); }