use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.
the class TransitionEventTest method testGetHistoricalReport.
@Test
@Request
public void testGetHistoricalReport() {
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);
Page<HistoricalRow> page = HistoricalRow.getHistoricalReport(FastTestDataset.PROVINCE.getServerObject(), FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE, null, null);
List<HistoricalRow> results = page.getResults();
Assert.assertEquals(1, results.size());
HistoricalRow result = results.get(0);
Assert.assertEquals(event.getEventId(), result.getEventId());
Assert.assertEquals(TransitionType.REASSIGN.name(), result.getEventType());
Assert.assertEquals(FastTestDataset.DEFAULT_OVER_TIME_DATE, result.getEventDate());
Assert.assertEquals("Test", result.getDescription().getValue());
Assert.assertEquals(event.getBeforeTypeCode(), result.getBeforeType());
Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), result.getBeforeCode());
Assert.assertEquals(FastTestDataset.CAMBODIA.getDisplayLabel(), result.getBeforeLabel().getValue());
Assert.assertEquals(event.getAfterTypeCode(), result.getAfterType());
Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), result.getAfterCode());
Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getDisplayLabel(), result.getAfterLabel().getValue());
} finally {
event.delete();
}
}
use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.
the class TransitionEventTest method testUpdateTransition.
@Test
@Request
public void testUpdateTransition() {
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.REASSIGN, TransitionImpact.FULL);
transition.apply(event, transition.getOrder(), (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject(), (VertexServerGeoObject) FastTestDataset.PROV_WESTERN.getServerObject());
List<Task> tasks = Task.getTasks(transition.getOid());
Assert.assertEquals(6, tasks.size());
} finally {
event.delete();
}
}
use of net.geoprism.registry.graph.transition.TransitionEvent 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());
}
use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.
the class TransitionEventTest method testCreateBasicEvent.
@Test
@Request
public void testCreateBasicEvent() {
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();
Assert.assertTrue(event.isAppliedToDb());
} finally {
event.delete();
}
}
use of net.geoprism.registry.graph.transition.TransitionEvent in project geoprism-registry by terraframe.
the class TransitionEventTest method testAddTransitionBadType.
@Test(expected = ProgrammingErrorException.class)
@Request
public void testAddTransitionBadType() {
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.DIST_CENTRAL.getServerObject(), TransitionType.REASSIGN, TransitionImpact.FULL);
} finally {
event.delete();
}
}
Aggregations