Search in sources :

Example 31 with Application

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();
}
Also used : ApplicationVersion(com.openmeap.model.dto.ApplicationVersion) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive) Application(com.openmeap.model.dto.Application)

Example 32 with Application

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());
}
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)

Example 33 with Application

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);
}
Also used : Deployment(com.openmeap.model.dto.Deployment) Application(com.openmeap.model.dto.Application) ApplicationArchive(com.openmeap.model.dto.ApplicationArchive)

Example 34 with Application

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);
}
Also used : Application(com.openmeap.model.dto.Application)

Aggregations

Application (com.openmeap.model.dto.Application)34 ApplicationVersion (com.openmeap.model.dto.ApplicationVersion)12 Test (org.junit.Test)9 ProcessingEvent (com.openmeap.event.ProcessingEvent)7 Deployment (com.openmeap.model.dto.Deployment)7 ModelManager (com.openmeap.model.ModelManager)6 ApplicationArchive (com.openmeap.model.dto.ApplicationArchive)6 GlobalSettings (com.openmeap.model.dto.GlobalSettings)6 PersistenceException (javax.persistence.PersistenceException)6 MessagesEvent (com.openmeap.event.MessagesEvent)5 Anchor (com.openmeap.web.html.Anchor)5 ArrayList (java.util.ArrayList)5 AddSubNavAnchorEvent (com.openmeap.admin.web.events.AddSubNavAnchorEvent)4 EventNotificationException (com.openmeap.event.EventNotificationException)4 HashMap (java.util.HashMap)4 InvalidPropertiesException (com.openmeap.model.InvalidPropertiesException)3 DigestException (com.openmeap.digest.DigestException)2 HttpResponse (com.openmeap.http.HttpResponse)2 WebServiceException (com.openmeap.protocol.WebServiceException)2 UpdateHeader (com.openmeap.protocol.dto.UpdateHeader)2