Cocoa-Puffs commented on code in PR #6094:
URL: https://github.com/apache/fineract/pull/6094#discussion_r3534551900


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/WorkingCapitalLoanDelinquencyActionEffectiveEndDateTest.java:
##########
@@ -0,0 +1,208 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.fineract.client.feign.util.FeignCalls;
+import org.apache.fineract.client.models.DelinquencyRangeRequest;
+import org.apache.fineract.client.models.PostDelinquencyBucketResponse;
+import org.apache.fineract.client.models.PostDelinquencyRangeResponse;
+import 
org.apache.fineract.client.models.WorkingCapitalLoanDelinquencyActionData;
+import org.apache.fineract.integrationtests.common.BusinessDateHelper;
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import 
org.apache.fineract.integrationtests.common.products.DelinquencyRangesHelper;
+import 
org.apache.fineract.integrationtests.common.workingcapitalloan.WorkingCapitalLoanApplicationTestBuilder;
+import 
org.apache.fineract.integrationtests.common.workingcapitalloan.WorkingCapitalLoanDelinquencyActionHelper;
+import 
org.apache.fineract.integrationtests.common.workingcapitalloan.WorkingCapitalLoanDelinquencyRangeScheduleHelper;
+import 
org.apache.fineract.integrationtests.common.workingcapitalloan.WorkingCapitalLoanHelper;
+import 
org.apache.fineract.integrationtests.common.workingcapitalloanproduct.WorkingCapitalLoanProductHelper;
+import 
org.apache.fineract.integrationtests.common.workingcapitalloanproduct.WorkingCapitalLoanProductTestBuilder;
+import org.junit.jupiter.api.Test;
+
+public class WorkingCapitalLoanDelinquencyActionEffectiveEndDateTest {
+
+    private static final int PERIOD_FREQUENCY_DAYS = 30;
+
+    private final WorkingCapitalLoanHelper applicationHelper = new 
WorkingCapitalLoanHelper();
+    private final WorkingCapitalLoanProductHelper productHelper = new 
WorkingCapitalLoanProductHelper();
+
+    @Test
+    public void testPauseCreatesDelinquencyActionWithNoEffectiveEndDate() {
+        BusinessDateHelper.runAt("01 July 2026", () -> {
+            final Long loanId = createActiveLoan(LocalDate.of(2026, 7, 1));
+
+            
WorkingCapitalLoanDelinquencyActionHelper.createDelinquencyAction(loanId, 
"pause", LocalDate.of(2026, 7, 1),
+                    LocalDate.of(2026, 7, 10));
+
+            final List<WorkingCapitalLoanDelinquencyActionData> actions = 
WorkingCapitalLoanDelinquencyActionHelper
+                    .retrieveDelinquencyActions(loanId);
+            assertEquals(1, actions.size());
+
+            final WorkingCapitalLoanDelinquencyActionData pause = 
actions.getFirst();
+            
assertEquals(WorkingCapitalLoanDelinquencyActionData.ActionEnum.PAUSE, 
pause.getAction());
+            assertEquals(LocalDate.of(2026, 7, 1), pause.getStartDate());
+            assertEquals(LocalDate.of(2026, 7, 10), pause.getEndDate());
+            assertNull(pause.getEffectiveEndDate(), "effectiveEndDate must be 
null when the pause has not been resumed");
+        });
+    }
+
+    @Test
+    public void testResumeCreatesResumeActionAndSetsEffectiveEndDateOnPause() {
+        final Long[] loanIdHolder = new Long[1];
+        BusinessDateHelper.runAt("01 July 2026", () -> {
+            loanIdHolder[0] = createActiveLoan(LocalDate.of(2026, 7, 1));
+
+            
WorkingCapitalLoanDelinquencyActionHelper.createDelinquencyAction(loanIdHolder[0],
 "pause", LocalDate.of(2026, 7, 1),
+                    LocalDate.of(2026, 7, 10));
+        });
+
+        BusinessDateHelper.runAt("05 July 2026", () -> {
+            
WorkingCapitalLoanDelinquencyActionHelper.createDelinquencyAction(loanIdHolder[0],
 "resume", LocalDate.of(2026, 7, 5), null);

Review Comment:
   I have modified the local date creations to use java.time.Month for their 
second parameter, which should not trigger the sonar rule anymore.
   
   DayOfWeek however doesn't apply here. It's an enum that simply represents 
Monday-Sunday without date information. Used for things like 
`LocalDate.now().getDayOfWeek()` or `TemporalAdjusters.next(DayOfWeek.MONDAY)`. 
There is no `LocalDate.of(year, month, DayOfWeek)` overload.



-- 
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