30
30
31
31
import java .time .LocalDate ;
32
32
import java .time .Month ;
33
- import java .time .ZoneId ;
34
33
import java .time .ZonedDateTime ;
35
34
import java .util .Arrays ;
36
35
import java .util .LinkedHashSet ;
37
36
import java .util .NavigableSet ;
38
37
38
+ import static no .bekk .bekkopen .date .NorwegianDateUtil .ZONE_NORWAY ;
39
39
import static org .hamcrest .MatcherAssert .assertThat ;
40
40
import static org .junit .jupiter .api .Assertions .assertEquals ;
41
41
import static org .junit .jupiter .api .Assertions .assertFalse ;
44
44
45
45
public class NorwegianDateUtilTest {
46
46
47
- public static ZoneId NORGESONE = ZoneId .of ("Europe/Oslo" );
48
47
49
48
@ Test
50
49
public void testAdd2DaysWithinSameWeek () {
51
- ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 18 ).atStartOfDay (NORGESONE );
50
+ ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 18 ).atStartOfDay (ZONE_NORWAY );
52
51
53
52
ZonedDateTime ny = NorwegianDateUtil .addWorkingDaysToDate (zonedDateTime , 2 );
54
53
@@ -58,7 +57,7 @@ public void testAdd2DaysWithinSameWeek() {
58
57
59
58
@ Test
60
59
public void testAdd2DaysBeforeWeekend () {
61
- ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 20 ).atStartOfDay (NORGESONE );
60
+ ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 20 ).atStartOfDay (ZONE_NORWAY );
62
61
63
62
ZonedDateTime ny = NorwegianDateUtil .addWorkingDaysToDate (zonedDateTime , 2 );
64
63
@@ -68,7 +67,7 @@ public void testAdd2DaysBeforeWeekend() {
68
67
69
68
@ Test
70
69
void testAdd2DaysToLastDayOfMonth () {
71
- ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 30 ).atStartOfDay (NORGESONE );
70
+ ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 30 ).atStartOfDay (ZONE_NORWAY );
72
71
73
72
ZonedDateTime ny = NorwegianDateUtil .addWorkingDaysToDate (zonedDateTime , 2 );
74
73
@@ -78,7 +77,7 @@ void testAdd2DaysToLastDayOfMonth() {
78
77
79
78
@ Test
80
79
void testAdd5DaysWithNoHolidays () {
81
- ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 30 ).atStartOfDay (NORGESONE );
80
+ ZonedDateTime zonedDateTime = LocalDate .of (2024 , 9 , 30 ).atStartOfDay (ZONE_NORWAY );
82
81
83
82
ZonedDateTime ny = NorwegianDateUtil .addWorkingDaysToDate (zonedDateTime , 5 );
84
83
@@ -88,7 +87,7 @@ void testAdd5DaysWithNoHolidays() {
88
87
89
88
@ Test
90
89
void testAdd5DaysBeforeEasterHoliday () {
91
- ZonedDateTime zonedDateTime = LocalDate .of (2025 , 4 , 11 ).atStartOfDay (NORGESONE );
90
+ ZonedDateTime zonedDateTime = LocalDate .of (2025 , 4 , 11 ).atStartOfDay (ZONE_NORWAY );
92
91
93
92
ZonedDateTime ny = NorwegianDateUtil .addWorkingDaysToDate (zonedDateTime , 5 );
94
93
@@ -98,7 +97,7 @@ void testAdd5DaysBeforeEasterHoliday() {
98
97
99
98
@ Test
100
99
void testAdd5DaysBeforeNationalDay () {
101
- ZonedDateTime zonedDateTime = LocalDate .of (2007 , 5 , 16 ).atStartOfDay (NORGESONE );
100
+ ZonedDateTime zonedDateTime = LocalDate .of (2007 , 5 , 16 ).atStartOfDay (ZONE_NORWAY );
102
101
103
102
ZonedDateTime ny = NorwegianDateUtil .addWorkingDaysToDate (zonedDateTime , 5 );
104
103
@@ -108,7 +107,7 @@ void testAdd5DaysBeforeNationalDay() {
108
107
109
108
@ Test
110
109
void testAdd5DaysBeforeChristmas () {
111
- ZonedDateTime zonedDateTime = LocalDate .of (2024 , 12 , 20 ).atStartOfDay (NORGESONE );
110
+ ZonedDateTime zonedDateTime = LocalDate .of (2024 , 12 , 20 ).atStartOfDay (ZONE_NORWAY );
112
111
113
112
ZonedDateTime ny = NorwegianDateUtil .addWorkingDaysToDate (zonedDateTime , 6 );
114
113
@@ -119,10 +118,10 @@ void testAdd5DaysBeforeChristmas() {
119
118
120
119
@ Test
121
120
public void testWorkingDays () {
122
- assertFalse (NorwegianDateUtil .isWorkingDay (LocalDate .of (2024 , 9 , 22 ).atStartOfDay (NORGESONE )), "Sunday not working day" );
123
- assertTrue (NorwegianDateUtil .isWorkingDay (LocalDate .of (2024 , 9 , 16 ).atStartOfDay (NORGESONE )), "Monday is working day" );
124
- assertFalse (NorwegianDateUtil .isWorkingDay (LocalDate .of (2025 , 1 , 1 ).atStartOfDay (NORGESONE )), "New years day not working day" );
125
- assertFalse (NorwegianDateUtil .isWorkingDay (LocalDate .of (2007 , 4 , 8 ).atStartOfDay (NORGESONE )), "Easter day not working day" );
121
+ assertFalse (NorwegianDateUtil .isWorkingDay (LocalDate .of (2024 , 9 , 22 ).atStartOfDay (ZONE_NORWAY )), "Sunday not working day" );
122
+ assertTrue (NorwegianDateUtil .isWorkingDay (LocalDate .of (2024 , 9 , 16 ).atStartOfDay (ZONE_NORWAY )), "Monday is working day" );
123
+ assertFalse (NorwegianDateUtil .isWorkingDay (LocalDate .of (2025 , 1 , 1 ).atStartOfDay (ZONE_NORWAY )), "New years day not working day" );
124
+ assertFalse (NorwegianDateUtil .isWorkingDay (LocalDate .of (2007 , 4 , 8 ).atStartOfDay (ZONE_NORWAY )), "Easter day not working day" );
126
125
}
127
126
128
127
@@ -185,6 +184,6 @@ public void testGetAllNorwegianHolidaysForYear() {
185
184
}
186
185
187
186
private void checkHoliday (LocalDate date ) {
188
- assertThat (date .atStartOfDay (NORGESONE ), where (NorwegianDateUtil ::isHoliday ));
187
+ assertThat (date .atStartOfDay (ZONE_NORWAY ), where (NorwegianDateUtil ::isHoliday ));
189
188
}
190
189
}
0 commit comments