@Test public void shouldInsertAttachmentListOfMailMessage() throws Exception { repository = mock(EmailNotificationRepository.class); EmailService service = new EmailService(mailSender, repository, true); List<EmailAttachment> attachments = asList(new EmailAttachment(), new EmailAttachment()); service.insertEmailAttachmentList(attachments); verify(repository, times(2)).insertEmailAttachment(any(EmailAttachment.class)); }
public List<EmailAttachment> insertEmailAttachmentList(List<EmailAttachment> attachments) { for (EmailAttachment attachment : attachments) { repository.insertEmailAttachment(attachment); } return attachments; }
EmailService { public List<EmailAttachment> insertEmailAttachmentList(List<EmailAttachment> attachments) { for (EmailAttachment attachment : attachments) { repository.insertEmailAttachment(attachment); } return attachments; } }
EmailService { public List<EmailAttachment> insertEmailAttachmentList(List<EmailAttachment> attachments) { for (EmailAttachment attachment : attachments) { repository.insertEmailAttachment(attachment); } return attachments; } @Autowired  EmailService(@Qualifier("mailSender") JavaMailSenderImpl mailSender, EmailNotificationRepository repository,
                      @Value("${mail.sending.flag}") Boolean mailSendingFlag); }
EmailService { public List<EmailAttachment> insertEmailAttachmentList(List<EmailAttachment> attachments) { for (EmailAttachment attachment : attachments) { repository.insertEmailAttachment(attachment); } return attachments; } @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 { public List<EmailAttachment> insertEmailAttachmentList(List<EmailAttachment> attachments) { for (EmailAttachment attachment : attachments) { repository.insertEmailAttachment(attachment); } return attachments; } @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);  }