@Test public void shouldNotSendEmailIfMailSendingFlagIsFalse() throws ExecutionException, InterruptedException { SimpleMailMessage message = make(a(defaultEmailMessage, with(receiver, "alert.open.lmis@gmail.com"))); EmailService service = new EmailService(mailSender, repository, false); boolean status = service.send(message).get(); assertTrue(status); }
@Async public Future<Boolean> send(SimpleMailMessage emailMessage) { if (!mailSendingFlag) { return new AsyncResult<>(true); } sendMsgHelper(emailMessage); return new AsyncResult<>(true); }
EmailService { @Async public Future<Boolean> send(SimpleMailMessage emailMessage) { if (!mailSendingFlag) { return new AsyncResult<>(true); } sendMsgHelper(emailMessage); return new AsyncResult<>(true); } }
EmailService { @Async public Future<Boolean> send(SimpleMailMessage emailMessage) { if (!mailSendingFlag) { return new AsyncResult<>(true); } sendMsgHelper(emailMessage); return new AsyncResult<>(true); } @Autowired  EmailService(@Qualifier("mailSender") JavaMailSenderImpl mailSender, EmailNotificationRepository repository,
                      @Value("${mail.sending.flag}") Boolean mailSendingFlag); }
EmailService { @Async public Future<Boolean> send(SimpleMailMessage emailMessage) { if (!mailSendingFlag) { return new AsyncResult<>(true); } sendMsgHelper(emailMessage); return new AsyncResult<>(true); } @Autowired  EmailService(@Qualifier("mailSender") JavaMailSenderImpl mailSender, EmailNotificationRepository repository,
                      @Value("${mail.sending.flag}") Boolean mailSendingFlag); @Async Future<Boolean> send(SimpleMailMessage emailMessage); void processEmails(@Payload List<EmailMessage> mailMessage); @Async void processEmailsAsync(List<EmailMessage> simpleMailMessage); void queueMessage(SimpleMailMessage message); EmailMessage queueEmailMessage(EmailMessage message); List<EmailAttachment> insertEmailAttachmentList(List<EmailAttachment> attachments); void queueHtmlMessage(String to, String subject, String template, Map model); void sendMimeMessage(final String to, final String subject, final String messageBody,
                              final String attachmentFileName, final DataSource dataSource); }
EmailService { @Async public Future<Boolean> send(SimpleMailMessage emailMessage) { if (!mailSendingFlag) { return new AsyncResult<>(true); } sendMsgHelper(emailMessage); return new AsyncResult<>(true); } @Autowired  EmailService(@Qualifier("mailSender") JavaMailSenderImpl mailSender, EmailNotificationRepository repository,
                      @Value("${mail.sending.flag}") Boolean mailSendingFlag); @Async Future<Boolean> send(SimpleMailMessage emailMessage); void processEmails(@Payload List<EmailMessage> mailMessage); @Async void processEmailsAsync(List<EmailMessage> simpleMailMessage); void queueMessage(SimpleMailMessage message); EmailMessage queueEmailMessage(EmailMessage message); List<EmailAttachment> insertEmailAttachmentList(List<EmailAttachment> attachments); void queueHtmlMessage(String to, String subject, String template, Map model); void sendMimeMessage(final String to, final String subject, final String messageBody,
                              final String attachmentFileName, final DataSource dataSource);  }