use of org.activityinfo.shared.command.result.Bucket in project activityinfo by bedatadriven.
the class PivotTableGeneratorTest method testIndicatorSortOrder.
@Test
public void testIndicatorSortOrder() {
// test input data: user
User user = new User();
user.setLocale("fr");
// test input data: PivotTableElement
PivotTableReportElement element = new PivotTableReportElement();
Dimension indicatorDim = new Dimension(DimensionType.Indicator);
element.addRowDimension(indicatorDim);
// test input data: aggregated results
List<Bucket> buckets = new ArrayList<Bucket>();
buckets.add(newBucket(300, category(indicatorDim, 1, "Nb. menages", 3)));
buckets.add(newBucket(400, category(indicatorDim, 2, "Nb. personnes", 1)));
buckets.add(newBucket(600, category(indicatorDim, 3, "Nb. deplaces", 2)));
// collaborator : PivotDAO
DispatcherSync dispatcher = createMock(DispatcherSync.class);
expect(dispatcher.execute(isA(PivotSites.class))).andReturn(new PivotSites.PivotResult(buckets));
replay(dispatcher);
// CLASS UNDER TEST!!
PivotTableGenerator generator = new PivotTableGenerator(dispatcher);
generator.generate(user, element, null, null);
Assert.assertNotNull("element content", element.getContent());
List<PivotTableData.Axis> rows = element.getContent().getData().getRootRow().getChildren();
Assert.assertEquals(2, ((EntityCategory) rows.get(0).getCategory()).getId());
Assert.assertEquals(3, ((EntityCategory) rows.get(1).getCategory()).getId());
Assert.assertEquals(1, ((EntityCategory) rows.get(2).getCategory()).getId());
}
use of org.activityinfo.shared.command.result.Bucket in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method testLinkedAttributegroupFilterData.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void testLinkedAttributegroupFilterData() {
withAttributeGroupDim();
forFilterData();
execute();
assertThat().thereAre(2).buckets();
Dimension dim = new Dimension(DimensionType.AttributeGroup);
Bucket causeBucket = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", causeBucket.getCategory(dim).getLabel());
assertEquals(0, (int) causeBucket.doubleValue());
Bucket contenuBucket = findBucketsByCategory(buckets, dim, new EntityCategory(2)).get(0);
assertEquals("contenu du kit", contenuBucket.getCategory(dim).getLabel());
assertEquals(0, (int) contenuBucket.doubleValue());
}
use of org.activityinfo.shared.command.result.Bucket in project activityinfo by bedatadriven.
the class PivotSitesHandlerTest method testLinkedAttributegroupFilterDataForIndicator.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void testLinkedAttributegroupFilterDataForIndicator() {
withAttributeGroupDim();
forFilterData();
Dimension dim = new Dimension(DimensionType.AttributeGroup);
// empty
filter.addRestriction(DimensionType.Indicator, 100);
execute();
assertThat().thereAre(0).buckets();
// cause, contenu du kit
filter = new Filter();
filter.addRestriction(DimensionType.Indicator, 1);
execute();
assertThat().thereAre(2).buckets();
Bucket bucket1 = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", bucket1.getCategory(dim).getLabel());
assertEquals(0, (int) bucket1.doubleValue());
Bucket bucket2 = findBucketsByCategory(buckets, dim, new EntityCategory(2)).get(0);
assertEquals("contenu du kit", bucket2.getCategory(dim).getLabel());
assertEquals(0, (int) bucket2.doubleValue());
// cause
filter = new Filter();
filter.addRestriction(DimensionType.Indicator, 2);
execute();
assertThat().thereAre(1).buckets();
bucket1 = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", bucket1.getCategory(dim).getLabel());
assertEquals(0, (int) bucket1.doubleValue());
// cause, contenu du kit
filter = new Filter();
filter.addRestriction(DimensionType.Indicator, Arrays.asList(1, 2, 100));
execute();
assertThat().thereAre(2).buckets();
bucket1 = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", bucket1.getCategory(dim).getLabel());
assertEquals(0, (int) bucket1.doubleValue());
bucket2 = findBucketsByCategory(buckets, dim, new EntityCategory(2)).get(0);
assertEquals("contenu du kit", bucket2.getCategory(dim).getLabel());
assertEquals(0, (int) bucket2.doubleValue());
}
use of org.activityinfo.shared.command.result.Bucket in project activityinfo by bedatadriven.
the class PivotSitesHandlerLocalTest method testLinkedAttributegroupFilterData.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void testLinkedAttributegroupFilterData() {
withAttributeGroupDim();
forFilterData();
execute();
assertThat().thereAre(2).buckets();
Dimension dim = new Dimension(DimensionType.AttributeGroup);
Bucket causeBucket = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", causeBucket.getCategory(dim).getLabel());
assertEquals(0, (int) causeBucket.doubleValue());
Bucket contenuBucket = findBucketsByCategory(buckets, dim, new EntityCategory(2)).get(0);
assertEquals("contenu du kit", contenuBucket.getCategory(dim).getLabel());
assertEquals(0, (int) contenuBucket.doubleValue());
}
use of org.activityinfo.shared.command.result.Bucket in project activityinfo by bedatadriven.
the class PivotSitesHandlerLocalTest method testLinkedAttributegroupFilterDataForIndicator.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void testLinkedAttributegroupFilterDataForIndicator() {
withAttributeGroupDim();
forFilterData();
Dimension dim = new Dimension(DimensionType.AttributeGroup);
// empty
filter.addRestriction(DimensionType.Indicator, 100);
execute();
assertThat().thereAre(0).buckets();
// cause, contenu du kit
filter = new Filter();
filter.addRestriction(DimensionType.Indicator, 1);
execute();
assertThat().thereAre(2).buckets();
Bucket bucket1 = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", bucket1.getCategory(dim).getLabel());
assertEquals(0, (int) bucket1.doubleValue());
Bucket bucket2 = findBucketsByCategory(buckets, dim, new EntityCategory(2)).get(0);
assertEquals("contenu du kit", bucket2.getCategory(dim).getLabel());
assertEquals(0, (int) bucket2.doubleValue());
// cause
filter = new Filter();
filter.addRestriction(DimensionType.Indicator, 2);
execute();
assertThat().thereAre(1).buckets();
bucket1 = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", bucket1.getCategory(dim).getLabel());
assertEquals(0, (int) bucket1.doubleValue());
// cause, contenu du kit
filter = new Filter();
filter.addRestriction(DimensionType.Indicator, Arrays.asList(1, 2, 100));
execute();
assertThat().thereAre(2).buckets();
bucket1 = findBucketsByCategory(buckets, dim, new EntityCategory(1)).get(0);
assertEquals("cause", bucket1.getCategory(dim).getLabel());
assertEquals(0, (int) bucket1.doubleValue());
bucket2 = findBucketsByCategory(buckets, dim, new EntityCategory(2)).get(0);
assertEquals("contenu du kit", bucket2.getCategory(dim).getLabel());
assertEquals(0, (int) bucket2.doubleValue());
}
Aggregations