use of net.geoprism.registry.test.TestUserInfo 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.TestUserInfo in project geoprism-registry by terraframe.
the class HierarchyServiceTest method testCreateHierarchyTypeAsBadRole.
@Test(expected = SmartExceptionDTO.class)
public void testCreateHierarchyTypeAsBadRole() {
String organizationCode = FastTestDataset.ORG_CGOV.getCode();
HierarchyType reportingDivision = MetadataFactory.newHierarchyType(TEST_HT.getCode(), new LocalizedValue("Reporting Division"), new LocalizedValue("The rporting division hieracy..."), organizationCode, testData.adapter);
String gtJSON = reportingDivision.toJSON().toString();
TestUserInfo[] users = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RM };
for (TestUserInfo user : users) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
ServiceFactory.getHierarchyService().createHierarchyType(request.getSessionId(), gtJSON);
});
Assert.fail("Able to update a geo object type as a user with bad roles");
} catch (RunwayExceptionDTO e) {
// This is expected
}
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testRemoveChild.
@Test
public void testRemoveChild() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
UndirectedGraphControllerWrapper controller = new UndirectedGraphControllerWrapper(adapter, request);
controller.addChild(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
controller.removeChild(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
validateRemoveChild();
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testGetChildren.
@Test
public void testGetChildren() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
UndirectedGraphControllerWrapper controller = new UndirectedGraphControllerWrapper(adapter, request);
controller.addChild(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
ServerChildGraphNode node = controller.getChildren(FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, false, FastTestDataset.DEFAULT_OVER_TIME_DATE);
List<ServerChildGraphNode> children = node.getChildren();
Assert.assertEquals(1, children.size());
Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), children.get(0).getGeoObject().getCode());
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class ChangeRequestDocumentActionServiceTest method testDownloadDocument.
// @Test
public void testDownloadDocument() throws IOException {
String vfOid = uploadDocumentsAsAdmin();
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN, FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : allowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
downloadDocumentAsUser(request, vfOid);
});
} catch (SmartExceptionDTO e) {
e.printStackTrace();
Assert.fail("Unexpected permission exception was thrown on user [" + user.getUsername() + "].");
}
}
TestUserInfo[] disAllowedUsers = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC };
for (TestUserInfo user : disAllowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
downloadDocumentAsUser(request, vfOid);
Assert.fail("Expected a permission exception.");
});
} catch (SmartExceptionDTO e) {
Assert.assertEquals(CGRPermissionException.CLASS, e.getType());
// Expected
}
TestDataSet.deleteAllVaultFiles();
}
}
Aggregations