JSONExtractor { public Map<String, List<UsageStatistic>> getAllUserUsageStatistic(String date) throws IOException, DatabaseFileNotFoundException { List<UsageStatistic> allStatistics = loadStatisticOf(date); ConcurrentHashMap<String, List<UsageStatistic>> groupUserUsageStatistic = new ConcurrentHashMap<>(); allStatistics.forEach(p -> { String user = p.getUser(); groupUserUsageStatistic.computeIfAbsent(user, userName -> { List<UsageStatistic> singleUserStatistic; try { singleUserStatistic = getSingleUserStatistic(userName, date); } catch (IOException exception) { throw new UncheckedIOException(exception); } return singleUserStatistic; }); }); return groupUserUsageStatistic; }  List<UsageStatistic> loadStatisticOf(String date); Map<String, List<UsageStatistic>> getAllUserUsageStatistic(String date); List<UsageStatistic> getUsageStatisticsSince(String startDate); Map<String, List<UsageStatistic>> getAllUserUsageBetween(String startDate, String endDate); Map<String, List<UsageStatistic>> getAllDateUsageBetween(String startDate, String endDate); Map<String, List<UsageStatistic>> getAllQueueUsageBetween(String startDate, String endDate); UsageStatistic getSingleStatistic(String jobId, String date); List<UsageStatistic> getSingleUserStatistic(String userName, String date); List<UsageStatistic> getSingleUserUsageBetween(String user, String startDate, String endDate); List<UsageStatistic> getSingleUserUsageInYear(String user, String year); List<UsageStatistic> getSingleUserUsageInYearMonth(String user, String year, String month); List<UsageStatistic> getSingleUserUsageYearMonthDay(String user, String year, String month,
                                                               String day);  }
@Test public void testSummaryOfAllUsers() throws Exception { Map<String, List<UsageStatistic>> allUserStatistic = jsonExtractor.getAllUserUsageStatistic("2017-01-10"); Set<String> keySet = allUserStatistic.keySet(); assertEquals(keySet.size(), 12); }