Skip to content

Commit a119483

Browse files
ruzeynalovoleksii-novikov-onix
authored andcommitted
FINERACT-2455: Added e2e tests for validating working capital breach schedule
1 parent 8170564 commit a119483

3 files changed

Lines changed: 276 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,12 @@ public static String wrongErrorCode(Integer actual, Integer expected) {
662662
actual.toString(), expected.toString());
663663
}
664664

665+
public static String wrongStatusCodeInBreachScheduleRetrieval(Integer actual, Integer expected, Long loanId) {
666+
return String.format(
667+
"Not the expected HTTP status code for GET breach-schedule on loanId %d: Actual code is: %s. Expected code is: %s", loanId,
668+
actual.toString(), expected.toString());
669+
}
670+
665671
public static String idNull() {
666672
return "The requested ID is null";
667673
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.fineract.test.stepdef.loan;
2020

21+
import static org.apache.fineract.client.feign.util.FeignCalls.fail;
2122
import static org.apache.fineract.client.feign.util.FeignCalls.ok;
2223
import static org.assertj.core.api.Assertions.assertThat;
2324

@@ -29,8 +30,10 @@
2930
import lombok.RequiredArgsConstructor;
3031
import lombok.extern.slf4j.Slf4j;
3132
import org.apache.fineract.client.feign.FineractFeignClient;
33+
import org.apache.fineract.client.feign.util.CallFailedRuntimeException;
3234
import org.apache.fineract.client.models.PostWorkingCapitalLoansResponse;
3335
import org.apache.fineract.client.models.WorkingCapitalLoanBreachScheduleData;
36+
import org.apache.fineract.test.helper.ErrorMessageHelper;
3437
import org.apache.fineract.test.stepdef.AbstractStepDef;
3538
import org.apache.fineract.test.support.TestContextKey;
3639

@@ -50,6 +53,28 @@ public void verifyBreachScheduleIsEmpty() {
5053
log.info("Verified that loan {} has no breach schedule", loanId);
5154
}
5255

56+
@Then("Working Capital loan breach schedule has {int} period(s)")
57+
public void verifyBreachScheduleSize(final int expectedSize) {
58+
final Long loanId = extractLoanId();
59+
final List<WorkingCapitalLoanBreachScheduleData> schedule = retrieveBreachSchedule(loanId);
60+
61+
assertThat(schedule).as("Breach schedule size for loan %d", loanId).hasSize(expectedSize);
62+
63+
log.info("Verified that loan {} has {} breach schedule period(s)", loanId, expectedSize);
64+
}
65+
66+
@Then("Retrieving Working Capital loan breach schedule for non-existent loanId {long} fails with status code {int}")
67+
public void verifyBreachScheduleNotFound(final long loanId, final int expectedStatus) {
68+
final CallFailedRuntimeException exception = fail(
69+
() -> fineractClient.workingCapitalLoanBreachSchedule().retrieveBreachSchedule(loanId));
70+
71+
assertThat(exception.getStatus())
72+
.as(ErrorMessageHelper.wrongStatusCodeInBreachScheduleRetrieval(exception.getStatus(), expectedStatus, loanId))
73+
.isEqualTo(expectedStatus);
74+
75+
log.info("Verified that GET breach schedule for loanId {} fails with status {}", loanId, expectedStatus);
76+
}
77+
5378
@Then("Working Capital loan breach schedule has the following data:")
5479
public void verifyBreachSchedule(final DataTable dataTable) {
5580
final Long loanId = extractLoanId();

0 commit comments

Comments
 (0)