String mimeType = mimeTypesMap.getContentType(attachment.getFilename()); if (StringUtils.isBlank(mimeType)) { mimeType = "application/octet-stream"; mbp[i].setFileName(attachment.getFilename()); mp.addBodyPart(mbp[i]); i++;
@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 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); }