@Test public void shouldCheckFirstDaysOfJanuaryForHolidays() { LocalDate hiringDate = new GregorianCalendar(2019, Calendar.JANUARY, 10).getTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); Holiday newYear2019 = new Holiday(); newYear2019.setId(2); newYear2019.setCompensation(false); newYear2019.setDate(new GregorianCalendar(2019, Calendar.JANUARY, 1).getTime()); List<Holiday> january2019 = Arrays.asList(newYear2019); Date januaryMin = new GregorianCalendar(2019, Calendar.JANUARY, 01, 0, 0).getTime(); Date januaryMax = new GregorianCalendar(2019, Calendar.JANUARY, 31, 23, 59).getTime(); HolidaySearch holidaySearch = new HolidaySearch(); holidaySearch.setStartDate(januaryMin); holidaySearch.setEndDate(januaryMax); List<Holiday> result = sut.getCorrespondingHolidays(january2019, hiringDate, 2019); verify(holidayManager).getAllEntities(holidaySearch, null); }
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);  }