Search in sources :

Example 31 with DataQueryGroups

use of org.hisp.dhis.analytics.DataQueryGroups in project dhis2-core by dhis2.

the class QueryPlannerGroupByAggregationTypeTest method verifySingleNonDataElementRetainAggregationTypeButNullDataType.

@Test
void verifySingleNonDataElementRetainAggregationTypeButNullDataType() {
    List<DimensionalItemObject> periods = new ArrayList<>();
    periods.add(new MonthlyPeriodType().createPeriod(new DateTime(2014, 4, 1, 0, 0).toDate()));
    // DataQueryParams with **one** Indicator
    DataQueryParams queryParams = DataQueryParams.newBuilder().withDimensions(// PERIOD DIMENSION
    Lists.newArrayList(new BaseDimensionalObject("pe", DimensionType.PERIOD, periods), new BaseDimensionalObject("dx", DimensionType.DATA_X, DISPLAY_NAME_DATA_X, "display name", Lists.newArrayList(createIndicator('A', createIndicatorType('A')))))).withFilters(Lists.newArrayList(// OU FILTER
    new BaseDimensionalObject("ou", DimensionType.ORGANISATION_UNIT, null, DISPLAY_NAME_ORGUNIT, ImmutableList.of(new OrganisationUnit("bbb", "bbb", "OU_2", null, null, "c2"))))).withAggregationType(AnalyticsAggregationType.AVERAGE).build();
    DataQueryGroups dataQueryGroups = subject.planQuery(queryParams, QueryPlannerParams.newBuilder().withTableType(AnalyticsTableType.DATA_VALUE).build());
    assertThat(dataQueryGroups.getAllQueries(), hasSize(1));
    assertThat(dataQueryGroups.getAllQueries(), hasItem(both(hasProperty("aggregationType", hasProperty("aggregationType", is(AggregationType.AVERAGE)))).and(hasProperty("aggregationType", hasProperty("dataType", is(nullValue()))))));
}
Also used : DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) ArrayList(java.util.ArrayList) DataQueryGroups(org.hisp.dhis.analytics.DataQueryGroups) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test)

Aggregations

DataQueryGroups (org.hisp.dhis.analytics.DataQueryGroups)31 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)31 Test (org.junit.jupiter.api.Test)25 QueryPlannerParams (org.hisp.dhis.analytics.QueryPlannerParams)24 DhisSpringTest (org.hisp.dhis.DhisSpringTest)20 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)11 Function (java.util.function.Function)5 CategoryCombo (org.hisp.dhis.category.CategoryCombo)5 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)5 DimensionalObject (org.hisp.dhis.common.DimensionalObject)5 ArrayList (java.util.ArrayList)4 DataElement (org.hisp.dhis.dataelement.DataElement)3 HashMap (java.util.HashMap)2 QueryModifiers (org.hisp.dhis.common.QueryModifiers)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)2 PeriodType.getPeriodTypeFromIsoString (org.hisp.dhis.period.PeriodType.getPeriodTypeFromIsoString)2 Timer (org.hisp.dhis.util.Timer)2 DateTime (org.joda.time.DateTime)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1