Skip to content

Commit

Permalink
Merge pull request #191 from focus-shift/187-denmark
Browse files Browse the repository at this point in the history
denmark: general prayer day only until 2023
  • Loading branch information
derTobsch authored Mar 21, 2023
2 parents 24ab4fd + 660e6c3 commit 56bd042
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ target/
# Ignore eclipse files
.classpath
.settings/
.project
.project

# jqwik
/jollyday-tests/.jqwik-database
2 changes: 1 addition & 1 deletion jollyday-core/src/main/resources/holidays/Holidays_dk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<tns:ChristianHoliday type="MAUNDY_THURSDAY" descriptionPropertiesKey="christian.MAUNDY_THURSDAY"/>
<tns:ChristianHoliday type="GOOD_FRIDAY" descriptionPropertiesKey="christian.GOOD_FRIDAY"/>
<tns:ChristianHoliday type="EASTER_MONDAY" descriptionPropertiesKey="christian.EASTER_MONDAY"/>
<tns:ChristianHoliday type="GENERAL_PRAYER_DAY" descriptionPropertiesKey="christian.GENERAL_PRAYER_DAY"/>
<tns:ChristianHoliday type="GENERAL_PRAYER_DAY" validTo="2023" descriptionPropertiesKey="christian.GENERAL_PRAYER_DAY"/>
<tns:ChristianHoliday type="ASCENSION_DAY" descriptionPropertiesKey="christian.ASCENSION_DAY"/>
<tns:ChristianHoliday type="WHIT_MONDAY" descriptionPropertiesKey="christian.WHIT_MONDAY"/>
<tns:ChristianHoliday type="PENTECOST" descriptionPropertiesKey="christian.PENTECOST"/>
Expand Down
6 changes: 6 additions & 0 deletions jollyday-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik</artifactId>
<version>1.7.2</version>
<scope>test</scope>
</dependency>

<!-- Logging -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package de.focus_shift.tests;

import de.focus_shift.Holiday;
import de.focus_shift.HolidayManager;
import de.focus_shift.tests.base.AbstractCountryTestBase;
import net.jqwik.api.ForAll;
import net.jqwik.api.Property;
import net.jqwik.time.api.constraints.YearRange;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.Year;
import java.util.Set;

import static de.focus_shift.HolidayCalendar.DENMARK;
import static de.focus_shift.HolidayType.OFFICIAL_HOLIDAY;
import static de.focus_shift.ManagerParameters.create;
import static java.time.Month.DECEMBER;
import static java.time.Month.JANUARY;
import static java.time.Month.MAY;
import static org.assertj.core.api.Assertions.assertThat;

class HolidayDKTest extends AbstractCountryTestBase {

@Property
void ensuresThatNewYearIsOnFirstJanuary(@ForAll @YearRange Year year) {
final HolidayManager holidayManager = HolidayManager.getInstance(create(DENMARK));
final Set<Holiday> holidays = holidayManager.getHolidays(year.getValue());
assertThat(holidays)
.isNotEmpty()
.contains(new Holiday(LocalDate.of(year.getValue(), JANUARY, 1), "NEW_YEAR", OFFICIAL_HOLIDAY));
}

@Property
void ensuresThatFirstAndSecondChristmasIsCorrect(@ForAll @YearRange Year year) {
final HolidayManager holidayManager = HolidayManager.getInstance(create(DENMARK));
final Set<Holiday> holidays = holidayManager.getHolidays(year.getValue());
assertThat(holidays)
.isNotEmpty()
.contains(new Holiday(LocalDate.of(year.getValue(), DECEMBER, 25), "CHRISTMAS", OFFICIAL_HOLIDAY))
.contains(new Holiday(LocalDate.of(year.getValue(), DECEMBER, 26), "STEPHENS", OFFICIAL_HOLIDAY));
}

@Test
void ensuresThatGeneralPrayersDayIsOnlyUntil2023() {
final HolidayManager holidayManagerDK = HolidayManager.getInstance(create(DENMARK));

final Set<Holiday> holidays2023 = holidayManagerDK.getHolidays(2023);
assertThat(holidays2023)
.isNotEmpty()
.contains(new Holiday(LocalDate.of(2023, MAY, 5), "christian.GENERAL_PRAYER_DAY", OFFICIAL_HOLIDAY));

final Set<Holiday> holidays2024 = holidayManagerDK.getHolidays(2024);
assertThat(holidays2024)
.isNotEmpty()
.extracting(Holiday::getPropertiesKey)
.doesNotContain("christian.GENERAL_PRAYER_DAY");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jqwik.reporting.onlyfailures = true

0 comments on commit 56bd042

Please sign in to comment.