Search in sources :

Example 51 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class TransitionEventTest method testAddTransition.

@Test
@Request
public void testAddTransition() {
    long beforeCount = new TaskQuery(new QueryFactory()).getCount();
    TransitionEvent event = new TransitionEvent();
    try {
        LocalizedValueConverter.populate(event, TransitionEvent.DESCRIPTION, new LocalizedValue("Test"));
        event.setEventDate(FastTestDataset.DEFAULT_OVER_TIME_DATE);
        event.setBeforeTypeCode(FastTestDataset.COUNTRY.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().getCode());
        event.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        Transition transition = event.addTransition(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.PROV_CENTRAL.getServerObject(), TransitionType.DOWNGRADE, TransitionImpact.FULL);
        Assert.assertEquals(6, Task.getTasks(transition.getOid()).size());
        List<Transition> transitions = event.getTransitions();
        Assert.assertEquals(1, transitions.size());
        transition = transitions.get(0);
        VertexServerGeoObject source = transition.getSourceVertex();
        VertexServerGeoObject target = transition.getTargetVertex();
        Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), source.getCode());
        Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), target.getCode());
    } finally {
        event.delete();
    }
    // Ensure that the unresolved tasks are deleted on event delete
    Assert.assertEquals(beforeCount, new TaskQuery(new QueryFactory()).getCount());
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TaskQuery(net.geoprism.registry.task.TaskQuery) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Transition(net.geoprism.registry.graph.transition.Transition) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)51 VertexObject (com.runwaysdk.business.graph.VertexObject)20 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)19 JsonObject (com.google.gson.JsonObject)18 Request (com.runwaysdk.session.Request)13 Date (java.util.Date)12 LinkedList (java.util.LinkedList)11 ChangeRequest (net.geoprism.registry.action.ChangeRequest)11 JsonArray (com.google.gson.JsonArray)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)10 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)9 GraphQuery (com.runwaysdk.business.graph.GraphQuery)8 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)8 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)8 QueryFactory (com.runwaysdk.query.QueryFactory)6 SimpleDateFormat (java.text.SimpleDateFormat)6 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)6 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)6 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)5