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()));
}
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));
}
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());
}
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);
}
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());
}
Aggregations