oluexpert99 commented on code in PR #5559:
URL: https://github.com/apache/fineract/pull/5559#discussion_r2983938373


##########
fineract-provider/src/test/java/org/apache/fineract/infrastructure/core/service/DateUtilsTest.java:
##########
@@ -91,4 +92,69 @@ public void isDateInTheFuture() {
     public void getBusinesLocalDate() {
         assertTrue(DateUtils.isEqualBusinessDate(LocalDate.of(2022, 6, 12)));
     }
+
+    // --- safeMonthDay (clamps day to last valid day of month for current 
business year) ---
+
+    @Test
+    public void safeMonthDay_validDay_returnsSameMonthDay() {
+        assertEquals(MonthDay.of(1, 15), DateUtils.safeMonthDay(1, 15));
+        assertEquals(MonthDay.of(3, 31), DateUtils.safeMonthDay(3, 31));
+        assertEquals(MonthDay.of(4, 30), DateUtils.safeMonthDay(4, 30));
+        assertEquals(MonthDay.of(12, 31), DateUtils.safeMonthDay(12, 31));
+    }
+
+    @Test
+    public void safeMonthDay_february29_inNonLeapYear_clampedTo28() {
+        // business date initialized to 2022-06-12 (non-leap year) in 
@BeforeEach
+        assertEquals(MonthDay.of(2, 28), DateUtils.safeMonthDay(2, 29));
+    }
+
+    @Test
+    public void safeMonthDay_february30_inNonLeapYear_clampedTo28() {
+        assertEquals(MonthDay.of(2, 28), DateUtils.safeMonthDay(2, 30));
+    }
+
+    @Test
+    public void safeMonthDay_february31_inNonLeapYear_clampedTo28() {

Review Comment:
   @adamsaghy  , see test cases for both leap and non leap years 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to