Search in sources :

Example 26 with GPUser

use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.

the class WSAccountTest method testRetrieveUser.

@Test
public void testRetrieveUser() throws ResourceNotFoundFault {
    // Number of Account Like
    long numAccountsLike = gpWSClient.getAccountsCount(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
    assertEquals("Number of Account Like", 1L, numAccountsLike);
    // Get User from Id
    // Get UserDTO from Id
    UserDTOResponse userDTOResponse = gpWSClient.getShortUser(idUserTest);
    UserDTO userDTOFromWS = userDTOResponse.getUserDTO();
    assertNotNull(userDTOFromWS);
    assertEquals("Error found UserDTO from Id", idUserTest, userDTOFromWS.getId().longValue());
    // Get GPUser from Id
    GPUser userFromWS = gpWSClient.getUserDetail(idUserTest);
    assertNotNull(userFromWS);
    assertEquals("Error found GPUser from Id", idUserTest, userFromWS.getId().longValue());
    // Get User from Username
    // Get UserDTO from Username
    userDTOFromWS = gpWSClient.getShortUserByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS)).getUserDTO();
    assertNotNull(userDTOFromWS);
    assertEquals("Error found UserDTO from Username", idUserTest, userDTOFromWS.getId().longValue());
    // Get GPUser from Username
    userFromWS = gpWSClient.getUserDetailByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
    assertNotNull(userFromWS);
    assertEquals("Error found GPUser from Username", idUserTest, userFromWS.getId().longValue());
}
Also used : SearchRequest(org.geosdi.geoplatform.request.SearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) UserDTOResponse(org.geosdi.geoplatform.response.UserDTOResponse) UserDTO(org.geosdi.geoplatform.response.UserDTO) Test(org.junit.Test)

Example 27 with GPUser

use of org.geosdi.geoplatform.core.model.GPUser 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)

Example 28 with GPUser

use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.

the class WSAccountTest method testAuthorizationCorrectUsername.

@Test
public void testAuthorizationCorrectUsername() throws Exception {
    GPUser user = gpWSClient.getUserDetailByUsernameAndPassword(usernameTest, passwordTest);
    assertNotNull("User is null", user);
    assertEquals(usernameTest, user.getUsername());
}
Also used : GPUser(org.geosdi.geoplatform.core.model.GPUser) Test(org.junit.Test)

Example 29 with GPUser

use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.

the class WSAccountTest method testInsertIncorrectUserWRTUOrganization.

@Test
public void testInsertIncorrectUserWRTUOrganization() {
    GPUser user = super.createUser("no-organization", new GPOrganization("organization-inexistent"), USER);
    try {
        gpWSClient.insertAccount(new InsertAccountRequest(user, FALSE));
        fail("User incorrect wrt organization");
    } catch (IllegalParameterFault ex) {
        if (!ex.getMessage().toLowerCase().contains("organization")) {
            // Must be fail for other reasons
            fail("Not fail for User incorrect wrt organization, 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) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) Test(org.junit.Test)

Example 30 with GPUser

use of org.geosdi.geoplatform.core.model.GPUser in project geo-platform by geosdi.

the class WSAccountTest method testAuthorizationCorrectEmail.

@Test
public void testAuthorizationCorrectEmail() throws Exception {
    GPUser user = gpWSClient.getUserDetailByUsernameAndPassword(emailTest, passwordTest);
    assertNotNull("User is null", user);
    assertEquals(emailTest, user.getEmailAddress());
}
Also used : GPUser(org.geosdi.geoplatform.core.model.GPUser) Test(org.junit.Test)

Aggregations

GPUser (org.geosdi.geoplatform.core.model.GPUser)33 Test (org.junit.Test)15 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)8 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)7 InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)7 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)6 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)6 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)4 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)4 UserDTO (org.geosdi.geoplatform.response.UserDTO)4 Query (javax.persistence.Query)3 ClientErrorException (javax.ws.rs.ClientErrorException)3 GPRestExceptionMessage (org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage)3 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)3 SearchRequest (org.geosdi.geoplatform.request.SearchRequest)3 ArrayList (java.util.ArrayList)2 GPApplication (org.geosdi.geoplatform.core.model.GPApplication)2 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)2 UserDTOResponse (org.geosdi.geoplatform.response.UserDTOResponse)2 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)1