use of org.commongeoregistry.adapter.dataaccess.ParentTreeNode in project geoprism-registry by terraframe.
the class GeoObjectRelationshipServiceTest method testGetParentGeoObjects.
@Test
public void testGetParentGeoObjects() {
final String childCode = FastTestDataset.PROV_CENTRAL.getCode();
final String childTypeCode = FastTestDataset.PROVINCE.getCode();
final String[] parentTypes = new String[] { FastTestDataset.COUNTRY.getCode() };
final List<TestGeoObjectInfo> expectedParents = new ArrayList<TestGeoObjectInfo>();
expectedParents.add(FastTestDataset.CAMBODIA);
expectedParents.add(FastTestDataset.CAMBODIA);
// Recursive
ParentTreeNode tn = testData.adapter.getParentGeoObjects(childCode, childTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, parentTypes, true);
FastTestDataset.PROV_CENTRAL.parentTreeNodeAssert(tn, expectedParents);
Assert.assertEquals(tn.toJSON().toString(), ParentTreeNode.fromJSON(tn.toJSON().toString(), testData.adapter).toJSON().toString());
// Not recursive
ParentTreeNode tn2 = testData.adapter.getParentGeoObjects(childCode, childTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, parentTypes, false);
FastTestDataset.PROV_CENTRAL.parentTreeNodeAssert(tn2, expectedParents);
Assert.assertEquals(tn2.toJSON().toString(), ParentTreeNode.fromJSON(tn2.toJSON().toString(), testData.adapter).toJSON().toString());
// Test only getting countries
String[] countryArr = new String[] { FastTestDataset.COUNTRY.getCode() };
ParentTreeNode tn3 = testData.adapter.getParentGeoObjects(childCode, childTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, countryArr, true);
FastTestDataset.PROV_CENTRAL.parentTreeNodeAssert(tn3, expectedParents);
Assert.assertEquals(tn3.toJSON().toString(), ParentTreeNode.fromJSON(tn3.toJSON().toString(), testData.adapter).toJSON().toString());
// Test null parent types
ParentTreeNode tn4 = testData.adapter.getParentGeoObjects(childCode, childTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, null, true);
FastTestDataset.PROV_CENTRAL.parentTreeNodeAssert(tn4, expectedParents);
Assert.assertEquals(tn4.toJSON().toString(), ParentTreeNode.fromJSON(tn4.toJSON().toString(), testData.adapter).toJSON().toString());
// Test empty parent types
ParentTreeNode tn5 = testData.adapter.getParentGeoObjects(childCode, childTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, new String[] {}, true);
FastTestDataset.PROV_CENTRAL.parentTreeNodeAssert(tn5, expectedParents);
Assert.assertEquals(tn5.toJSON().toString(), ParentTreeNode.fromJSON(tn5.toJSON().toString(), testData.adapter).toJSON().toString());
// Null dates
ParentTreeNode tn6 = testData.adapter.getParentGeoObjects(childCode, childTypeCode, null, new String[] {}, true);
FastTestDataset.PROV_CENTRAL.parentTreeNodeAssert(tn6, expectedParents);
Assert.assertEquals(tn6.toJSON().toString(), ParentTreeNode.fromJSON(tn6.toJSON().toString(), testData.adapter).toJSON().toString());
}
Aggregations