adamsaghy commented on code in PR #3656:
URL: https://github.com/apache/fineract/pull/3656#discussion_r1441472960
##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java:
##########
@@ -376,6 +376,86 @@ public void testApplyHolidaysToLoansJobOutcome() throws
InterruptedException {
"Verifying Repayment Rescheduled Day after Running Apply
Holidays to Loans Scheduler Job");
}
+ @Test
+ public void testApplyType1HolidaysToLoansJobOutcome() throws
InterruptedException {
+ this.loanTransactionHelper = new LoanTransactionHelper(requestSpec,
responseSpec);
+
+ final Integer clientID = ClientHelper.createClient(requestSpec,
responseSpec);
+ Assertions.assertNotNull(clientID);
+
+ Integer holidayId = HolidayHelper.createTyoe1Holidays(requestSpec,
responseSpec);
+ Assertions.assertNotNull(holidayId);
+
+ final Integer loanProductID = createLoanProduct(null);
+ Assertions.assertNotNull(loanProductID);
+
+ final Integer loanID = applyForLoanApplication(clientID.toString(),
loanProductID.toString(), null, "01 January 2013");
+ Assertions.assertNotNull(loanID);
+
+ HashMap loanStatusHashMap =
LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
+ LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
+
+ loanStatusHashMap =
this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE,
loanID);
+ LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
+
+ String loanDetails =
this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
+ loanStatusHashMap =
this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_DISBURSAL_DATE,
loanID,
+
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
+ LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
+
+ // Retrieving All Global Configuration details
+ final ArrayList<HashMap> globalConfig =
GlobalConfigurationHelper.getAllGlobalConfigurations(requestSpec, responseSpec);
+ Assertions.assertNotNull(globalConfig);
+
+ // Updating Value for reschedule-repayments-on-holidays Global
+ // Configuration
+ Integer configId = (Integer) globalConfig.get(3).get("id");
+ Assertions.assertNotNull(configId);
+
+ HashMap configData =
GlobalConfigurationHelper.getGlobalConfigurationById(requestSpec, responseSpec,
configId.toString());
+ Assertions.assertNotNull(configData);
+
+ Boolean enabled = (Boolean) globalConfig.get(3).get("enabled");
+
+ if (!enabled) {
+ enabled = true;
+
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(requestSpec,
responseSpec, configId, enabled);
+ }
+
+ holidayId = HolidayHelper.activateHolidays(requestSpec, responseSpec,
holidayId.toString());
+ Assertions.assertNotNull(holidayId);
+
+ HashMap holidayData = HolidayHelper.getHolidayById(requestSpec,
responseSpec, holidayId.toString());
+ LinkedHashMap repaymentScheduleHashMap =
JsonPath.from(loanDetails).get("repaymentSchedule");
+ ArrayList<LinkedHashMap> periods = (ArrayList<LinkedHashMap>)
repaymentScheduleHashMap.get("periods");
+ String JobName = "Apply Holidays To Loans";
+
+ this.schedulerJobHelper.executeAndAwaitJob(JobName);
+
+ // Loan Repayment Schedule After Apply Holidays To Loans
+ loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec,
responseSpec, loanID);
+ repaymentScheduleHashMap =
JsonPath.from(loanDetails).get("repaymentSchedule");
+ ArrayList<LinkedHashMap> periodsAfterRescheduleApplied =
(ArrayList<LinkedHashMap>) repaymentScheduleHashMap.get("periods");
+ ArrayList<Integer> dateToApplyHolidays = null;
+
+ int periodsLength = periodsAfterRescheduleApplied.size();
+ for (int i = 0; i < periodsLength; i++) {
+ LinkedHashMap periodRescheduled =
periodsAfterRescheduleApplied.get(i);
+ ArrayList<Integer> fromDate = (ArrayList<Integer>)
periodRescheduled.get("fromDate");
+ LinkedHashMap periodBeforeRescheduled =
periodsAfterRescheduleApplied.get(i);
+ ArrayList<Integer> dueDateBeforeRescheduled = (ArrayList<Integer>)
periodBeforeRescheduled.get("dueDate");
+ if (fromDate != null && Objects.equals(fromDate.get(1),
dueDateBeforeRescheduled.get(1))) {
+ dateToApplyHolidays = fromDate;
+ }
+ Assertions.assertNotNull(dateToApplyHolidays);
Review Comment:
I understand what you say (the old loans might be rescheduled multiple
times, but the new is only once), but with each test you are creating a brand
new loan and that loan will be rescheduled just once (hence it is brand new).
And that loan periods are checked, so it should be always the same. Feel free
to test it ;)
--
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]