Merge pull request #4042 from alberto-art3ch/enhancement/loan_account_mandatory_parameters
FINERACT-2081: Validation error in mandatory loan account parameters
This commit is contained in:
+2
-3
@@ -160,7 +160,7 @@ public class LoanApplicationApprovalTest {
|
||||
log.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}",
|
||||
loanProductId);
|
||||
|
||||
loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode400);
|
||||
loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal("1000").withLoanTermFrequency("1")
|
||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("1").withRepaymentEveryAfter("1")
|
||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("0").withInterestTypeAsFlatBalance()
|
||||
@@ -169,8 +169,7 @@ public class LoanApplicationApprovalTest {
|
||||
.withRepaymentStrategy(AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY)
|
||||
.build(clientId.toString(), loanProductId.toString(), null);
|
||||
List<HashMap> error = (List<HashMap>) loanTransactionHelper.createLoanAccount(loanApplicationJSON, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals(
|
||||
"validation.msg.loan.transactionProcessingStrategyCode.strategy.cannot.be.advanced.payment.allocation.if.not.configured",
|
||||
assertEquals("strategy.cannot.be.advanced.payment.allocation.if.not.configured",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
+90
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.fineract.integrationtests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
import io.restassured.http.ContentType;
|
||||
@@ -172,6 +174,94 @@ public class LoanOriginationValidationTest extends BaseLoanIntegrationTest {
|
||||
});
|
||||
}
|
||||
|
||||
// uc3: Negative Test: Loan application without required parameters
|
||||
// 1. Create a Loan product
|
||||
// 2. Submit Loan application without required parameters
|
||||
@Test
|
||||
public void uc3() {
|
||||
String operationDate = "15 August 2024";
|
||||
runAt(operationDate, () -> {
|
||||
|
||||
LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
PostLoanProductsResponse loanProductResponse = loanProductHelper
|
||||
.createLoanProduct(createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
|
||||
.loanScheduleType(LoanScheduleType.PROGRESSIVE.toString()));
|
||||
// Product Id null
|
||||
final PostLoansRequest applicationRequest01 = applyLoanRequest(client.getClientId(), null, operationDate, 100.0, 5)
|
||||
.numberOfRepayments(6)//
|
||||
.loanTermFrequency(6)//
|
||||
.loanTermFrequencyType(2)//
|
||||
.repaymentEvery(1)//
|
||||
.repaymentFrequencyType(2)//
|
||||
;//
|
||||
CallFailedRuntimeException callFailedRuntimeException = Assertions.assertThrows(CallFailedRuntimeException.class,
|
||||
() -> loanTransactionHelper.applyLoan(applicationRequest01));
|
||||
assertEquals(400, callFailedRuntimeException.getResponse().code());
|
||||
Assertions.assertTrue(callFailedRuntimeException.getMessage().contains("The parameter `productId` is mandatory."));
|
||||
|
||||
// Transaction Processing Strategy Code null
|
||||
final PostLoansRequest applicationRequest02 = applyLoanRequest(client.getClientId(), loanProductResponse.getResourceId(),
|
||||
operationDate, 100.0, 5).numberOfRepayments(6)//
|
||||
.loanTermFrequency(6)//
|
||||
.loanTermFrequencyType(2)//
|
||||
.transactionProcessingStrategyCode(null)//
|
||||
.repaymentEvery(1)//
|
||||
.repaymentFrequencyType(2)//
|
||||
;//
|
||||
|
||||
callFailedRuntimeException = Assertions.assertThrows(CallFailedRuntimeException.class,
|
||||
() -> loanTransactionHelper.applyLoan(applicationRequest02));
|
||||
assertEquals(400, callFailedRuntimeException.getResponse().code());
|
||||
Assertions.assertTrue(
|
||||
callFailedRuntimeException.getMessage().contains("The parameter `transactionProcessingStrategyCode` is mandatory."));
|
||||
|
||||
final PostLoansRequest applicationRequest03 = applyLoanRequest(null, loanProductResponse.getResourceId(), operationDate, 100.0,
|
||||
5).numberOfRepayments(6)//
|
||||
.loanTermFrequency(6)//
|
||||
.loanTermFrequencyType(2)//
|
||||
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY)//
|
||||
.repaymentEvery(1)//
|
||||
.repaymentFrequencyType(2)//
|
||||
;//
|
||||
callFailedRuntimeException = Assertions.assertThrows(CallFailedRuntimeException.class,
|
||||
() -> loanTransactionHelper.applyLoan(applicationRequest03));
|
||||
LOG.info("DETAIL: {}", callFailedRuntimeException.getMessage());
|
||||
assertEquals(400, callFailedRuntimeException.getResponse().code());
|
||||
Assertions.assertTrue(callFailedRuntimeException.getMessage().contains("The parameter `clientId` is mandatory."));
|
||||
|
||||
// Submitted Date null
|
||||
final PostLoansRequest applicationRequest04 = applyLoanRequest(client.getClientId(), loanProductResponse.getResourceId(),
|
||||
operationDate, 100.0, 5).numberOfRepayments(6)//
|
||||
.submittedOnDate(null) //
|
||||
.loanTermFrequency(6)//
|
||||
.loanTermFrequencyType(2)//
|
||||
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY)//
|
||||
.repaymentEvery(1)//
|
||||
.repaymentFrequencyType(2)//
|
||||
;//
|
||||
callFailedRuntimeException = Assertions.assertThrows(CallFailedRuntimeException.class,
|
||||
() -> loanTransactionHelper.applyLoan(applicationRequest04));
|
||||
assertEquals(400, callFailedRuntimeException.getResponse().code());
|
||||
Assertions.assertTrue(callFailedRuntimeException.getMessage().contains("The parameter `submittedOnDate` is mandatory."));
|
||||
|
||||
// Expected disbursement Date null
|
||||
final PostLoansRequest applicationRequest05 = applyLoanRequest(client.getClientId(), loanProductResponse.getResourceId(),
|
||||
operationDate, 100.0, 5).numberOfRepayments(6)//
|
||||
.expectedDisbursementDate(null) //
|
||||
.loanTermFrequency(6)//
|
||||
.loanTermFrequencyType(2)//
|
||||
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY)//
|
||||
.repaymentEvery(1)//
|
||||
.repaymentFrequencyType(2)//
|
||||
;//
|
||||
callFailedRuntimeException = Assertions.assertThrows(CallFailedRuntimeException.class,
|
||||
() -> loanTransactionHelper.applyLoan(applicationRequest05));
|
||||
assertEquals(400, callFailedRuntimeException.getResponse().code());
|
||||
Assertions
|
||||
.assertTrue(callFailedRuntimeException.getMessage().contains("The parameter `expectedDisbursementDate` is mandatory."));
|
||||
});
|
||||
}
|
||||
|
||||
private static Integer createLoanProduct(final String principal, final String repaymentAfterEvery, final String numberOfRepayments,
|
||||
boolean downPaymentEnabled, String downPaymentPercentage, boolean autoPayForDownPayment, LoanScheduleType loanScheduleType,
|
||||
LoanScheduleProcessingType loanScheduleProcessingType, final Account... accounts) {
|
||||
|
||||
Reference in New Issue
Block a user