use of com.openmeap.model.event.notifier.ModelServiceEventNotifier 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());
}
Aggregations