use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method testMonthlyCalculatedIndicatorsByAttribute.
@Test
@OnDataSet("/dbunit/monthly-calc-indicators.db.xml")
public void testMonthlyCalculatedIndicatorsByAttribute() {
withIndicatorAsDimension();
filteringOnDatabases(1);
withAttributeGroupDim(1);
dimensions.add(new DateDimension(DateUnit.MONTH));
execute();
assertThat().forMonth(2009, 1).forIndicator(7003).forAttributeGroupLabeled(1, "B").thereIsOneBucketWithValue(500);
assertThat().forMonth(2009, 1).forIndicator(7003).forAttributeGroupLabeled(1, "A").thereIsOneBucketWithValue(37);
assertThat().forMonth(2009, 2).forIndicator(7003).forAttributeGroupLabeled(1, "B").thereIsOneBucketWithValue(480);
assertThat().forMonth(2009, 2).forIndicator(7003).forAttributeGroupLabeled(1, "A").thereIsOneBucketWithValue(154);
PivotTableReportElement report = new PivotTableReportElement();
report.setColumnDimensions(Arrays.asList(indicatorDim, new AttributeGroupDimension(1)));
report.setRowDimensions(Arrays.<Dimension>asList(yearDim, monthDim));
PivotTableDataBuilder tableDataBuilder = new PivotTableDataBuilder();
PivotTableData table = tableDataBuilder.build(report.getRowDimensions(), report.getColumnDimensions(), buckets);
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class ActivityFormClassBuilderTest method nullLocationTypeIsNotVisible.
@Test
@OnDataSet("/dbunit/chad-form.db.xml")
public void nullLocationTypeIsNotVisible() {
setUser(9944);
int databaseId = 1470;
FormClass formClass = assertResolves(locator.getFormClass(CuidAdapter.activityFormClass(11218)));
ResourceId locationFieldId = CuidAdapter.field(formClass.getId(), CuidAdapter.LOCATION_FIELD);
assertThat(formClass.getFields(), not(hasItem(withId(locationFieldId))));
// Make sure we can update if location is not specified
FormInstance instance = new FormInstance(CuidAdapter.newLegacyFormInstanceId(formClass.getId()), formClass.getId());
instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.START_DATE_FIELD), new LocalDate(2014, 1, 1));
instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.END_DATE_FIELD), new LocalDate(2014, 1, 2));
instance.set(CuidAdapter.field(formClass.getId(), CuidAdapter.PARTNER_FIELD), CuidAdapter.partnerRef(databaseId, 1734));
instance.set(ResourceId.valueOf("Q0000031845"), new EnumValue(CuidAdapter.attributeField(166617)));
assertResolves(locator.persist(instance));
// Make sure the null location object is visible to legacy code
SiteDTO site = execute(GetSites.byId(CuidAdapter.getLegacyIdFromCuid(instance.getId()))).getData().get(0);
assertThat(site.getLocationName(), equalTo("Chad"));
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class GetPartnersDimensionHandlerTest method testActivity.
// data entry filter population query
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void testActivity() throws CommandException {
PartnerResult result = execute(DimensionType.Activity, 1);
assertThat(result.getData().size(), equalTo(2));
assertThat(result.getData().get(0).getName(), equalTo("NRC"));
assertThat(result.getData().get(1).getName(), equalTo("Solidarites"));
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class GetPartnersDimensionHandlerTest method testActivityWithDateFilter.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void testActivityWithDateFilter() throws CommandException {
Filter filter = new Filter();
filter.addRestriction(DimensionType.Activity, 1);
filter.getEndDateRange().setMinDate(new LocalDate(1998, 1, 1).atMidnightInMyTimezone());
filter.getEndDateRange().setMaxDate(new LocalDate(2099, 1, 15).atMidnightInMyTimezone());
PartnerResult result = execute(filter);
assertThat(result.getData().size(), equalTo(2));
assertThat(result.getData().get(0).getName(), equalTo("NRC"));
assertThat(result.getData().get(1).getName(), equalTo("Solidarites"));
}
use of org.activityinfo.server.database.OnDataSet in project activityinfo by bedatadriven.
the class GetPartnersDimensionHandlerTest method testIndicatorValues.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void testIndicatorValues() throws CommandException {
// NRC, Solidarites
PartnerResult result = execute(DimensionType.Indicator, 1, 2);
assertThat(result.getData().size(), equalTo(2));
assertThat(result.getData().get(0).getName(), equalTo("NRC"));
assertThat(result.getData().get(1).getName(), equalTo("Solidarites"));
}
Aggregations