Search in sources :

Example 11 with MailStatusStore

use of org.xwiki.mail.MailStatusStore in project xwiki-platform by xwiki.

the class DatabaseMailResenderTest method resendAsynchronouslySeveralMessages.

@Test
public void resendAsynchronouslySeveralMessages() throws Exception {
    Map filterMap = Collections.singletonMap("state", "prepare_%");
    MailStatus status1 = new MailStatus();
    status1.setBatchId("batch1");
    status1.setMessageId("message1");
    MailStatus status2 = new MailStatus();
    status2.setBatchId("batch2");
    status2.setMessageId("message2");
    List<MailStatus> statuses = new ArrayList<>();
    statuses.add(status1);
    statuses.add(status2);
    MailStatusStore statusStore = this.mocker.getInstance(MailStatusStore.class, "database");
    when(statusStore.load(filterMap, 0, 0, null, true)).thenReturn(statuses);
    MailContentStore contentStore = this.mocker.getInstance(MailContentStore.class, "filesystem");
    ExtendedMimeMessage message1 = new ExtendedMimeMessage();
    when(contentStore.load(any(), eq("batch1"), eq("message1"))).thenReturn(message1);
    ExtendedMimeMessage message2 = new ExtendedMimeMessage();
    when(contentStore.load(any(), eq("batch2"), eq("message2"))).thenReturn(message2);
    MailSender sender = this.mocker.getInstance(MailSender.class);
    this.mocker.getComponentUnderTest().resendAsynchronously(filterMap, 0, 0);
    // The test is here
    verify(sender).sendAsynchronously(eq(Arrays.asList(message1)), any(), any(MailListener.class));
    verify(sender).sendAsynchronously(eq(Arrays.asList(message2)), any(), any(MailListener.class));
}
Also used : ExtendedMimeMessage(org.xwiki.mail.ExtendedMimeMessage) MailListener(org.xwiki.mail.MailListener) MailStatusStore(org.xwiki.mail.MailStatusStore) MailContentStore(org.xwiki.mail.MailContentStore) ArrayList(java.util.ArrayList) MailSender(org.xwiki.mail.MailSender) Map(java.util.Map) MailStatus(org.xwiki.mail.MailStatus) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 MailStatusStore (org.xwiki.mail.MailStatusStore)11 MailListener (org.xwiki.mail.MailListener)10 MailStatus (org.xwiki.mail.MailStatus)9 MailStoreException (org.xwiki.mail.MailStoreException)7 MailContentStore (org.xwiki.mail.MailContentStore)5 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ExtendedMimeMessage (org.xwiki.mail.ExtendedMimeMessage)2 MailSender (org.xwiki.mail.MailSender)2