@Test public void sendMailWithTemplateShouldThrowExceptionWhenEmailIsNull() throws CannotSendEmailException { final String imageName = "100_percent_free.jpg"; final File inlineImageFile = new File(getClass().getClassLoader() .getResource("images" + File.separator + imageName).getFile()); thrown.expect(NullPointerException.class); mailService.send(null, "never_called.ftl", Maps.newHashMap(), getInlinePicture(inlineImageFile, imageName)); 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);  }