154154import org .apache .fineract .test .messaging .store .EventStore ;
155155import org .apache .fineract .test .stepdef .AbstractStepDef ;
156156import org .apache .fineract .test .support .TestContextKey ;
157+ import org .assertj .core .api .SoftAssertions ;
157158import org .springframework .beans .factory .annotation .Autowired ;
158159import retrofit2 .Response ;
159160
@@ -4181,6 +4182,13 @@ public void checkPagination(Integer totalPagesExpected, Integer size, String exc
41814182
41824183 @ Then ("Loan Product response contains interestRecognitionOnDisbursementDate flag with value {string}" )
41834184 public void verifyInterestRecognitionOnDisbursementDateFlag (final String expectedValue ) throws IOException {
4185+ GetLoanProductsResponse targetProduct = getLoanProductResponse ();
4186+
4187+ assertNotNull (targetProduct .getInterestRecognitionOnDisbursementDate ());
4188+ assertThat (targetProduct .getInterestRecognitionOnDisbursementDate ().toString ()).isEqualTo (expectedValue );
4189+ }
4190+
4191+ public GetLoanProductsResponse getLoanProductResponse () throws IOException {
41844192 final Response <PostLoansResponse > loanResponse = testContext ().get (TestContextKey .LOAN_CREATE_RESPONSE );
41854193 assertNotNull (loanResponse .body ());
41864194 final Long loanId = loanResponse .body ().getLoanId ();
@@ -4203,8 +4211,94 @@ public void verifyInterestRecognitionOnDisbursementDateFlag(final String expecte
42034211 return product .getId ().equals (targetLoanProductId );
42044212 }).findFirst ().orElseThrow (() -> new AssertionError ("Loan product with ID " + targetLoanProductId + " not found in response" ));
42054213
4206- assertNotNull (targetProduct .getInterestRecognitionOnDisbursementDate ());
4207- assertThat (targetProduct .getInterestRecognitionOnDisbursementDate ().toString ()).isEqualTo (expectedValue );
4214+ return targetProduct ;
4215+ }
4216+
4217+ @ Then ("Loan Product response contains Buy Down Fees flag {string} with data:" )
4218+ public void verifyLoanProductWithBuyDownFeesData (String expectedValue , DataTable table ) throws IOException {
4219+ GetLoanProductsResponse targetProduct = getLoanProductResponse ();
4220+
4221+ assertNotNull (targetProduct .getEnableBuyDownFee ());
4222+ assertThat (targetProduct .getEnableBuyDownFee ().toString ()).isEqualTo (expectedValue );
4223+
4224+ List <String > data = table .asLists ().get (1 ); // skip header
4225+ String buyDownFeeCalculationType = data .get (0 );
4226+ String buyDownFeeStrategy = data .get (1 );
4227+ String buyDownFeeIncomeType = data .get (2 );
4228+
4229+ assertNotNull (targetProduct .getBuyDownFeeCalculationType ());
4230+ assertNotNull (targetProduct .getBuyDownFeeStrategy ());
4231+ assertNotNull (targetProduct .getBuyDownFeeIncomeType ());
4232+
4233+ SoftAssertions assertions = new SoftAssertions ();
4234+ assertions .assertThat (buyDownFeeCalculationType ).isEqualTo (targetProduct .getBuyDownFeeCalculationType ().getValue ());
4235+ assertions .assertThat (buyDownFeeStrategy ).isEqualTo (targetProduct .getBuyDownFeeStrategy ().getValue ());
4236+ assertions .assertThat (buyDownFeeIncomeType ).isEqualTo (targetProduct .getBuyDownFeeIncomeType ().getValue ());
4237+ assertions .assertAll ();
4238+ }
4239+
4240+ @ Then ("Loan Product response contains Buy Down Fees flag {string}" )
4241+ public void verifyLoanProductWithBuyDownFeesFlag (String expectedValue ) throws IOException {
4242+ GetLoanProductsResponse targetProduct = getLoanProductResponse ();
4243+
4244+ assertNotNull (targetProduct .getEnableBuyDownFee ());
4245+ assertThat (targetProduct .getEnableBuyDownFee ().toString ()).isEqualTo (expectedValue );
4246+ }
4247+
4248+ public Response <GetLoansLoanIdResponse > getLoanDetailsResponse () throws IOException {
4249+ Response <PostLoansResponse > loanResponse = testContext ().get (TestContextKey .LOAN_CREATE_RESPONSE );
4250+
4251+ long loanId = loanResponse .body ().getLoanId ();
4252+
4253+ Optional <Response <GetLoansLoanIdResponse >> loanDetailsResponseOptional = Optional
4254+ .of (loansApi .retrieveLoan (loanId , false , "" , "" , "" ).execute ());
4255+ Response <GetLoansLoanIdResponse > loanDetailsResponse = loanDetailsResponseOptional
4256+ .orElseThrow (() -> new RuntimeException ("Failed to retrieve loan details - response is null" ));
4257+
4258+ ErrorHelper .checkSuccessfulApiCall (loanDetailsResponse );
4259+ testContext ().set (TestContextKey .LOAN_RESPONSE , loanDetailsResponse );
4260+ return loanDetailsResponse ;
4261+ }
4262+
4263+ @ Then ("Loan Details response contains Buy Down Fees flag {string} and data:" )
4264+ public void verifyBuyDownFeeDataInLoanResponse (final String expectedValue , DataTable table ) throws IOException {
4265+ Response <GetLoansLoanIdResponse > loanDetailsResponse = getLoanDetailsResponse ();
4266+
4267+ ErrorHelper .checkSuccessfulApiCall (loanDetailsResponse );
4268+ testContext ().set (TestContextKey .LOAN_RESPONSE , loanDetailsResponse );
4269+
4270+ GetLoansLoanIdResponse loanDetails = loanDetailsResponse .body ();
4271+
4272+ assertNotNull (loanDetails .getEnableBuyDownFee ());
4273+ assertThat (loanDetails .getEnableBuyDownFee ().toString ()).isEqualTo (expectedValue );
4274+
4275+ List <String > data = table .asLists ().get (1 ); // skip header
4276+ String buyDownFeeCalculationType = data .get (0 );
4277+ String buyDownFeeStrategy = data .get (1 );
4278+ String buyDownFeeIncomeType = data .get (2 );
4279+
4280+ assertNotNull (loanDetails .getBuyDownFeeCalculationType ());
4281+ assertNotNull (loanDetails .getBuyDownFeeStrategy ());
4282+ assertNotNull (loanDetails .getBuyDownFeeIncomeType ());
4283+
4284+ SoftAssertions assertions = new SoftAssertions ();
4285+ assertions .assertThat (buyDownFeeCalculationType ).isEqualTo (loanDetails .getBuyDownFeeCalculationType ().getValue ());
4286+ assertions .assertThat (buyDownFeeStrategy ).isEqualTo (loanDetails .getBuyDownFeeStrategy ().getValue ());
4287+ assertions .assertThat (buyDownFeeIncomeType ).isEqualTo (loanDetails .getBuyDownFeeIncomeType ().getValue ());
4288+ assertions .assertAll ();
4289+ }
4290+
4291+ @ Then ("Loan Details response contains Buy Down Fees flag {string}" )
4292+ public void verifyBuyDownFeeFlagInLoanResponse (final String expectedValue ) throws IOException {
4293+ Response <GetLoansLoanIdResponse > loanDetailsResponse = getLoanDetailsResponse ();
4294+
4295+ ErrorHelper .checkSuccessfulApiCall (loanDetailsResponse );
4296+ testContext ().set (TestContextKey .LOAN_RESPONSE , loanDetailsResponse );
4297+
4298+ GetLoansLoanIdResponse loanDetails = loanDetailsResponse .body ();
4299+
4300+ assertNotNull (loanDetails .getEnableBuyDownFee ());
4301+ assertThat (loanDetails .getEnableBuyDownFee ().toString ()).isEqualTo (expectedValue );
42084302 }
42094303
42104304 @ Then ("Loan Details response contains chargedOffOnDate set to {string}" )
@@ -4283,23 +4377,6 @@ public Response<PostLoansLoanIdTransactionsResponse> addCapitalizedIncomeToTheLo
42834377 return capitalizedIncomeResponse ;
42844378 }
42854379
4286- public Response <PostLoansLoanIdTransactionsResponse > addBuyDownFeeToTheLoanOnWithEURTransactionAmount (
4287- final String transactionPaymentType , final String transactionDate , final String amount ) throws IOException {
4288- final Response <PostLoansResponse > loanResponse = testContext ().get (TestContextKey .LOAN_CREATE_RESPONSE );
4289- final long loanId = loanResponse .body ().getLoanId ();
4290-
4291- final DefaultPaymentType paymentType = DefaultPaymentType .valueOf (transactionPaymentType );
4292- final Long paymentTypeValue = paymentTypeResolver .resolve (paymentType );
4293-
4294- final PostLoansLoanIdTransactionsRequest buyDownFeeRequest = LoanRequestFactory .defaultBuyDownFeeIncomeRequest ()
4295- .transactionDate (transactionDate ).transactionAmount (Double .valueOf (amount )).paymentTypeId (paymentTypeValue )
4296- .externalId ("EXT-BUY-DOWN-FEES" + UUID .randomUUID ());
4297-
4298- final Response <PostLoansLoanIdTransactionsResponse > buyDownFeeResponse = loanTransactionsApi
4299- .executeLoanTransaction (loanId , buyDownFeeRequest , "buyDownFee" ).execute ();
4300- return buyDownFeeResponse ;
4301- }
4302-
43034380 @ And ("Admin adds capitalized income with {string} payment type to the loan on {string} with {string} EUR transaction amount" )
43044381 public void adminAddsCapitalizedIncomeToTheLoanOnWithEURTransactionAmount (final String transactionPaymentType ,
43054382 final String transactionDate , final String amount ) throws IOException {
@@ -4309,15 +4386,6 @@ public void adminAddsCapitalizedIncomeToTheLoanOnWithEURTransactionAmount(final
43094386 ErrorHelper .checkSuccessfulApiCall (capitalizedIncomeResponse );
43104387 }
43114388
4312- @ And ("Admin adds buy down fee with {string} payment type to the loan on {string} with {string} EUR transaction amount" )
4313- public void adminAddsBuyDownFeesToTheLoanOnWithEURTransactionAmount (final String transactionPaymentType , final String transactionDate ,
4314- final String amount ) throws IOException {
4315- final Response <PostLoansLoanIdTransactionsResponse > buyDownFeesIncomeResponse = addBuyDownFeeToTheLoanOnWithEURTransactionAmount (
4316- transactionPaymentType , transactionDate , amount );
4317- testContext ().set (TestContextKey .LOAN_BUY_DOWN_FEE_RESPONSE , buyDownFeesIncomeResponse );
4318- ErrorHelper .checkSuccessfulApiCall (buyDownFeesIncomeResponse );
4319- }
4320-
43214389 public Response <PostLoansLoanIdTransactionsResponse > adjustCapitalizedIncome (final String transactionPaymentType ,
43224390 final String transactionDate , final String amount , final Long transactionId ) throws IOException {
43234391
0 commit comments