Search in sources :

Example 1 with TaskQuery

use of net.geoprism.registry.task.TaskQuery in project geoprism-registry by terraframe.

the class TransitionEventTest method testAddTransitionSameType.

@Test
@Request
public void testAddTransitionSameType() {
    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.PROVINCE.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        Transition transition = event.addTransition(FastTestDataset.PROV_WESTERN.getServerObject(), FastTestDataset.PROV_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
        Assert.assertEquals(3, 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.PROV_WESTERN.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)

Example 2 with TaskQuery

use of net.geoprism.registry.task.TaskQuery 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

QueryFactory (com.runwaysdk.query.QueryFactory)2 Request (com.runwaysdk.session.Request)2 Transition (net.geoprism.registry.graph.transition.Transition)2 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)2 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)2 TaskQuery (net.geoprism.registry.task.TaskQuery)2 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)2 Test (org.junit.Test)2