Search in sources :

Example 1 with GPRestExceptionMessage

use of org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage in project geo-platform by geosdi.

the class RSAccountTest method testInsertDuplicateUserWRTUsernameRest.

@Test
public void testInsertDuplicateUserWRTUsernameRest() throws Exception {
    GPUser user = super.createUser(usernameTest, organizationTest, GPRole.USER);
    try {
        gpWSClient.insertAccount(new InsertAccountRequest(user, Boolean.FALSE));
        Assert.fail("User already exist wrt username");
    } catch (ClientErrorException ex) {
        GPRestExceptionMessage exMess = ex.getResponse().readEntity(GPRestExceptionMessage.class);
        logger.debug("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ {}\n", exMess);
        if (!exMess.getMessage().toLowerCase().contains("username")) {
            // Must be fail for other reasons
            Assert.fail("Not fail for User already exist wrt username, but for: " + ex.getMessage());
        }
    }
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) ClientErrorException(javax.ws.rs.ClientErrorException) GPRestExceptionMessage(org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage) Test(org.junit.Test)

Example 2 with GPRestExceptionMessage

use of org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage in project geo-platform by geosdi.

the class RSLayerTest method testTransactionOnRemoveAndAddLayerRest.

@Test
public void testTransactionOnRemoveAndAddLayerRest() throws IllegalParameterFault, ResourceNotFoundFault {
    logger.trace("\n\t@@@ testTransactionOnRemoveAndAddLayerRest @@@");
    Map<Long, Integer> map = new HashMap();
    GPWebServiceMapData descendantsMapData = new GPWebServiceMapData();
    descendantsMapData.setDescendantsMap(map);
    map.put(idRootFolderA, 3);
    try {
        // Delete "rasterLayer1" from "rootFolderA"
        boolean erased = gpWSClient.deleteLayer(idRaster1);
        Assert.assertTrue("Deletion of the layer rasterLayer1", erased);
        GPRasterLayer raster = new GPRasterLayer();
        super.createLayer(raster, rootFolderA, null, "", "", 5, spatialReferenceSystem, // Title must be NOT NULL
        urlServer);
        gpWSClient.saveAddedLayerAndTreeModifications(new WSAddLayerAndTreeModificationsRequest(projectTest.getId(), rootFolderA.getId(), raster, descendantsMapData));
        Assert.fail("Add layer must fail because title value is null");
    } catch (ClientErrorException ex) {
        GPRestExceptionMessage exMess = ex.getResponse().readEntity(GPRestExceptionMessage.class);
        logger.debug("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@{}\n", exMess);
        try {
            raster1 = gpWSClient.getRasterLayer(idRaster1).getRasterLayer();
            Assert.fail("rasterLayer1 must not exist");
        } catch (NotFoundException rnf) {
            GPRestExceptionMessage rnfMess = rnf.getResponse().readEntity(GPRestExceptionMessage.class);
            logger.debug("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@{}\n", rnfMess);
        }
    }
}
Also used : GPWebServiceMapData(org.geosdi.geoplatform.response.collection.GPWebServiceMapData) ClientErrorException(javax.ws.rs.ClientErrorException) NotFoundException(javax.ws.rs.NotFoundException) GPRestExceptionMessage(org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage) WSAddLayerAndTreeModificationsRequest(org.geosdi.geoplatform.request.layer.WSAddLayerAndTreeModificationsRequest) Test(org.junit.Test)

Example 3 with GPRestExceptionMessage

use of org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage in project geo-platform by geosdi.

the class RSAccountTest method testInsertDuplicateUserWRTEmailRest.

@Test
public void testInsertDuplicateUserWRTEmailRest() throws Exception {
    GPUser user = super.createUser("duplicate-email-rs", organizationTest, GPRole.USER);
    user.setEmailAddress(super.userTest.getEmailAddress());
    try {
        gpWSClient.insertAccount(new InsertAccountRequest(user, Boolean.FALSE));
        Assert.fail("User already exist wrt email");
    } catch (ClientErrorException ex) {
        GPRestExceptionMessage exMess = ex.getResponse().readEntity(GPRestExceptionMessage.class);
        logger.debug("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ {}\n", exMess);
        if (!exMess.getMessage().toLowerCase().contains("email")) {
            // Must be fail for other reasons
            Assert.fail("Not fail for User already exist wrt email, but for: " + ex.getMessage());
        }
    }
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) ClientErrorException(javax.ws.rs.ClientErrorException) GPRestExceptionMessage(org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage) Test(org.junit.Test)

Example 4 with GPRestExceptionMessage

use of org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage in project geo-platform by geosdi.

the class RSAccountTest method testInsertIncorrectUserWRTUOrganizationRest.

@Test
public void testInsertIncorrectUserWRTUOrganizationRest() throws Exception {
    GPUser user = super.createUser("no-organization-rs", new GPOrganization("organization-inexistent-rs"), GPRole.USER);
    try {
        gpWSClient.insertAccount(new InsertAccountRequest(user, Boolean.FALSE));
        Assert.fail("User incorrect wrt organization");
    } catch (ClientErrorException ex) {
        GPRestExceptionMessage exMess = ex.getResponse().readEntity(GPRestExceptionMessage.class);
        logger.debug("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ {}\n", exMess);
        if (!exMess.getMessage().toLowerCase().contains("organization")) {
            // Must be fail for other reasons
            Assert.fail("Not fail for User incorrect wrt organization, but for: " + ex.getMessage());
        }
    }
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) ClientErrorException(javax.ws.rs.ClientErrorException) GPRestExceptionMessage(org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage) Test(org.junit.Test)

Aggregations

ClientErrorException (javax.ws.rs.ClientErrorException)4 GPRestExceptionMessage (org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage)4 Test (org.junit.Test)4 GPUser (org.geosdi.geoplatform.core.model.GPUser)3 InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)3 NotFoundException (javax.ws.rs.NotFoundException)1 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)1 WSAddLayerAndTreeModificationsRequest (org.geosdi.geoplatform.request.layer.WSAddLayerAndTreeModificationsRequest)1 GPWebServiceMapData (org.geosdi.geoplatform.response.collection.GPWebServiceMapData)1