Skip to content

Commit 67e823f

Browse files
mariiaKraievskaadamsaghy
authored andcommitted
FINERACT-2354: Second step - charge-off edge case of re-aging for Interest bearing loans - Default Behavior, interestRecalculation = true, without dueDate change
1 parent 6386eb1 commit 67e823f

File tree

5 files changed

+338
-4
lines changed

5 files changed

+338
-4
lines changed

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/helper/ErrorMessageHelper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,4 +1072,12 @@ public static String wrongAvailableDisbursementAmountWithOverApplied(final doubl
10721072
"Wrong value in LoanDetails/availableDisbursementAmountWithOverApplied. %nActual value is: %s %nExpected Value is: %s",
10731073
actual, expected);
10741074
}
1075+
1076+
public static String reAgeChargedOffLoanFailure() {
1077+
return "Loan re-aging is not allowed on charged-off loan.";
1078+
}
1079+
1080+
public static String reAgeContractTerminatedLoanFailure() {
1081+
return "Loan re-aging is not allowed on contract terminated loan.";
1082+
}
10751083
}

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanReAgingStepDef.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.apache.fineract.client.services.LoanTransactionsApi;
3434
import org.apache.fineract.test.factory.LoanRequestFactory;
3535
import org.apache.fineract.test.helper.ErrorHelper;
36+
import org.apache.fineract.test.helper.ErrorMessageHelper;
37+
import org.apache.fineract.test.helper.ErrorResponse;
3638
import org.apache.fineract.test.messaging.EventAssertion;
3739
import org.apache.fineract.test.messaging.event.loan.LoanReAgeEvent;
3840
import org.apache.fineract.test.stepdef.AbstractStepDef;
@@ -146,4 +148,53 @@ public void adminFailsToCreateReAgingTransactionWithError(final String expectedE
146148
ErrorHelper.checkFailedApiCall(response, 403);
147149
}
148150

151+
@Then("Admin fails to create a Loan re-aging transaction with the following data because loan was charged-off:")
152+
public void reAgeChargedOffLoanFailure(final DataTable table) throws IOException {
153+
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
154+
assert loanResponse.body() != null;
155+
final long loanId = loanResponse.body().getLoanId();
156+
157+
final List<String> data = table.asLists().get(1);
158+
159+
final PostLoansLoanIdTransactionsRequest reAgingRequest = LoanRequestFactory//
160+
.defaultReAgingRequest()//
161+
.frequencyNumber(Integer.parseInt(data.get(0)))//
162+
.frequencyType(data.get(1))//
163+
.startDate(data.get(2))//
164+
.numberOfInstallments(Integer.parseInt(data.get(3)));//
165+
166+
final Response<PostLoansLoanIdTransactionsResponse> response = loanTransactionsApi
167+
.executeLoanTransaction(loanId, reAgingRequest, "reAge").execute();
168+
testContext().set(TestContextKey.LOAN_REAGING_RESPONSE, response);
169+
final ErrorResponse errorDetails = ErrorResponse.from(response);
170+
final String developerMessage = errorDetails.getSingleError().getDeveloperMessage();
171+
172+
assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.dateFailureErrorCodeMsg()).isEqualTo(403);
173+
assertThat(developerMessage).matches(ErrorMessageHelper.reAgeChargedOffLoanFailure());
174+
}
175+
176+
@Then("Admin fails to create a Loan re-aging transaction with the following data because loan was contract terminated:")
177+
public void reAgeContractTerminatedLoanFailure(final DataTable table) throws IOException {
178+
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
179+
assert loanResponse.body() != null;
180+
final long loanId = loanResponse.body().getLoanId();
181+
182+
final List<String> data = table.asLists().get(1);
183+
184+
final PostLoansLoanIdTransactionsRequest reAgingRequest = LoanRequestFactory//
185+
.defaultReAgingRequest()//
186+
.frequencyNumber(Integer.parseInt(data.get(0)))//
187+
.frequencyType(data.get(1))//
188+
.startDate(data.get(2))//
189+
.numberOfInstallments(Integer.parseInt(data.get(3)));//
190+
191+
final Response<PostLoansLoanIdTransactionsResponse> response = loanTransactionsApi
192+
.executeLoanTransaction(loanId, reAgingRequest, "reAge").execute();
193+
testContext().set(TestContextKey.LOAN_REAGING_RESPONSE, response);
194+
final ErrorResponse errorDetails = ErrorResponse.from(response);
195+
final String developerMessage = errorDetails.getSingleError().getDeveloperMessage();
196+
197+
assertThat(errorDetails.getHttpStatusCode()).as(ErrorMessageHelper.dateFailureErrorCodeMsg()).isEqualTo(403);
198+
assertThat(developerMessage).matches(ErrorMessageHelper.reAgeContractTerminatedLoanFailure());
199+
}
149200
}

0 commit comments

Comments
 (0)