@Test public void resendAsynchronouslySingleMesssage() throws Exception { MailListener listener = this.mocker.registerMockComponent(MailListener.class, "database"); ExtendedMimeMessage message = new ExtendedMimeMessage(); String batchId = UUID.randomUUID().toString(); MailContentStore contentStore = this.mocker.getInstance(MailContentStore.class, "filesystem"); when(contentStore.load(any(), eq(batchId), eq("messageId"))).thenReturn(message); MailSender sender = this.mocker.getInstance(MailSender.class); when(sender.sendAsynchronously(eq(Arrays.asList(message)), any(), any(MailListener.class))) .thenReturn(new DefaultMailResult(batchId)); this.mocker.getComponentUnderTest().resendAsynchronously(batchId, "messageId"); verify(sender).sendAsynchronously(eq(Arrays.asList(message)), any(), same(listener)); verify(listener).getMailStatusResult(); }
@Override public MailStatusResult resendAsynchronously(String batchId, String uniqueMessageId) throws MailStoreException { Session session = this.sessionFactory.create(Collections.singletonMap(SESSION_BATCHID_KEY, batchId)); MimeMessage message = loadMessage(session, batchId, uniqueMessageId); MailListener databaseMailListener = this.databaseMailListenerProvider.get(); this.mailSender.sendAsynchronously(Arrays.asList(message), session, databaseMailListener); return databaseMailListener.getMailStatusResult(); }
DatabaseMailResender implements MailResender { @Override public MailStatusResult resendAsynchronously(String batchId, String uniqueMessageId) throws MailStoreException { Session session = this.sessionFactory.create(Collections.singletonMap(SESSION_BATCHID_KEY, batchId)); MimeMessage message = loadMessage(session, batchId, uniqueMessageId); MailListener databaseMailListener = this.databaseMailListenerProvider.get(); this.mailSender.sendAsynchronously(Arrays.asList(message), session, databaseMailListener); return databaseMailListener.getMailStatusResult(); } }
DatabaseMailResender implements MailResender { @Override public MailStatusResult resendAsynchronously(String batchId, String uniqueMessageId) throws MailStoreException { Session session = this.sessionFactory.create(Collections.singletonMap(SESSION_BATCHID_KEY, batchId)); MimeMessage message = loadMessage(session, batchId, uniqueMessageId); MailListener databaseMailListener = this.databaseMailListenerProvider.get(); this.mailSender.sendAsynchronously(Arrays.asList(message), session, databaseMailListener); return databaseMailListener.getMailStatusResult(); }  }
DatabaseMailResender implements MailResender { @Override public MailStatusResult resendAsynchronously(String batchId, String uniqueMessageId) throws MailStoreException { Session session = this.sessionFactory.create(Collections.singletonMap(SESSION_BATCHID_KEY, batchId)); MimeMessage message = loadMessage(session, batchId, uniqueMessageId); MailListener databaseMailListener = this.databaseMailListenerProvider.get(); this.mailSender.sendAsynchronously(Arrays.asList(message), session, databaseMailListener); return databaseMailListener.getMailStatusResult(); }  @Override MailStatusResult resendAsynchronously(String batchId, String uniqueMessageId); @Override List<Pair<MailStatus, MailStatusResult>> resendAsynchronously(Map<String, Object> filterMap, int offset,
        int count); }
DatabaseMailResender implements MailResender { @Override public MailStatusResult resendAsynchronously(String batchId, String uniqueMessageId) throws MailStoreException { Session session = this.sessionFactory.create(Collections.singletonMap(SESSION_BATCHID_KEY, batchId)); MimeMessage message = loadMessage(session, batchId, uniqueMessageId); MailListener databaseMailListener = this.databaseMailListenerProvider.get(); this.mailSender.sendAsynchronously(Arrays.asList(message), session, databaseMailListener); return databaseMailListener.getMailStatusResult(); }  @Override MailStatusResult resendAsynchronously(String batchId, String uniqueMessageId); @Override List<Pair<MailStatus, MailStatusResult>> resendAsynchronously(Map<String, Object> filterMap, int offset,
        int count);  }