DeathGun44 commented on code in PR #6005:
URL: https://github.com/apache/fineract/pull/6005#discussion_r3454331763


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/FixedLengthLoanProductIntegrationTest.java:
##########
@@ -18,107 +18,121 @@
  */
 package org.apache.fineract.integrationtests;
 
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.builder.ResponseSpecBuilder;
+import io.restassured.http.ContentType;
+import io.restassured.specification.RequestSpecification;
+import io.restassured.specification.ResponseSpecification;
 import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
 import org.apache.fineract.client.models.GetLoansLoanIdResponse;
 import org.apache.fineract.client.models.PostLoanProductsRequest;
-import org.apache.fineract.client.models.PostLoanProductsResponse;
 import org.apache.fineract.client.models.PostLoansRequest;
-import org.apache.fineract.client.models.PostLoansResponse;
 import org.apache.fineract.client.models.PutLoanProductsProductIdRequest;
 import org.apache.fineract.client.models.PutLoanProductsProductIdResponse;
-import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.Utils;
 import 
org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
 import 
org.apache.fineract.portfolio.loanaccount.domain.transactionprocessor.impl.AdvancedPaymentScheduleTransactionProcessor;
-import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleProcessingType;
-import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-public class FixedLengthLoanProductIntegrationTest extends 
BaseLoanIntegrationTest {
+public class FixedLengthLoanProductIntegrationTest extends FeignLoanTestBase {
 
     @Test
     public void testCreateReadUpdateReadLoanProductWithFixedLength() {
         // create with 4
         PostLoanProductsRequest loanProductsRequest = 
fixedLengthLoanProduct(4);
-        PostLoanProductsResponse loanProduct = 
loanProductHelper.createLoanProduct(loanProductsRequest);
-        Assertions.assertNotNull(loanProduct.getResourceId());
+        Long loanProductId = createLoanProduct(loanProductsRequest);
+        Assertions.assertNotNull(loanProductId);
 
         // read
-        GetLoanProductsProductIdResponse getLoanProductsProductIdResponse = 
loanProductHelper
-                .retrieveLoanProductById(loanProduct.getResourceId());
+        GetLoanProductsProductIdResponse getLoanProductsProductIdResponse = 
retrieveLoanProduct(loanProductId);
         Assertions.assertEquals(4, 
getLoanProductsProductIdResponse.getFixedLength());
 
         // update to 5
         PutLoanProductsProductIdRequest updateRequest = new 
PutLoanProductsProductIdRequest().fixedLength(5).locale("en");
-        PutLoanProductsProductIdResponse putLoanProductsProductIdResponse = 
loanProductHelper
-                .updateLoanProductById(loanProduct.getResourceId(), 
updateRequest);
+        PutLoanProductsProductIdResponse putLoanProductsProductIdResponse = 
updateLoanProduct(loanProductId, updateRequest);
         
Assertions.assertNotNull(putLoanProductsProductIdResponse.getResourceId());
 
         // read again
-        getLoanProductsProductIdResponse = 
loanProductHelper.retrieveLoanProductById(loanProduct.getResourceId());
+        getLoanProductsProductIdResponse = retrieveLoanProduct(loanProductId);
         Assertions.assertEquals(5, 
getLoanProductsProductIdResponse.getFixedLength());
 
-        // update to null
-        
loanTransactionHelper.updateLoanProduct(putLoanProductsProductIdResponse.getResourceId(),
 """
+        // update to null (raw JSON required to send explicit null through 
NON_NULL ObjectMapper)
+        updateLoanProduct(loanProductId, """
                 {
                     "fixedLength": null,
                     "locale": "en"
                 }
                 """);
 
         // read again
-        getLoanProductsProductIdResponse = 
loanProductHelper.retrieveLoanProductById(loanProduct.getResourceId());
+        getLoanProductsProductIdResponse = retrieveLoanProduct(loanProductId);
         
Assertions.assertNull(getLoanProductsProductIdResponse.getFixedLength());
     }
 
     @Test
     public void testLoanApplicationWithFixedLengthInheritedFromLoanProduct() {
         runAt("01 January 2023", () -> {
-            Long clientId = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+            Long clientId = createClient();
 
-            PostLoanProductsResponse loanProduct = 
loanProductHelper.createLoanProduct(fixedLengthLoanProduct(4));
-            Assertions.assertNotNull(loanProduct.getResourceId());
+            Long loanProductId = createLoanProduct(fixedLengthLoanProduct(4));
+            Assertions.assertNotNull(loanProductId);
 
-            PostLoansRequest applicationRequest = applyLoanRequest(clientId, 
loanProduct.getResourceId(), "01 January 2023", 1000.0, 4);
+            PostLoansRequest applicationRequest = applyLoanRequest(clientId, 
loanProductId, "01 January 2023", 1000.0, 4);
             applicationRequest = applicationRequest
                     
.transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY);
 
-            PostLoansResponse loanResponse = 
loanTransactionHelper.applyLoan(applicationRequest);
-            Long loanId = loanResponse.getLoanId();
+            Long loanId = applyForLoan(applicationRequest);
 
-            GetLoansLoanIdResponse loanDetails = 
loanTransactionHelper.getLoanDetails(loanId);
+            GetLoansLoanIdResponse loanDetails = getLoanDetails(loanId);
             Assertions.assertEquals(4, loanDetails.getFixedLength());
         });
     }
 
     @Test
     public void 
testLoanApplicationWithFixedLengthOverriddenByLoanApplication() {
         runAt("01 January 2023", () -> {
-            Long clientId = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+            Long clientId = createClient();
 
-            PostLoanProductsResponse loanProduct = 
loanProductHelper.createLoanProduct(fixedLengthLoanProduct(4));
-            Assertions.assertNotNull(loanProduct.getResourceId());
+            Long loanProductId = createLoanProduct(fixedLengthLoanProduct(4));
+            Assertions.assertNotNull(loanProductId);
 
-            PostLoansRequest applicationRequest = applyLoanRequest(clientId, 
loanProduct.getResourceId(), "01 January 2023", 1000.0, 4);
+            PostLoansRequest applicationRequest = applyLoanRequest(clientId, 
loanProductId, "01 January 2023", 1000.0, 4);
             applicationRequest = 
applicationRequest.fixedLength(5).repaymentEvery(1).repaymentFrequencyType(2).loanTermFrequencyType(2)
                     
.loanTermFrequency(4).transactionProcessingStrategyCode(LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY);
 
-            PostLoansResponse loanResponse = 
loanTransactionHelper.applyLoan(applicationRequest);
-            Long loanId = loanResponse.getLoanId();
+            Long loanId = applyForLoan(applicationRequest);
 
-            GetLoansLoanIdResponse loanDetails = 
loanTransactionHelper.getLoanDetails(loanId);
+            GetLoansLoanIdResponse loanDetails = getLoanDetails(loanId);
             Assertions.assertEquals(5, loanDetails.getFixedLength());
         });
     }
 
     private PostLoanProductsRequest fixedLengthLoanProduct(Integer 
fixedLength) {
         return 
createOnePeriod30DaysLongNoInterestPeriodicAccrualProductWithAdvancedPaymentAllocation()
 //
                 .numberOfRepayments(4).repaymentEvery(1) //
-                
.repaymentFrequencyType(RepaymentFrequencyType.MONTHS.longValue()) //
-                .loanScheduleType(LoanScheduleType.PROGRESSIVE.toString()) //
+                
.repaymentFrequencyType(LoanTestData.RepaymentFrequencyType.MONTHS.longValue()) 
//
+                .loanScheduleType("PROGRESSIVE") //
                 
.transactionProcessingStrategyCode(AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY)
 //
-                
.loanScheduleProcessingType(LoanScheduleProcessingType.HORIZONTAL.name()) //
+                .loanScheduleProcessingType("HORIZONTAL") //
                 .interestRatePerPeriod(0.0).fixedLength(fixedLength);
     }
 
+    /**
+     * Updates a loan product using raw JSON. Required here because the global 
NON_NULL ObjectMapper prevents sending
+     * explicit null values through the typed Feign client.
+     */
+    private void updateLoanProduct(Long productId, String rawJsonBody) {

Review Comment:
   good point. I've replaced the REST-assured workaround with a 
FeignRawHttpHelper that uses java.net.HttpURLConnection directly and no 
REST-assured dependency at all now. this helper can also serve as a drop-in 
replacement for all remaining Utils.performServer* calls as we phase out 
REST-assured entirely.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to