use of org.apache.commons.collections4.multimap.ArrayListValuedHashMap in project dhis2-core by dhis2.
the class QueryPlannerTest method testGetPermutationDimensionalItemValueMapCocDisabled.
@Test
void testGetPermutationDimensionalItemValueMapCocDisabled() {
MultiValuedMap<String, DimensionItemObjectValue> aggregatedDataMap = new ArrayListValuedHashMap<>();
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deA, 1d));
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deA, 2d));
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deA, 3d));
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deA, 4d));
aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deB, 5d));
aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deB, 6d));
aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deB, 7d));
aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deB, 8d));
Map<String, List<DimensionItemObjectValue>> permutationMap = DataQueryParams.getPermutationDimensionalItemValueMap(aggregatedDataMap);
assertNotNull(permutationMap);
String ouAM1Key = ouA.getUid() + DIMENSION_SEP + "200101";
String ouAM2Key = ouA.getUid() + DIMENSION_SEP + "200102";
String ouBM1Key = ouB.getUid() + DIMENSION_SEP + "200101";
String ouBM2Key = ouB.getUid() + DIMENSION_SEP + "200102";
List<DimensionItemObjectValue> ouAM1 = permutationMap.get(ouAM1Key);
List<DimensionItemObjectValue> ouAM2 = permutationMap.get(ouAM2Key);
List<DimensionItemObjectValue> ouBM1 = permutationMap.get(ouBM1Key);
List<DimensionItemObjectValue> ouBM2 = permutationMap.get(ouBM2Key);
assertEquals(2, ouAM1.size());
assertEquals(2, ouAM2.size());
assertEquals(2, ouBM1.size());
assertEquals(2, ouBM2.size());
List<DimensionItemObjectValue> ouAM1Expected = new ArrayList<>();
ouAM1Expected.add(new DimensionItemObjectValue(deA, 1d));
ouAM1Expected.add(new DimensionItemObjectValue(deB, 5d));
List<DimensionItemObjectValue> ouAM2Expected = new ArrayList<>();
ouAM2Expected.add(new DimensionItemObjectValue(deA, 2d));
ouAM2Expected.add(new DimensionItemObjectValue(deB, 6d));
List<DimensionItemObjectValue> ouBM1Expected = new ArrayList<>();
ouBM1Expected.add(new DimensionItemObjectValue(deA, 3d));
ouBM1Expected.add(new DimensionItemObjectValue(deB, 7d));
List<DimensionItemObjectValue> ouBM2Expected = new ArrayList<>();
ouBM2Expected.add(new DimensionItemObjectValue(deA, 4d));
ouBM2Expected.add(new DimensionItemObjectValue(deB, 8d));
assertCollectionsMatch(ouAM1Expected, ouAM1);
assertCollectionsMatch(ouAM2Expected, ouAM2);
assertCollectionsMatch(ouBM1Expected, ouBM1);
assertCollectionsMatch(ouBM2Expected, ouBM2);
}
use of org.apache.commons.collections4.multimap.ArrayListValuedHashMap in project dhis2-core by dhis2.
the class QueryPlannerTest method testGetPermutationDimensionalItemValueMap.
@Test
void testGetPermutationDimensionalItemValueMap() {
MultiValuedMap<String, DimensionItemObjectValue> aggregatedDataMap = new ArrayListValuedHashMap<>();
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q1", new DimensionItemObjectValue(deA, 1d));
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q2", new DimensionItemObjectValue(deA, 2d));
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q1", new DimensionItemObjectValue(deA, 3d));
aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q2", new DimensionItemObjectValue(deA, 4d));
aggregatedDataMap.put(makeKey(deB, coc, ouA, "2000Q1"), new DimensionItemObjectValue(deB, 5d));
aggregatedDataMap.put(makeKey(deB, coc, ouA, "2000Q2"), new DimensionItemObjectValue(deB, 6d));
aggregatedDataMap.put(makeKey(deB, coc, ouB, "2000Q1"), new DimensionItemObjectValue(deB, 7d));
aggregatedDataMap.put(makeKey(deB, coc, ouB, "2000Q2"), new DimensionItemObjectValue(deB, 8d));
Map<String, List<DimensionItemObjectValue>> permutationMap = DataQueryParams.getPermutationDimensionalItemValueMap(aggregatedDataMap);
assertNotNull(permutationMap);
String ouAQ1Key = ouA.getUid() + DIMENSION_SEP + "2000Q1";
String ouAQ2Key = ouA.getUid() + DIMENSION_SEP + "2000Q2";
String ouBQ1Key = ouB.getUid() + DIMENSION_SEP + "2000Q1";
String ouBQ2Key = ouB.getUid() + DIMENSION_SEP + "2000Q2";
List<DimensionItemObjectValue> ouAQ1 = permutationMap.get(ouAQ1Key);
List<DimensionItemObjectValue> ouAQ2 = permutationMap.get(ouAQ2Key);
List<DimensionItemObjectValue> ouBQ1 = permutationMap.get(ouBQ1Key);
List<DimensionItemObjectValue> ouBQ2 = permutationMap.get(ouBQ2Key);
assertEquals(2, ouAQ1.size());
assertEquals(2, ouAQ2.size());
assertEquals(2, ouBQ1.size());
assertEquals(2, ouBQ2.size());
List<DimensionItemObjectValue> ouAQ1Expected = new ArrayList<>();
ouAQ1Expected.add(new DimensionItemObjectValue(deA, 1d));
ouAQ1Expected.add(new DimensionItemObjectValue(deB, 5d));
List<DimensionItemObjectValue> ouAQ2Expected = new ArrayList<>();
ouAQ2Expected.add(new DimensionItemObjectValue(deA, 2d));
ouAQ2Expected.add(new DimensionItemObjectValue(deB, 6d));
List<DimensionItemObjectValue> ouBQ1Expected = new ArrayList<>();
ouBQ1Expected.add(new DimensionItemObjectValue(deA, 3d));
ouBQ1Expected.add(new DimensionItemObjectValue(deB, 7d));
List<DimensionItemObjectValue> ouBQ2Expected = new ArrayList<>();
ouBQ2Expected.add(new DimensionItemObjectValue(deA, 4d));
ouBQ2Expected.add(new DimensionItemObjectValue(deB, 8d));
assertCollectionsMatch(ouAQ1Expected, ouAQ1);
assertCollectionsMatch(ouAQ2Expected, ouAQ2);
assertCollectionsMatch(ouBQ1Expected, ouBQ1);
assertCollectionsMatch(ouBQ2Expected, ouBQ2);
}
Aggregations