-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency to jollyday-jackson from pojo module no longer need…
…ed since pojo-generator reads xml files. add unittest for customization of java configuration via code
- Loading branch information
Showing
5 changed files
with
41 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
jollyday-pojo/src/test/java/de/focus_shift/jollyday/pojo/test/JavaConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.focus_shift.jollyday.pojo.test; | ||
|
||
import java.time.LocalDate; | ||
import java.time.MonthDay; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import de.focus_shift.jollyday.core.HolidayManager; | ||
import de.focus_shift.jollyday.core.HolidayType; | ||
import de.focus_shift.jollyday.core.ManagerParameter; | ||
import de.focus_shift.jollyday.core.ManagerParameters; | ||
import de.focus_shift.jollyday.core.spi.Configuration; | ||
import de.focus_shift.jollyday.core.spi.YearCycle; | ||
import de.focus_shift.jollyday.pojo.JavaConfigurationService; | ||
import de.focus_shift.jollyday.pojo.JavaFixed; | ||
|
||
class JavaConfigurationTest { | ||
|
||
@Test | ||
void enhanceJavaConfigurationService() { | ||
|
||
JavaConfigurationService javaConfigurationService = new JavaConfigurationService(); | ||
ManagerParameter parameter = ManagerParameters.create("de"); | ||
|
||
HolidayManager holidayManager = HolidayManager.getInstance(parameter); | ||
Assertions.assertFalse(holidayManager.isHoliday(LocalDate.of(2022, 03, 22)), "Precondition 22.3 should be no holiday"); | ||
|
||
// add new holiday for 22.3 dynamically via code/api | ||
Configuration configuration = javaConfigurationService.getConfiguration(parameter); | ||
JavaFixed stgandulfholiday = new JavaFixed("st.gandulf's day", HolidayType.UNOFFICIAL_HOLIDAY, null, null, YearCycle.EVERY_YEAR, null, MonthDay.of(3, 22)); | ||
configuration.holidays().fixed().add(stgandulfholiday); | ||
HolidayManager.clearManagerCache(); // we have to clear the manager cache because otherwise the holidaymanager from above with old configuration would be reused. | ||
|
||
holidayManager = HolidayManager.getInstance(parameter); | ||
Assertions.assertTrue(holidayManager.isHoliday(LocalDate.of(2022, 03, 22), HolidayType.UNOFFICIAL_HOLIDAY), "Ensure newly added holiday is recognized"); | ||
|
||
} | ||
} | ||
|
Oops, something went wrong.