ReportGenerator { String generateJsonUserSingleJob(List<UsageStatistic> usageStatistics) { Gson gson = new GsonBuilder().setPrettyPrinting().create(); return gson.toJson(usageStatistics); }    }
@Test public void canGenerateSingleUserJson() throws Exception { List<UsageStatistic> usageStatistics = jsonExtractor.getSingleUserStatistic("cvop", "2017-01-20"); reportGenerator = new ReportGenerator(); assertThat(reportGenerator.generateJsonUserSingleJob(usageStatistics), equalTo("{\n" + " \"memoryUsagePrice\": \"1.78\",\n" + " \"totalFileReadingMb\": \"37,826,596\",\n" + " \"cpuUsagePrice\": \"10.33\",\n" + " \"diskUsageprice\": \"415.15\",\n" + " \"totalPrice\": \"427.26\",\n" + " \"totalFileWritingMb\": \"130,388\",\n" + " \"totalMemoryUsedMbs\": \"29,343,671,531\",\n" + " \"totalCpuTimeSpent\": \"6426:17:03\",\n" + " \"jobsProcessed\": \"1381\",\n" + " \"user\": \"cvop\",\n" + " \"totalVcoresUsed\": \"28,138,453\",\n" + " \"totalMap\": \"0\"\n" + "}")); }
@Test public void canGenerateSingleUserYearJson() throws Exception { List<UsageStatistic> usageStatistics = jsonExtractor.getSingleUserUsageInYear("cvop", "2017"); reportGenerator = new ReportGenerator(); assertThat(reportGenerator.generateJsonUserSingleJob(usageStatistics), equalTo("{\n" + " \"memoryUsagePrice\": \"3.55\",\n" + " \"totalFileReadingMb\": \"75,653,192\",\n" + " \"cpuUsagePrice\": \"20.67\",\n" + " \"diskUsageprice\": \"830.3\",\n" + " \"totalPrice\": \"854.52\",\n" + " \"totalFileWritingMb\": \"260,776\",\n" + " \"totalMemoryUsedMbs\": \"58,687,343,062\",\n" + " \"totalCpuTimeSpent\": \"12852:34:07\",\n" + " \"jobsProcessed\": \"2762\",\n" + " \"user\": \"cvop\",\n" + " \"totalVcoresUsed\": \"56,276,906\",\n" + " \"totalMap\": \"0\"\n" + "}")); }