Search in sources :

Example 31 with TestUserInfo

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

the class DirectedAcyclicGraphTest method testAddChild.

@Test
public void testAddChild() {
    // Allowed Users
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
    for (TestUserInfo user : allowedUsers) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            DirectedAcyclicGraphControllerWrapper controller = new DirectedAcyclicGraphControllerWrapper(adapter, request);
            ServerParentGraphNode node = controller.addChild(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
            validateAddChild(node, FastTestDataset.PROV_CENTRAL, FastTestDataset.PROV_WESTERN);
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) DirectedAcyclicGraphControllerWrapper(net.geoprism.registry.test.graph.DirectedAcyclicGraphControllerWrapper) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode) Test(org.junit.Test)

Example 32 with TestUserInfo

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

the class HierarchyServiceTest method testDeleteHierarchyTypeAsBadRole.

@Test
public void testDeleteHierarchyTypeAsBadRole() {
    String organizationCode = FastTestDataset.ORG_CGOV.getCode();
    HierarchyType reportingDivision = MetadataFactory.newHierarchyType(TEST_HT.getCode(), new LocalizedValue("Reporting Division"), new LocalizedValue("The rporting division hieracy..."), organizationCode, testData.adapter);
    String gtJSON = reportingDivision.toJSON().toString();
    ServiceFactory.getHierarchyService().createHierarchyType(testData.clientSession.getSessionId(), gtJSON);
    TestUserInfo[] users = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RM };
    for (TestUserInfo user : users) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                ServiceFactory.getHierarchyService().deleteHierarchyType(request.getSessionId(), TEST_HT.getCode());
            });
            Assert.fail("Able to update a geo object type as a user with bad roles");
        } catch (SmartExceptionDTO e) {
        // This is expected
        }
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Example 33 with TestUserInfo

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

the class HierarchyServiceTest method testGetHierarchyGroupedTypes.

@Test
public void testGetHierarchyGroupedTypes() {
    for (TestUserInfo user : new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM }) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            JsonArray ja = service.getHierarchyGroupedTypes(request.getSessionId());
            ArrayList<String> hierarchyLabels = new ArrayList<String>();
            ArrayList<String> hierarchyCodes = new ArrayList<String>();
            for (int i = 0; i < ja.size(); ++i) {
                JsonObject hierarchy = ja.get(i).getAsJsonObject();
                Assert.assertNotNull(hierarchy.get("label").getAsString());
                Assert.assertNotNull(hierarchy.get("code").getAsString());
                hierarchyLabels.add(hierarchy.get("label").getAsString());
                hierarchyCodes.add(hierarchy.get("code").getAsString());
            }
            Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_ADMIN.getCode()));
            Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_ADMIN.getDisplayLabel()));
            Assert.assertFalse(hierarchyCodes.contains(FastTestDataset.HIER_HEALTH_ADMIN.getCode()));
            Assert.assertFalse(hierarchyLabels.contains(FastTestDataset.HIER_HEALTH_ADMIN.getDisplayLabel()));
        });
    }
    for (TestUserInfo user : new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_MOHA_RM }) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            JsonArray ja = service.getHierarchyGroupedTypes(request.getSessionId());
            ArrayList<String> hierarchyLabels = new ArrayList<String>();
            ArrayList<String> hierarchyCodes = new ArrayList<String>();
            for (int i = 0; i < ja.size(); ++i) {
                JsonObject hierarchy = ja.get(i).getAsJsonObject();
                Assert.assertNotNull(hierarchy.get("label").getAsString());
                Assert.assertNotNull(hierarchy.get("code").getAsString());
                hierarchyLabels.add(hierarchy.get("label").getAsString());
                hierarchyCodes.add(hierarchy.get("code").getAsString());
            }
            Assert.assertFalse(hierarchyCodes.contains(FastTestDataset.HIER_ADMIN.getCode()));
            Assert.assertFalse(hierarchyLabels.contains(FastTestDataset.HIER_ADMIN.getDisplayLabel()));
            Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_HEALTH_ADMIN.getCode()));
            Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_HEALTH_ADMIN.getDisplayLabel()));
        });
    }
    for (TestUserInfo user : new TestUserInfo[] { FastTestDataset.USER_ADMIN }) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            JsonArray ja = service.getHierarchyGroupedTypes(request.getSessionId());
            ArrayList<String> hierarchyLabels = new ArrayList<String>();
            ArrayList<String> hierarchyCodes = new ArrayList<String>();
            for (int i = 0; i < ja.size(); ++i) {
                JsonObject hierarchy = ja.get(i).getAsJsonObject();
                Assert.assertNotNull(hierarchy.get("label").getAsString());
                Assert.assertNotNull(hierarchy.get("code").getAsString());
                hierarchyLabels.add(hierarchy.get("label").getAsString());
                hierarchyCodes.add(hierarchy.get("code").getAsString());
            }
            Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_ADMIN.getCode()));
            Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_ADMIN.getDisplayLabel()));
            Assert.assertTrue(hierarchyCodes.contains(FastTestDataset.HIER_HEALTH_ADMIN.getCode()));
            Assert.assertTrue(hierarchyLabels.contains(FastTestDataset.HIER_HEALTH_ADMIN.getDisplayLabel()));
        });
    }
}
Also used : JsonArray(com.google.gson.JsonArray) TestUserInfo(net.geoprism.registry.test.TestUserInfo) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test)

Example 34 with TestUserInfo

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

the class UndirectedGraphTest method testAddChild.

@Test
public void testAddChild() {
    // Allowed Users
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN };
    for (TestUserInfo user : allowedUsers) {
        FastTestDataset.runAsUser(user, (request, adapter) -> {
            UndirectedGraphControllerWrapper controller = new UndirectedGraphControllerWrapper(adapter, request);
            ServerParentGraphNode node = controller.addChild(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode(), FastTestDataset.PROV_WESTERN.getCode(), FastTestDataset.PROV_WESTERN.getGeoObjectType().getCode(), graphTypeCode, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
            validateAddChild(node, FastTestDataset.PROV_CENTRAL, FastTestDataset.PROV_WESTERN);
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) UndirectedGraphControllerWrapper(net.geoprism.registry.test.graph.UndirectedGraphControllerWrapper) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode) Test(org.junit.Test)

Example 35 with TestUserInfo

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

the class AttributeClassificationTest method testCreateGeoObject.

@Test
public void testCreateGeoObject() {
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA };
    for (TestUserInfo user : allowedUsers) {
        TestDataSet.runAsUser(user, (request, adapter) -> {
            TestDataSet.populateAdapterIds(user, adapter);
            GeoObject object = TEST_GO.newGeoObject(adapter);
            object.setValue(testClassification.getName(), CODE);
            GeoObject returned = adapter.createGeoObject(object.toJSON().toString(), TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
            Assert.assertEquals(CODE, returned.getAttribute(testClassification.getName()).getValue());
            TEST_GO.assertApplied();
            TEST_GO.delete();
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Test(org.junit.Test) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest)

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