use of org.olat.modules.reminder.SentReminder in project openolat by klemens.
the class ReminderDAOTest method createAndPersistSendReminder.
@Test
public void createAndPersistSendReminder() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-2");
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("mind-1");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder reminder = reminderDao.createReminder(entry, creator);
reminder.setConfiguration("<rules></rules>");
reminder.setDescription("Reminder - 2");
reminder.setEmailSubject("This is a subject");
reminder.setEmailBody("Hello world");
Reminder savedReminder = reminderDao.save(reminder);
Assert.assertNotNull(savedReminder);
dbInstance.commitAndCloseSession();
// mark as sent
reminderDao.markAsSend(reminder, id, "ok");
dbInstance.commitAndCloseSession();
// reload
List<SentReminder> sentReminders = reminderDao.getSendReminders(savedReminder);
Assert.assertNotNull(sentReminders);
Assert.assertEquals(1, sentReminders.size());
SentReminder sentReminder = sentReminders.get(0);
Assert.assertNotNull(sentReminder);
Assert.assertNotNull(sentReminder.getCreationDate());
Assert.assertEquals(id, sentReminder.getIdentity());
Assert.assertEquals(savedReminder, sentReminder.getReminder());
}
use of org.olat.modules.reminder.SentReminder in project openolat by klemens.
the class ReminderDAOTest method getSendReminders_byReminder.
@Test
public void getSendReminders_byReminder() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-7");
Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-7a");
Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-7b");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder savedReminder = createAndSaveReminder(entry, creator, 7);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedReminder);
// send 3 reminders
SentReminderImpl sentReminder1 = reminderDao.markAsSend(savedReminder, recepient1, "ok");
SentReminderImpl sentReminder2 = reminderDao.markAsSend(savedReminder, recepient2, "error");
SentReminderImpl sentReminder3 = reminderDao.markAsSend(savedReminder, recepient1, "error");
dbInstance.commitAndCloseSession();
// load the sent reminder log
List<SentReminder> sentReminders = reminderDao.getSendReminders(savedReminder);
Assert.assertNotNull(sentReminders);
Assert.assertEquals(3, sentReminders.size());
Assert.assertTrue(sentReminders.contains(sentReminder1));
Assert.assertTrue(sentReminders.contains(sentReminder2));
Assert.assertTrue(sentReminders.contains(sentReminder3));
}
use of org.olat.modules.reminder.SentReminder in project openolat by klemens.
the class ReminderDAOTest method markAsSend.
@Test
public void markAsSend() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-5");
Identity recepient = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-5");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder savedReminder = createAndSaveReminder(entry, creator, 5);
Assert.assertNotNull(savedReminder);
dbInstance.commitAndCloseSession();
SentReminderImpl sentReminder = reminderDao.markAsSend(savedReminder, recepient, "ok");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(sentReminder);
Assert.assertNotNull(sentReminder.getKey());
Assert.assertEquals("ok", sentReminder.getStatus());
Assert.assertEquals(savedReminder, sentReminder.getReminder());
Assert.assertEquals(recepient, sentReminder.getIdentity());
}
use of org.olat.modules.reminder.SentReminder in project openolat by klemens.
the class ReminderDAOTest method getSendReminders_byRepositoryEntry.
@Test
public void getSendReminders_byRepositoryEntry() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-8");
Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-8a");
Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-8b");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder savedReminder = createAndSaveReminder(entry, creator, 8);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedReminder);
// send 3 reminders
SentReminderImpl sentReminder1 = reminderDao.markAsSend(savedReminder, recepient1, "ok");
SentReminderImpl sentReminder2 = reminderDao.markAsSend(savedReminder, recepient2, "error");
SentReminderImpl sentReminder3 = reminderDao.markAsSend(savedReminder, recepient2, "error");
dbInstance.commitAndCloseSession();
// load the sent reminder log
List<SentReminder> sentReminders = reminderDao.getSendReminders(entry);
Assert.assertNotNull(sentReminders);
Assert.assertEquals(3, sentReminders.size());
Assert.assertTrue(sentReminders.contains(sentReminder1));
Assert.assertTrue(sentReminders.contains(sentReminder2));
Assert.assertTrue(sentReminders.contains(sentReminder3));
}
use of org.olat.modules.reminder.SentReminder in project openolat by klemens.
the class ReminderDAOTest method deleteReminder_paranoia.
/**
* Check that not all reminders are deleted from the database.
*/
@Test
public void deleteReminder_paranoia() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-10");
Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-10a");
Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-10b");
Identity recepient3 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-10c");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder reminderToDelete = createAndSaveReminder(entry, creator, 10);
Reminder survivingReminder = createAndSaveReminder(entry, creator, 10);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(reminderToDelete);
// send 4 reminders
reminderDao.markAsSend(reminderToDelete, recepient1, "ok");
reminderDao.markAsSend(reminderToDelete, recepient2, "error");
SentReminder sentReminder1 = reminderDao.markAsSend(survivingReminder, recepient3, "error");
SentReminder sentReminder2 = reminderDao.markAsSend(survivingReminder, recepient2, "error");
dbInstance.commitAndCloseSession();
// check
List<SentReminder> sentRemindersToDelete = reminderDao.getSendReminders(reminderToDelete);
Assert.assertNotNull(sentRemindersToDelete);
Assert.assertEquals(2, sentRemindersToDelete.size());
List<SentReminder> survivingSentReminders = reminderDao.getSendReminders(survivingReminder);
Assert.assertNotNull(survivingSentReminders);
Assert.assertEquals(2, survivingSentReminders.size());
reminderDao.delete(reminderToDelete);
dbInstance.commit();
// check that the reminder is missing
List<Reminder> deletedReminders = reminderDao.getReminders(entry);
Assert.assertNotNull(deletedReminders);
Assert.assertEquals(1, deletedReminders.size());
Assert.assertEquals(survivingReminder, deletedReminders.get(0));
// check that the send reminders are deleted but not all
List<SentReminder> reloadedSurvivingSentReminders = reminderDao.getSendReminders(survivingReminder);
Assert.assertNotNull(reloadedSurvivingSentReminders);
Assert.assertEquals(2, reloadedSurvivingSentReminders.size());
List<SentReminder> allSurvivingSentReminders = reminderDao.getSendReminders(entry);
Assert.assertNotNull(allSurvivingSentReminders);
Assert.assertEquals(2, allSurvivingSentReminders.size());
Assert.assertTrue(allSurvivingSentReminders.contains(sentReminder1));
Assert.assertTrue(allSurvivingSentReminders.contains(sentReminder2));
}
Aggregations