Search in sources :

Example 1 with InsertAccountRequest

use of org.geosdi.geoplatform.request.InsertAccountRequest 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 InsertAccountRequest

use of org.geosdi.geoplatform.request.InsertAccountRequest in project geo-platform by geosdi.

the class WSAccountTest method testInsertDuplicateUserWRTEmail.

@Test
public void testInsertDuplicateUserWRTEmail() {
    GPUser user = super.createUser("duplicate-email", organizationTest, USER);
    user.setEmailAddress(super.userTest.getEmailAddress());
    try {
        gpWSClient.insertAccount(new InsertAccountRequest(user, FALSE));
        fail("User already exist wrt email");
    } catch (IllegalParameterFault ex) {
        if (!ex.getMessage().toLowerCase().contains("email")) {
            // Must be fail for other reasons
            fail("Not fail for User already exist wrt email, but for: " + ex.getMessage());
        }
    }
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) Test(org.junit.Test)

Example 3 with InsertAccountRequest

use of org.geosdi.geoplatform.request.InsertAccountRequest in project geo-platform by geosdi.

the class GPJacksonAccountSupportTest method insertAccountRequestMapperTest.

@Test
public void insertAccountRequestMapperTest() throws Exception {
    InsertAccountRequest insertAccountRequest = jacksonSupport.getDefaultMapper().readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream(INSERT_ACCOUNT_REQUEST_DATA_JSON), InsertAccountRequest.class);
    logger.info("\n\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@INSERT_ACCOUNT_REQUEST" + " : {}\n\n", insertAccountRequest);
    super.marshall(insertAccountRequest);
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) Test(org.junit.Test)

Example 4 with InsertAccountRequest

use of org.geosdi.geoplatform.request.InsertAccountRequest in project geo-platform by geosdi.

the class UserService method insertUser.

@Override
public Long insertUser(IGPUserManageDetail userDetail, String organization, HttpServletRequest httpServletRequest, boolean checkUserSession, boolean sendEmail) throws GeoPlatformException {
    if (checkUserSession) {
        this.getCheckLoggedUser(httpServletRequest);
    }
    logger.debug("\nUser to INSERT (of the organization \"{}\"):\n{}", organization, userDetail);
    Long iserId = null;
    try {
        GPUser user = this.dtoUserConverter.convertToGPUser(userDetail);
        user.setOrganization(new GPOrganization(organization));
        iserId = geoPlatformServiceClient.insertAccount(new InsertAccountRequest(user, sendEmail));
    } catch (IllegalParameterFault ipf) {
        throw new GeoPlatformException(ipf.getMessage());
    }
    return iserId;
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 5 with InsertAccountRequest

use of org.geosdi.geoplatform.request.InsertAccountRequest in project geo-platform by geosdi.

the class WSAccountTest method testInsertDuplicateUserWRTUsername.

@Test
public void testInsertDuplicateUserWRTUsername() {
    GPUser user = super.createUser(usernameTest, organizationTest, USER);
    try {
        gpWSClient.insertAccount(new InsertAccountRequest(user, FALSE));
        fail("User already exist wrt username");
    } catch (IllegalParameterFault ex) {
        ex.printStackTrace();
    // if (!ex.getMessage().toLowerCase().contains("username")) { // Must be fail for other reasons
    // fail("Not fail for User already exist wrt username, but for: " + ex.getMessage());
    // }
    }
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) Test(org.junit.Test)

Aggregations

InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)9 GPUser (org.geosdi.geoplatform.core.model.GPUser)7 Test (org.junit.Test)7 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)4 ClientErrorException (javax.ws.rs.ClientErrorException)3 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)3 GPRestExceptionMessage (org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage)3 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)1