use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testSetActionStatus.
@Test
public void testSetActionStatus() {
String serializedCR = createTestChangeRequest(UpdateAttributeAction.CLASS);
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN, FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM };
for (TestUserInfo user : allowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
testSetActionStatus(request, serializedCR);
});
} 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, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : disAllowedUsers) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
testSetActionStatus(request, serializedCR);
Assert.fail("Expected a permission exception to be thrown on user [" + user.getUsername() + "].");
});
} catch (SmartExceptionDTO e) {
Assert.assertEquals(e.getType(), CGRPermissionException.CLASS);
}
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class GeoObjectOverTimeServiceTest method testGetGeoObjectOverTimeByCode.
@Test
public void testGetGeoObjectOverTimeByCode() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
for (TestUserInfo user : allowedUsers) {
FastTestDataset.runAsUser(user, (request, adapter) -> {
GeoObjectOverTime geoObj = adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
Assert.assertEquals(geoObj.toJSON().toString(), GeoObjectOverTime.fromJSON(adapter, geoObj.toJSON().toString()).toJSON().toString());
Assert.assertEquals(true, geoObj.getExists(TestDataSet.DEFAULT_OVER_TIME_DATE));
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class GeoObjectRelationshipServiceTest method testGetHierarchiesPrivate.
@Test
public void testGetHierarchiesPrivate() {
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM_PRIVATE };
for (TestUserInfo user : allowedUsers) {
TestDataSet.runAsUser(user, (request, adapter) -> {
JsonArray ptn = adapter.getHierarchiesForGeoObjectOverTime(FastTestDataset.PROV_CENTRAL_PRIVATE.getCode(), FastTestDataset.PROVINCE_PRIVATE.getCode());
Assert.assertEquals(1, ptn.size());
});
}
TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC };
for (TestUserInfo user : disallowedUsers) {
TestDataSet.runAsUser(user, (request, adapter) -> {
try {
adapter.getHierarchiesForGeoObjectOverTime(FastTestDataset.PROV_CENTRAL_PRIVATE.getCode(), FastTestDataset.PROVINCE_PRIVATE.getCode());
Assert.fail("Expected a permission exception");
} catch (SmartExceptionDTO ex) {
Assert.assertEquals(ReadGeoObjectPermissionException.CLASS, ex.getType());
}
});
}
}
use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.
the class GeoObjectRelationshipServiceTest method testGetPrivateHierarchyTypes.
@Test
public void testGetPrivateHierarchyTypes() {
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_RM_PRIVATE, FastTestDataset.USER_CGOV_RC_PRIVATE, FastTestDataset.USER_CGOV_AC_PRIVATE };
for (TestUserInfo user : allowedUsers) {
TestDataSet.runAsUser(user, (request, adapter) -> {
HierarchyType[] hts = adapter.getHierarchyTypes(null);
checkHierarchyTypeResponse(hts, true);
});
}
TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM, FastTestDataset.USER_MOHA_RC, FastTestDataset.USER_MOHA_AC };
for (TestUserInfo user : disallowedUsers) {
TestDataSet.runAsUser(user, (request, adapter) -> {
HierarchyType[] hts = adapter.getHierarchyTypes(null);
checkHierarchyTypeResponse(hts, false);
});
}
}
use of net.geoprism.registry.test.TestUserInfo 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());
}
});
}
}
Aggregations