@Test void testSendMultipleMailsWithExceptionWhileSending() throws Exception { AmazonSimpleEmailService emailService = mock(AmazonSimpleEmailService.class); SimpleEmailServiceMailSender mailSender = new SimpleEmailServiceMailSender( emailService); SimpleMailMessage firstMessage = createSimpleMailMessage(); firstMessage.setBcc("bcc@domain.com"); SimpleMailMessage failureMail = createSimpleMailMessage(); when(emailService.sendEmail(ArgumentMatchers.isA(SendEmailRequest.class))) .thenReturn(new SendEmailResult()) .thenThrow(new AmazonClientException("error")) .thenReturn(new SendEmailResult()); SimpleMailMessage thirdMessage = createSimpleMailMessage(); try { mailSender.send(firstMessage, failureMail, thirdMessage); fail("Exception expected due to error while sending mail"); } catch (MailSendException e) { assertThat(e.getFailedMessages().size()).isEqualTo(1); assertThat(e.getFailedMessages().containsKey(failureMail)).isTrue(); } }
@Override public void send(SimpleMailMessage simpleMailMessage) throws MailException { send(new SimpleMailMessage[] { simpleMailMessage }); }
SimpleEmailServiceMailSender implements MailSender, DisposableBean { @Override public void send(SimpleMailMessage simpleMailMessage) throws MailException { send(new SimpleMailMessage[] { simpleMailMessage }); } }
SimpleEmailServiceMailSender implements MailSender, DisposableBean { @Override public void send(SimpleMailMessage simpleMailMessage) throws MailException { send(new SimpleMailMessage[] { simpleMailMessage }); } SimpleEmailServiceMailSender(
			AmazonSimpleEmailService amazonSimpleEmailService); }
SimpleEmailServiceMailSender implements MailSender, DisposableBean { @Override public void send(SimpleMailMessage simpleMailMessage) throws MailException { send(new SimpleMailMessage[] { simpleMailMessage }); } SimpleEmailServiceMailSender(
			AmazonSimpleEmailService amazonSimpleEmailService); @Override void send(SimpleMailMessage simpleMailMessage); @SuppressWarnings("OverloadedVarargsMethod") @Override void send(SimpleMailMessage... simpleMailMessages); @Override final void destroy(); }
SimpleEmailServiceMailSender implements MailSender, DisposableBean { @Override public void send(SimpleMailMessage simpleMailMessage) throws MailException { send(new SimpleMailMessage[] { simpleMailMessage }); } SimpleEmailServiceMailSender(
			AmazonSimpleEmailService amazonSimpleEmailService); @Override void send(SimpleMailMessage simpleMailMessage); @SuppressWarnings("OverloadedVarargsMethod") @Override void send(SimpleMailMessage... simpleMailMessages); @Override final void destroy();  }