Search in sources :

Example 6 with SentReminderImpl

use of org.olat.modules.reminder.model.SentReminderImpl in project OpenOLAT by OpenOLAT.

the class ReminderDAO method markAsSend.

public SentReminderImpl markAsSend(Reminder reminder, Identity identity, String status) {
    SentReminderImpl send = new SentReminderImpl();
    send.setCreationDate(new Date());
    send.setStatus(status);
    send.setReminder(reminder);
    send.setIdentity(identity);
    dbInstance.getCurrentEntityManager().persist(send);
    return send;
}
Also used : SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) Date(java.util.Date)

Example 7 with SentReminderImpl

use of org.olat.modules.reminder.model.SentReminderImpl in project OpenOLAT by OpenOLAT.

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());
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 8 with SentReminderImpl

use of org.olat.modules.reminder.model.SentReminderImpl in project OpenOLAT by OpenOLAT.

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());
}
Also used : Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 9 with SentReminderImpl

use of org.olat.modules.reminder.model.SentReminderImpl 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());
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 10 with SentReminderImpl

use of org.olat.modules.reminder.model.SentReminderImpl in project openolat by klemens.

the class ReminderDAO method markAsSend.

public SentReminderImpl markAsSend(Reminder reminder, Identity identity, String status) {
    SentReminderImpl send = new SentReminderImpl();
    send.setCreationDate(new Date());
    send.setStatus(status);
    send.setReminder(reminder);
    send.setIdentity(identity);
    dbInstance.getCurrentEntityManager().persist(send);
    return send;
}
Also used : SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) Date(java.util.Date)

Aggregations

SentReminderImpl (org.olat.modules.reminder.model.SentReminderImpl)10 Test (org.junit.Test)8 Identity (org.olat.core.id.Identity)8 Reminder (org.olat.modules.reminder.Reminder)8 SentReminder (org.olat.modules.reminder.SentReminder)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 Date (java.util.Date)2 ReminderInfos (org.olat.modules.reminder.model.ReminderInfos)2