use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testUpdateGeoObject.
@Test
public void testUpdateGeoObject() {
// Allowed Users
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM };
for (TestUserInfo user : allowedUsers) {
TestGeoObjectInfo go = testData.newTestGeoObjectInfo("UpdateTest", FastTestDataset.COUNTRY);
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_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.COUNTRY);
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
}
});
}
}
use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testCreateGeoObjectBadGeometry.
@Test
public void testCreateGeoObjectBadGeometry() {
GeometryBuilder builder = new GeometryBuilder(new GeometryFactory());
Point point = builder.point(48.44, -123.37);
GeoObject geoObj = testData.adapter.newGeoObjectInstance(FastTestDataset.PROVINCE.getCode());
geoObj.setGeometry(point);
geoObj.setCode(FastTestDataset.CAMBODIA.getCode());
geoObj.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, FastTestDataset.CAMBODIA.getDisplayLabel());
try {
testData.adapter.createGeoObject(geoObj.toJSON().toString(), TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
Assert.fail("Able to create a GeoObject with a wrong geometry type");
} catch (SmartExceptionDTO e) {
// This is expected
Assert.assertEquals(GeometryTypeException.CLASS, e.getType());
}
}
use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class GeoObjectServiceTest method testCreateGeoObject.
@Test
public void testCreateGeoObject() {
TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM };
for (TestUserInfo user : allowedUsers) {
TestDataSet.runAsUser(user, (request, adapter) -> {
TestDataSet.populateAdapterIds(user, adapter);
GeoObject returned = adapter.createGeoObject(TEST_GO.newGeoObject(adapter).toJSON().toString(), TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
TEST_GO.assertEquals(returned);
Assert.assertEquals(true, returned.getExists());
TEST_GO.assertApplied();
TEST_GO.delete();
});
}
TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_MOHA_RA };
for (TestUserInfo user : disallowedUsers) {
TestDataSet.runAsUser(user, (request, adapter) -> {
TestDataSet.populateAdapterIds(user, adapter);
try {
adapter.createGeoObject(TEST_GO.newGeoObject(ServiceFactory.getAdapter()).toJSON().toString(), TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
Assert.fail();
} catch (SmartExceptionDTO ex) {
Assert.assertEquals(CreateGeoObjectPermissionException.CLASS, ex.getType());
}
});
}
}
use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.
the class ListTypeTest method testCreateFromBadRole.
// @Test
// public void testCreatePublishedVersions()
// {
// JsonObject listJson = getJson(USATestData.ORG_NPS.getServerObject(),
// USATestData.HIER_ADMIN, USATestData.STATE, USATestData.COUNTRY);
//
// ListTypeService service = new ListTypeService();
// JsonObject result = service.apply(testData.clientRequest.getSessionId(),
// listJson);
// String oid = result.get(ComponentInfo.OID).getAsString();
//
// try
// {
// service.createPublishedVersions(testData.clientRequest.getSessionId(),
// oid);
//
// final JsonObject json =
// service.getEntries(testData.clientRequest.getSessionId(), oid);
//
// Assert.assertEquals(USATestData.DEFAULT_TIME_YEAR_DIFF, json.size());
// }
// finally
// {
// service.remove(testData.clientRequest.getSessionId(), oid);
// }
// }
@Test
public void testCreateFromBadRole() {
JsonObject listJson = getJson(USATestData.ORG_NPS.getServerObject(), USATestData.HIER_ADMIN, USATestData.STATE, USATestData.COUNTRY);
TestUserInfo[] users = new TestUserInfo[] { USATestData.USER_PPP_RA };
for (TestUserInfo user : users) {
USATestData.runAsUser(user, (request, adapter) -> {
ListTypeService service = new ListTypeService();
try {
service.apply(request.getSessionId(), listJson);
Assert.fail("Expected an exception to be thrown.");
} catch (SmartExceptionDTO e) {
// This is expected
}
});
}
}
Aggregations