use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method testPointsInferred.
@Test
@OnDataSet("/dbunit/sites-points.db.xml")
public void testPointsInferred() {
dimensions.add(new Dimension(DimensionType.Location));
withPoints();
execute();
assertThat().forLocation(1).thereIsOneBucketWithValue(1500).at((26.8106418 + 28.37725848) / 2.0, (-4.022388142 + -1.991221064) / 2.0);
assertThat().forLocation(2).thereIsOneBucketWithValue(3600).at(27.328491, -2.712609);
}
use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method targetFilter.
@Test
public void targetFilter() {
// Pivoting: PivotSites [dimensions=[Date, Partner, Date, Target,
// Activity, Indicator],
// filter=AdminLevel={ 141801 }, Partner={ 130 },
// Indicator={ 747 746 745 744 749 748 739 738 743 740 119 118 3661 125
// 124 123 122 121 }, valueType=INDICATOR]
withPartnerAsDimension();
dimensions.add(new DateDimension(DateUnit.YEAR));
dimensions.add(new Dimension(DimensionType.Target));
dimensions.add(new Dimension(DimensionType.Activity));
dimensions.add(new Dimension(DimensionType.Indicator));
filter.addRestriction(DimensionType.AdminLevel, 141801);
filter.addRestriction(DimensionType.Partner, 130);
filter.addRestriction(DimensionType.Indicator, 1);
execute();
}
use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method withPartnerAsDimension.
private void withPartnerAsDimension() {
partnerDim = new Dimension(DimensionType.Partner);
dimensions.add(partnerDim);
}
use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method execute.
private void execute() {
setUser(OWNER_USER_ID);
try {
PivotSites pivot = new PivotSites(dimensions, filter);
pivot.setValueType(valueType);
pivot.setPointRequested(pointsRequested);
buckets = execute(pivot).getBuckets();
} catch (CommandException e) {
throw new RuntimeException(e);
}
System.out.println("Buckets = [");
for (Bucket bucket : buckets) {
System.out.print(" { Value: " + bucket.doubleValue());
for (Dimension dim : bucket.dimensions()) {
DimensionCategory cat = bucket.getCategory(dim);
System.out.print("\n " + dim.toString() + ": ");
System.out.print(cat.toString());
}
System.out.println("\n }");
}
System.out.print("]\n");
}
use of org.activityinfo.shared.report.model.Dimension in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method testWeeks.
@Test
@OnDataSet("/dbunit/sites-weeks.db.xml")
public void testWeeks() {
final Dimension weekDim = new DateDimension(DateUnit.WEEK_MON);
dimensions.add(weekDim);
filter.addRestriction(DimensionType.Indicator, 1);
execute();
assertEquals(3, buckets.size());
assertEquals(3600, (int) findBucketByWeek(buckets, 2011, 52).doubleValue());
assertEquals(1500, (int) findBucketByWeek(buckets, 2012, 1).doubleValue());
assertEquals(4142, (int) findBucketByWeek(buckets, 2012, 13).doubleValue());
}
Aggregations