@Test public void resendAsynchronouslySingleMessageWhenMailContentStoreLoadingFails() throws Exception { MailContentStore contentStore = this.mocker.getInstance(MailContentStore.class, "filesystem"); when(contentStore.load(any(), eq("batchId"), eq("messageId"))).thenThrow( new MailStoreException("error")); try { this.mocker.getComponentUnderTest().resendAsynchronously("batchId", "messageId"); fail("Should have thrown an exception here"); } catch (MailStoreException expected) { assertEquals("error", expected.getMessage()); } }
@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);  }