Search in sources :

Example 21 with TestUserInfo

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

Example 22 with TestUserInfo

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));
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Test(org.junit.Test)

Example 23 with TestUserInfo

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

Example 24 with TestUserInfo

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);
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) Test(org.junit.Test)

Example 25 with TestUserInfo

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());
            }
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) ArrayList(java.util.ArrayList) ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) TestGeoObjectInfo(net.geoprism.registry.test.TestGeoObjectInfo) 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