Repository: focus-shift/jollyday
Pull request #468 (2024-02-21 10:04:02)

Added St Brigid moving pattern and tests Fixes gh-458
Fixes issue #458 


Patch:
diff --git a/jollyday-core/src/main/resources/holidays/Holidays_ie.xml b/jollyday-core/src/main/resources/holidays/Holidays_ie.xml
index 3fcf255f..d0c28c4b 100644
--- a/jollyday-core/src/main/resources/holidays/Holidays_ie.xml
+++ b/jollyday-core/src/main/resources/holidays/Holidays_ie.xml
@@ -9,7 +9,16 @@
     <Fixed month="MARCH" day="17" descriptionPropertiesKey="ST_PATRICK"/>
     <Fixed month="DECEMBER" day="25" descriptionPropertiesKey="CHRISTMAS"/>
     <Fixed month="DECEMBER" day="26" descriptionPropertiesKey="STEPHENS"/>
-    <FixedWeekday which="FIRST" weekday="MONDAY" month="FEBRUARY" validFrom="2023" descriptionPropertiesKey="ST_BRIGID"/>
+
+    <!-- The public holiday is the first Monday in February, except where St Brigid’s Day (1 February) happens to fall on a Friday, in which case Friday 1 February will be a public holiday. -->
+    <Fixed month="FEBRUARY" day="1" validFrom="2023" descriptionPropertiesKey="ST_BRIGID">
+      <MovingCondition substitute="TUESDAY" with="NEXT" weekday="MONDAY"/>
+      <MovingCondition substitute="WEDNESDAY" with="NEXT" weekday="MONDAY"/>
+      <MovingCondition substitute="THURSDAY" with="NEXT" weekday="MONDAY"/>
+      <MovingCondition substitute="SATURDAY" with="NEXT" weekday="MONDAY"/>
+      <MovingCondition substitute="SUNDAY" with="NEXT" weekday="MONDAY"/>
+    </Fixed>
+
     <FixedWeekday which="FIRST" weekday="MONDAY" month="MAY" descriptionPropertiesKey="LABOUR_DAY"/>
     <FixedWeekday which="FIRST" weekday="MONDAY" month="JUNE" descriptionPropertiesKey="BANK_HOLIDAY"/>
     <FixedWeekday which="FIRST" weekday="MONDAY" month="AUGUST" descriptionPropertiesKey="BANK_HOLIDAY"/>


Test patch:
diff --git a/jollyday-tests/src/test/java/de/focus_shift/jollyday/tests/country/HolidayIETest.java b/jollyday-tests/src/test/java/de/focus_shift/jollyday/tests/country/HolidayIETest.java
index 13d13eb7..9a6e529f 100644
--- a/jollyday-tests/src/test/java/de/focus_shift/jollyday/tests/country/HolidayIETest.java
+++ b/jollyday-tests/src/test/java/de/focus_shift/jollyday/tests/country/HolidayIETest.java
@@ -77,6 +77,7 @@ class HolidayIETest extends AbstractCountryTestBase {
       .extracting(Holiday::getPropertiesKey)
       .contains("christian.EASTER_MONDAY");
   }
+
   @Property
   void ensureStBrigidNotConfiguredBefore2023(@ForAll @YearRange(max = 2022) Year year) {
     final HolidayManager holidayManager = HolidayManager.getInstance(create(IRELAND));
@@ -105,4 +106,58 @@ class HolidayIETest extends AbstractCountryTestBase {
     assertThat(holidays2023)
       .contains(new Holiday(LocalDate.of(2023, FEBRUARY, 6), "ST_BRIGID", OFFICIAL_HOLIDAY));
   }
+
+  @Test
+  void testStBrigidsDayOn2024() {
+    final HolidayManager holidayManagerIE = HolidayManager.getInstance(create(IRELAND));
+
+    final Set<Holiday> holidays2024 = holidayManagerIE.getHolidays(2024);
+    assertThat(holidays2024)
+      .contains(new Holiday(LocalDate.of(2024, FEBRUARY, 5), "ST_BRIGID", OFFICIAL_HOLIDAY));
+  }
+
+  @Test
+  void testStBrigidsDayOn2025() {
+    final HolidayManager holidayManagerIE = HolidayManager.getInstance(create(IRELAND));
+
+    final Set<Holiday> holidays2025 = holidayManagerIE.getHolidays(2025);
+    assertThat(holidays2025)
+      .contains(new Holiday(LocalDate.of(2025, FEBRUARY, 3), "ST_BRIGID", OFFICIAL_HOLIDAY));
+  }
+
+  @Test
+  void testStBrigidsDayOn2026() {
+    final HolidayManager holidayManagerIE = HolidayManager.getInstance(create(IRELAND));
+
+    final Set<Holiday> holidays2026 = holidayManagerIE.getHolidays(2026);
+    assertThat(holidays2026)
+      .contains(new Holiday(LocalDate.of(2026, FEBRUARY, 2), "ST_BRIGID", OFFICIAL_HOLIDAY));
+  }
+
+  @Test
+  void testStBrigidsDayOn2027() {
+    final HolidayManager holidayManagerIE = HolidayManager.getInstance(create(IRELAND));
+
+    final Set<Holiday> holidays2027 = holidayManagerIE.getHolidays(2027);
+    assertThat(holidays2027)
+      .contains(new Holiday(LocalDate.of(2027, FEBRUARY, 1), "ST_BRIGID", OFFICIAL_HOLIDAY));
+  }
+
+  @Test
+  void testStBrigidsDayOn2028() {
+    final HolidayManager holidayManagerIE = HolidayManager.getInstance(create(IRELAND));
+
+    final Set<Holiday> holidays2028 = holidayManagerIE.getHolidays(2028);
+    assertThat(holidays2028)
+      .contains(new Holiday(LocalDate.of(2028, FEBRUARY, 7), "ST_BRIGID", OFFICIAL_HOLIDAY));
+  }
+
+  @Test
+  void testStBrigidsDayOn2030() {
+    final HolidayManager holidayManagerIE = HolidayManager.getInstance(create(IRELAND));
+
+    final Set<Holiday> holidays2030 = holidayManagerIE.getHolidays(2030);
+    assertThat(holidays2030)
+      .contains(new Holiday(LocalDate.of(2030, FEBRUARY, 1), "ST_BRIGID", OFFICIAL_HOLIDAY));
+  }
 }