userTO.addMembership(membershipTO);
userController.create(new MockHttpServletResponse(), userTO);
// 3. Set number of retries
SyncopeConf retryConf = confDAO.find("notification.maxRetries");
retryConf.setValue("5");
confDAO.save(retryConf);
confDAO.flush();
// 4. Stop mail server to force error sending mail
stopGreenMail();
// 5. force Quartz job execution multiple times
for (int i = 0; i < 10; i++) {
notificationJob.execute(null);
}
// 6. get NotificationTask, count number of executions
NotificationTask foundTask = null;
for (NotificationTask task : taskDAO.findAll(NotificationTask.class)) {
if (sender.equals(task.getSender())) {
foundTask = task;
}
}
assertNotNull(foundTask);
assertEquals(6, notificationManager.countExecutionsWithStatus(foundTask.getId(),
NotificationJob.Status.NOT_SENT.name()));
// 7. start mail server again
startGreenMail();
// 8. reset number of retries
retryConf.setValue("0");
confDAO.save(retryConf);
confDAO.flush();
}