Search in sources :

Example 6 with UserResult

use of org.activityinfo.shared.command.result.UserResult in project activityinfo by bedatadriven.

the class GetUsersTest method testUnsorted.

@Test
public void testUnsorted() throws CommandException {
    setUser(DATABASE_OWNER);
    GetUsers cmd = new GetUsers(1);
    UserResult result = execute(cmd);
    Assert.assertEquals(3, result.getData().size());
}
Also used : UserResult(org.activityinfo.shared.command.result.UserResult) GetUsers(org.activityinfo.shared.command.GetUsers) Test(org.junit.Test)

Example 7 with UserResult

use of org.activityinfo.shared.command.result.UserResult in project activityinfo by bedatadriven.

the class GetUsersTest method testManageUsersPermission.

/**
 * Verify that users with ManageUsers permission can get a list of users
 * within their organisation
 */
@Test
public void testManageUsersPermission() throws CommandException {
    // populate with a known state and authenticate as user 3, who
    // has ManageUser permissions for Solidarites
    // Lisa from Solidarites
    setUser(3);
    // execute
    UserResult result = execute(new GetUsers(1));
    // VERIFY that we have 1 result:
    // - the one other solidarites user
    Assert.assertEquals("number of results", 1, result.getTotalLength());
    Assert.assertEquals("user name", "Marlene", result.getData().get(0).getName());
}
Also used : UserResult(org.activityinfo.shared.command.result.UserResult) GetUsers(org.activityinfo.shared.command.GetUsers) Test(org.junit.Test)

Example 8 with UserResult

use of org.activityinfo.shared.command.result.UserResult in project activityinfo by bedatadriven.

the class UpdateUserPermissionsHandlerTest method testAuthorizedCreate.

/**
 * Verifies that a user with the manageUsers permission can add another user to the UserDatabase
 *
 * @throws CommandException
 */
@Test
@OnDataSet("/dbunit/schema1.db.xml")
public void testAuthorizedCreate() throws CommandException {
    setUser(2);
    UserPermissionDTO user = new UserPermissionDTO();
    user.setEmail("ralph@lauren.com");
    user.setName("Ralph");
    user.setPartner(new PartnerDTO(1, "NRC"));
    user.setAllowView(true);
    user.setAllowEdit(true);
    UpdateUserPermissions cmd = new UpdateUserPermissions(1, user);
    execute(cmd);
    UserResult result = execute(new GetUsers(1));
    Assert.assertEquals(1, result.getTotalLength());
    Assert.assertEquals("ralph@lauren.com", result.getData().get(0).getEmail());
    Assert.assertTrue("edit permissions", result.getData().get(0).getAllowEdit());
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) UpdateUserPermissions(org.activityinfo.shared.command.UpdateUserPermissions) UserResult(org.activityinfo.shared.command.result.UserResult) GetUsers(org.activityinfo.shared.command.GetUsers) UserPermissionDTO(org.activityinfo.shared.dto.UserPermissionDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

UserResult (org.activityinfo.shared.command.result.UserResult)8 GetUsers (org.activityinfo.shared.command.GetUsers)6 Test (org.junit.Test)5 UserPermissionDTO (org.activityinfo.shared.dto.UserPermissionDTO)4 ArrayList (java.util.ArrayList)2 OnDataSet (org.activityinfo.server.database.OnDataSet)2 UpdateUserPermissions (org.activityinfo.shared.command.UpdateUserPermissions)2 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)2 StoreEvent (com.extjs.gxt.ui.client.store.StoreEvent)1 CheckColumnConfig (com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig)1 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)1 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Date (java.util.Date)1 Query (javax.persistence.Query)1 ServletException (javax.servlet.ServletException)1 UserPermission (org.activityinfo.server.database.hibernate.entity.UserPermission)1