JSONExtractor { public List<UsageStatistic> loadStatisticOf(String date) throws IOException, DatabaseFileNotFoundException { String[] fileList = Paths.get(databaseFolderPath).toFile().list(); if (fileList != null) { Predicate<String> filterFileLogBtwDate = filterFileLogBtwDate(date); Optional<String> fileNameOptional = Arrays.stream(fileList).filter(filterFileLogBtwDate).findFirst(); String fileName = fileNameOptional.orElse(""); String fullPathToLogFile = Paths.get(databaseFolderPath).resolve(fileName).toString(); return getAllStatistics(fullPathToLogFile); } else { throw new DatabaseFileNotFoundException("Database path '" + databaseFolderPath + "' is empty."); } }  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 canExtractAll() throws Exception { List<UsageStatistic> allStatistics = jsonExtractor.loadStatisticOf("2017-01-10"); assertThat(allStatistics.size(), equalTo(3549)); assertThat(allStatistics.get(0).getJobId(), equalTo("job_1481485063251_15808")); assertThat(allStatistics.get(0).getUser(), equalTo("martin")); assertThat(allStatistics.get(1).getJobId(), equalTo("job_1481485063251_15809")); assertThat(allStatistics.get(1).getUser(), equalTo("martin")); assertThat(allStatistics.get(2).getJobId(), equalTo("job_1481485063251_16187")); assertThat(allStatistics.get(2).getUser(), equalTo("martin")); assertThat(allStatistics.get(3).getJobId(), equalTo("job_1481485063251_16801")); assertThat(allStatistics.get(3).getUser(), equalTo("martin")); }