use of org.hisp.dhis.analytics.QueryPlannerParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryAggregationTypeB.
/**
* Split on two data elements. Set aggregation type average and value type
* boolean on query. Convert aggregation type from data elements to average
* and then to average boolean.
*/
@Test
void planQueryAggregationTypeB() {
DataElement deA = createDataElement('A', ValueType.BOOLEAN, AggregationType.SUM);
DataElement deB = createDataElement('B', ValueType.BOOLEAN, AggregationType.COUNT);
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB)).withOrganisationUnits(getList(ouA)).withPeriods(getList(createPeriod("200101"))).withAggregationType(AnalyticsAggregationType.AVERAGE).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(2, queryGroups.getAllQueries().size());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertNotNull(query.getAggregationType());
assertEquals(AggregationType.AVERAGE, query.getAggregationType().getAggregationType());
assertEquals(DataType.BOOLEAN, query.getAggregationType().getDataType());
}
}
Aggregations