Search in sources :

Example 16 with TransitionEvent

use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.

the class TransitionEventTest method testGetHistoricalReportToJson.

@Test
@Request
public void testGetHistoricalReportToJson() {
    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.setAfterTypeCode(FastTestDataset.PROVINCE.getCode());
        event.setBeforeTypeOrgCode(FastTestDataset.COUNTRY.getOrganization().getCode());
        event.setAfterTypeOrgCode(FastTestDataset.PROVINCE.getOrganization().getCode());
        event.apply();
        event.addTransition(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.PROV_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
        Page<HistoricalRow> page = HistoricalRow.getHistoricalReport(FastTestDataset.PROVINCE.getServerObject(), FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE, null, null);
        JsonObject json = page.toJSON().getAsJsonObject();
        Assert.assertEquals(1, json.get("count").getAsInt());
        Assert.assertTrue(json.get("pageNumber").isJsonNull());
        Assert.assertTrue(json.get("pageSize").isJsonNull());
        JsonArray results = json.get("resultSet").getAsJsonArray();
        Assert.assertEquals(1, results.size());
        JsonObject result = results.get(0).getAsJsonObject();
        Assert.assertEquals(event.getEventId(), new Long(result.get(HistoricalRow.EVENT_ID).getAsLong()));
        Assert.assertEquals("Reassign", result.get(HistoricalRow.EVENT_TYPE).getAsString());
    } finally {
        event.delete();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) HistoricalRow(net.geoprism.registry.view.HistoricalRow) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 17 with TransitionEvent

use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.

the class TransitionEventTest method testRemoveEventsByTarget.

@Test
@Request
public void testRemoveEventsByTarget() {
    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();
        event.addTransition(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.PROV_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
        Assert.assertEquals(1, TransitionEvent.getAll(FastTestDataset.PROVINCE.getServerObject()).size());
        TransitionEvent.removeAll(FastTestDataset.PROVINCE.getServerObject());
        Assert.assertEquals(0, TransitionEvent.getAll(FastTestDataset.PROVINCE.getServerObject()).size());
    } finally {
        event.delete();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TransitionEvent(net.geoprism.registry.graph.transition.TransitionEvent) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)17 Test (org.junit.Test)16 HistoricalRow (net.geoprism.registry.view.HistoricalRow)4 Date (java.util.Date)3 Transition (net.geoprism.registry.graph.transition.Transition)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 QueryFactory (com.runwaysdk.query.QueryFactory)2 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)2 TaskQuery (net.geoprism.registry.task.TaskQuery)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Task (net.geoprism.registry.task.Task)1 Row (org.apache.poi.ss.usermodel.Row)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1