use of com.autentia.tnt.mail.MailService in project TNTConcept by autentia.
the class SiiBean method sendReportEmail.
public void sendReportEmail(String report) {
if (report != null) {
Map<InputStream, String> attachments = new ConcurrentHashMap<>();
String filename = reportName();
attachments.put(getStreamReport(report), filename);
String subject = "SII_" + filename.split(".csv")[0];
ExecutorService executor = Executors.newFixedThreadPool(1);
// Runnable, return void, submit and run the task async
executor.submit(() -> {
try {
String[] recipients = to.trim().split("[;,]");
MailService mailService = (DefaultMailService) SpringUtils.getSpringBean("mailService");
mailService.sendOutputStreams(recipients, subject, "", attachments);
context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Email enviado correctamente", null));
} catch (MessagingException e) {
System.err.println(e.getMessage());
}
});
executor.shutdown();
}
}
use of com.autentia.tnt.mail.MailService in project TNTConcept by autentia.
the class ActivityEvidenceNotificationBean_IT method setup.
@Before
public void setup() {
// load test application context including security configuration
ApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext-test.xml");
SpringUtilsForTesting.configure(appCtx);
// each test starts its own transaction
sessionFactory = HibernateUtil.getSessionFactory();
sessionFactory.openSession();
sessionFactory.getCurrentSession().beginTransaction();
// a user is required in the database to load the security context
SpringUtilsForTesting.loadPrincipalInSecurityContext("admin");
mailService = Mockito.mock(MailService.class);
}
Aggregations