Search in sources :

Example 1 with NotificationsManagerImpl

use of org.olat.core.commons.services.notifications.manager.NotificationsManagerImpl in project OpenOLAT by OpenOLAT.

the class NotificationsManagerTest method testDuplicateSubscribers.

@Test(expected = DBRuntimeException.class)
public void testDuplicateSubscribers() throws Exception {
    try {
        PublisherData pd = new PublisherData("CreateSubscriber@2x", "e.g. forumdata=keyofforum", null);
        SubscriptionContext sc = new SubscriptionContext("Course", new Long(1238778567), UUID.randomUUID().toString().replace("-", ""));
        Identity id = JunitTestHelper.createAndPersistIdentityAsUser("fci@2x-" + UUID.randomUUID().toString());
        Publisher publisher = notificationManager.getOrCreatePublisher(sc, pd);
        dbInstance.commit();
        ((NotificationsManagerImpl) notificationManager).doCreateAndPersistSubscriber(publisher, id);
        dbInstance.commit();
        ((NotificationsManagerImpl) notificationManager).doCreateAndPersistSubscriber(publisher, id);
        dbInstance.commit();
    } catch (Exception e) {
        dbInstance.rollback();
        throw e;
    }
}
Also used : NotificationsManagerImpl(org.olat.core.commons.services.notifications.manager.NotificationsManagerImpl) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) DBRuntimeException(org.olat.core.logging.DBRuntimeException) Test(org.junit.Test)

Example 2 with NotificationsManagerImpl

use of org.olat.core.commons.services.notifications.manager.NotificationsManagerImpl in project openolat by klemens.

the class NotificationsManagerTest method testDuplicateSubscribers.

@Test(expected = DBRuntimeException.class)
public void testDuplicateSubscribers() throws Exception {
    try {
        PublisherData pd = new PublisherData("CreateSubscriber@2x", "e.g. forumdata=keyofforum", null);
        SubscriptionContext sc = new SubscriptionContext("Course", new Long(1238778567), UUID.randomUUID().toString().replace("-", ""));
        Identity id = JunitTestHelper.createAndPersistIdentityAsUser("fci@2x-" + UUID.randomUUID().toString());
        Publisher publisher = notificationManager.getOrCreatePublisher(sc, pd);
        dbInstance.commit();
        ((NotificationsManagerImpl) notificationManager).doCreateAndPersistSubscriber(publisher, id);
        dbInstance.commit();
        ((NotificationsManagerImpl) notificationManager).doCreateAndPersistSubscriber(publisher, id);
        dbInstance.commit();
    } catch (Exception e) {
        dbInstance.rollback();
        throw e;
    }
}
Also used : NotificationsManagerImpl(org.olat.core.commons.services.notifications.manager.NotificationsManagerImpl) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) DBRuntimeException(org.olat.core.logging.DBRuntimeException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Publisher (org.olat.core.commons.services.notifications.Publisher)2 PublisherData (org.olat.core.commons.services.notifications.PublisherData)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 NotificationsManagerImpl (org.olat.core.commons.services.notifications.manager.NotificationsManagerImpl)2 Identity (org.olat.core.id.Identity)2 DBRuntimeException (org.olat.core.logging.DBRuntimeException)2