use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class ActivityTest method testActivity.
@Test
public void testActivity() throws CommandException {
/*
* Initial data load
*/
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO db = schema.getDatabaseById(1);
/*
* Create a new activity
*/
LocationTypeDTO locType = schema.getCountryById(1).getLocationTypes().get(0);
ActivityDTO act = new ActivityDTO();
act.setName("Warshing the dishes");
act.setLocationTypeId(locType.getId());
act.setReportingFrequency(ActivityDTO.REPORT_MONTHLY);
CreateResult cresult = execute(CreateEntity.Activity(db, act));
int newId = cresult.getNewId();
/*
* Reload schema to verify the changes have stuck
*/
schema = execute(new GetSchema());
act = schema.getActivityById(newId);
Assert.assertEquals("name", "Warshing the dishes", act.getName());
Assert.assertEquals("locationType", locType.getName(), act.getLocationType().getName());
Assert.assertEquals("reportingFrequency", ActivityDTO.REPORT_MONTHLY, act.getReportingFrequency());
Assert.assertEquals("public", Published.NOT_PUBLISHED.getIndex(), act.getPublished());
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class CreateDatabaseTest method testCreate.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void testCreate() throws CommandException {
UserDatabaseDTO db = new UserDatabaseDTO();
db.setName("RIMS");
db.setFullName("Reintegration Management Information System");
CreateResult cr = execute(new CreateEntity(db));
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO newdb = schema.getDatabaseById(cr.getNewId());
assertNotNull(newdb);
assertEquals(db.getName(), newdb.getName());
assertEquals(db.getFullName(), newdb.getFullName());
assertNotNull(newdb.getCountry());
assertEquals("Alex", newdb.getOwnerName());
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class DeleteTest method testDeleteIndicator.
@Test
public void testDeleteIndicator() throws CommandException {
SchemaDTO schema = execute(new GetSchema());
execute(new Delete(schema.getIndicatorById(1)));
schema = execute(new GetSchema());
Assert.assertNull(schema.getIndicatorById(1));
PagingResult<SiteDTO> sites = execute(GetSites.byId(1));
Assert.assertNull(sites.getData().get(0).getIndicatorValue(1));
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class AttributeGroupTest method testUpdate.
@Test
public void testUpdate() throws Exception {
// initial data load
SchemaDTO schema = execute(new GetSchema());
// change the name of an entity group
ActivityDTO activity = schema.getActivityById(1);
AttributeGroupDTO group = activity.getAttributeGroups().get(0);
group.setName("Foobar");
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("name", group.getName());
execute(new UpdateEntity(group, changes));
// reload data
schema = execute(new GetSchema());
// verify the property has been duly changed
Assert.assertEquals(group.getName(), schema.getActivityById(1).getAttributeGroups().get(0).getName());
}
use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method updateIndicator.
@Test
public void updateIndicator() {
synchronizeFirstTime();
Map<String, Object> changes = Maps.newHashMap();
changes.put("name", "New Name");
UpdateEntity update = new UpdateEntity("Indicator", 5, changes);
executeRemotely(update);
synchronize();
SchemaDTO schema = executeLocally(new GetSchema());
assertThat(schema.getIndicatorById(5).getName(), equalTo("New Name"));
}
Aggregations