final String subject = composedMessage.getSubject(); final SendMailConfig sendMailConfig = configurationService.getSendMailConfiguration(); message.setSubject(subject, sendMailConfig.getCharset()); message.setSentDate(new Date()); message.setText(composedMessage.getContent(), composedMessage.getCharset(), composedMessage.getContentType()); } else { message.setText(composedMessage.getContent(), sendMailConfig.getCharset());
@Test public void sendMailSyncWithIcalAndAttachmentTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = "ABC"; final Collection<MailAttachment> attachments = new ArrayList<>(); when(attachment.getFilename()).thenReturn("test.abc"); sendMail.send(message, icalContent, attachments, false); }
@Test public void sendMailSyncWithAttachmentTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = null; final Collection<MailAttachment> attachments = new ArrayList<>(); when(attachment.getFilename()).thenReturn("test.abc"); attachments.add(attachment); sendMail.send(message, icalContent, attachments, false); }
@Test public void sendMailSyncWithIcalTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = "ABC"; final Collection<? extends MailAttachment> attachments = null; sendMail.send(message, icalContent, attachments, false); }
@Test public void sendMailSyncTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); message.setContent(""); final String icalContent = null; final Collection<? extends MailAttachment> attachments = null; sendMail.send(message, icalContent, attachments, false); }
@Test public void sendMailSyncNullContentTest() { when(mailSessionLocalSettingsConfigModel.isEmailEnabled()).thenReturn(true); when(mailSessionLocalSettingsConfigModel.getStandardEmailSender()).thenReturn("sender@test.de"); when(configurationService.createMailSessionLocalSettingsConfigModel()).thenReturn(mailSessionLocalSettingsConfigModel); when(configurationService.getSendMailConfiguration()).thenReturn(sendMailConfiguration); when(sendMailConfiguration.getCharset()).thenReturn("UTF-8"); final Mail message = new Mail(); final PFUserDO toUser = new PFUserDO(); toUser.setEmail("devnull@test.de"); message.setTo(toUser); final String icalContent = null; final Collection<? extends MailAttachment> attachments = null; try { sendMail.send(message, icalContent, attachments, false); assertTrue(false); } catch (InternalErrorException e) { //OK //java.lang.NullPointerException: null //at com.sun.mail.handlers.text_plain.writeTo(text_plain.java:152) } }
} else { type = "text/html; charset="; type += sendMailConfig.getCharset();