Search in sources :

Example 36 with TestUserInfo

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

the class AttributeClassificationTest method testCreateGeoObjectOverTime.

@Test
public void testCreateGeoObjectOverTime() {
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA };
    for (TestUserInfo user : allowedUsers) {
        TestDataSet.runAsUser(user, (request, adapter) -> {
            TestDataSet.populateAdapterIds(user, adapter);
            GeoObjectOverTime object = TEST_GO.newGeoObjectOverTime(adapter);
            object.setValue(testClassification.getName(), CODE, TEST_GO.getDate(), ValueOverTime.INFINITY_END_DATE);
            GeoObjectOverTime returned = adapter.createGeoObjectOverTime(object.toJSON().toString());
            Assert.assertEquals(CODE, returned.getValue(testClassification.getName(), TEST_GO.getDate()));
            TEST_GO.assertApplied();
            TEST_GO.delete();
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Test(org.junit.Test) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest)

Example 37 with TestUserInfo

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

the class ChangeRequestDocumentActionServiceTest method testListDocuments.

// @Test
public void testListDocuments() {
    uploadDocumentsAsAdmin();
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN, FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
    for (TestUserInfo user : allowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                testListDocumentsAsUser(request);
            });
        } 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 };
    for (TestUserInfo user : disAllowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                testListDocumentsAsUser(request);
                Assert.fail("Expected a permission exception.");
            });
        } catch (SmartExceptionDTO e) {
            Assert.assertEquals(CGRPermissionException.CLASS, e.getType());
        // Expected
        }
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO)

Example 38 with TestUserInfo

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

the class ChangeRequestDocumentActionServiceTest method testUploadDocument.

// @Test
public void testUploadDocument() {
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN, FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
    for (TestUserInfo user : allowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                new ChangeRequestService().uploadFileCR(request.getSessionId(), this.cr.getOid(), "parent-test.xlsx", ChangeRequestDocumentActionServiceTest.class.getResourceAsStream("/parent-test.xlsx"));
                TestDataSet.deleteAllVaultFiles();
            });
        } 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 };
    for (TestUserInfo user : disAllowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                new ChangeRequestService().uploadFileCR(request.getSessionId(), this.cr.getOid(), "parent-test.xlsx", ChangeRequestDocumentActionServiceTest.class.getResourceAsStream("/parent-test.xlsx"));
                Assert.fail("Expected a permission exception.");
            });
        } catch (SmartExceptionDTO e) {
            Assert.assertEquals(CGRPermissionException.CLASS, e.getType());
        // Expected
        }
        TestDataSet.deleteAllVaultFiles();
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO)

Example 39 with TestUserInfo

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

the class ChangeRequestDocumentServiceTest method testUploadDocument.

@Test
public void testUploadDocument() {
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_ADMIN, FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC };
    for (TestUserInfo user : allowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                new ChangeRequestService().uploadFileCR(request.getSessionId(), this.crOid, "parent-test.xlsx", ChangeRequestDocumentServiceTest.class.getResourceAsStream("/parent-test.xlsx"));
                TestDataSet.deleteAllVaultFiles();
            });
        } 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 };
    for (TestUserInfo user : disAllowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                new ChangeRequestService().uploadFileCR(request.getSessionId(), this.crOid, "parent-test.xlsx", ChangeRequestDocumentServiceTest.class.getResourceAsStream("/parent-test.xlsx"));
                Assert.fail("Expected a permission exception.");
            });
        } catch (SmartExceptionDTO e) {
            Assert.assertEquals(CGRPermissionException.CLASS, e.getType());
        // Expected
        }
        TestDataSet.deleteAllVaultFiles();
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Example 40 with TestUserInfo

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

the class ChangeRequestServiceTest method testImplementParentDecisions.

@Test
public void testImplementParentDecisions() {
    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) -> {
                testImplementParentDecisions(request, createTestChangeRequest(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME));
            });
        } catch (SmartExceptionDTO e) {
            e.printStackTrace();
            Assert.fail("Unexpected exception was thrown on user [" + user.getUsername() + "].");
        }
        tearDown();
        setUp();
    }
    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) -> {
                testImplementParentDecisions(request, createTestChangeRequest(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME));
                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)

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