Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

denmark: general prayer day only until 2023 #191

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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