ReportGenerator { String generateJsonUsageBetween(Map<String, List<UsageStatistic>> allUserStatisticsMap, String keyToCreate) { List<Map<String, String>> multiJobJsonContentsPerUserMap = new ArrayList<>(); allUserStatisticsMap.forEach((key, usageStatisticsList) -> { Map<String, String> multiJobJsonContentsPerUser = getMultiJobJsonContents(usageStatisticsList); if (multiJobJsonContentsPerUser != null) { multiJobJsonContentsPerUser.put(keyToCreate, key); multiJobJsonContentsPerUserMap.add(multiJobJsonContentsPerUser); } }); Gson gson = new Gson(); return gson.toJson(multiJobJsonContentsPerUserMap); }    }
@Test public void testGenerateAllDateJobSummaryBetween() throws Exception { reportGenerator = new ReportGenerator(); Map<String, List<UsageStatistic>> allUserStatistic = jsonExtractor.getAllDateUsageBetween("2017-01-01", "2017-01-12"); String jsonAllUserJobSummary = reportGenerator.generateJsonUsageBetween(allUserStatistic, "jobsInDate"); assertNotNull(jsonAllUserJobSummary); }
@Test public void testGenerateAllQueueJobSummaryBetween() throws Exception { reportGenerator = new ReportGenerator(); Map<String, List<UsageStatistic>> allUserStatistic = jsonExtractor.getAllQueueUsageBetween("2017-01-01", "2017-01-30"); String queue = reportGenerator.generateJsonUsageBetween(allUserStatistic, "jobsInQueue"); assertNotNull(queue); }