@Test public void sendMailShouldEnqueueEmailWithOtherStateAndDelayWhenSpecified() throws Exception { MailImpl mail = MailImpl.builder() .name("mail1") .sender(mailAddress) .addRecipient(mailAddress) .mimeMessage(MimeMessageUtil.defaultMimeMessage()) .build(); String other = "other"; testee.sendMail(mail, other, 5, TimeUnit.MINUTES); ArgumentCaptor<Mail> mailArgumentCaptor = ArgumentCaptor.forClass(Mail.class); ArgumentCaptor<Long> delayArgumentCaptor = ArgumentCaptor.forClass(Long.class); ArgumentCaptor<TimeUnit> timeUnitArgumentCaptor = ArgumentCaptor.forClass(TimeUnit.class); verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture(), delayArgumentCaptor.capture(), timeUnitArgumentCaptor.capture()); verifyNoMoreInteractions(spoolMailQueue); softly.assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(other); softly.assertThat(delayArgumentCaptor.getValue()).isEqualTo(5L); softly.assertThat(timeUnitArgumentCaptor.getValue()).isEqualTo(TimeUnit.MINUTES); }
@Override public void sendMail(MimeMessage message) throws MessagingException { MailAddress sender = new MailAddress((InternetAddress) message.getFrom()[0]); Collection<MailAddress> recipients = new HashSet<>(); Address[] addresses = message.getAllRecipients(); if (addresses != null) { for (Address address : addresses) { if (address instanceof InternetAddress) { recipients.add(new MailAddress((InternetAddress) address)); } } } sendMail(sender, recipients, message); }
JamesMailetContext implements MailetContext, Configurable, Disposable { @Override public void sendMail(MimeMessage message) throws MessagingException { MailAddress sender = new MailAddress((InternetAddress) message.getFrom()[0]); Collection<MailAddress> recipients = new HashSet<>(); Address[] addresses = message.getAllRecipients(); if (addresses != null) { for (Address address : addresses) { if (address instanceof InternetAddress) { recipients.add(new MailAddress((InternetAddress) address)); } } } sendMail(sender, recipients, message); } }
JamesMailetContext implements MailetContext, Configurable, Disposable { @Override public void sendMail(MimeMessage message) throws MessagingException { MailAddress sender = new MailAddress((InternetAddress) message.getFrom()[0]); Collection<MailAddress> recipients = new HashSet<>(); Address[] addresses = message.getAllRecipients(); if (addresses != null) { for (Address address : addresses) { if (address instanceof InternetAddress) { recipients.add(new MailAddress((InternetAddress) address)); } } } sendMail(sender, recipients, message); } @Inject  JamesMailetContext(DNSService dns, DomainList domains, LocalResources localResources, MailQueueFactory<?> mailQueueFactory); }
JamesMailetContext implements MailetContext, Configurable, Disposable { @Override public void sendMail(MimeMessage message) throws MessagingException { MailAddress sender = new MailAddress((InternetAddress) message.getFrom()[0]); Collection<MailAddress> recipients = new HashSet<>(); Address[] addresses = message.getAllRecipients(); if (addresses != null) { for (Address address : addresses) { if (address instanceof InternetAddress) { recipients.add(new MailAddress((InternetAddress) address)); } } } sendMail(sender, recipients, message); } @Inject  JamesMailetContext(DNSService dns, DomainList domains, LocalResources localResources, MailQueueFactory<?> mailQueueFactory); @PreDestroy @Override void dispose(); @Override Collection<String> getMailServers(Domain host); @Override Object getAttribute(String key); @Override void setAttribute(String key, Object object); @Override void removeAttribute(String key); @Override Iterator<String> getAttributeNames(); @Override void bounce(Mail mail, String message); @Override void bounce(Mail mail, String message, MailAddress bouncer); @Override List<String> dnsLookup(String s, RecordType recordType); @Override boolean isLocalUser(String name); @Override boolean isLocalEmail(MailAddress mailAddress); @Override Collection<MailAddress> localRecipients(Collection<MailAddress> recipients); @Override MailAddress getPostmaster(); @Override int getMajorVersion(); @Override int getMinorVersion(); @Override @Deprecated Iterator<org.apache.mailet.HostAddress> getSMTPHostAddresses(Domain domainName); @Override String getServerInfo(); @Override boolean isLocalServer(Domain domain); @Override @Deprecated void log(String arg0); @Override @Deprecated void log(String arg0, Throwable arg1); @Override @Deprecated void log(LogLevel logLevel, String s); @Override @Deprecated void log(LogLevel logLevel, String s, Throwable throwable); @Override void sendMail(MimeMessage message); @Override void sendMail(MailAddress sender, Collection<MailAddress> recipients, MimeMessage message); @Override void sendMail(Mail mail); @Override void sendMail(Mail mail, long delay, TimeUnit unit); @Override void sendMail(Mail mail, String state); @Override void sendMail(Mail mail, String state, long delay, TimeUnit unit); @Override void sendMail(MailAddress sender, Collection<MailAddress> recipients, MimeMessage message, String state); @Override void configure(HierarchicalConfiguration<ImmutableNode> config); @Override Logger getLogger(); }
JamesMailetContext implements MailetContext, Configurable, Disposable { @Override public void sendMail(MimeMessage message) throws MessagingException { MailAddress sender = new MailAddress((InternetAddress) message.getFrom()[0]); Collection<MailAddress> recipients = new HashSet<>(); Address[] addresses = message.getAllRecipients(); if (addresses != null) { for (Address address : addresses) { if (address instanceof InternetAddress) { recipients.add(new MailAddress((InternetAddress) address)); } } } sendMail(sender, recipients, message); } @Inject  JamesMailetContext(DNSService dns, DomainList domains, LocalResources localResources, MailQueueFactory<?> mailQueueFactory); @PreDestroy @Override void dispose(); @Override Collection<String> getMailServers(Domain host); @Override Object getAttribute(String key); @Override void setAttribute(String key, Object object); @Override void removeAttribute(String key); @Override Iterator<String> getAttributeNames(); @Override void bounce(Mail mail, String message); @Override void bounce(Mail mail, String message, MailAddress bouncer); @Override List<String> dnsLookup(String s, RecordType recordType); @Override boolean isLocalUser(String name); @Override boolean isLocalEmail(MailAddress mailAddress); @Override Collection<MailAddress> localRecipients(Collection<MailAddress> recipients); @Override MailAddress getPostmaster(); @Override int getMajorVersion(); @Override int getMinorVersion(); @Override @Deprecated Iterator<org.apache.mailet.HostAddress> getSMTPHostAddresses(Domain domainName); @Override String getServerInfo(); @Override boolean isLocalServer(Domain domain); @Override @Deprecated void log(String arg0); @Override @Deprecated void log(String arg0, Throwable arg1); @Override @Deprecated void log(LogLevel logLevel, String s); @Override @Deprecated void log(LogLevel logLevel, String s, Throwable throwable); @Override void sendMail(MimeMessage message); @Override void sendMail(MailAddress sender, Collection<MailAddress> recipients, MimeMessage message); @Override void sendMail(Mail mail); @Override void sendMail(Mail mail, long delay, TimeUnit unit); @Override void sendMail(Mail mail, String state); @Override void sendMail(Mail mail, String state, long delay, TimeUnit unit); @Override void sendMail(MailAddress sender, Collection<MailAddress> recipients, MimeMessage message, String state); @Override void configure(HierarchicalConfiguration<ImmutableNode> config); @Override Logger getLogger();  }