Search in sources :

Example 16 with CreateResult

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

the class LocalSiteCreateTest method siteRemovePartnerConflict.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void siteRemovePartnerConflict() {
    // FIRST U1 adds a new partner
    int databaseId = 1;
    PartnerDTO iom = new PartnerDTO();
    iom.setName("IOM");
    CreateResult result = executeRemotely(new AddPartner(databaseId, iom));
    iom.setId(result.getNewId());
    // Now U2 synchronizes, and adds a new site with this partner
    synchronizeFirstTime();
    SiteDTO site = new SiteDTO();
    site.setId(3343234);
    site.setActivityId(1);
    site.setPartner(iom);
    site.setDate1(new Date());
    site.setDate2(new Date());
    site.setLocationId(1);
    executeLocally(new CreateSite(site));
    // At T+3, U2 thinks better, removes IOM
    executeRemotely(new RemovePartner(databaseId, iom.getId()));
    // At T+4, U1 synchronizes, and IOM is removed, but site remains
    synchronize();
    // Verify that there is still a label for this partner
    SiteResult sites = executeLocally(GetSites.byId(site.getId()));
    assertThat(sites.getTotalLength(), equalTo(1));
    assertThat(sites.getData().get(0).getName(), equalTo(site.getName()));
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) SiteResult(org.activityinfo.shared.command.result.SiteResult) RemovePartner(org.activityinfo.shared.command.RemovePartner) AddPartner(org.activityinfo.shared.command.AddPartner) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Date(java.util.Date) CreateSite(org.activityinfo.shared.command.CreateSite) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 17 with CreateResult

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

the class LockedPeriodTest method createTest.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void createTest() throws CommandException {
    setUser(1);
    LockedPeriodDTO dto = new LockedPeriodDTO();
    dto.setName("my name");
    dto.setFromDate(new LocalDate(2011, 1, 1));
    dto.setToDate(new LocalDate(2011, 1, 31));
    dto.setEnabled(true);
    CreateLockedPeriod create = new CreateLockedPeriod(dto);
    create.setUserDatabaseId(1);
    CreateResult result = execute(create);
    Map<String, Object> changes = Maps.newHashMap();
    changes.put("toDate", new LocalDate(2011, 2, 28));
    execute(new UpdateEntity("LockedPeriod", result.getNewId(), changes));
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) UpdateEntity(org.activityinfo.shared.command.UpdateEntity) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) CreateLockedPeriod(org.activityinfo.shared.command.CreateLockedPeriod) LockedPeriodDTO(org.activityinfo.shared.dto.LockedPeriodDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 18 with CreateResult

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

the class PartnerTest method testAddPartner.

@Test
public void testAddPartner() throws Exception {
    PartnerDTO newPartner = new PartnerDTO();
    newPartner.setName("Solidarites");
    CreateResult cr = execute(new AddPartner(PEAR_PLUS_DB_ID, newPartner));
    Assert.assertEquals(SOL_ID, cr.getNewId());
    SchemaDTO schema = execute(new GetSchema());
    PartnerDTO partner = schema.getDatabaseById(PEAR_PLUS_DB_ID).getPartnerById(SOL_ID);
    Assert.assertNotNull(partner);
    Assert.assertEquals(newPartner.getName(), partner.getName());
}
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 19 with CreateResult

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

the class TargetTest method deleteTargetTest.

@Test
public void deleteTargetTest() {
    TargetDTO target = createTarget();
    CreateResult cresult = execute(new AddTarget(db.getId(), target));
    int newId = cresult.getNewId();
    /*
         * Load Targets to verify the changes have stuck
         */
    List<TargetDTO> targets = execute(new GetTargets(db.getId())).getData();
    TargetDTO dto = getTargetById(targets, newId);
    Assert.assertEquals("name", "Target0071", dto.getName());
    /*
         * Delete new target now
         */
    execute(new Delete(dto));
    /*
         * Verify if target is deleted.
         */
    targets = execute(new GetTargets()).getData();
    TargetDTO deleted = getTargetById(targets, newId);
    Assert.assertNull(deleted);
}
Also used : Delete(org.activityinfo.shared.command.Delete) GetTargets(org.activityinfo.shared.command.GetTargets) CreateResult(org.activityinfo.shared.command.result.CreateResult) AddTarget(org.activityinfo.shared.command.AddTarget) TargetDTO(org.activityinfo.shared.dto.TargetDTO) Test(org.junit.Test)

Example 20 with CreateResult

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

the class TargetTest method testTarget.

@Test
public void testTarget() throws CommandException {
    /*
         * Create a new Target
         */
    TargetDTO target = createTarget();
    CreateResult cresult = execute(new AddTarget(db.getId(), target));
    int newId = cresult.getNewId();
    /*
         * Load Targets to verify the changes have stuck
         */
    List<TargetDTO> targets = execute(new GetTargets(db.getId())).getData();
    TargetDTO dto = getTargetById(targets, newId);
    Assert.assertNotNull(dto);
    Assert.assertEquals("name", "Target0071", dto.getName());
}
Also used : GetTargets(org.activityinfo.shared.command.GetTargets) CreateResult(org.activityinfo.shared.command.result.CreateResult) AddTarget(org.activityinfo.shared.command.AddTarget) TargetDTO(org.activityinfo.shared.dto.TargetDTO) Test(org.junit.Test)

Aggregations

CreateResult (org.activityinfo.shared.command.result.CreateResult)36 Test (org.junit.Test)17 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)9 Date (java.util.Date)8 GetSchema (org.activityinfo.shared.command.GetSchema)8 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)8 CreateSite (org.activityinfo.shared.command.CreateSite)7 SiteDTO (org.activityinfo.shared.dto.SiteDTO)7 AddPartner (org.activityinfo.shared.command.AddPartner)6 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)6 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)6 OnDataSet (org.activityinfo.server.database.OnDataSet)5 UserDatabase (org.activityinfo.server.database.hibernate.entity.UserDatabase)5 CreateEntity (org.activityinfo.shared.command.CreateEntity)5 DuplicateCreateResult (org.activityinfo.shared.command.result.DuplicateCreateResult)5 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)4 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)4 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)4 Activity (org.activityinfo.server.database.hibernate.entity.Activity)4 AddTarget (org.activityinfo.shared.command.AddTarget)4