Search in sources :

Example 11 with ParentTreeNode

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());
}
Also used : ArrayList(java.util.ArrayList) ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) TestGeoObjectInfo(net.geoprism.registry.test.TestGeoObjectInfo) Test(org.junit.Test)

Aggregations

ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)11 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)5 Test (org.junit.Test)5 TestGeoObjectInfo (net.geoprism.registry.test.TestGeoObjectInfo)4 Endpoint (com.runwaysdk.mvc.Endpoint)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)2 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)2 ChildTreeNode (org.commongeoregistry.adapter.dataaccess.ChildTreeNode)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 SmartExceptionDTO (com.runwaysdk.business.SmartExceptionDTO)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)1 Request (com.runwaysdk.session.Request)1 Universal (com.runwaysdk.system.gis.geo.Universal)1 InputStream (java.io.InputStream)1 Instant (java.time.Instant)1 LinkedList (java.util.LinkedList)1