use of com.openmeap.model.dto.Application in project OpenMEAP by OpenMEAP.
the class EntityRelationshipsTest method testModel.
@Test
public void testModel() {
assertInserts(em);
makeModifications(em);
ApplicationArchive aa = null;
ApplicationVersion av = null;
Application app = null;
// Verify that deleting an application version
// deletes only the version and archive
av = em.find(ApplicationVersion.class, 1L);
app = em.find(Application.class, 1L);
em.getTransaction().begin();
app.removeVersion(av);
em.remove(av);
em.getTransaction().commit();
app = em.find(Application.class, 1L);
aa = em.find(ApplicationArchive.class, 1L);
Assert.assertTrue(app != null);
Assert.assertTrue(aa != null);
// Verify that deleting an application deletes all the crap associated to it
app = em.find(Application.class, 1L);
Assert.assertTrue(app != null);
em.getTransaction().begin();
em.remove(app);
em.getTransaction().commit();
av = em.find(ApplicationVersion.class, 2L);
Assert.assertTrue(av != null);
em.clear();
}
use of com.openmeap.model.dto.Application 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());
}
use of com.openmeap.model.dto.Application in project OpenMEAP by OpenMEAP.
the class ModelServiceImplTest method testGetApplicationArchiveByDeployment.
public void testGetApplicationArchiveByDeployment() {
Application app = modelService.findApplicationByName("Application.name");
Deployment d = modelService.getLastDeployment(app);
ApplicationArchive a = modelService.getApplicationArchiveByDeployment(d);
Assert.assertNotNull(a);
}
use of com.openmeap.model.dto.Application in project OpenMEAP by OpenMEAP.
the class ModelServiceImplTest method testFind.
public void testFind() {
Application appFound = modelService.findByPrimaryKey(Application.class, 1L);
Assert.assertTrue(appFound.getName() != null && appFound.getName().compareTo("Application.name") == 0);
}
Aggregations