|
33 | 33 | import org.apache.fineract.client.services.LoanTransactionsApi; |
34 | 34 | import org.apache.fineract.test.factory.LoanRequestFactory; |
35 | 35 | import org.apache.fineract.test.helper.ErrorHelper; |
| 36 | +import org.apache.fineract.test.helper.ErrorMessageHelper; |
| 37 | +import org.apache.fineract.test.helper.ErrorResponse; |
36 | 38 | import org.apache.fineract.test.messaging.EventAssertion; |
37 | 39 | import org.apache.fineract.test.messaging.event.loan.LoanReAgeEvent; |
38 | 40 | import org.apache.fineract.test.stepdef.AbstractStepDef; |
@@ -146,4 +148,53 @@ public void adminFailsToCreateReAgingTransactionWithError(final String expectedE |
146 | 148 | ErrorHelper.checkFailedApiCall(response, 403); |
147 | 149 | } |
148 | 150 |
|
| 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 | + } |
149 | 200 | } |
0 commit comments