use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class AnalyticsUtilsTest method testGetByDataDimensionType.
@Test
void testGetByDataDimensionType() {
Program prA = createProgram('A');
DataElement deA = createDataElement('A', new CategoryCombo());
DataElement deB = createDataElement('B', new CategoryCombo());
ProgramDataElementDimensionItem pdeA = new ProgramDataElementDimensionItem(prA, deA);
ProgramDataElementDimensionItem pdeB = new ProgramDataElementDimensionItem(prA, deB);
ProgramIndicator piA = createProgramIndicator('A', prA, null, null);
List<DimensionalItemObject> list = Lists.newArrayList(deA, deB, pdeA, pdeB, piA);
assertEquals(Lists.newArrayList(deA, deB), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.DATA_ELEMENT, list));
assertEquals(Lists.newArrayList(pdeA, pdeB), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.PROGRAM_DATA_ELEMENT, list));
assertEquals(Lists.newArrayList(piA), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.PROGRAM_INDICATOR, list));
assertEquals(Lists.newArrayList(), AnalyticsUtils.getByDataDimensionItemType(DataDimensionItemType.PROGRAM_ATTRIBUTE, list));
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class AnalyticsUtilsTest method testGetDimensionalItemObjectMap.
@Test
void testGetDimensionalItemObjectMap() {
DataElement deA = createDataElement('A');
Indicator inA = createIndicator('A', null);
DataSet dsA = createDataSet('A');
DimensionalObject dx = new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, DimensionalObjectUtils.getList(deA, inA, dsA));
DataQueryParams params = DataQueryParams.newBuilder().addDimension(dx).withDisplayProperty(DisplayProperty.NAME).build();
Map<String, DimensionalItemObject> map = AnalyticsUtils.getDimensionalItemObjectMap(params);
assertEquals(map.get(deA.getDimensionItem()), deA);
assertEquals(map.get(inA.getDimensionItem()), inA);
assertEquals(map.get(dsA.getDimensionItem()), dsA);
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class ReportRatesHelperTest method testGetCalculatedTargetWhenDataSetIsDailyAndHasPeriodInFilter.
@Test
void testGetCalculatedTargetWhenDataSetIsDailyAndHasPeriodInFilter() {
// Given
final Double theTarget = 10d;
final List<DimensionalItemObject> theFilterPeriods = asList(stubPeriod());
final PeriodType theDailyPeriodType = DailyPeriodType.getByNameIgnoreCase("Daily");
final int anyNegativePeriodInDimensionIndex = -1;
final int anyTimeUnits = 1;
final List<String> anyDataRow = asList("TuL8IOPzpHh");
final PeriodType aDataSetDailyPeriodType = DailyPeriodType.getByNameIgnoreCase("Daily");
// When
final Double actualResult = getCalculatedTarget(anyNegativePeriodInDimensionIndex, anyTimeUnits, anyDataRow, theTarget, theDailyPeriodType, aDataSetDailyPeriodType, theFilterPeriods);
// Then
assertThat(actualResult, is(10.0d));
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class ReportRatesHelperTest method testGetCalculatedTargetWhenDataSetIsDailyAndHasPeriodInFilterAndMultiplePeriods.
@Test
void testGetCalculatedTargetWhenDataSetIsDailyAndHasPeriodInFilterAndMultiplePeriods() {
// Given
final Double theTarget = 10d;
final List<DimensionalItemObject> multipleFilterPeriods = asList(stubPeriod(), stubPeriod(), stubPeriod());
final PeriodType theDailyPeriodType = DailyPeriodType.getByNameIgnoreCase("Daily");
final int anyNegativePeriodInDimensionIndex = -1;
final int anyTimeUnits = 2;
final List<String> anyDataRow = asList("TuL8IOPzpHh");
final PeriodType aDataSetDailyPeriodType = DailyPeriodType.getByNameIgnoreCase("Daily");
// When
final Double actualResult = getCalculatedTarget(anyNegativePeriodInDimensionIndex, anyTimeUnits, anyDataRow, theTarget, theDailyPeriodType, aDataSetDailyPeriodType, multipleFilterPeriods);
// Then
assertThat(actualResult, is(60.0d));
}
use of org.hisp.dhis.common.DimensionalItemObject in project dhis2-core by dhis2.
the class ReportRatesHelperTest method testGetCalculatedTargetWhenDataSetIsDailyAndHasPeriodInDimension.
@Test
void testGetCalculatedTargetWhenDataSetIsDailyAndHasPeriodInDimension() {
// Given
final Double theTarget = 10d;
final List<DimensionalItemObject> theFilterPeriods = asList(stubPeriod());
final PeriodType theDailyPeriodType = DailyPeriodType.getByNameIgnoreCase("Daily");
// Relates to "aDailyDataPeriodRow" objects
final int anyPositivePeriodInDimensionIndex = 1;
final List<String> aDailyDataPeriodRow = asList("TuL8IOPzpHh", "20210415");
final int anyTimeUnits = 2;
final PeriodType aDataSetDailyPeriodType = DailyPeriodType.getByNameIgnoreCase("Daily");
// When
final Double actualResult = getCalculatedTarget(anyPositivePeriodInDimensionIndex, anyTimeUnits, aDailyDataPeriodRow, theTarget, theDailyPeriodType, aDataSetDailyPeriodType, theFilterPeriods);
// Then
assertThat(actualResult, is(20.0d));
}
Aggregations