1818 */
1919package org .apache .fineract .test .stepdef .loan ;
2020
21+ import static org .apache .fineract .client .feign .util .FeignCalls .fail ;
2122import static org .apache .fineract .client .feign .util .FeignCalls .ok ;
2223import static org .assertj .core .api .Assertions .assertThat ;
2324
2930import lombok .RequiredArgsConstructor ;
3031import lombok .extern .slf4j .Slf4j ;
3132import org .apache .fineract .client .feign .FineractFeignClient ;
33+ import org .apache .fineract .client .feign .util .CallFailedRuntimeException ;
3234import org .apache .fineract .client .models .PostWorkingCapitalLoansResponse ;
3335import org .apache .fineract .client .models .WorkingCapitalLoanBreachScheduleData ;
36+ import org .apache .fineract .test .helper .ErrorMessageHelper ;
3437import org .apache .fineract .test .stepdef .AbstractStepDef ;
3538import 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