private Map<String, Integer> calcToCountMap(CalcResult result) { // the result is a map going from list of grouping attributes to value Map<List<String>, Integer> map = result.toMap(); return map.entrySet() .stream() .collect(Collectors.toMap(x -> x.getKey().get(0), x -> x.getValue())); }
/** Helper method the checks if the calculation result contains the expected result. */ private void checkResults(CalcResult calcResult, Object[][] expectedResults) { assertThat(calcResult, notNullValue()); // check that the array conversion looks sane Object[] results = calcResult.toArray(); assertThat(results.length, is(expectedResults.length)); // check that map conversion looks sane Map resultMap = calcResult.toMap(); assertThat(resultMap.entrySet().size(), is(expectedResults.length)); // check that the obtained values correspond to the expected ones for (Object[] expectedResult : expectedResults) { assertThat(contains(results, expectedResult), is(true)); } }
groupByVisitors .stream() .map(visitor -> (Map<List<Object>, Object>) visitor.getResult().toMap()) .collect(Collectors.toList()); return new Results(