use of org.olat.modules.reminder.Reminder in project openolat by klemens.
the class ReminderDAOTest method getReminders_repositoryEntry_softDeleted.
@Test
public void getReminders_repositoryEntry_softDeleted() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-12");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder reminder = reminderDao.createReminder(entry, creator);
reminder.setConfiguration("<rules></rules>");
reminder.setDescription("Reminder - 12");
reminder.setEmailSubject("This is a deleted subject");
reminder.setEmailBody("Hello, I'm deleted");
Reminder savedReminder = reminderDao.save(reminder);
Assert.assertNotNull(savedReminder);
dbInstance.commitAndCloseSession();
// check that we found the reminder
List<Reminder> loadedReminders = reminderDao.getReminders(new Date());
Assert.assertNotNull(loadedReminders);
Assert.assertTrue(loadedReminders.contains(savedReminder));
// delete the resource
repositoryService.deleteSoftly(entry, creator, false);
dbInstance.commitAndCloseSession();
// check we don't found the reminder
List<Reminder> reloadedReminders = reminderDao.getReminders(new Date());
Assert.assertNotNull(reloadedReminders);
Assert.assertFalse(reloadedReminders.contains(savedReminder));
}
use of org.olat.modules.reminder.Reminder in project openolat by klemens.
the class ReminderDAOTest method getReminderInfos.
@Test
public void getReminderInfos() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-6");
Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-6a");
Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-6b");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder savedReminder = createAndSaveReminder(entry, creator, 6);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedReminder);
// send 2 reminders
SentReminderImpl sentReminder1 = reminderDao.markAsSend(savedReminder, recepient1, "ok");
SentReminderImpl sentReminder2 = reminderDao.markAsSend(savedReminder, recepient2, "error");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(sentReminder1);
Assert.assertNotNull(sentReminder2);
// check reminder infos
List<ReminderInfos> reminderInfos = reminderDao.getReminderInfos(entry);
Assert.assertNotNull(reminderInfos);
Assert.assertEquals(1, reminderInfos.size());
ReminderInfos reminderInfo = reminderInfos.get(0);
Assert.assertNotNull(reminderInfo);
Assert.assertEquals(savedReminder.getKey(), reminderInfo.getKey());
Assert.assertEquals(2, reminderInfo.getNumOfRemindersSent());
Assert.assertEquals(creator.getKey(), reminderInfo.getCreatorKey());
Assert.assertEquals("Reminder - 6", reminderInfo.getDescription());
}
use of org.olat.modules.reminder.Reminder in project openolat by klemens.
the class ReminderDAOTest method getReminders_repositoryEntry.
@Test
public void getReminders_repositoryEntry() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-4");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder reminder = reminderDao.createReminder(entry, creator);
reminder.setConfiguration("<rules></rules>");
reminder.setDescription("Reminder - 4");
reminder.setEmailSubject("This is a subject");
reminder.setEmailBody("Hello world");
Reminder savedReminder = reminderDao.save(reminder);
Assert.assertNotNull(savedReminder);
dbInstance.commitAndCloseSession();
List<Reminder> loadedReminders = reminderDao.getReminders(entry);
Assert.assertNotNull(loadedReminders);
Assert.assertEquals(1, loadedReminders.size());
Reminder loadedReminder = loadedReminders.get(0);
Assert.assertNotNull(loadedReminder);
Assert.assertEquals(savedReminder, loadedReminder);
Assert.assertEquals(entry, loadedReminder.getEntry());
Assert.assertEquals("Reminder - 4", loadedReminder.getDescription());
Assert.assertEquals("This is a subject", loadedReminder.getEmailSubject());
Assert.assertEquals("Hello world", loadedReminder.getEmailBody());
}
use of org.olat.modules.reminder.Reminder in project openolat by klemens.
the class ReminderDAOTest method createAndPersistReminder.
@Test
public void createAndPersistReminder() {
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-1");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder reminder = reminderDao.createReminder(entry, creator);
Assert.assertNotNull(reminder);
reminder.setConfiguration("<rules></rules>");
reminder.setDescription("Reminder - 1");
reminder.setEmailSubject("This is a subject");
reminder.setEmailBody("Hello world");
// save and check
Reminder savedReminder = reminderDao.save(reminder);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedReminder);
Assert.assertNotNull(savedReminder.getKey());
Assert.assertNotNull(savedReminder.getCreationDate());
Assert.assertNotNull(savedReminder.getLastModified());
Assert.assertNotNull(savedReminder.getEntry());
Assert.assertEquals(entry, savedReminder.getEntry());
Assert.assertEquals("Reminder - 1", savedReminder.getDescription());
Assert.assertEquals("<rules></rules>", savedReminder.getConfiguration());
Assert.assertEquals("This is a subject", savedReminder.getEmailSubject());
Assert.assertEquals("Hello world", savedReminder.getEmailBody());
// reload and double check
Reminder reloadedReminder = reminderDao.loadByKey(savedReminder.getKey());
dbInstance.commitAndCloseSession();
Assert.assertNotNull(reloadedReminder);
Assert.assertEquals(savedReminder.getKey(), reloadedReminder.getKey());
Assert.assertNotNull(reloadedReminder.getCreationDate());
Assert.assertNotNull(reloadedReminder.getLastModified());
Assert.assertEquals(entry, reloadedReminder.getEntry());
Assert.assertEquals(savedReminder, reloadedReminder);
Assert.assertEquals("Reminder - 1", reloadedReminder.getDescription());
Assert.assertEquals("<rules></rules>", reloadedReminder.getConfiguration());
Assert.assertEquals("This is a subject", reloadedReminder.getEmailSubject());
Assert.assertEquals("Hello world", reloadedReminder.getEmailBody());
}
use of org.olat.modules.reminder.Reminder in project openolat by klemens.
the class ReminderDAOTest method getReminders_startDate.
@Test
public void getReminders_startDate() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-3");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder savedReminder = createAndSaveReminder(entry, creator, 3);
Assert.assertNotNull(savedReminder);
dbInstance.commitAndCloseSession();
Date now = new Date();
boolean found = false;
List<Reminder> loadedReminders = reminderDao.getReminders(now);
for (Reminder loadedReminder : loadedReminders) {
if (loadedReminder.equals(savedReminder)) {
found = true;
}
}
Assert.assertTrue(found);
}
Aggregations