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