@Test public void fromShouldThrowOnNullMimeMessageToDecorate() throws Exception { assertThatThrownBy(() -> mimeMessageBodyGenerator.from(null, Optional.empty(), Optional.empty())) .isInstanceOf(NullPointerException.class); }
public MimeMessage from(MimeMessage messageHoldingHeaders, Optional<String> plainText, Optional<String> htmlText) throws MessagingException { Preconditions.checkNotNull(messageHoldingHeaders); Preconditions.checkNotNull(plainText); Preconditions.checkNotNull(htmlText); if (htmlText.isPresent()) { messageHoldingHeaders.setContent(generateMultipart(htmlText.get(), plainText)); } else { messageHoldingHeaders.setText(plainText.orElse(EMPTY_TEXT)); } return messageHoldingHeaders; }
MimeMessageBodyGenerator { public MimeMessage from(MimeMessage messageHoldingHeaders, Optional<String> plainText, Optional<String> htmlText) throws MessagingException { Preconditions.checkNotNull(messageHoldingHeaders); Preconditions.checkNotNull(plainText); Preconditions.checkNotNull(htmlText); if (htmlText.isPresent()) { messageHoldingHeaders.setContent(generateMultipart(htmlText.get(), plainText)); } else { messageHoldingHeaders.setText(plainText.orElse(EMPTY_TEXT)); } return messageHoldingHeaders; } }
MimeMessageBodyGenerator { public MimeMessage from(MimeMessage messageHoldingHeaders, Optional<String> plainText, Optional<String> htmlText) throws MessagingException { Preconditions.checkNotNull(messageHoldingHeaders); Preconditions.checkNotNull(plainText); Preconditions.checkNotNull(htmlText); if (htmlText.isPresent()) { messageHoldingHeaders.setContent(generateMultipart(htmlText.get(), plainText)); } else { messageHoldingHeaders.setText(plainText.orElse(EMPTY_TEXT)); } return messageHoldingHeaders; } @Inject @VisibleForTesting  MimeMessageBodyGenerator(HtmlTextExtractor htmlTextExtractor); }
MimeMessageBodyGenerator { public MimeMessage from(MimeMessage messageHoldingHeaders, Optional<String> plainText, Optional<String> htmlText) throws MessagingException { Preconditions.checkNotNull(messageHoldingHeaders); Preconditions.checkNotNull(plainText); Preconditions.checkNotNull(htmlText); if (htmlText.isPresent()) { messageHoldingHeaders.setContent(generateMultipart(htmlText.get(), plainText)); } else { messageHoldingHeaders.setText(plainText.orElse(EMPTY_TEXT)); } return messageHoldingHeaders; } @Inject @VisibleForTesting  MimeMessageBodyGenerator(HtmlTextExtractor htmlTextExtractor); MimeMessage from(MimeMessage messageHoldingHeaders, Optional<String> plainText, Optional<String> htmlText); }
MimeMessageBodyGenerator { public MimeMessage from(MimeMessage messageHoldingHeaders, Optional<String> plainText, Optional<String> htmlText) throws MessagingException { Preconditions.checkNotNull(messageHoldingHeaders); Preconditions.checkNotNull(plainText); Preconditions.checkNotNull(htmlText); if (htmlText.isPresent()) { messageHoldingHeaders.setContent(generateMultipart(htmlText.get(), plainText)); } else { messageHoldingHeaders.setText(plainText.orElse(EMPTY_TEXT)); } return messageHoldingHeaders; } @Inject @VisibleForTesting  MimeMessageBodyGenerator(HtmlTextExtractor htmlTextExtractor); MimeMessage from(MimeMessage messageHoldingHeaders, Optional<String> plainText, Optional<String> htmlText); static final String MIXED; static final String EMPTY_TEXT; }