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