Search in sources :

Example 11 with ProcessingEvent

use of com.openmeap.event.ProcessingEvent in project OpenMEAP by OpenMEAP.

the class ProcessingUtils method toArray.

@SuppressWarnings("rawtypes")
public static ProcessingEvent[] toArray(Collection<ProcessingEvent> events) {
    ProcessingEvent[] ev = new ProcessingEvent[events.size()];
    int i = 0;
    for (ProcessingEvent event : events) ev[i++] = event;
    return ev;
}
Also used : ProcessingEvent(com.openmeap.event.ProcessingEvent)

Example 12 with ProcessingEvent

use of com.openmeap.event.ProcessingEvent in project OpenMEAP by OpenMEAP.

the class ModelManagerImplTest method testFireEventHandlers.

@Test
public void testFireEventHandlers() throws InvalidPropertiesException, PersistenceException {
    List<ModelServiceEventNotifier> handlers = new ArrayList<ModelServiceEventNotifier>();
    class MockUpdateNotifier extends AbstractModelServiceEventNotifier<ModelEntity> {

        public Boolean eventFired = false;

        public Boolean getEventFired() {
            return eventFired;
        }

        @Override
        public Boolean notifiesFor(ModelServiceOperation operation, ModelEntity payload) {
            return true;
        }

        @Override
        public <E extends Event<ModelEntity>> void onInCommitAfterCommit(E event, List<ProcessingEvent> events) throws EventNotificationException {
            eventFired = true;
        }
    }
    ;
    handlers.add(new MockUpdateNotifier());
    modelManager.setEventNotifiers(handlers);
    Application app = modelManager.getModelService().findByPrimaryKey(Application.class, 1L);
    try {
        modelManager.begin().addModify(app, null);
        modelManager.commit();
    } catch (Exception e) {
        modelManager.rollback();
    }
    Assert.assertTrue(((MockUpdateNotifier) modelManager.getEventNotifiers().toArray()[0]).getEventFired());
}
Also used : ArrayList(java.util.ArrayList) AbstractModelServiceEventNotifier(com.openmeap.model.event.notifier.AbstractModelServiceEventNotifier) ModelServiceEventNotifier(com.openmeap.model.event.notifier.ModelServiceEventNotifier) PersistenceException(javax.persistence.PersistenceException) EventNotificationException(com.openmeap.event.EventNotificationException) AbstractModelServiceEventNotifier(com.openmeap.model.event.notifier.AbstractModelServiceEventNotifier) ProcessingEvent(com.openmeap.event.ProcessingEvent) Event(com.openmeap.event.Event) ArrayList(java.util.ArrayList) List(java.util.List) Application(com.openmeap.model.dto.Application) Test(org.junit.Test)

Aggregations

ProcessingEvent (com.openmeap.event.ProcessingEvent)12 Application (com.openmeap.model.dto.Application)7 ApplicationVersion (com.openmeap.model.dto.ApplicationVersion)7 ArrayList (java.util.ArrayList)6 MessagesEvent (com.openmeap.event.MessagesEvent)5 Anchor (com.openmeap.web.html.Anchor)5 HashMap (java.util.HashMap)5 PersistenceException (javax.persistence.PersistenceException)5 AddSubNavAnchorEvent (com.openmeap.admin.web.events.AddSubNavAnchorEvent)4 InvalidPropertiesException (com.openmeap.model.InvalidPropertiesException)4 Test (org.junit.Test)4 ModelManager (com.openmeap.model.ModelManager)3 AddModifyApplicationVersionBacking (com.openmeap.admin.web.backing.AddModifyApplicationVersionBacking)2 Deployment (com.openmeap.model.dto.Deployment)2 GlobalSettings (com.openmeap.model.dto.GlobalSettings)2 Event (com.openmeap.event.Event)1 EventNotificationException (com.openmeap.event.EventNotificationException)1 ClusterNode (com.openmeap.model.dto.ClusterNode)1 AbstractModelServiceEventNotifier (com.openmeap.model.event.notifier.AbstractModelServiceEventNotifier)1 ModelServiceEventNotifier (com.openmeap.model.event.notifier.ModelServiceEventNotifier)1