Search in sources :

Example 1 with RunwayExceptionDTO

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

the class HierarchyServiceTest method testCreateHierarchyTypeAsBadRole.

@Test(expected = SmartExceptionDTO.class)
public void testCreateHierarchyTypeAsBadRole() {
    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();
    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().createHierarchyType(request.getSessionId(), gtJSON);
            });
            Assert.fail("Able to update a geo object type as a user with bad roles");
        } catch (RunwayExceptionDTO 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) RunwayExceptionDTO(com.runwaysdk.RunwayExceptionDTO) Test(org.junit.Test)

Aggregations

RunwayExceptionDTO (com.runwaysdk.RunwayExceptionDTO)1 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)1 TestUserInfo (net.geoprism.registry.test.TestUserInfo)1 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)1 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)1 Test (org.junit.Test)1