Search in sources :

Example 6 with GetUsers

use of org.activityinfo.shared.command.GetUsers 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

GetUsers (org.activityinfo.shared.command.GetUsers)6 UserResult (org.activityinfo.shared.command.result.UserResult)6 Test (org.junit.Test)5 OnDataSet (org.activityinfo.server.database.OnDataSet)2 UpdateUserPermissions (org.activityinfo.shared.command.UpdateUserPermissions)2 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)2 UserPermissionDTO (org.activityinfo.shared.dto.UserPermissionDTO)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Date (java.util.Date)1 ServletException (javax.servlet.ServletException)1