FINERACT-2081: fix disburse error scenario
This commit is contained in:
committed by
Adam Saghy
parent
bd19f28cb6
commit
ec1c55d022
+4
@@ -66,6 +66,10 @@ public final class ErrorMessageHelper {
|
||||
return "Loan disbursal amount can't be greater than maximum applied loan amount calculation. Total disbursed amount: [0-9]* Maximum disbursal amount: [0-9]*";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static String loanSubmitDateInFutureFailureMsg() {
|
||||
return "The date on which a loan is submitted cannot be in the future.";
|
||||
}
|
||||
|
||||
+17
@@ -1892,6 +1892,23 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
assertThat(fixedLengthactual).as(ErrorMessageHelper.wrongfixedLength(fixedLengthactual, fieldValue)).isEqualTo(fieldValue);
|
||||
}
|
||||
|
||||
@Then("Admin fails to disburse the loan on {string} with {string} EUR transaction amount because disbursement date is earlier than {string}")
|
||||
public void disburseLoanFailureWithPastDate(String actualDisbursementDate, String transactionAmount, String futureApproveDate)
|
||||
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));
|
||||
|
||||
String futureApproveDateISO = FORMATTER_EVENTS.format(FORMATTER.parse(futureApproveDate));
|
||||
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.dateFailureErrorCodeMsg()).isEqualTo(403);
|
||||
assertThat(errorDetails.getSingleError().getDeveloperMessage())
|
||||
.isEqualTo(ErrorMessageHelper.disbursePastDateFailure((int) loanId, futureApproveDateISO));
|
||||
}
|
||||
|
||||
private LoanStatusEnumDataV1 getExpectedStatus(String loanStatus) {
|
||||
LoanStatusEnumDataV1 result = new LoanStatusEnumDataV1();
|
||||
switch (loanStatus) {
|
||||
|
||||
Reference in New Issue
Block a user