ReportingService { @GET @Path("/all/users") @Produces(MediaType.APPLICATION_JSON) public String getUserAggregatedJobReports() { try { Map<String, List<UsageStatistic>> allUserStatistics = jsonExtractor.getAllUserUsageStatistic("2017-01-01"); if (allUserStatistics.size() < 1) { throw new JobNotFoundException("No job found for any users"); } return reportGenerator.generateJsonAllUserJobSummary(allUserStatistics); } catch (IOException | JobNotFoundException |DatabaseFileNotFoundException exception) { return getErrorResponse(exception); } } ReportingService(); @GET @Path("job/{jobId}/{date}") @Produces(MediaType.APPLICATION_JSON) String getSingleJobReport(@PathParam("jobId") String jobId, @PathParam("date") String date); @GET @Path("{user}") @Produces(MediaType.APPLICATION_JSON) String getAllJobReportsForUser(@PathParam("user") String user); @GET @Path("/all/users") @Produces(MediaType.APPLICATION_JSON) String getUserAggregatedJobReports(); @GET @Path("{user}/time/{year}") @Produces(MediaType.APPLICATION_JSON) String getYearlyJobReportTxt(@PathParam("user") String user, @PathParam("year") String year); @GET @Path("{user}/time/{year}/{month}") @Produces(MediaType.APPLICATION_JSON) String getMonthlyJobReportTxt(@PathParam("user") String user,
                                         @PathParam("year") String year,
                                         @PathParam("month") String month); @GET @Path("{user}/time/{year}/{month}/{day}") @Produces(MediaType.APPLICATION_JSON) String getMonthlyJobReportTxt(@PathParam("user") String user,
                                         @PathParam("year") String year,
                                         @PathParam("month") String month,
                                         @PathParam("day") String day); @GET @Path("{user}/range/{date_start}/{date_end}") @Produces(MediaType.APPLICATION_JSON) String getTimeSpecificJobReportTxt(@PathParam("user") String user,
                                              @PathParam("date_start") String start,
                                              @PathParam("date_end") String end); @GET @Path("/range-user/{date_start}/{date_end}") @Produces(MediaType.APPLICATION_JSON) String getRangeUserBetween(@PathParam("date_start") String start, @PathParam("date_end") String end); @GET @Path("/range-date/{date_start}/{date_end}") @Produces(MediaType.APPLICATION_JSON) String getRangeDateBetween(@PathParam("date_start") String start, @PathParam("date_end") String end); @GET @Path("/range-queue/{date_start}/{date_end}") @Produces(MediaType.APPLICATION_JSON) String getRangeQueueBetween(@PathParam("date_start") String start, @PathParam("date_end") String end); @GET @Path("/date/{date_start}") @Produces(MediaType.APPLICATION_JSON) String getFromDate(@PathParam("date_start") String startDate);  }
@Test public void canGetUserAggregatedJobReports() { String userAggregatedStatistics = reportingService.getUserAggregatedJobReports(); assertThat(userAggregatedStatistics, equalTo("[\n" + " {\n" + " \"memoryUsagePrice\": \"9.787222222222221E-6\",\n" + " \"totalFileReadingMb\": \"1,340\",\n" + " \"cpuUsagePrice\": \"0.0\",\n" + " \"diskUsageprice\": \"0.0224\",\n" + " \"totalPrice\": \"0.022409787222222224\",\n" + " \"totalFileWritingMb\": \"1,338\",\n" + " \"totalMemoryUsedMbs\": \"161,838\",\n" + " \"totalCpuTimeSpent\": \"00:01:43\",\n" + " \"jobsProcessed\": \"2\",\n" + " \"user\": \"user1\",\n" + " \"totalVcoresUsed\": \"158\",\n" + " \"totalMap\": \"2\"\n" + " },\n" + " {\n" + " \"memoryUsagePrice\": \"4.875027777777778E-5\",\n" + " \"totalFileReadingMb\": \"0\",\n" + " \"cpuUsagePrice\": \"0.0\",\n" + " \"diskUsageprice\": \"0.0\",\n" + " \"totalPrice\": \"4.875027777777778E-5\",\n" + " \"totalFileWritingMb\": \"8\",\n" + " \"totalMemoryUsedMbs\": \"806,758\",\n" + " \"totalCpuTimeSpent\": \"00:00:06\",\n" + " \"jobsProcessed\": \"2\",\n" + " \"user\": \"martin\",\n" + " \"totalVcoresUsed\": \"0\",\n" + " \"totalMap\": \"0\"\n" + " },\n" + " {\n" + " \"memoryUsagePrice\": \"1.265525E-4\",\n" + " \"totalFileReadingMb\": \"4,267\",\n" + " \"cpuUsagePrice\": \"0.0\",\n" + " \"diskUsageprice\": \"0.056\",\n" + " \"totalPrice\": \"0.0561265525\",\n" + " \"totalFileWritingMb\": \"994\",\n" + " \"totalMemoryUsedMbs\": \"2,092,547\",\n" + " \"totalCpuTimeSpent\": \"00:13:44\",\n" + " \"jobsProcessed\": \"9\",\n" + " \"user\": \"cvop\",\n" + " \"totalVcoresUsed\": \"1,011\",\n" + " \"totalMap\": \"9\"\n" + " }\n" + "]")); }