FINERACT-2317: added e2e test for update available disbursement amount
This commit is contained in:
committed by
Adam Saghy
parent
1c82507707
commit
514a684281
+8
@@ -1006,6 +1006,14 @@ public final class ErrorMessageHelper {
|
||||
return "The parameter `amount` must be greater than 0.";
|
||||
}
|
||||
|
||||
public static String updateAvailableDisbursementLoanExceedPrincipalFailure() {
|
||||
return "Failed data validation due to: can't.be.greater.than.maximum.available.disbursement.amount.calculation.";
|
||||
}
|
||||
|
||||
public static String updateAvailableDisbursementLoanLessMinAllowedAmountFailure() {
|
||||
return "The parameter `amount` must be greater than or equal to 0.";
|
||||
}
|
||||
|
||||
public static String wrongValueInLineInBuyDownFeeTab(String resourceId, int line, List<List<String>> actualList,
|
||||
List<String> expected) {
|
||||
String actual = actualList.stream().map(Object::toString).collect(Collectors.joining(System.lineSeparator()));
|
||||
|
||||
+88
@@ -104,6 +104,8 @@ import org.apache.fineract.client.models.PutLoanProductsProductIdRequest;
|
||||
import org.apache.fineract.client.models.PutLoanProductsProductIdResponse;
|
||||
import org.apache.fineract.client.models.PutLoansApprovedAmountRequest;
|
||||
import org.apache.fineract.client.models.PutLoansApprovedAmountResponse;
|
||||
import org.apache.fineract.client.models.PutLoansAvailableDisbursementAmountRequest;
|
||||
import org.apache.fineract.client.models.PutLoansAvailableDisbursementAmountResponse;
|
||||
import org.apache.fineract.client.models.PutLoansLoanIdRequest;
|
||||
import org.apache.fineract.client.models.PutLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.services.BusinessDateManagementApi;
|
||||
@@ -5311,6 +5313,92 @@ public class LoanStepDef extends AbstractStepDef {
|
||||
assertThat(developerMessage).isEqualTo(ErrorMessageHelper.updateApprovedLoanLessMinAllowedAmountFailure());
|
||||
}
|
||||
|
||||
@Then("Update loan available disbursement amount with new amount {string} value")
|
||||
public void updateLoanAvailableDisbursementAmount(final String amount) throws IOException {
|
||||
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
final long loanId = loanResponse.body().getLoanId();
|
||||
final Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
|
||||
final PutLoansAvailableDisbursementAmountRequest modifyLoanAvailableDisbursementAmountRequest = new PutLoansAvailableDisbursementAmountRequest()
|
||||
.locale(LOCALE_EN).amount(new BigDecimal(amount));
|
||||
|
||||
final Response<PutLoansAvailableDisbursementAmountResponse> modifyLoanAvailableDisbursementAmountResponse = loansApi
|
||||
.modifyLoanAvailableDisbursementAmount(loanId, modifyLoanAvailableDisbursementAmountRequest).execute();
|
||||
|
||||
ErrorHelper.checkSuccessfulApiCall(modifyLoanAvailableDisbursementAmountResponse);
|
||||
}
|
||||
|
||||
@Then("Update loan available disbursement amount by external-id with new amount {string} value")
|
||||
public void updateLoanAvailableDisbursementAmountByExternalId(final String amount) throws IOException {
|
||||
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
final long loanId = loanResponse.body().getLoanId();
|
||||
final String externalId = loanResponse.body().getResourceExternalId();
|
||||
final Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
|
||||
final PutLoansAvailableDisbursementAmountRequest modifyLoanAvailableDisbursementAmountRequest = new PutLoansAvailableDisbursementAmountRequest()
|
||||
.locale(LOCALE_EN).amount(new BigDecimal(amount));
|
||||
|
||||
final Response<PutLoansAvailableDisbursementAmountResponse> modifyLoanAvailableDisbursementAmountResponse = loansApi
|
||||
.modifyLoanAvailableDisbursementAmount1(externalId, modifyLoanAvailableDisbursementAmountRequest).execute();
|
||||
|
||||
ErrorHelper.checkSuccessfulApiCall(modifyLoanAvailableDisbursementAmountResponse);
|
||||
}
|
||||
|
||||
@Then("Update loan available disbursement amount is forbidden with amount {string} due to exceed applied amount")
|
||||
public void updateLoanAvailableDisbursementAmountForbiddenExceedAppliedAmount(final String amount) throws IOException {
|
||||
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
final long loanId = loanResponse.body().getLoanId();
|
||||
final String externalId = loanResponse.body().getResourceExternalId();
|
||||
final Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
|
||||
final PutLoansAvailableDisbursementAmountRequest modifyLoanAvailableDisbursementAmountRequest = new PutLoansAvailableDisbursementAmountRequest()
|
||||
.locale(LOCALE_EN).amount(new BigDecimal(amount));
|
||||
|
||||
final Response<PutLoansAvailableDisbursementAmountResponse> modifyLoanAvailableDisbursementAmountResponse = loansApi
|
||||
.modifyLoanAvailableDisbursementAmount1(externalId, modifyLoanAvailableDisbursementAmountRequest).execute();
|
||||
|
||||
ErrorResponse errorDetails = ErrorResponse.from(modifyLoanAvailableDisbursementAmountResponse);
|
||||
assertThat(errorDetails.getHttpStatusCode()).isEqualTo(403);
|
||||
|
||||
Object errorArgs = errorDetails.getErrors().getFirst().getArgs().getFirst().getValue();
|
||||
String developerMessage;
|
||||
if (errorArgs instanceof Map errorArgsMap) {
|
||||
developerMessage = (String) errorArgsMap.get("developerMessage");
|
||||
} else {
|
||||
developerMessage = errorDetails.getDeveloperMessage();
|
||||
}
|
||||
assertThat(developerMessage).isEqualTo(ErrorMessageHelper.updateAvailableDisbursementLoanExceedPrincipalFailure());
|
||||
}
|
||||
|
||||
@Then("Update loan available disbursement amount is forbidden with amount {string} due to min allowed amount")
|
||||
public void updateLoanAvailableDisbursementAmountForbiddenMinAllowedAmount(final String amount) throws IOException {
|
||||
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
final long loanId = loanResponse.body().getLoanId();
|
||||
final Response<GetLoansLoanIdResponse> loanDetailsResponse = loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
|
||||
ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
|
||||
|
||||
final PutLoansAvailableDisbursementAmountRequest modifyLoanAvailableDisbursementAmountRequest = new PutLoansAvailableDisbursementAmountRequest()
|
||||
.locale(LOCALE_EN).amount(new BigDecimal(amount));
|
||||
|
||||
final Response<PutLoansAvailableDisbursementAmountResponse> modifyLoanAvailableDisbursementAmountResponse = loansApi
|
||||
.modifyLoanAvailableDisbursementAmount(loanId, modifyLoanAvailableDisbursementAmountRequest).execute();
|
||||
|
||||
ErrorResponse errorDetails = ErrorResponse.from(modifyLoanAvailableDisbursementAmountResponse);
|
||||
assertThat(errorDetails.getHttpStatusCode()).isEqualTo(403);
|
||||
|
||||
Object errorArgs = errorDetails.getErrors().getFirst().getArgs().getFirst().getValue();
|
||||
String developerMessage;
|
||||
if (errorArgs instanceof Map errorArgsMap) {
|
||||
developerMessage = (String) errorArgsMap.get("developerMessage");
|
||||
} else {
|
||||
developerMessage = errorDetails.getDeveloperMessage();
|
||||
}
|
||||
assertThat(developerMessage).isEqualTo(ErrorMessageHelper.updateAvailableDisbursementLoanLessMinAllowedAmountFailure());
|
||||
}
|
||||
|
||||
private Response<PostLoansLoanIdTransactionsResponse> addInterestRefundTransaction(final double amount, final Long transactionId)
|
||||
throws IOException {
|
||||
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
|
||||
|
||||
Reference in New Issue
Block a user