EmailServiceCamelSmtpImpl implements EmailService { @Override public void sendFormattedEmail(String recipients, String subject, String body, Object... values) { Assert.hasText(subject, "the subject must not be empty"); Assert.hasText(body, "the body must not be empty"); if (StringUtils.isNotEmpty(recipients)) { Map<String, Object> map = new HashMap<String, Object>(); map.put("To", recipients); map.put("From", from.getValue()); map.put("Subject", subject); producerTemplate.sendBodyAndHeaders("smtp: } }  @Override void sendEmailToAdmins(String subject, String body); @Override void sendFormattedEmail(String recipients, String subject, String body, Object... values);  }
@Test public void testSendFormattedEmail_ok() { final String recipients = "admin@oh.or"; final String from = "openhub@openwise.cz"; setPrivateField(emailService, "from", new FixedConfigurationItem<>(from)); emailService.sendFormattedEmail(recipients, TEST_SUBJECT, TEST_BODY); final Map<String, Object> expected = new HashMap<>(); expected.put("To", recipients); expected.put("From", from); expected.put("Subject", TEST_SUBJECT); verify(producerTemplateMock, times(1)).sendBodyAndHeaders(eq("smtp: }
@Test public void testSendFormattedEmail_noRecipients() { emailService.sendFormattedEmail(null, TEST_SUBJECT, TEST_BODY); verify(producerTemplateMock, never()).sendBodyAndHeaders(eq("smtp: }