use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphTest method testAddChild.
@Test
public void testAddChild() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
DirectedAcyclicGraphControllerWrapper controller = new DirectedAcyclicGraphControllerWrapper(adapter, request);
ServerParentGraphNode node = 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);
validateAddChild(node, FastTestDataset.PROV_CENTRAL, FastTestDataset.PROV_WESTERN);
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class HierarchyServiceTest method testDeleteHierarchyTypeAsBadRole.
@Test
public void testDeleteHierarchyTypeAsBadRole() {
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();
ServiceFactory.getHierarchyService().createHierarchyType(testData.clientSession.getSessionId(), gtJSON);
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().deleteHierarchyType(request.getSessionId(), TEST_HT.getCode());
});
Assert.fail("Able to update a geo object type as a user with bad roles");
} catch (SmartExceptionDTO e) {
// This is expected
}
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class HierarchyServiceTest method testGetHierarchyGroupedTypes.
@Test
public void testGetHierarchyGroupedTypes() {
for (TestUserInfo user : new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM }) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
JsonArray ja = service.getHierarchyGroupedTypes(request.getSessionId());
ArrayList<String> hierarchyLabels = new ArrayList<String>();
ArrayList<String> hierarchyCodes = new ArrayList<String>();
for (int i = 0; i < ja.size(); ++i) {
JsonObject hierarchy = ja.get(i).getAsJsonObject();
Assert.assertNotNull(hierarchy.get("label").getAsString());
Assert.assertNotNull(hierarchy.get("code").getAsString());
hierarchyLabels.add(hierarchy.get("label").getAsString());
hierarchyCodes.add(hierarchy.get("code").getAsString());
}
Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_ADMIN.getCode()));
Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_ADMIN.getDisplayLabel()));
Assert.assertFalse(hierarchyCodes.contains(FastTestDataset.HIER_HEALTH_ADMIN.getCode()));
Assert.assertFalse(hierarchyLabels.contains(FastTestDataset.HIER_HEALTH_ADMIN.getDisplayLabel()));
});
}
for (TestUserInfo user : new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM }) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
JsonArray ja = service.getHierarchyGroupedTypes(request.getSessionId());
ArrayList<String> hierarchyLabels = new ArrayList<String>();
ArrayList<String> hierarchyCodes = new ArrayList<String>();
for (int i = 0; i < ja.size(); ++i) {
JsonObject hierarchy = ja.get(i).getAsJsonObject();
Assert.assertNotNull(hierarchy.get("label").getAsString());
Assert.assertNotNull(hierarchy.get("code").getAsString());
hierarchyLabels.add(hierarchy.get("label").getAsString());
hierarchyCodes.add(hierarchy.get("code").getAsString());
}
Assert.assertFalse(hierarchyCodes.contains(FastTestDataset.HIER_ADMIN.getCode()));
Assert.assertFalse(hierarchyLabels.contains(FastTestDataset.HIER_ADMIN.getDisplayLabel()));
Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_HEALTH_ADMIN.getCode()));
Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_HEALTH_ADMIN.getDisplayLabel()));
});
}
for (TestUserInfo user : new TestUserInfo[] { FastTestDataset.USER_ADMIN }) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
JsonArray ja = service.getHierarchyGroupedTypes(request.getSessionId());
ArrayList<String> hierarchyLabels = new ArrayList<String>();
ArrayList<String> hierarchyCodes = new ArrayList<String>();
for (int i = 0; i < ja.size(); ++i) {
JsonObject hierarchy = ja.get(i).getAsJsonObject();
Assert.assertNotNull(hierarchy.get("label").getAsString());
Assert.assertNotNull(hierarchy.get("code").getAsString());
hierarchyLabels.add(hierarchy.get("label").getAsString());
hierarchyCodes.add(hierarchy.get("code").getAsString());
}
Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_ADMIN.getCode()));
Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_ADMIN.getDisplayLabel()));
Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_HEALTH_ADMIN.getCode()));
Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_HEALTH_ADMIN.getDisplayLabel()));
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testAddChild.
@Test
public void testAddChild() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
UndirectedGraphControllerWrapper controller = new UndirectedGraphControllerWrapper(adapter, request);
ServerParentGraphNode node = 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);
validateAddChild(node, FastTestDataset.PROV_CENTRAL, FastTestDataset.PROV_WESTERN);
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class AttributeClassificationTest method testCreateGeoObject.
@Test
public void testCreateGeoObject() {
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA };
for (TestUserInfo user : allowedUsers) {
TestDataSet.runAsUser(user, (request, adapter) -> {
TestDataSet.populateAdapterIds(user, adapter);
GeoObject object = TEST_GO.newGeoObject(adapter);
object.setValue(testClassification.getName(), CODE);
GeoObject returned = adapter.createGeoObject(object.toJSON().toString(), TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
Assert.assertEquals(CODE, returned.getAttribute(testClassification.getName()).getValue());
TEST_GO.assertApplied();
TEST_GO.delete();
});
}
}
Aggregations