Search in sources :

Example 26 with TestUserInfo

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

Example 27 with TestUserInfo

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

the class GeoObjectServiceTest method testGetGeoObject.

@Test
public void testGetGeoObject() {
    // 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.getGeoObject(FastTestDataset.CAMBODIA.getRegistryId(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
            FastTestDataset.CAMBODIA.assertEquals(geoObj);
            Assert.assertEquals(true, geoObj.getExists());
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Test(org.junit.Test)

Example 28 with TestUserInfo

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

the class GeoObjectServiceTest method testGetPrivateGeoObject.

@Test
public void testGetPrivateGeoObject() {
    // Test allowed users on a private GeoObjectType
    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) -> {
            GeoObject geoObj = adapter.getGeoObject(FastTestDataset.PROV_CENTRAL_PRIVATE.getRegistryId(), FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
            FastTestDataset.PROV_CENTRAL_PRIVATE.assertEquals(geoObj);
            Assert.assertEquals(true, geoObj.getExists());
        });
    }
    // Disallowed Users
    TestUserInfo[] disllowedUsers = 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 : disllowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                adapter.getGeoObject(FastTestDataset.PROV_CENTRAL_PRIVATE.getRegistryId(), FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
                Assert.fail();
            });
        } catch (SmartExceptionDTO e) {
        // Expected
        }
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Example 29 with TestUserInfo

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

the class GeoObjectServiceTest method testGetPrivateGeoObjectByCode.

@Test
public void testGetPrivateGeoObjectByCode() {
    // Allowed Users
    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) -> {
            GeoObject geoObj = adapter.getGeoObjectByCode(FastTestDataset.PROV_CENTRAL_PRIVATE.getCode(), FastTestDataset.PROV_CENTRAL_PRIVATE.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());
        });
    }
    // Disallowed Users
    TestUserInfo[] disllowedUsers = 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 : disllowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                adapter.getGeoObjectByCode(FastTestDataset.PROV_CENTRAL_PRIVATE.getCode(), FastTestDataset.PROV_CENTRAL_PRIVATE.getGeoObjectType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
                Assert.fail();
            });
        } catch (SmartExceptionDTO e) {
        // This is expected
        }
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Example 30 with TestUserInfo

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

the class ListTypeTest method testRemoveFromBadRole.

@Test
public void testRemoveFromBadRole() {
    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();
    this.waitUntilPublished(oid);
    try {
        TestUserInfo[] users = new TestUserInfo[] { USATestData.USER_PPP_RA };
        for (TestUserInfo user : users) {
            USATestData.runAsUser(user, (request, adapter) -> {
                try {
                    service.remove(request.getSessionId(), oid);
                    Assert.fail("Expected an exception to be thrown.");
                } catch (SmartExceptionDTO e) {
                // This is expected
                }
            });
        }
    } finally {
        service.remove(testData.clientRequest.getSessionId(), oid);
    }
}
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