use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testGetAllCR.
@Test
public void testGetAllCR() {
createTestChangeRequest(CreateGeoObjectAction.CLASS);
createTestChangeRequest(UpdateAttributeAction.CLASS);
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) -> {
testGetAllCR(request, true);
});
} 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) -> {
testGetAllCR(request, false);
});
} catch (SmartExceptionDTO e) {
e.printStackTrace();
Assert.fail("Unexpected permission exception was thrown on user [" + user.getUsername() + "].");
}
}
}
use of com.runwaysdk.business.SmartExceptionDTO 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 com.runwaysdk.business.SmartExceptionDTO 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 com.runwaysdk.business.SmartExceptionDTO 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 com.runwaysdk.business.SmartExceptionDTO 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