@Test public void shouldRemoveCompensationDaysInOrder() { List<Holiday> holidays = this.getListOfCompensationDays(2); LocalDate hiringDate = new GregorianCalendar(2019, Calendar.JANUARY, 3).getTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); Holiday newYear2019 = new Holiday(); newYear2019.setId(6); newYear2019.setCompensation(false); newYear2019.setDate(new GregorianCalendar(2019, Calendar.JANUARY, 1).getTime()); List<Holiday> january2019 = Arrays.asList(newYear2019); doReturn(january2019).when(holidayManager).getAllEntities(any(), any()); List<Holiday> result = sut.getCorrespondingHolidays(holidays, hiringDate, 2019); assertThat(result, is(not(empty()))); assertThat(result.get(0), is(holidays.get(holidays.size()-1))); assertThat(result.size(), is(1)); }
protected List<Holiday> getCorrespondingHolidays(List<Holiday> holidays, LocalDate hiringDate, int yearOfCalculation) { List<Holiday> holidaysFromCalculationYear = holidays.stream() .filter(holiday -> parseDate(holiday.getDate()).getYear() == yearOfCalculation) .collect(Collectors.toList()); if (isHiringYearThisYear(yearOfCalculation, hiringDate)) { removeCompensationDays(holidaysFromCalculationYear, yearOfCalculation, hiringDate); } return holidaysFromCalculationYear; }
CorrespondingHolidayManager { protected List<Holiday> getCorrespondingHolidays(List<Holiday> holidays, LocalDate hiringDate, int yearOfCalculation) { List<Holiday> holidaysFromCalculationYear = holidays.stream() .filter(holiday -> parseDate(holiday.getDate()).getYear() == yearOfCalculation) .collect(Collectors.toList()); if (isHiringYearThisYear(yearOfCalculation, hiringDate)) { removeCompensationDays(holidaysFromCalculationYear, yearOfCalculation, hiringDate); } return holidaysFromCalculationYear; } }
CorrespondingHolidayManager { protected List<Holiday> getCorrespondingHolidays(List<Holiday> holidays, LocalDate hiringDate, int yearOfCalculation) { List<Holiday> holidaysFromCalculationYear = holidays.stream() .filter(holiday -> parseDate(holiday.getDate()).getYear() == yearOfCalculation) .collect(Collectors.toList()); if (isHiringYearThisYear(yearOfCalculation, hiringDate)) { removeCompensationDays(holidaysFromCalculationYear, yearOfCalculation, hiringDate); } return holidaysFromCalculationYear; } protected  CorrespondingHolidayManager(); }
CorrespondingHolidayManager { protected List<Holiday> getCorrespondingHolidays(List<Holiday> holidays, LocalDate hiringDate, int yearOfCalculation) { List<Holiday> holidaysFromCalculationYear = holidays.stream() .filter(holiday -> parseDate(holiday.getDate()).getYear() == yearOfCalculation) .collect(Collectors.toList()); if (isHiringYearThisYear(yearOfCalculation, hiringDate)) { removeCompensationDays(holidaysFromCalculationYear, yearOfCalculation, hiringDate); } return holidaysFromCalculationYear; } protected  CorrespondingHolidayManager(); static CorrespondingHolidayManager getDefault(); List<Holiday> calculateCorrespondingHolidays(Calendar calMin, Calendar calMax, List<Holiday> allHolidays,
			Date hiringDate); }
CorrespondingHolidayManager { protected List<Holiday> getCorrespondingHolidays(List<Holiday> holidays, LocalDate hiringDate, int yearOfCalculation) { List<Holiday> holidaysFromCalculationYear = holidays.stream() .filter(holiday -> parseDate(holiday.getDate()).getYear() == yearOfCalculation) .collect(Collectors.toList()); if (isHiringYearThisYear(yearOfCalculation, hiringDate)) { removeCompensationDays(holidaysFromCalculationYear, yearOfCalculation, hiringDate); } return holidaysFromCalculationYear; } protected  CorrespondingHolidayManager(); static CorrespondingHolidayManager getDefault(); List<Holiday> calculateCorrespondingHolidays(Calendar calMin, Calendar calMax, List<Holiday> allHolidays,
			Date hiringDate);  }