@Test public void sendMailWithTemplateAndInlinePictureThrowExceptionWhenPictureIsNull() throws IOException, CannotSendEmailException, TemplateException { final Email email = getSimpleMail(); assertThat(email.getSentAt(), is(nullValue())); when(templateService.mergeTemplateIntoString(any(String.class), any(Map.class))).thenReturn("doesn't matter"); thrown.expect(NullPointerException.class); mailService.send(email, "never_called.ftl", Maps.newHashMap(), null); fail(); }
@Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final TemplateService templateService,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final TemplateService templateService,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Override MimeMessage send(final @NonNull Email email); MimeMessage send(final @NonNull Email email,
                            final @NonNull String template,
                            final Map<String, Object> modelObject,
                            final @NonNull InlinePicture... inlinePictures); }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final TemplateService templateService,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Override MimeMessage send(final @NonNull Email email); MimeMessage send(final @NonNull Email email,
                            final @NonNull String template,
                            final Map<String, Object> modelObject,
                            final @NonNull InlinePicture... inlinePictures);  }