Search in sources :

Example 21 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class UpdateUserPermissionsHandlerTest method testFolderLevelUpdate.

@Test
@OnDataSet("/dbunit/schema3.db.xml")
public void testFolderLevelUpdate() {
    setUser(1);
    UserPermissionDTO newUser = new UserPermissionDTO();
    newUser.setName("Bavon");
    newUser.setEmail("bavon@nrcdrc.org");
    newUser.setPartner(new PartnerDTO(1, "NRC"));
    newUser.setAllowView(true);
    newUser.setAllowViewAll(false);
    newUser.setAllowEdit(true);
    newUser.setAllowEdit(false);
    newUser.setAllowDesign(true);
    FolderDTO health = new FolderDTO();
    health.setId(3);
    newUser.setFolders(Arrays.asList(health));
    newUser.setFolderLimitation(true);
    execute(new UpdateUserPermissions(1, newUser));
    UserResult users = execute(new GetUsers(1));
    UserPermissionDTO bavon = users.getData().get(0);
    assertThat(bavon.hasFolderLimitation(), equalTo(true));
}
Also used : FolderDTO(org.activityinfo.legacy.shared.model.FolderDTO) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) UserResult(org.activityinfo.legacy.shared.command.result.UserResult) GetUsers(org.activityinfo.legacy.shared.command.GetUsers) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 22 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerTest method testAddNewPartner.

@Test
public void testAddNewPartner() throws Exception {
    PartnerDTO newPartner = new PartnerDTO();
    newPartner.setName("VDE");
    newPartner.setFullName("Vision d'Espoir");
    CreateResult cr = execute(new UpdatePartner(1, newPartner));
    SchemaDTO schema = execute(new GetSchema());
    PartnerDTO partner = schema.getDatabaseById(1).getPartnerById(cr.getNewId());
    Assert.assertNotNull(partner);
    Assert.assertEquals("VDE", partner.getName());
    Assert.assertEquals("Vision d'Espoir", partner.getFullName());
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.legacy.shared.command.result.DuplicateCreateResult) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) UpdatePartner(org.activityinfo.legacy.shared.command.UpdatePartner) Test(org.junit.Test)

Example 23 with PartnerDTO

use of org.activityinfo.legacy.shared.model.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerTest method testAddDuplicatePartner.

public void testAddDuplicatePartner() throws Exception {
    PartnerDTO newPartner = new PartnerDTO();
    newPartner.setName("NRC");
    newPartner.setFullName("Norweigen Refugee Committe");
    CreateResult cr = execute(new UpdatePartner(1, newPartner));
    Assert.assertTrue(cr instanceof DuplicateCreateResult);
}
Also used : DuplicateCreateResult(org.activityinfo.legacy.shared.command.result.DuplicateCreateResult) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.legacy.shared.command.result.DuplicateCreateResult) UpdatePartner(org.activityinfo.legacy.shared.command.UpdatePartner)

Aggregations

PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)23 Test (org.junit.Test)6 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)5 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)5 UserResult (org.activityinfo.legacy.shared.command.result.UserResult)4 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)4 OnDataSet (org.activityinfo.server.database.OnDataSet)4 ArrayList (java.util.ArrayList)3 Filter (org.activityinfo.legacy.shared.command.Filter)3 GetPartnersDimension (org.activityinfo.legacy.shared.command.GetPartnersDimension)3 GetUsers (org.activityinfo.legacy.shared.command.GetUsers)3 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)3 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)3 PartnerResult (org.activityinfo.legacy.shared.command.result.PartnerResult)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)2 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)2 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)2