use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.
the class DimensionPrunerTest method setupData.
@Before
public void setupData() {
ActivityDTO dist = new ActivityDTO(1, "Distribution");
IndicatorDTO nbMenages = new IndicatorDTO();
nbMenages.setId(NB_MENAGES_INDICATOR_ID);
nbMenages.setName("Nb Menages");
dist.getIndicators().add(nbMenages);
AttributeGroupDTO distFunding = new AttributeGroupDTO(NFI_FUNDING_GROUP_ID);
distFunding.setName("Funding Source");
dist.getAttributeGroups().add(distFunding);
ActivityDTO fairs = new ActivityDTO(2, "Faire");
AttributeGroupDTO fairFunding = new AttributeGroupDTO(FAIR_FUNDING_GROUP_ID);
fairFunding.setName("Funding Source");
fairs.getAttributeGroups().add(fairFunding);
IndicatorDTO voucherValue = new IndicatorDTO();
voucherValue.setId(VOUCHER_INDICATOR_ID);
voucherValue.setName("Voucher Value");
fairs.getIndicators().add(voucherValue);
UserDatabaseDTO nfi = new UserDatabaseDTO(1, "NFI");
nfi.getActivities().add(dist);
nfi.getActivities().add(fairs);
this.schema = new SchemaDTO();
schema.getDatabases().add(nfi);
dispatcher.setResult(GetSchema.class, schema);
}
use of org.activityinfo.shared.dto.ActivityDTO 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.ActivityDTO in project activityinfo by bedatadriven.
the class SiteRendererTest method multipleGroupsRender.
@Test
public void multipleGroupsRender() {
IndicatorDTO indicator1 = new IndicatorDTO();
indicator1.setId(1);
indicator1.setAggregation(IndicatorDTO.AGGREGATE_SUM);
indicator1.setName("First indicator");
indicator1.setCategory("First group");
IndicatorDTO indicator2 = new IndicatorDTO();
indicator2.setAggregation(IndicatorDTO.AGGREGATE_SUM);
indicator2.setId(2);
indicator2.setName("Second indicator");
indicator2.setCategory("Second group");
ActivityDTO activity = new ActivityDTO();
activity.setId(1);
activity.getIndicators().add(indicator1);
activity.getIndicators().add(indicator2);
SiteDTO site = new SiteDTO();
site.setIndicatorValue(1, 1000d);
site.setIndicatorValue(2, 2000d);
String html = siteRenderer.renderSite(site, activity, false, true);
assertTrue(html.contains(indicator1.getName()));
assertTrue(html.contains(indicator2.getName()));
}
use of org.activityinfo.shared.dto.ActivityDTO 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.ActivityDTO in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method createActivity.
@Test
public void createActivity() {
synchronizeFirstTime();
SchemaDTO schema = executeLocally(new GetSchema());
ActivityDTO activity = new ActivityDTO();
activity.setName("New Activity");
activity.setReportingFrequency(0);
activity.setLocationTypeId(1);
CreateResult createResult = executeRemotely(CreateEntity.Activity(schema.getDatabaseById(1), activity));
synchronize();
schema = executeLocally(new GetSchema());
ActivityDTO createdActivity = schema.getActivityById(createResult.getNewId());
assertThat(createdActivity, is(not(nullValue())));
assertThat(createdActivity.getName(), equalTo(activity.getName()));
}
Aggregations