FINERACT-2413: added e2e test for handling multiple re-amortization on the loan

This commit is contained in:
Rustam Zeinalov
2026-02-02 18:59:07 +01:00
committed by Adam Saghy
parent 2ee19f9825
commit 007187111d
3 changed files with 161 additions and 3 deletions
@@ -994,4 +994,8 @@ public final class ErrorMessageHelper {
public static String reAmortizeClosedLoanFailure() {
return "Loan re-amortization can only be done on active loans";
}
public static String reAmortizeSameDateFailure() {
return "Validation errors: [id] Loan reamortization can only be done once a day. There has already been a reamortization done for today";
}
}
@@ -70,6 +70,18 @@ public class LoanReAmortizationStepDef extends AbstractStepDef {
testContext().set(TestContextKey.LOAN_REAMORTIZATION_RESPONSE, response);
}
@When("Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling {string} should FAIL")
public void createLoanReAmortizationWithInterestHandlingShouldFail(final String reAmortizationInterestHandling) {
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
final Long loanId = loanResponse.getLoanId();
final PostLoansLoanIdTransactionsRequest reAmortizationRequest = LoanRequestFactory.defaultLoanReAmortizationRequest()
.reAmortizationInterestHandling(reAmortizationInterestHandling);
fail(() -> fineractClient.loanTransactions().executeLoanTransaction(loanId, reAmortizationRequest,
Map.of("command", "reAmortize")));
}
@When("Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling {string}")
public void createLoanReAmortizationWithInterestHandling(final String reAmortizationInterestHandling) {
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
@@ -157,6 +169,11 @@ public class LoanReAmortizationStepDef extends AbstractStepDef {
reAmortizationFailure(ErrorMessageHelper.reAmortizeClosedLoanFailure());
}
@When("Admin creates a Loan re-amortization transaction on current business date is forbidden as re-amortization already done for today")
public void reAmortizationSameDateFailure() {
reAmortizationFailure(ErrorMessageHelper.reAmortizeSameDateFailure());
}
@When("Admin creates re-amortization trn on current business date with reAmortizationInterestHandling {string} is forbidden as loan was closed")
public void reAmortizationWithInterestHandlingClosedLoanFailure(final String reAmortizationInterestHandling) {
reAmortizationInterestHandlingLoanLoanFailure(reAmortizationInterestHandling, ErrorMessageHelper.reAmortizeClosedLoanFailure());