Search in sources :

Example 21 with PartnerDTO

use of org.activityinfo.shared.dto.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 AddPartner(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.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) AddPartner(org.activityinfo.shared.command.AddPartner) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 22 with PartnerDTO

use of org.activityinfo.shared.dto.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 AddPartner(1, newPartner));
    Assert.assertTrue(cr instanceof DuplicateCreateResult);
}
Also used : DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) AddPartner(org.activityinfo.shared.command.AddPartner)

Example 23 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO 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

PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)23 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 Test (org.junit.Test)8 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)6 SiteDTO (org.activityinfo.shared.dto.SiteDTO)6 AddPartner (org.activityinfo.shared.command.AddPartner)5 CreateSite (org.activityinfo.shared.command.CreateSite)4 DuplicateCreateResult (org.activityinfo.shared.command.result.DuplicateCreateResult)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 GregorianCalendar (java.util.GregorianCalendar)3 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)3 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)3 OnDataSet (org.activityinfo.server.database.OnDataSet)3 GetPartnersDimension (org.activityinfo.shared.command.GetPartnersDimension)3 PartnerResult (org.activityinfo.shared.command.result.PartnerResult)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)2