use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class QueryPlannerTest method assertQueryMods.
private void assertQueryMods(List<DataQueryParams> group, QueryModifiers mods, DataElement... elements) {
List<DataElement> modElements = Arrays.asList(elements);
for (DataQueryParams params : group) {
List<DimensionalItemObject> groupElements = params.getDataElements();
assertNotEquals(0, groupElements.size());
QueryModifiers groupMods = groupElements.get(0).getQueryMods();
if (Objects.equals(mods, groupMods)) {
assertTrue(Objects.equals(params.getStartDate(), mods == null ? null : mods.getMinDate()));
assertTrue(Objects.equals(params.getEndDate(), mods == null ? null : mods.getMaxDate()));
assertEquals(modElements.size(), groupElements.size());
assertTrue(groupElements.containsAll(modElements));
groupElements.forEach(e -> {
assertEquals(mods, e.getQueryMods());
});
return;
}
}
throw new RuntimeException("No group found for queryMods " + mods);
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class QueryPlannerTest method samePeriodType.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private static boolean samePeriodType(List<DimensionalItemObject> isoPeriods) {
Iterator<DimensionalItemObject> periods = new ArrayList<>(isoPeriods).iterator();
PeriodType first = ((Period) periods.next()).getPeriodType();
while (periods.hasNext()) {
PeriodType next = ((Period) periods.next()).getPeriodType();
if (!first.equals(next)) {
return false;
}
}
return true;
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class AbstractJdbcEventAnalyticsManagerTest method verifyGetSelectSqlWithNonTextDataElement.
@Test
void verifyGetSelectSqlWithNonTextDataElement() {
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.NUMBER);
String column = subject.getSelectSql(new QueryFilter(), item, from, to);
assertThat(column, is("ax.\"" + dataElementA.getUid() + "\""));
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class AbstractJdbcEventAnalyticsManagerTest method verifyGetAggregateClauseWithValueFails.
@Test
void verifyGetAggregateClauseWithValueFails() {
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
EventQueryParams params = new EventQueryParams.Builder(createRequestParams()).withValue(dio).withAggregationType(fromAggregationType(AggregationType.CUSTOM)).build();
assertThrows(IllegalArgumentException.class, () -> subject.getAggregateClause(params));
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class AbstractJdbcEventAnalyticsManagerTest method verifyGetSelectSqlWithTextDataElement.
@Test
void verifyGetSelectSqlWithTextDataElement() {
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.TEXT);
QueryFilter queryFilter = new QueryFilter(QueryOperator.EQ, "EQ");
String column = subject.getSelectSql(queryFilter, item, from, to);
assertThat(column, is("ax.\"" + dataElementA.getUid() + "\""));
}
Aggregations