use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class EventQueryParamsTest method testIsOrgUnitFieldValidWithOneProgramIndicator.
@Test
void testIsOrgUnitFieldValidWithOneProgramIndicator() {
QueryItem iA = new QueryItem(createDataElement('A', new CategoryCombo()));
ProgramIndicator programIndicatorA = createProgramIndicator('A', prA, "", "");
EventQueryParams params = new EventQueryParams.Builder().withProgram(null).withOrgUnitField(deD.getUid()).addItem(iA).addItemProgramIndicator(programIndicatorA).build();
assertTrue(params.orgUnitFieldIsValid());
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class EventQueryParamsTest method testIsTimeFieldValid.
@Test
void testIsTimeFieldValid() {
QueryItem iA = new QueryItem(createDataElement('A', new CategoryCombo()));
EventQueryParams params = new EventQueryParams.Builder().withProgram(prA).withTimeField(deC.getUid()).addItem(iA).build();
assertTrue(params.timeFieldIsValid());
params = new EventQueryParams.Builder().withProgram(prA).withTimeField(TimeField.SCHEDULED_DATE.name()).addItem(iA).build();
assertTrue(params.timeFieldIsValid());
params = new EventQueryParams.Builder().withProgram(prA).withTimeField("someInvalidTimeField").addItem(iA).build();
assertFalse(params.timeFieldIsValid());
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class QueryPlannerGroupByAggregationTypeTest method verifyMultipleDataElementAsFilterHavingDifferentDataTypeDoNotRetainAggregationType.
@Test
void verifyMultipleDataElementAsFilterHavingDifferentDataTypeDoNotRetainAggregationType() {
// DataQueryParams with **two** DataElement as filter
// One Data Element has Type Numeric
// Aggregation type is overridden (COUNT)
DataQueryParams queryParams = createDataQueryParamsWithAggregationType(new BaseDimensionalObject("dx", DimensionType.DATA_X, DISPLAY_NAME_DATA_X, "display name", Lists.newArrayList(createDataElement('A', new CategoryCombo()), createDataElement('B', ValueType.TEXT, AggregationType.COUNT))), AnalyticsAggregationType.COUNT);
DataQueryGroups dataQueryGroups = subject.planQuery(queryParams, QueryPlannerParams.newBuilder().withTableType(AnalyticsTableType.DATA_VALUE).build());
assertThat(dataQueryGroups.getAllQueries(), hasSize(1));
DataQueryParams dataQueryParam = dataQueryGroups.getAllQueries().get(0);
// Aggregation type defaults to SUM
assertDefaultAggregationType(dataQueryParam);
assertThat(dataQueryParam.getAggregationType().getDataType(), is(nullValue()));
assertThat(dataQueryParam.getPeriods(), hasSize(1));
assertThat(dataQueryParam.getFilterDataElements(), hasSize(2));
assertThat(dataQueryParam.getFilterOrganisationUnits(), hasSize(1));
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class QueryPlannerGroupByAggregationTypeTest method verifyMultipleDataElementAsFilterRetainAggregationTypeAndAggregationDataType.
@Test
void verifyMultipleDataElementAsFilterRetainAggregationTypeAndAggregationDataType() {
// DataQueryParams with **two** DataElement as filter
// Both have DataType NUMERIC and AggregationType SUM
DataQueryParams queryParams = createDataQueryParams(new BaseDimensionalObject("dx", DimensionType.DATA_X, DISPLAY_NAME_DATA_X, "display name", Lists.newArrayList(createDataElement('A', new CategoryCombo()), createDataElement('B', new CategoryCombo()))));
DataQueryGroups dataQueryGroups = subject.planQuery(queryParams, QueryPlannerParams.newBuilder().withTableType(AnalyticsTableType.DATA_VALUE).build());
assertThat(dataQueryGroups.getAllQueries(), hasSize(1));
DataQueryParams dataQueryParam = dataQueryGroups.getAllQueries().get(0);
assertTrue(dataQueryParam.getAggregationType().isAggregationType(AggregationType.SUM));
assertThat(dataQueryParam.getAggregationType().getDataType(), is(DataType.NUMERIC));
assertThat(dataQueryParam.getPeriods(), hasSize(1));
assertThat(dataQueryParam.getFilterDataElements(), hasSize(2));
assertThat(dataQueryParam.getFilterOrganisationUnits(), hasSize(1));
}
use of org.hisp.dhis.category.CategoryCombo in project dhis2-core by dhis2.
the class QueryPlannerGroupByAggregationTypeTest method verifyMultipleDataElementAsFilterHavingDifferentAggTypeDoNotRetainAggregationType.
@Test
void verifyMultipleDataElementAsFilterHavingDifferentAggTypeDoNotRetainAggregationType() {
// DataQueryParams with **two** DataElement as filter
// Both have DataType NUMERIC but different AggregationType
DataQueryParams queryParams = createDataQueryParams(new BaseDimensionalObject("dx", DimensionType.DATA_X, DISPLAY_NAME_DATA_X, "display name", Lists.newArrayList(createDataElement('A', new CategoryCombo()), createDataElement('B', ValueType.INTEGER, AggregationType.COUNT))));
DataQueryGroups dataQueryGroups = subject.planQuery(queryParams, QueryPlannerParams.newBuilder().withTableType(AnalyticsTableType.DATA_VALUE).build());
assertThat(dataQueryGroups.getAllQueries(), hasSize(1));
DataQueryParams dataQueryParam = dataQueryGroups.getAllQueries().get(0);
// Aggregation type defaults to SUM
assertDefaultAggregationType(dataQueryParam);
assertThat(dataQueryParam.getAggregationType().getDataType(), is(nullValue()));
assertThat(dataQueryParam.getPeriods(), hasSize(1));
assertThat(dataQueryParam.getFilterDataElements(), hasSize(2));
assertThat(dataQueryParam.getFilterOrganisationUnits(), hasSize(1));
}
Aggregations