ReportingService { @GET @Path("{user}") @Produces(MediaType.APPLICATION_JSON) public String getAllJobReportsForUser(@PathParam("user") String user) { try { List<UsageStatistic> singleUserStatistics = jsonExtractor.getSingleUserStatistic(user, "2017-01-20"); Gson gson = new GsonBuilder().setPrettyPrinting().create(); return gson.toJson(singleUserStatistics); } catch (IOException | 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 canGetAllJobReportsForUser() { String userJobStatistics = reportingService.getAllJobReportsForUser("user1"); assertThat(userJobStatistics, equalTo("[\n" + " {\n" + " \"jobId\": \"job_1484837520075_13157\",\n" + " \"user\": \"user1\",\n" + " \"queue\": \"test\",\n" + " \"submitTime\": 0,\n" + " \"startTime\": 1486371600000,\n" + " \"finishTime\": 1486061314131,\n" + " \"state\": \"SUCCEEDED\",\n" + " \"jobName\": \"S3 tar-to-zip 2017-02-02\",\n" + " \"processType\": \"tar2zip\",\n" + " \"inputPath\": \"hdfs: " \"mapsCompleted\": 1,\n" + " \"totalMaps\": 1,\n" + " \"reducesCompleted\": 0,\n" + " \"fileBytesRead\": 0,\n" + " \"inputFileBytesRead\": 0,\n" + " \"fileSplitBytesRead\": 0,\n" + " \"fileBytesWritten\": 265778,\n" + " \"hdfsBytesRead\": 703253073,\n" + " \"hdfsBytesWritten\": 701246583,\n" + " \"mbMillisMapTotal\": 80919552,\n" + " \"mbMillisReduceTotal\": 0,\n" + " \"vCoresMillisTotal\": 79023,\n" + " \"cpuMilliseconds\": 51550\n" + " },\n" + " {\n" + " \"jobId\": \"job_1484837520075_13158\",\n" + " \"user\": \"user1\",\n" + " \"queue\": \"test\",\n" + " \"submitTime\": 0,\n" + " \"startTime\": 1486425600000,\n" + " \"finishTime\": 1486458000000,\n" + " \"state\": \"SUCCEEDED\",\n" + " \"jobName\": \"S3 tar-to-zip 2017-02-02\",\n" + " \"processType\": \"tar2zip\",\n" + " \"inputPath\": \"hdfs: " \"mapsCompleted\": 1,\n" + " \"totalMaps\": 1,\n" + " \"reducesCompleted\": 0,\n" + " \"fileBytesRead\": 0,\n" + " \"inputFileBytesRead\": 0,\n" + " \"fileSplitBytesRead\": 0,\n" + " \"fileBytesWritten\": 265778,\n" + " \"hdfsBytesRead\": 703253073,\n" + " \"hdfsBytesWritten\": 701246583,\n" + " \"mbMillisMapTotal\": 80919552,\n" + " \"mbMillisReduceTotal\": 0,\n" + " \"vCoresMillisTotal\": 79023,\n" + " \"cpuMilliseconds\": 51550\n" + " }\n" + "]")); }