FINERACT-2090: restructure loan approvals

This commit is contained in:
Kristof Jozsa
2024-06-24 11:30:53 +02:00
committed by Adam Saghy
parent 9152408c24
commit fac4832723
31 changed files with 438 additions and 384 deletions
@@ -76,9 +76,9 @@ public class AccountTransferTest {
public static final String TO_LOAN_ACCOUNT_TYPE = "1";
public static final String TO_SAVINGS_ACCOUNT_TYPE = "2";
public static final String LOAN_APPROVAL_DATE = "01 March 2013";
public static final String LOAN_APPROVAL_DATE_PLUS_ONE = "02 March 2013";
public static final String LOAN_DISBURSAL_DATE = "01 March 2013";
public static final String LOAN_APPROVAL_DATE = "10 January 2013";
public static final String LOAN_APPROVAL_DATE_PLUS_ONE = "11 January 2013";
public static final String LOAN_DISBURSAL_DATE = "10 January 2013";
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@@ -107,12 +107,12 @@ public class AccountTransferTest {
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
if (financialActivities.isEmpty()) {
/** Setup liability transfer account **/
/** Create a Liability and an Asset Transfer Account **/
/* Setup liability transfer account **/
/* Create a Liability and an Asset Transfer Account **/
liabilityTransferAccount = accountHelper.createLiabilityAccount();
Assertions.assertNotNull(liabilityTransferAccount);
/*** Create A Financial Activity to Account Mapping **/
/* Create A Financial Activity to Account Mapping **/
financialActivityAccountId = (Integer) financialActivityAccountHelper.createFinancialActivityAccount(
FinancialActivityAccountsTest.LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID, liabilityTransferAccount.getAccountID(),
responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
@@ -573,10 +573,10 @@ public class BatchApiTest {
final BatchRequest applyLoanRequest = BatchHelper.applyLoanRequestWithClientId(applyLoanRequestId, clientId, productId);
final BatchRequest approveLoanRequest = BatchHelper.transistionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
final BatchRequest approveLoanRequest = BatchHelper.transitionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(10), "approve");
final BatchRequest disburseLoanRequest = BatchHelper.transistionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
final BatchRequest disburseLoanRequest = BatchHelper.transitionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(8), "disburse");
final BatchRequest getLoanRequest = BatchHelper.getLoanByExternalIdRequest(getLoanRequestId, approveLoanRequestId,
@@ -2348,10 +2348,10 @@ public class BatchApiTest {
final BatchRequest applyLoanRequest = BatchHelper.applyLoanRequestWithClientId(applyLoanRequestId, clientId, productId);
final BatchRequest approveLoanRequest = BatchHelper.transistionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
final BatchRequest approveLoanRequest = BatchHelper.transitionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(10), "approve");
final BatchRequest disburseLoanRequest = BatchHelper.transistionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
final BatchRequest disburseLoanRequest = BatchHelper.transitionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(8), "disburse");
final BatchRequest updateLoanRequest = BatchHelper.modifyLoanByExternalIdRequest(updateLoanRequestId, approveLoanRequestId);
@@ -2414,10 +2414,10 @@ public class BatchApiTest {
final BatchRequest applyLoanRequest = BatchHelper.applyLoanRequestWithClientId(applyLoanRequestId, clientId, productId);
final BatchRequest approveLoanRequest = BatchHelper.transistionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
final BatchRequest approveLoanRequest = BatchHelper.transitionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(10), "approve");
final BatchRequest disburseLoanRequest = BatchHelper.transistionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
final BatchRequest disburseLoanRequest = BatchHelper.transitionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(8), "disburse");
final BatchRequest getLoanRequest = BatchHelper.getLoanByExternalIdRequest(getLoanRequestId, approveLoanRequestId,
@@ -2496,10 +2496,10 @@ public class BatchApiTest {
final BatchRequest applyLoanRequest = BatchHelper.applyLoanRequestWithClientId(applyLoanRequestId, clientId, productId);
final BatchRequest approveLoanRequest = BatchHelper.transistionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
final BatchRequest approveLoanRequest = BatchHelper.transitionLoanStateByExternalId(approveLoanRequestId, applyLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(10), "approve");
final BatchRequest disburseLoanRequest = BatchHelper.transistionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
final BatchRequest disburseLoanRequest = BatchHelper.transitionLoanStateByExternalId(disburseLoanRequestId, approveLoanRequestId,
LocalDate.now(Utils.getZoneIdOfTenant()).minusDays(8), "disburse");
final BatchRequest getLoanRequest = BatchHelper.getLoanByExternalIdRequest(getLoanRequestId, approveLoanRequestId,
@@ -445,7 +445,7 @@ public class ClientLoanIntegrationTest {
DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US);
Calendar todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime());
final String LOAN_DISBURSEMENT_DATE = "2 June 2014";
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
@@ -1545,7 +1545,7 @@ public class ClientLoanIntegrationTest {
* amount plus interest
*/
@Test
public void loanWithCahargesOfTypeAmountPlusInterestPercentageAndCashBasedAccountingEnabled() {
public void loanWithChargesOfTypeAmountPlusInterestPercentageAndCashBasedAccountingEnabled() {
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC);
ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
@@ -101,7 +101,7 @@ public class GroupLoanIntegrationTest {
LOG.info("LoanId : {} ", loanId);
List<Map<String, Object>> approvalFormData = new ArrayList<>();
approvalFormData.add(approvalFormData(loanId, "22 September 2011"));
approvalFormData.add(approvalFormData(loanId, "20 September 2011"));
HashMap loanStatusHashMap = this.loanTransactionHelper.approveGlimAccount(this.requestSpec, this.responseSpec, approvalFormData,
glimId);
@@ -23,9 +23,6 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
@@ -65,15 +62,7 @@ public class LoanAccountsContainsCurrencyFieldTest {
@Test
public void testGetClientLoanAccountsUsingExternalIdContainsCurrency() {
// Get today's date
LocalDate today = LocalDate.now(ZoneId.systemDefault());
// Define a custom date formatter
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy");
// Format today's date using the custom formatter
String formattedDate = today.format(formatter);
String formattedDate = "01 September 2022";
// given
GlobalConfigurationHelper.manageConfigurations(requestSpec, responseSpec,
@@ -50,7 +50,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
@Slf4j
public class LoanApplicationApprovalTest {
private static final String DATETIME_PATTERN = "dd MMMM yyyy";
private ResponseSpecification responseSpec;
private ResponseSpecification responseSpecForStatusCode403;
private ResponseSpecification responseSpecForStatusCode400;
@@ -101,7 +100,7 @@ public class LoanApplicationApprovalTest {
final String proposedAmount = "5000";
final String approvalAmount = "9000";
final String approveDate = "20 September 2011";
final String approveDate = "2 April 2012";
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().build(null));
@@ -131,7 +130,6 @@ public class LoanApplicationApprovalTest {
@Test
public void loanApplicationApprovalAndValidationForMultiDisburseLoans() {
List<HashMap> createTranches = new ArrayList<>();
createTranches.add(createTrancheDetail("01 March 2014", "1000"));
createTranches.add(createTrancheDetail("23 March 2014", "4000"));
@@ -139,14 +137,16 @@ public class LoanApplicationApprovalTest {
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
log.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}", clientID);
final Integer loanProductID = this.loanTransactionHelper
.getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true)
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() //
.withInterestTypeAsDecliningBalance() //
.withTranches(true) //
.withInterestCalculationPeriodTypeAsRepaymentPeriod(true) //
.build(null));
log.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
loanProductID);
this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
}
@Test
@@ -266,12 +266,12 @@ public class LoanApplicationApprovalTest {
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
/* If tranches are not specified for a multi-disburse loan */
/**
/*
* error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate,
* approvalAmount5, loanID, approveTranche5, CommonConstants.RESPONSE_ERROR);
* assertEquals("error.msg.disbursementData.required",
* error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
**/
*/
}
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) {
@@ -285,7 +285,7 @@ public class LoanApplicationApprovalTest {
final String loanApplication = new LoanApplicationTestBuilder().withPrincipal(proposedAmount).withLoanTermFrequency("5")
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5").withRepaymentEveryAfter("1")
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("04 April 2012")
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("20 September 2012")
.withCollaterals(collaterals).withSubmittedOnDate("02 April 2012")
.build(clientID.toString(), loanProductID.toString(), null);
return this.loanTransactionHelper.getLoanId(loanApplication);
@@ -70,7 +70,6 @@ public class LoanApplicationUndoLastTrancheTest {
@Test
public void loanApplicationUndoLastTranche() {
final String proposedAmount = "5000";
final String approvalAmount = "2000";
final String approveDate = "01 March 2014";
@@ -139,8 +138,7 @@ public class LoanApplicationUndoLastTrancheTest {
@Test
public void loanApplicationUndoLastTrancheToClose() {
final LocalDate todaysDate = Utils.getLocalDateOfTenant();
LocalDate transactionDate = LocalDate.of(todaysDate.getYear(), 1, 1);
LocalDate transactionDate = LocalDate.of(2014, 3, 1);
String operationDate = Utils.dateFormatter.format(transactionDate);
LOG.info("Operation date {}", transactionDate);
@@ -98,7 +98,7 @@ public class LoanAuditingIntegrationTest {
OffsetDateTime now = Utils.getAuditDateTimeToCompare();
final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, Collections.emptyList(),
null, "10000", LoanApplicationTestBuilder.DEFAULT_STRATEGY, "10 July 2022");
null, "10000", LoanApplicationTestBuilder.DEFAULT_STRATEGY, "10 July 2022", "11 July 2022");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -143,7 +143,8 @@ public class LoanAuditingIntegrationTest {
}
private Integer applyForLoanApplicationWithPaymentStrategyAndPastMonth(final Integer clientID, final Integer loanProductID,
List<HashMap> charges, final String savingsId, String principal, final String repaymentStrategy, final String submittedOnDate) {
List<HashMap> charges, final String savingsId, String principal, final String repaymentStrategy, final String submittedOnDate,
final String disbursementDate) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
@@ -157,7 +158,7 @@ public class LoanAuditingIntegrationTest {
.withAmortizationTypeAsEqualInstallments() //
.withInterestTypeAsFlatBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
.withExpectedDisbursementDate(submittedOnDate) //
.withExpectedDisbursementDate(disbursementDate) //
.withSubmittedOnDate(submittedOnDate) //
.withRepaymentStrategy(repaymentStrategy) //
.withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
@@ -94,7 +94,7 @@ public class LoanCOBAccountLockCatchupInlineCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -150,7 +150,7 @@ public class LoanCOBAccountLockCatchupInlineCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -207,7 +207,7 @@ public class LoanCOBAccountLockCatchupInlineCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -279,7 +279,7 @@ public class LoanCOBAccountLockCatchupInlineCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -338,7 +338,7 @@ public class LoanCOBAccountLockCatchupInlineCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -393,7 +393,7 @@ public class LoanCOBAccountLockCatchupInlineCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -97,7 +97,7 @@ public class LoanCatchUpIntegrationTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -119,7 +119,7 @@ public class LoanDueCalculationTest extends BaseLoanIntegrationTest {
installment(250.0, false, "30 May 2024")) //
;
loanTransactionHelper.approveLoan(postLoansResponse.getResourceId(), approveLoanRequest(1000.0, "31 January 2024"));
loanTransactionHelper.approveLoan(postLoansResponse.getResourceId(), approveLoanRequest(1000.0, "30 January 2024"));
verifyRepaymentSchedule(postLoansResponse.getLoanId(), installment(1000.0, null, "30 January 2024"), //
installment(250.0, false, "29 February 2024"), //
@@ -96,7 +96,7 @@ public class LoanTransactionAuditingIntegrationTest {
expenseAccount, overpaymentAccount);
final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, Collections.emptyList(),
null, "10000", LoanApplicationTestBuilder.DEFAULT_STRATEGY, "10 July 2022");
null, "10000", LoanApplicationTestBuilder.DEFAULT_STRATEGY, "10 July 2022", "12 July 2022");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -151,7 +151,8 @@ public class LoanTransactionAuditingIntegrationTest {
}
private Integer applyForLoanApplicationWithPaymentStrategyAndPastMonth(final Integer clientID, final Integer loanProductID,
List<HashMap> charges, final String savingsId, String principal, final String repaymentStrategy, final String submittedOnDate) {
List<HashMap> charges, final String savingsId, String principal, final String repaymentStrategy, final String submittedOnDate,
final String disbursementDate) {
LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
@@ -165,7 +166,7 @@ public class LoanTransactionAuditingIntegrationTest {
.withAmortizationTypeAsEqualInstallments() //
.withInterestTypeAsFlatBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
.withExpectedDisbursementDate(submittedOnDate) //
.withExpectedDisbursementDate(disbursementDate) //
.withSubmittedOnDate(submittedOnDate) //
.withRepaymentStrategy(repaymentStrategy) //
.withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
@@ -103,6 +103,9 @@ public class SchedulerJobsTestResults {
private static final String TO_ACCOUNT_TYPE_SAVINGS = "2";
private static final String DATE_OF_JOINING = "01 January 2011";
private static final String TRANSACTION_DATE = "01 March 2013";
public static final String LOAN_APPROVAL_DATE = "01 March 2013";
public static final String LOAN_APPROVAL_DATE_PLUS_ONE = "02 March 2013";
public static final String LOAN_DISBURSAL_DATE = "01 March 2013";
private static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
private static final String MINIMUM_OPENING_BALANCE = "1000";
private static final Float SP_BALANCE = Float.valueOf(MINIMUM_OPENING_BALANCE);
@@ -263,14 +266,13 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProduct(null);
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), savingsId.toString(),
"10 January 2013");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), savingsId.toString(), "1 March 2013");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_APPROVAL_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
Integer specifiedDueDateChargeId = ChargesHelper.createCharges(requestSpec, responseSpec,
@@ -283,7 +285,7 @@ public class SchedulerJobsTestResults {
Assertions.assertEquals(1, chargesPendingState.size());
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID,
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
@@ -315,17 +317,17 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProduct(null);
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "01 January 2013");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "01 March 2013");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_APPROVAL_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID,
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -656,17 +658,17 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProduct(null);
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2013");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2013");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanStatusHashMap = loanTransactionHelper.approveLoan(LOAN_APPROVAL_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID,
loanStatusHashMap = loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -786,7 +788,7 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
@@ -832,7 +834,7 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProductNoInterest(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplicationNoInterest(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplicationNoInterest(clientID.toString(), loanProductID.toString(), null, "01 March 2020");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
@@ -883,7 +885,7 @@ public class SchedulerJobsTestResults {
List<Integer> loanIDs = new ArrayList<>();
HashMap loanStatusHashMap;
for (int i = 0; i < 3; i++) {
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -946,7 +948,7 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProductWithPeriodicAccrual(null);
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 June 2020");
Assertions.assertNotNull(loanID);
@@ -1011,7 +1013,7 @@ public class SchedulerJobsTestResults {
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 July 2020");
Assertions.assertNotNull(loanID);
@@ -1068,7 +1070,7 @@ public class SchedulerJobsTestResults {
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2019");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2019");
Assertions.assertNotNull(loanID);
@@ -1129,7 +1131,7 @@ public class SchedulerJobsTestResults {
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
// Test penalty where there is 1 day grace period
final Integer loanID2 = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID2 = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 April 2020");
Assertions.assertNotNull(loanID2);
@@ -1186,18 +1188,18 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2013");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2013");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_APPROVAL_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE,
loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_APPROVAL_DATE_PLUS_ONE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
String JobName = "Apply penalty to overdue loans";
@@ -1238,18 +1240,18 @@ public class SchedulerJobsTestResults {
final Integer loanProductID = createLoanProduct(null);
Assertions.assertNotNull(loanProductID);
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2013");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2013");
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID);
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_APPROVAL_DATE, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE,
loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_APPROVAL_DATE_PLUS_ONE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final Boolean isNPABefore = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA");
@@ -128,26 +128,35 @@ public class CobPartitioningTest {
// Let's create 1, 2, ..., N-1, N loans
final CountDownLatch createLatch = new CountDownLatch(N);
Integer loanProductID = createLoanProduct();
List<Future<?>> futures = new ArrayList<>();
for (int i = 0; i < N; i++) {
Future<?> unused = executorService.submit(() -> {
futures.add(executorService.submit(() -> {
Integer clientID = createClient();
Integer loanID = createLoanForClient(clientID, loanProductID);
loanIds.add(loanID);
createLatch.countDown();
});
}));
}
createLatch.await();
waitForFutures(futures, createLatch);
futures.clear();
// Force close loans 3, 4, ... , N-3, N-2
Collections.sort(loanIds);
final CountDownLatch closeLatch = new CountDownLatch(N - 4);
for (int i = 2; i < N - 2; i++) {
final int idx = i;
Future<?> unused = executorService.submit(() -> {
futures.add(executorService.submit(() -> {
LOAN_TRANSACTION_HELPER.forecloseLoan("02 March 2020", loanIds.get(idx));
closeLatch.countDown();
});
}));
}
futures.forEach(future -> {
try {
future.get(); // turn any possible async failures into errors
} catch (Exception e) {
throw new RuntimeException(e);
}
});
closeLatch.await();
// Let's retrieve the partitions
@@ -171,6 +180,17 @@ public class CobPartitioningTest {
}
}
private static void waitForFutures(List<Future<?>> futures, CountDownLatch createLatch) throws InterruptedException {
futures.forEach(future -> {
try {
future.get(); // turn any possible async failures into errors
} catch (Exception e) {
throw new RuntimeException(e);
}
});
createLatch.await();
}
private void setInitialBusinessDate(String date) {
GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.TRUE);
BusinessDateHelper.updateBusinessDate(REQUEST_SPEC, RESPONSE_SPEC, BUSINESS_DATE, LocalDate.parse(date));
@@ -210,7 +230,7 @@ public class CobPartitioningTest {
HashMap loanStatusHashMap;
Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), "10 January 2020");
Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -680,7 +680,7 @@ public final class BatchHelper {
br.setMethod("POST");
String dateString = date.format(DateTimeFormatter.ofPattern("dd MMMM yyyy"));
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"approvedOnDate\": \"" + dateString + "\","
+ "\"note\": \"Loan approval note\"}");
+ "\"note\": \"Loan approval note\", \"expectedDisbursementDate\": \"" + dateString + "\"}");
return br;
}
@@ -756,7 +756,7 @@ public final class BatchHelper {
* the action to transistion
* @return BatchRequest the batch request
*/
public static BatchRequest transistionLoanStateByExternalId(final Long requestId, final Long reference, final LocalDate date,
public static BatchRequest transitionLoanStateByExternalId(final Long requestId, final Long reference, final LocalDate date,
final String command) {
final BatchRequest br = new BatchRequest();
@@ -769,7 +769,7 @@ public final class BatchHelper {
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"actualDisbursementDate\": \"" + dateString + "\"}");
} else if ("approve".equals(command)) {
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"approvedOnDate\": \"" + dateString + "\","
+ "\"note\": \"Loan approval note\"}");
+ "\"note\": \"Loan approval note\", \"expectedDisbursementDate\": \"" + dateString + "\"}");
}
return br;
@@ -105,7 +105,7 @@ public class InlineLoanCOBTest {
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -190,7 +190,7 @@ public class InlineLoanCOBTest {
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -260,7 +260,7 @@ public class InlineLoanCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -318,7 +318,7 @@ public class InlineLoanCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -375,7 +375,7 @@ public class InlineLoanCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -442,7 +442,7 @@ public class InlineLoanCOBTest {
final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString());
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "10 January 2020");
final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null, "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -307,7 +307,7 @@ public class ExternalAssetOwnerTransferCancelTest {
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), "10 January 2020");
Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), "1 March 2020");
Assertions.assertNotNull(loanID);
@@ -1012,7 +1012,7 @@ public class InitiateExternalAssetOwnerTransferTest {
Assertions.assertNotNull(loanProductID);
HashMap loanStatusHashMap;
Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), "10 January 2020");
Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), "1 March 2020");
Assertions.assertNotNull(loanID);