Search in sources :

Example 46 with Dimension

use of org.activityinfo.shared.report.model.Dimension 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());
}
Also used : Bucket(org.activityinfo.shared.command.result.Bucket) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

Dimension (org.activityinfo.shared.report.model.Dimension)46 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)31 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)29 DateDimension (org.activityinfo.shared.report.model.DateDimension)28 Test (org.junit.Test)23 Bucket (org.activityinfo.shared.command.result.Bucket)11 OnDataSet (org.activityinfo.server.database.OnDataSet)10 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)10 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)9 ArrayList (java.util.ArrayList)6 PivotSites (org.activityinfo.shared.command.PivotSites)6 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)4 Comparator (java.util.Comparator)3 DispatcherSync (org.activityinfo.server.command.DispatcherSync)3 User (org.activityinfo.server.database.hibernate.entity.User)3 DimensionCategory (org.activityinfo.shared.report.content.DimensionCategory)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 JsonObject (com.google.gson.JsonObject)2 List (java.util.List)2 ReportChangeEvent (org.activityinfo.client.page.report.ReportChangeEvent)2