@Test void buildMailShouldThrowWhenNullMailboxMessage() throws Exception { MetaDataWithContent message = null; assertThatThrownBy(() -> MessageSender.buildMail(message, envelope)).isInstanceOf(NullPointerException.class); }
@VisibleForTesting static Mail buildMail(MetaDataWithContent message, Envelope envelope) throws MessagingException { String name = message.getMessageId().serialize(); return MailImpl.builder() .name(name) .sender(envelope.getFrom().asOptional().orElseThrow(() -> new RuntimeException("Sender is mandatory"))) .addRecipients(envelope.getRecipients()) .mimeMessage(toMimeMessage(name, message.getContent())) .build(); }
MessageSender { @VisibleForTesting static Mail buildMail(MetaDataWithContent message, Envelope envelope) throws MessagingException { String name = message.getMessageId().serialize(); return MailImpl.builder() .name(name) .sender(envelope.getFrom().asOptional().orElseThrow(() -> new RuntimeException("Sender is mandatory"))) .addRecipients(envelope.getRecipients()) .mimeMessage(toMimeMessage(name, message.getContent())) .build(); } }
MessageSender { @VisibleForTesting static Mail buildMail(MetaDataWithContent message, Envelope envelope) throws MessagingException { String name = message.getMessageId().serialize(); return MailImpl.builder() .name(name) .sender(envelope.getFrom().asOptional().orElseThrow(() -> new RuntimeException("Sender is mandatory"))) .addRecipients(envelope.getRecipients()) .mimeMessage(toMimeMessage(name, message.getContent())) .build(); } @Inject  MessageSender(MailSpool mailSpool); }
MessageSender { @VisibleForTesting static Mail buildMail(MetaDataWithContent message, Envelope envelope) throws MessagingException { String name = message.getMessageId().serialize(); return MailImpl.builder() .name(name) .sender(envelope.getFrom().asOptional().orElseThrow(() -> new RuntimeException("Sender is mandatory"))) .addRecipients(envelope.getRecipients()) .mimeMessage(toMimeMessage(name, message.getContent())) .build(); } @Inject  MessageSender(MailSpool mailSpool); void sendMessage(MetaDataWithContent message,
                            Envelope envelope,
                            MailboxSession session); void sendMessage(MessageId messageId,
                            Mail mail,
                            MailboxSession session); }
MessageSender { @VisibleForTesting static Mail buildMail(MetaDataWithContent message, Envelope envelope) throws MessagingException { String name = message.getMessageId().serialize(); return MailImpl.builder() .name(name) .sender(envelope.getFrom().asOptional().orElseThrow(() -> new RuntimeException("Sender is mandatory"))) .addRecipients(envelope.getRecipients()) .mimeMessage(toMimeMessage(name, message.getContent())) .build(); } @Inject  MessageSender(MailSpool mailSpool); void sendMessage(MetaDataWithContent message,
                            Envelope envelope,
                            MailboxSession session); void sendMessage(MessageId messageId,
                            Mail mail,
                            MailboxSession session);  }