This is an automated email from the ASF dual-hosted git repository.

fjtiradosarti pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f722efa0d [Fix_3818] Wrong calculation in test 
rollCalendarAfterHolidays if day is (#3819)
8f722efa0d is described below

commit 8f722efa0d1626ab00268303185ceef65a472f72
Author: Gonzalo Muñoz <gonzalo51...@gmail.com>
AuthorDate: Wed Jan 8 18:58:47 2025 +0100

    [Fix_3818] Wrong calculation in test rollCalendarAfterHolidays if day is 
(#3819)
    
    near to end-of-year
---
 .../core/timer/BusinessCalendarImplTest.java       | 43 ++++++++++++++++------
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git 
a/jbpm/jbpm-flow/src/test/java/org/jbpm/process/core/timer/BusinessCalendarImplTest.java
 
b/jbpm/jbpm-flow/src/test/java/org/jbpm/process/core/timer/BusinessCalendarImplTest.java
index e1038c8b39..1f06dbac83 100755
--- 
a/jbpm/jbpm-flow/src/test/java/org/jbpm/process/core/timer/BusinessCalendarImplTest.java
+++ 
b/jbpm/jbpm-flow/src/test/java/org/jbpm/process/core/timer/BusinessCalendarImplTest.java
@@ -222,20 +222,41 @@ class BusinessCalendarImplTest extends AbstractBaseTest {
     }
 
     @Test
-    void rollCalendarAfterHolidays() {
-        Instant now = Instant.now();
-        int holidayLeft = 4;
-        Instant startHolidayInstant = now.minus(2, DAYS);
-        Instant endHolidayInstant = now.plus(holidayLeft, DAYS);
-        Date startHoliday = Date.from(startHolidayInstant);
-        Date endHoliday = Date.from(endHolidayInstant);
-        List<BusinessCalendarImpl.TimePeriod> holidays = 
Collections.singletonList(new BusinessCalendarImpl.TimePeriod(startHoliday, 
endHoliday));
+    void rollCalendarAfterHolidaysWithoutYearRollover() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_YEAR, 360);
+        calendar.set(Calendar.YEAR, 2025);
+        Instant currentInstant = calendar.toInstant();
+
+        Instant startHolidayInstant = currentInstant.minus(2, DAYS);
+        Instant endHolidayInstant = currentInstant.plus(4, DAYS);
+        List<BusinessCalendarImpl.TimePeriod> holidays = 
Collections.singletonList(
+                new 
BusinessCalendarImpl.TimePeriod(Date.from(startHolidayInstant), 
Date.from(endHolidayInstant)));
         List<Integer> weekendDays = Collections.emptyList();
+
+        BusinessCalendarImpl.rollCalendarAfterHolidays(calendar, holidays, 
weekendDays, false);
+
+        int expectedDayOfYear = 360 + 4 + 1; //last day of the year, as it is 
not leap year
+        
assertThat(calendar.get(Calendar.DAY_OF_YEAR)).isEqualTo(expectedDayOfYear);
+    }
+
+    @Test
+    void rollCalendarAfterHolidaysWithYearRollover() {
         Calendar calendar = Calendar.getInstance();
-        int currentDayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
+        calendar.set(Calendar.DAY_OF_YEAR, 361);
+        calendar.set(Calendar.YEAR, 2025);
+        Instant currentInstant = calendar.toInstant();
+
+        Instant startHolidayInstant = currentInstant.minus(2, DAYS);
+        Instant endHolidayInstant = currentInstant.plus(4, DAYS);
+        List<BusinessCalendarImpl.TimePeriod> holidays = 
Collections.singletonList(
+                new 
BusinessCalendarImpl.TimePeriod(Date.from(startHolidayInstant), 
Date.from(endHolidayInstant)));
+        List<Integer> weekendDays = Collections.emptyList();
+
         BusinessCalendarImpl.rollCalendarAfterHolidays(calendar, holidays, 
weekendDays, false);
-        int expected = currentDayOfYear + holidayLeft + 1;
-        assertThat(calendar.get(Calendar.DAY_OF_YEAR)).isEqualTo(expected);
+
+        int expectedDayOfYear = 1; //since 2025 is not leap year
+        
assertThat(calendar.get(Calendar.DAY_OF_YEAR)).isEqualTo(expectedDayOfYear);
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@kie.apache.org
For additional commands, e-mail: commits-h...@kie.apache.org

Reply via email to