From edff4a410e010d38d061f7beb71c639efee80f3d Mon Sep 17 00:00:00 2001 From: taskain7 Date: Tue, 30 May 2023 16:23:43 +0200 Subject: [PATCH] [FINERACT-1724] Fix disabled integration tests --- .../DisbursalAndRepaymentScheduleTest.java | 44 ----------- .../LoanTransactionChargebackTest.java | 78 ++++++++++--------- .../RecurringDepositTest.java | 2 - .../integrationtests/SchedulerJobsTest.java | 2 - 4 files changed, 43 insertions(+), 83 deletions(-) diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java index 5c1b27c93..f6fbf64e3 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java @@ -45,7 +45,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtens import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -53,7 +52,6 @@ import org.junit.jupiter.api.extension.ExtendWith; * Tests loan schedule change based on group meeting changes and loan rescheduling **/ @SuppressWarnings({ "rawtypes" }) -@Disabled @ExtendWith(LoanTestLifecycleExtension.class) public class DisbursalAndRepaymentScheduleTest { @@ -82,10 +80,6 @@ public class DisbursalAndRepaymentScheduleTest { @Test public void testRescheduleJLGLoanSynk() { - // system.out.println("---------------------------------STARTING - // RESCHEDULE JLG - // LOAN TEST ------------------------------------------"); - Calendar meetingCalendar = Calendar.getInstance(); meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); meetingCalendar.setTime(new java.util.Date()); @@ -133,10 +127,6 @@ public class DisbursalAndRepaymentScheduleTest { this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); - // system.out.println("---------------------------------CREATING - // ENTITIES AND - // JLG LOAN ------------------------------------------"); - // create all required entities this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24") @@ -167,9 +157,6 @@ public class DisbursalAndRepaymentScheduleTest { loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - // system.out.println("---------------------------------CHANGING GROUP - // MEETING - // DATE ------------------------------------------"); CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New // meeting @@ -191,10 +178,6 @@ public class DisbursalAndRepaymentScheduleTest { (Integer) dueDateLoanSchedule.get(2)); assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY"); - // system.out.println("---------------------------------CREATING LOAN - // RESCHEDULE - // REQUEST------------------------------------------"); - String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2").updateGraceOnPrincipal("2") .updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate) .updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString()); @@ -209,14 +192,6 @@ public class DisbursalAndRepaymentScheduleTest { assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT"); - // system.out.println("Successfully created loan reschedule request (ID: - // " + - // this.loanRescheduleRequestId + ")"); - - // system.out.println("-----------------------------APPROVING LOAN - // RESCHEDULE - // REQUEST--------------------------"); - requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate) .getApproveLoanRescheduleRequestJSON(); this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); @@ -231,24 +206,12 @@ public class DisbursalAndRepaymentScheduleTest { (Integer) dueDateLoanSchedule.get(2)); assertEquals(3, dueDateCalendar.get(Calendar.DAY_OF_WEEK), "AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE"); - // system.out.println("Successfully changed group meeting date (CAELNDAR - // ID: " + - // this.groupCalendarId - // + ") and rescheduled loan (RESCHEDULE ID: " + - // this.loanRescheduleRequestId + - // ")"); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403); } @Test public void testChangeGroupMeetingMaturedOnDate() { - // system.out - // .println("---------------------------------STARTING GROUP LOAN - // MEETING CHANGE - // DATE EXPECTED MATURED - // CHANGE------------------------------------------"); - Calendar meetingCalendar = Calendar.getInstance(); meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); meetingCalendar.setTime(new java.util.Date()); @@ -291,10 +254,6 @@ public class DisbursalAndRepaymentScheduleTest { this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); - // system.out.println("---------------------------------CREATING - // ENTITIES AND - // JLG LOAN ------------------------------------------"); - // create all required entities this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24") @@ -325,9 +284,6 @@ public class DisbursalAndRepaymentScheduleTest { loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - // system.out.println("---------------------------------CHANGING GROUP - // MEETING - // DATE ------------------------------------------"); CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New // meeting diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java index 891dd0ac1..12adba163 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionChargebackTest.java @@ -55,7 +55,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtens import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -184,52 +183,61 @@ public class LoanTransactionChargebackTest { loanTransactionHelper.applyChargebackTransaction(loanId, transactionId, "0.00", 0, responseSpecErr400); } - @Disabled("Failing test.Need rework") @Test public void applyLoanTransactionChargebackInLongTermLoan() { - // Client and Loan account creation - final Integer daysToSubtract = 1; - final Integer numberOfRepayments = 3; - final Integer loanId = createAccounts(daysToSubtract, numberOfRepayments, false); + try { + GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); + LocalDate businessDate = LocalDate.of(2023, 1, 20); + todaysDate = businessDate; + BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate); + // Client and Loan account creation + final Integer daysToSubtract = 1; + final Integer numberOfRepayments = 3; + final Integer loanId = createAccounts(daysToSubtract, numberOfRepayments, false); - GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId); - assertNotNull(getLoansLoanIdResponse); + GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId); + assertNotNull(getLoansLoanIdResponse); - loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse); + loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse); - final String baseAmount = "333.33"; - Float amount = Float.valueOf(baseAmount); - final LocalDate transactionDate = this.todaysDate.minusMonths(numberOfRepayments - 1).plusDays(3); - String operationDate = Utils.dateFormatter.format(transactionDate); + final String baseAmount = "333.33"; + Float amount = Float.valueOf(baseAmount); + final LocalDate transactionDate = this.todaysDate.minusMonths(numberOfRepayments - 1).plusDays(3); + String operationDate = Utils.dateFormatter.format(transactionDate); - PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = loanTransactionHelper.makeLoanRepayment(operationDate, amount, - loanId); - assertNotNull(loanIdTransactionsResponse); - final Long transactionId = loanIdTransactionsResponse.getResourceId(); - reviewLoanTransactionRelations(loanId, transactionId, 0, Double.valueOf("666.67")); + PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = loanTransactionHelper.makeLoanRepayment(operationDate, amount, + loanId); + assertNotNull(loanIdTransactionsResponse); + final Long transactionId = loanIdTransactionsResponse.getResourceId(); + reviewLoanTransactionRelations(loanId, transactionId, 0, Double.valueOf("666.67")); - final Long chargebackTransactionId = loanTransactionHelper.applyChargebackTransaction(loanId, transactionId, amount.toString(), 0, - responseSpec); - reviewLoanTransactionRelations(loanId, transactionId, 1, Double.valueOf("666.67")); - reviewLoanTransactionRelations(loanId, chargebackTransactionId, 0, Double.valueOf("1000.00")); + final Long chargebackTransactionId = loanTransactionHelper.applyChargebackTransaction(loanId, transactionId, amount.toString(), + 0, responseSpec); + reviewLoanTransactionRelations(loanId, transactionId, 1, Double.valueOf("666.67")); + reviewLoanTransactionRelations(loanId, chargebackTransactionId, 0, Double.valueOf("1000.00")); - getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId); - assertNotNull(getLoansLoanIdResponse); + getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId); + assertNotNull(getLoansLoanIdResponse); - loanTransactionHelper.validateLoanPrincipalOustandingBalance(getLoansLoanIdResponse, Double.valueOf(amountVal)); + loanTransactionHelper.validateLoanPrincipalOustandingBalance(getLoansLoanIdResponse, Double.valueOf(amountVal)); - loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse); - GetLoansLoanIdRepaymentSchedule getLoanRepaymentSchedule = getLoansLoanIdResponse.getRepaymentSchedule(); - for (GetLoansLoanIdRepaymentPeriod period : getLoanRepaymentSchedule.getPeriods()) { - if (period.getPeriod() != null && period.getPeriod() == 3) { - log.info("Period number {} for due date {} and totalDueForPeriod {}", period.getPeriod(), period.getDueDate(), - period.getTotalDueForPeriod()); - assertEquals(Double.valueOf("666.67"), period.getTotalDueForPeriod()); + loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse); + GetLoansLoanIdRepaymentSchedule getLoanRepaymentSchedule = getLoansLoanIdResponse.getRepaymentSchedule(); + for (GetLoansLoanIdRepaymentPeriod period : getLoanRepaymentSchedule.getPeriods()) { + if (period.getPeriod() != null && period.getPeriod() == 3) { + log.info("Period number {} for due date {} and totalDueForPeriod {}", period.getPeriod(), period.getDueDate(), + period.getTotalDueForPeriod()); + assertEquals(Double.valueOf("666.67"), period.getTotalDueForPeriod()); + } } - } - loanTransactionHelper.evaluateLoanSummaryAdjustments(getLoansLoanIdResponse, Double.valueOf(baseAmount)); - DelinquencyBucketsHelper.evaluateLoanCollectionData(getLoansLoanIdResponse, 0, Double.valueOf("0.00")); + loanTransactionHelper.evaluateLoanSummaryAdjustments(getLoansLoanIdResponse, Double.valueOf(baseAmount)); + DelinquencyBucketsHelper.evaluateLoanCollectionData(getLoansLoanIdResponse, 0, Double.valueOf("0.00")); + } finally { + final LocalDate todaysDate = Utils.getLocalDateOfTenant(); + BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); + GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); + } } @Test diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RecurringDepositTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RecurringDepositTest.java index af2f2e9a5..be7718548 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RecurringDepositTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RecurringDepositTest.java @@ -58,7 +58,6 @@ import org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -687,7 +686,6 @@ public class RecurringDepositTest { } @Test - @Disabled // TODO FINERACT-1248 public void testRecurringDepositAccountWithClosureTypeTransferToSavings_WITH_HOLD_TAX() throws InterruptedException { this.recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java index e10527716..f3925d2c8 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java @@ -37,7 +37,6 @@ import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.Utils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -86,7 +85,6 @@ public class SchedulerJobsTest { } @Test - @Disabled // TODO FINERACT-1167 public void testFlippingSchedulerStatus() throws InterruptedException { // Retrieving Status of Scheduler Boolean schedulerStatus = schedulerJobHelper.getSchedulerStatus();