Skip to content

Commit

Permalink
austria: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
derTobsch committed Dec 11, 2024
1 parent b5b6942 commit 963c578
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ public static void assertIslamic(final HolidayCalendar calendar, final Year from


public static void assertFixed(final HolidayCalendar calendar, final Month month, final int day, final String propertiesKey) {
checkByDate(calendar, YEAR_FROM_DEFAULT, YEAR_TO_DEFAULT, month, day, propertiesKey, PUBLIC_HOLIDAY);
checkByDate(calendar, "", YEAR_FROM_DEFAULT, YEAR_TO_DEFAULT, month, day, propertiesKey, PUBLIC_HOLIDAY);
}
public static void assertFixed(final HolidayCalendar calendar, final String hierarchy, final Month month, final int day, final String propertiesKey) {
checkByDate(calendar, hierarchy, YEAR_FROM_DEFAULT, YEAR_TO_DEFAULT, month, day, propertiesKey, PUBLIC_HOLIDAY);
}
public static void assertFixed(final HolidayCalendar calendar, final Month month, final int day, final String propertiesKey, final HolidayType holidayType) {
checkByDate(calendar, "", YEAR_FROM_DEFAULT, YEAR_TO_DEFAULT, month, day, propertiesKey, holidayType);
}
public static void assertFixed(final HolidayCalendar calendar, final Year from, final Year to, final Month month, final int day, final String propertiesKey) {
checkByDate(calendar, from, to, month, day, propertiesKey, PUBLIC_HOLIDAY);
checkByDate(calendar, "", from, to, month, day, propertiesKey, PUBLIC_HOLIDAY);
}
public static void assertFixed(final HolidayCalendar calendar, final Year from, final Year to , final Month month, final int day, final String propertiesKey, final HolidayType holidayType) {
checkByDate(calendar, from, to, month, day, propertiesKey, holidayType);
checkByDate(calendar, "", from, to, month, day, propertiesKey, holidayType);
}

private static void checkByKey(final HolidayCalendar calendar, final Year from, final Year to, final String propertiesKey, final HolidayType holidayType) {
Expand All @@ -66,11 +72,11 @@ private static void checkByKey(final HolidayCalendar calendar, final Year from,
);
}

private static void checkByDate(final HolidayCalendar calendar, final Year from, final Year to, final Month month, final int day, final String propertiesKey, final HolidayType holidayType) {
private static void checkByDate(final HolidayCalendar calendar, final String hierarchy, final Year from, final Year to, final Month month, final int day, final String propertiesKey, final HolidayType holidayType) {
((YearArbitrary) Arbitraries.defaultFor(Year.class))
.between(from.getValue(), to.getValue())
.forEachValue(year -> {
final Set<Holiday> holidays = HolidayManager.getInstance(create(calendar)).getHolidays(year);
final Set<Holiday> holidays = HolidayManager.getInstance(create(calendar)).getHolidays(year, hierarchy);
assertThat(holidays)
.isNotEmpty()
.contains(new Holiday(LocalDate.of(year.getValue(), month, day), propertiesKey, holidayType));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package de.focus_shift.jollyday.tests.country;

import org.junit.jupiter.api.Test;

import static de.focus_shift.jollyday.core.HolidayCalendar.AUSTRIA;
import static de.focus_shift.jollyday.core.HolidayType.OBSERVANCE;
import static de.focus_shift.jollyday.tests.HolidayChecker.assertChristian;
import static de.focus_shift.jollyday.tests.HolidayChecker.assertFixed;
import static java.time.Month.AUGUST;
import static java.time.Month.DECEMBER;
import static java.time.Month.JANUARY;
import static java.time.Month.MARCH;
import static java.time.Month.MAY;
import static java.time.Month.NOVEMBER;
import static java.time.Month.OCTOBER;
import static java.time.Month.SEPTEMBER;

class HolidayATTest {

@Test
void ensuresHolidays() {
assertFixed(AUSTRIA, JANUARY, 1, "NEW_YEAR");
assertFixed(AUSTRIA, JANUARY, 6, "EPIPHANY");
assertFixed(AUSTRIA, MAY, 1, "LABOUR_DAY");
assertFixed(AUSTRIA, AUGUST, 15, "ASSUMPTION_DAY");
assertFixed(AUSTRIA, OCTOBER, 26, "NATIONAL_DAY");
assertFixed(AUSTRIA, NOVEMBER, 1, "ALL_SAINTS");
assertFixed(AUSTRIA, DECEMBER, 8, "IMMACULATE_CONCEPTION");
assertFixed(AUSTRIA, DECEMBER, 24, "CHRISTMAS_EVE", OBSERVANCE);
assertFixed(AUSTRIA, DECEMBER, 25, "CHRISTMAS");
assertFixed(AUSTRIA, DECEMBER, 26, "STEPHENS");
assertFixed(AUSTRIA, DECEMBER, 31, "NEW_YEARS_EVE", OBSERVANCE);
assertChristian(AUSTRIA, "EASTER");
assertChristian(AUSTRIA, "EASTER_MONDAY");
assertChristian(AUSTRIA, "ASCENSION_DAY");
assertChristian(AUSTRIA, "WHIT_MONDAY");
assertChristian(AUSTRIA, "CORPUS_CHRISTI");

assertFixed(AUSTRIA, "1", NOVEMBER, 11, "MARTINS_DAY");
assertFixed(AUSTRIA, "2", MARCH, 19, "JOSEFS_DAY");
assertFixed(AUSTRIA, "2", OCTOBER, 10, "PLEBISCITE");
assertFixed(AUSTRIA, "3", NOVEMBER, 15, "LEOPOLD");
assertFixed(AUSTRIA, "4", MAY, 4, "FLORIAN");
assertFixed(AUSTRIA, "5", SEPTEMBER, 24, "RUPERT");
assertFixed(AUSTRIA, "6", MARCH, 19, "JOSEFS_DAY");
assertFixed(AUSTRIA, "7", MARCH, 19, "JOSEFS_DAY");
assertFixed(AUSTRIA, "8", MARCH, 19, "JOSEFS_DAY");
assertFixed(AUSTRIA, "9", NOVEMBER, 15, "LEOPOLD");
}
}

0 comments on commit 963c578

Please sign in to comment.