FINERACT-2181: added e2e automation tests for disbursement with Capitalized income amount calculation fix

This commit is contained in:
mdmytriv
2025-06-02 21:24:31 +02:00
committed by Arnold Gálovics
parent 19270b7651
commit 5f223e527e
3 changed files with 135 additions and 2 deletions
@@ -64,6 +64,10 @@ public final class ErrorMessageHelper {
return String.format("The date on which a loan with identifier : %s is disbursed cannot be in the future.", loanIdStr);
}
public static String addDisbursementExceedApprovedAmountFailure() {
return "Loan can't be disbursed,disburse amount is exceeding approved principal ";
}
public static String disbursePastDateFailure(Integer loanId, String actualDisbursementDate) {
return String.format("The date on which a loan is disbursed cannot be before its approval date: %s", actualDisbursementDate);
}
@@ -1661,6 +1661,21 @@ public class LoanStepDef extends AbstractStepDef {
.isEqualTo(ErrorMessageHelper.disbursePastDateFailure((int) loanId, futureApproveDateISO));
}
@Then("Admin fails to disburse the loan on {string} with {string} EUR transaction amount due to exceed approved amount")
public void disbursementForbiddenExceedApprovedAmount(String actualDisbursementDate, String transactionAmount) throws IOException {
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
long loanId = loanResponse.body().getLoanId();
PostLoansLoanIdRequest disburseRequest = LoanRequestFactory.defaultLoanDisburseRequest()
.actualDisbursementDate(actualDisbursementDate).transactionAmount(new BigDecimal(transactionAmount));
Response<PostLoansLoanIdResponse> loanDisburseResponse = loansApi.stateTransitions(loanId, disburseRequest, "disburse").execute();
testContext().set(TestContextKey.LOAN_DISBURSE_RESPONSE, loanDisburseResponse);
ErrorResponse errorDetails = ErrorResponse.from(loanDisburseResponse);
assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.addDisbursementExceedApprovedAmountFailure()).isEqualTo(403);
assertThat(errorDetails.getSingleError().getDeveloperMessage())
.isEqualTo(ErrorMessageHelper.addDisbursementExceedApprovedAmountFailure());
}
@And("Admin does charge-off the loan on {string}")
public void chargeOffLoan(String transactionDate) throws IOException {
Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);