use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ShapefileServiceTest method testImportShapefileWithBadParentCode.
@Test
@Request
public void testImportShapefileWithBadParentCode() throws Throwable {
GeoObject geoObj = ServiceFactory.getRegistryService().newGeoObjectInstance(testData.clientRequest.getSessionId(), USATestData.COUNTRY.getCode());
geoObj.setCode("00");
geoObj.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, "Test Label");
geoObj.setUid(ServiceFactory.getIdService().getUids(1)[0]);
ServerGeoObjectIF serverGO = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).apply(geoObj, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE, true, false);
geoObj = RegistryService.getInstance().getGeoObjectByCode(Session.getCurrentSession().getOid(), serverGO.getCode(), serverGO.getType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
InputStream istream = this.getClass().getResourceAsStream("/cb_2017_us_state_500k.zip.test");
Assert.assertNotNull(istream);
ShapefileService service = new ShapefileService();
GeoObjectImportConfiguration config = this.getTestConfiguration(istream, service, null, ImportStrategy.NEW_AND_UPDATE);
ServerHierarchyType hierarchyType = ServerHierarchyType.get(USATestData.HIER_ADMIN.getCode());
config.setHierarchy(hierarchyType);
config.addParent(new Location(USATestData.COUNTRY.getServerObject(), hierarchyType, new BasicColumnFunction("GEOID"), ParentMatchStrategy.CODE));
ImportHistory hist = mockImport(config);
Assert.assertTrue(hist.getStatus().get(0).equals(AllJobStatus.FEEDBACK));
hist = ImportHistory.get(hist.getOid());
Assert.assertEquals(new Long(56), hist.getWorkTotal());
Assert.assertEquals(new Long(56), hist.getWorkProgress());
Assert.assertEquals(new Long(0), hist.getImportedRecords());
Assert.assertEquals(ImportStage.VALIDATION_RESOLVE, hist.getStage().get(0));
final GeoObjectImportConfiguration test = new GeoObjectImportConfiguration();
test.fromJSON(hist.getConfigJson(), false);
// TODO
// Assert.assertEquals(config.getParentLookupType(),
// test.getParentLookupType());
// JSONArray errors = new JSONArray(hist.getErrorJson());
//
// Assert.assertEquals(0, errors.length());
// Ensure the geo objects were not created
ServerGeoObjectQuery query = new ServerGeoObjectService().createQuery(USATestData.STATE.getServerObject(), config.getStartDate());
query.setRestriction(new ServerCodeRestriction("01"));
Assert.assertNull(query.getSingleResult());
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphTest method testAddParent.
@Test
@Request
public void testAddParent() {
ServerGeoObjectIF parent = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF child = FastTestDataset.PROV_WESTERN.getServerObject();
ServerParentGraphNode node = child.addGraphParent(parent, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
Assert.assertNotNull(node);
Assert.assertEquals(child.getCode(), node.getGeoObject().getCode());
Assert.assertEquals(FastTestDataset.DEFAULT_OVER_TIME_DATE, node.getStartDate());
Assert.assertEquals(FastTestDataset.DEFAULT_OVER_TIME_DATE, node.getEndDate());
List<ServerParentGraphNode> parents = node.getParents();
Assert.assertEquals(1, parents.size());
Assert.assertEquals(parent.getCode(), parents.get(0).getGeoObject().getCode());
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class GeoObjectQueryTest method testFailLookupRestriction.
@Test
@Request
public void testFailLookupRestriction() {
ServerGeoObjectType type = USATestData.STATE.getServerObject();
ServerLookupRestriction restriction = new ServerLookupRestriction(USATestData.CANADA.getCode(), USATestData.CANADA.getDate());
VertexGeoObjectQuery query = new VertexGeoObjectQuery(type, null);
query.setRestriction(restriction);
ServerGeoObjectIF result = query.getSingleResult();
Assert.assertNull(result);
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testAddMultipleChildren.
@Test
@Request
public void testAddMultipleChildren() {
ServerGeoObjectIF provCentral = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF provWestern = FastTestDataset.PROV_WESTERN.getServerObject();
ServerGeoObjectIF distCentral = FastTestDataset.DIST_CENTRAL.getServerObject();
provCentral.addGraphChild(provWestern, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_END_TIME_DATE);
provCentral.addGraphChild(distCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_END_TIME_DATE);
ServerChildGraphNode node = provCentral.getGraphChildren(type, false, FastTestDataset.DEFAULT_END_TIME_DATE);
List<ServerChildGraphNode> children = node.getChildren();
Assert.assertEquals(2, children.size());
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testAddMultipleParents.
@Test
@Request
public void testAddMultipleParents() {
ServerGeoObjectIF provCentral = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF provWestern = FastTestDataset.PROV_WESTERN.getServerObject();
ServerGeoObjectIF distCentral = FastTestDataset.DIST_CENTRAL.getServerObject();
provCentral.addGraphParent(provWestern, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
provCentral.addGraphParent(distCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
ServerParentGraphNode node = provCentral.getGraphParents(type, false, FastTestDataset.DEFAULT_OVER_TIME_DATE);
List<ServerParentGraphNode> parents = node.getParents();
Assert.assertEquals(2, parents.size());
}
Aggregations