Search in sources :

Example 31 with SmartExceptionDTO

use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.

the class ChangeRequestServiceTest method testUpdateGeoObjectTermCR.

/**
 * Update Term Attr Test
 */
@Test
public void testUpdateGeoObjectTermCR() throws Exception {
    String[] data = testUpdateGeoObjectTermCR_applyCR();
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA };
    for (TestUserInfo user : allowedUsers) {
        try {
            FastTestDataset.runAsUser(user, (request, adapter) -> {
                testUpdateGeoObjectTermCR(data, request);
            });
        } catch (SmartExceptionDTO e) {
            e.printStackTrace();
            Assert.fail("Unexpected exception was thrown on user [" + user.getUsername() + "].");
        }
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Example 32 with SmartExceptionDTO

use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.

the class GeoObjectOverTimeServiceTest method testCreateGeoObjectOverTimeBadGeometry.

@Test
public void testCreateGeoObjectOverTimeBadGeometry() {
    GeometryBuilder builder = new GeometryBuilder(new GeometryFactory());
    Point point = builder.point(48.44, -123.37);
    GeoObjectOverTime geoObj = TEST_GO.newGeoObjectOverTime(testData.adapter);
    geoObj.setGeometry(point, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_OVER_TIME_DATE);
    try {
        testData.adapter.createGeoObjectOverTime(geoObj.toJSON().toString());
        Assert.fail("Able to create a GeoObject with a wrong geometry type");
    } catch (SmartExceptionDTO e) {
        // This is expected
        Assert.assertEquals(GeometryTypeException.CLASS, e.getType());
    }
}
Also used : GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Point(com.vividsolutions.jts.geom.Point) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) GeometryBuilder(org.geotools.geometry.jts.GeometryBuilder) Test(org.junit.Test)

Example 33 with SmartExceptionDTO

use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.

the class GeoObjectOverTimeServiceTest method testUpdateGeoObjectOverTime.

@Test
public void testUpdateGeoObjectOverTime() {
    // Allowed Users
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM };
    for (TestUserInfo user : allowedUsers) {
        TestGeoObjectInfo go = testData.newTestGeoObjectInfo("UpdateTest", FastTestDataset.COUNTRY);
        go.apply();
        TestDataSet.runAsUser(user, (request, adapter) -> {
            updateGO(adapter, go);
        });
        go.delete();
    }
    // Disallowed Users
    TestUserInfo[] disallowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_MOHA_RA };
    for (TestUserInfo user : disallowedUsers) {
        TestGeoObjectInfo go = testData.newTestGeoObjectInfo("UpdateTest", FastTestDataset.COUNTRY);
        go.apply();
        TestDataSet.runAsUser(user, (request, adapter) -> {
            try {
                updateGO(adapter, go);
                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 34 with SmartExceptionDTO

use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.

the class GeoObjectOverTimeServiceTest method testCreateGeoObjectOverTime.

@Test
public void testCreateGeoObjectOverTime() {
    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);
            TEST_GO.assertEquals(adapter.createGeoObjectOverTime(TEST_GO.newGeoObjectOverTime(adapter).toJSON().toString()));
            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.createGeoObjectOverTime(TEST_GO.newGeoObjectOverTime(ServiceFactory.getAdapter()).toJSON().toString());
                Assert.fail();
            } catch (SmartExceptionDTO ex) {
            // expected
            }
        });
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Example 35 with SmartExceptionDTO

use of com.runwaysdk.business.SmartExceptionDTO in project geoprism-registry by terraframe.

the class GeoObjectServiceTest method testCreatePrivateGeoObject.

@Test
public void testCreatePrivateGeoObject() {
    // Allowed Users
    TestUserInfo[] allowedUsers = new TestUserInfo[] { FastTestDataset.USER_CGOV_RA, FastTestDataset.USER_CGOV_RM_PRIVATE };
    for (TestUserInfo user : allowedUsers) {
        TestDataSet.runAsUser(user, (request, adapter) -> {
            TestDataSet.populateAdapterIds(user, adapter);
            GeoObject returned = adapter.createGeoObject(TEST_GO_PRIVATE.newGeoObject(adapter).toJSON().toString(), TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
            TEST_GO_PRIVATE.assertEquals(returned);
            Assert.assertEquals(true, returned.getExists());
            TEST_GO_PRIVATE.assertApplied();
            TEST_GO_PRIVATE.delete();
        });
    }
    // Disallowed Users
    TestUserInfo[] disallowedUsers = new TestUserInfo[] { 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) -> {
            if (TestDataSet.populateAdapterIds(user, adapter)) {
                try {
                    adapter.newGeoObjectInstance(FastTestDataset.PROVINCE_PRIVATE.getCode());
                    Assert.fail("Expected an error: " + user.getUsername());
                } catch (GeoObjectTypeNotFoundException ex) {
                // Expected
                }
            }
            try {
                adapter.createGeoObject(TEST_GO_PRIVATE.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 : GeoObjectTypeNotFoundException(org.commongeoregistry.adapter.GeoObjectTypeNotFoundException) TestUserInfo(net.geoprism.registry.test.TestUserInfo) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) TestGeoObjectInfo(net.geoprism.registry.test.TestGeoObjectInfo) Test(org.junit.Test)

Aggregations

SmartExceptionDTO (com.runwaysdk.business.SmartExceptionDTO)39 TestUserInfo (net.geoprism.registry.test.TestUserInfo)37 Test (org.junit.Test)35 JsonObject (com.google.gson.JsonObject)6 TestGeoObjectInfo (net.geoprism.registry.test.TestGeoObjectInfo)6 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)5 JsonArray (com.google.gson.JsonArray)3 ListTypeTest (net.geoprism.registry.service.ListTypeTest)3 CurationControllerWrapper (net.geoprism.registry.test.curation.CurationControllerWrapper)3 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)2 Point (com.vividsolutions.jts.geom.Point)2 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)2 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)2 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)2 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)2 GeometryBuilder (org.geotools.geometry.jts.GeometryBuilder)2 ArrayList (java.util.ArrayList)1 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)1 GeoObjectTypeNotFoundException (org.commongeoregistry.adapter.GeoObjectTypeNotFoundException)1 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)1