use of net.geoprism.registry.test.TestGeoObjectInfo in project geoprism-registry by terraframe.
the class CurationTest method setUpTestCurate.
@Request
private Object[] setUpTestCurate() throws Throwable {
TestGeoObjectInfo noGeomGo = testData.newTestGeoObjectInfo("curationJobTest-NoGeom", FastTestDataset.PROVINCE);
noGeomGo.setWkt(null);
noGeomGo.apply();
version.publishNoAuth();
return new Object[] { noGeomGo, version.getOid() };
}
use of net.geoprism.registry.test.TestGeoObjectInfo in project geoprism-registry by terraframe.
the class CurationTest method testCurate.
@Test
public void testCurate() throws Throwable {
Object[] setup = setUpTestCurate();
final TestGeoObjectInfo noGeomGo = (TestGeoObjectInfo) setup[0];
final String listTypeVersionId = (String) setup[1];
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN, FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
final CurationControllerWrapper controller = new CurationControllerWrapper(adapter, request);
JsonObject joHistory = controller.curate(listTypeVersionId);
try {
waitUntilSuccess(joHistory);
} catch (Throwable e) {
throw new RuntimeException(e);
}
JsonObject page = controller.page(joHistory.get("historyId").getAsString(), false, 10, 1);
JsonArray results = page.get("resultSet").getAsJsonArray();
Assert.assertEquals(1, results.size());
for (int i = 0; i < results.size(); ++i) {
JsonObject problem = results.get(i).getAsJsonObject();
Assert.assertEquals(joHistory.get("historyId").getAsString(), problem.get("historyId").getAsString());
Assert.assertEquals(CurationResolution.UNRESOLVED.name(), problem.get("resolution").getAsString());
Assert.assertEquals(GeoObjectProblemType.NO_GEOMETRY.name(), problem.get("type").getAsString());
Assert.assertTrue(problem.get("id").getAsString() != null && problem.get("id").getAsString() != "");
Assert.assertEquals(FastTestDataset.PROVINCE.getCode(), problem.get("typeCode").getAsString());
Assert.assertEquals(noGeomGo.getCode(), problem.get("goCode").getAsString());
}
});
}
// Disallowed Users
TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM };
for (TestUserInfo user : disallowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
final CurationControllerWrapper controller = new CurationControllerWrapper(adapter, request);
try {
controller.curate(listTypeVersionId);
Assert.fail("Expected to get an exception.");
} catch (SmartExceptionDTO e) {
Assert.assertTrue(OrganizationRAException.CLASS.equals(e.getType()) || OrganizationRMException.CLASS.equals(e.getType()));
}
});
}
}
use of net.geoprism.registry.test.TestGeoObjectInfo in project geoprism-registry by terraframe.
the class GeoObjectRelationshipServiceTest method testGetChildGeoObjects.
@Test
public void testGetChildGeoObjects() {
final String parentCode = FastTestDataset.CAMBODIA.getCode();
final String parentTypeCode = FastTestDataset.CAMBODIA.getGeoObjectType().getCode();
final String[] childrenTypes = new String[] { FastTestDataset.PROVINCE.getCode() };
final List<TestGeoObjectInfo> expectedChildren = new ArrayList<TestGeoObjectInfo>();
expectedChildren.add(FastTestDataset.PROV_CENTRAL);
expectedChildren.add(FastTestDataset.PROV_CENTRAL);
expectedChildren.add(FastTestDataset.PROV_WESTERN);
// Recursive
ChildTreeNode tn = testData.adapter.getChildGeoObjects(parentCode, parentTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, childrenTypes, true);
FastTestDataset.CAMBODIA.childTreeNodeAssert(tn, expectedChildren);
Assert.assertEquals(tn.toJSON().toString(), ChildTreeNode.fromJSON(tn.toJSON().toString(), testData.adapter).toJSON().toString());
// Not recursive
ChildTreeNode tn2 = testData.adapter.getChildGeoObjects(parentCode, parentTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, childrenTypes, false);
FastTestDataset.CAMBODIA.childTreeNodeAssert(tn2, expectedChildren);
Assert.assertEquals(tn2.toJSON().toString(), ChildTreeNode.fromJSON(tn2.toJSON().toString(), testData.adapter).toJSON().toString());
// Null date
ChildTreeNode tn3 = testData.adapter.getChildGeoObjects(parentCode, parentTypeCode, null, childrenTypes, false);
FastTestDataset.CAMBODIA.childTreeNodeAssert(tn3, expectedChildren);
Assert.assertEquals(tn3.toJSON().toString(), ChildTreeNode.fromJSON(tn3.toJSON().toString(), testData.adapter).toJSON().toString());
}
use of net.geoprism.registry.test.TestGeoObjectInfo in project geoprism-registry by terraframe.
the class GeoObjectRelationshipServiceTest method testGetPrivateParentGeoObjects.
@Test
public void testGetPrivateParentGeoObjects() {
final String childCode = FastTestDataset.PROV_CENTRAL_PRIVATE.getCode();
final String childTypeCode = FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode();
final String[] parentTypes = new String[] { FastTestDataset.COUNTRY.getCode() };
final List<TestGeoObjectInfo> expectedParents = new ArrayList<TestGeoObjectInfo>();
expectedParents.add(FastTestDataset.CAMBODIA);
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM_PRIVATE, FastTestDataset.USER_CGOV_RC_PRIVATE, FastTestDataset.USER_CGOV_AC_PRIVATE };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
ParentTreeNode tn = adapter.getParentGeoObjects(childCode, childTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, parentTypes, true);
FastTestDataset.PROV_CENTRAL_PRIVATE.parentTreeNodeAssert(tn, expectedParents);
Assert.assertEquals(tn.toJSON().toString(), ParentTreeNode.fromJSON(tn.toJSON().toString(), testData.adapter).toJSON().toString());
});
}
TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : disallowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
try {
adapter.getParentGeoObjects(childCode, childTypeCode, TestDataSet.DEFAULT_OVER_TIME_DATE, parentTypes, true);
Assert.fail("Expected a permissions error.");
} catch (SmartExceptionDTO e) {
Assert.assertEquals(ReadGeoObjectPermissionException.CLASS, e.getType());
}
});
}
}
use of net.geoprism.registry.test.TestGeoObjectInfo in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testUpdatePrivateGeoObject.
@Test
public void testUpdatePrivateGeoObject() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM_PRIVATE };
for (TestUserInfo user : allowedUsers) {
TestGeoObjectInfo go = testData.newTestGeoObjectInfo("UpdateTest", FastTestDataset.PROVINCE_PRIVATE);
go.apply();
TestDataSet.runAsUser(user, (request, adapter) -> {
updateGO(adapter, go, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
});
go.delete();
}
// Disallowed Users
TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC };
for (TestUserInfo user : disallowedUsers) {
TestGeoObjectInfo go = testData.newTestGeoObjectInfo("UpdateTest", FastTestDataset.PROVINCE_PRIVATE);
go.apply();
TestDataSet.runAsUser(user, (request, adapter) -> {
try {
updateGO(adapter, go, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
Assert.fail();
} catch (SmartExceptionDTO ex) {
// expected
}
});
}
}
Aggregations