Search in sources :

Example 51 with TestUserInfo

use of net.geoprism.registry.test.TestUserInfo 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());
            }
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Example 52 with TestUserInfo

use of net.geoprism.registry.test.TestUserInfo in project geoprism-registry by terraframe.

the class GeoObjectServiceTest method testGetGeoObjectByCode.

@Test
public void testGetGeoObjectByCode() {
    // Allowed Users
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
    for (TestUserInfo user : allowedUsers) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            GeoObject geoObj = adapter.getGeoObjectByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
            Assert.assertEquals(geoObj.toJSON().toString(), GeoObject.fromJSON(adapter, geoObj.toJSON().toString()).toJSON().toString());
            Assert.assertEquals(true, geoObj.getExists());
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Test(org.junit.Test)

Example 53 with TestUserInfo

use of net.geoprism.registry.test.TestUserInfo 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
            }
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) JsonObject(com.google.gson.JsonObject) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test)

Aggregations

TestUserInfo (net.geoprism.registry.test.TestUserInfo)53 Test (org.junit.Test)49 SmartExceptionDTO (com.runwaysdk.business.SmartExceptionDTO)37 JsonObject (com.google.gson.JsonObject)8 TestGeoObjectInfo (net.geoprism.registry.test.TestGeoObjectInfo)7 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)7 JsonArray (com.google.gson.JsonArray)5 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)4 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)4 ArrayList (java.util.ArrayList)3 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)3 ListTypeTest (net.geoprism.registry.service.ListTypeTest)3 CurationControllerWrapper (net.geoprism.registry.test.curation.CurationControllerWrapper)3 UndirectedGraphControllerWrapper (net.geoprism.registry.test.graph.UndirectedGraphControllerWrapper)3 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)3 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)3 ServerChildGraphNode (net.geoprism.registry.model.ServerChildGraphNode)2 ServerParentGraphNode (net.geoprism.registry.model.ServerParentGraphNode)2 DirectedAcyclicGraphControllerWrapper (net.geoprism.registry.test.graph.DirectedAcyclicGraphControllerWrapper)2 RunwayExceptionDTO (com.runwaysdk.RunwayExceptionDTO)1