@Test public void test_filterDateAndGroup_monthly() { final Map<LocalDate, List<LocalDate>> group = UsageDataManager.filterDateAndGroup(dateList, now, Freq.monthly); Assert.assertEquals(5, group.size()); testLeftGroup(group); }
static Map<LocalDate, List<LocalDate>> filterDateAndGroup(final List<String> dateList, final LocalDate current, final Freq fileFrequency) { return dateList.stream() .map(s -> LocalDate.parse(s)) .filter(d -> !d.withDayOfMonth(1).equals(current.withDayOfMonth(1))) .collect(Collectors.groupingBy(d -> { switch (fileFrequency) { case weekly: return d.with(ChronoField.DAY_OF_WEEK, 1); case monthly: return d.withDayOfMonth(1); case yearly: return d.withDayOfYear(1); default: } return d; })); }
UsageDataManager { static Map<LocalDate, List<LocalDate>> filterDateAndGroup(final List<String> dateList, final LocalDate current, final Freq fileFrequency) { return dateList.stream() .map(s -> LocalDate.parse(s)) .filter(d -> !d.withDayOfMonth(1).equals(current.withDayOfMonth(1))) .collect(Collectors.groupingBy(d -> { switch (fileFrequency) { case weekly: return d.with(ChronoField.DAY_OF_WEEK, 1); case monthly: return d.withDayOfMonth(1); case yearly: return d.withDayOfYear(1); default: } return d; })); } }
UsageDataManager { static Map<LocalDate, List<LocalDate>> filterDateAndGroup(final List<String> dateList, final LocalDate current, final Freq fileFrequency) { return dateList.stream() .map(s -> LocalDate.parse(s)) .filter(d -> !d.withDayOfMonth(1).equals(current.withDayOfMonth(1))) .collect(Collectors.groupingBy(d -> { switch (fileFrequency) { case weekly: return d.with(ChronoField.DAY_OF_WEEK, 1); case monthly: return d.withDayOfMonth(1); case yearly: return d.withDayOfYear(1); default: } return d; })); } private  UsageDataManager(); }
UsageDataManager { static Map<LocalDate, List<LocalDate>> filterDateAndGroup(final List<String> dateList, final LocalDate current, final Freq fileFrequency) { return dateList.stream() .map(s -> LocalDate.parse(s)) .filter(d -> !d.withDayOfMonth(1).equals(current.withDayOfMonth(1))) .collect(Collectors.groupingBy(d -> { switch (fileFrequency) { case weekly: return d.with(ChronoField.DAY_OF_WEEK, 1); case monthly: return d.withDayOfMonth(1); case yearly: return d.withDayOfYear(1); default: } return d; })); } private  UsageDataManager(); static UsageDataManager get(); JSONObject collect(final Map<String, Object> parameters); Path getUsageRepositoryPath(); String getAutoRefreshInterval(); List<File> getCollectorFiles(); List<String> getDateOfCollectorFiles(); void saveToRepository(); }
UsageDataManager { static Map<LocalDate, List<LocalDate>> filterDateAndGroup(final List<String> dateList, final LocalDate current, final Freq fileFrequency) { return dateList.stream() .map(s -> LocalDate.parse(s)) .filter(d -> !d.withDayOfMonth(1).equals(current.withDayOfMonth(1))) .collect(Collectors.groupingBy(d -> { switch (fileFrequency) { case weekly: return d.with(ChronoField.DAY_OF_WEEK, 1); case monthly: return d.withDayOfMonth(1); case yearly: return d.withDayOfYear(1); default: } return d; })); } private  UsageDataManager(); static UsageDataManager get(); JSONObject collect(final Map<String, Object> parameters); Path getUsageRepositoryPath(); String getAutoRefreshInterval(); List<File> getCollectorFiles(); List<String> getDateOfCollectorFiles(); void saveToRepository();  }