AsyncEmailSender extends AbstractSender { @Override public boolean send(AlertMessageEntity message) { CommandFuture<EmailResponse> future = EmailService.DEFAULT.sendEmailAsync(createEmail(message), executor); future.addListener(commandFuture -> { EmailResponse response = commandFuture.getNow(); alertEventService.insert(createEventModel(message, response)); }); if(future.isDone() && !future.isSuccess()) { callbackFunction.fail(future.cause()); return false; } return true; }  @Override String getId(); @PostConstruct void initListeners(); @Override boolean send(AlertMessageEntity message); @VisibleForTesting AsyncEmailSenderCallback getCallbackFunction(); static final String ID; }
@Test public void testSend() throws Exception { sender.send(new AlertMessageEntity("Test", "test", Lists.newArrayList("test-list"))); }