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


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanChargePaymentWithAdvancedPaymentAllocationTest.java:
##########
@@ -20,195 +20,113 @@
 
 import static 
org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity.LIABILITY_TRANSFER;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
-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 java.math.BigDecimal;
 import java.time.LocalDate;
+import java.time.Month;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.client.feign.FineractFeignClient;
 import org.apache.fineract.client.models.AdvancedPaymentData;
-import org.apache.fineract.client.models.BusinessDateUpdateRequest;
+import 
org.apache.fineract.client.models.DeleteFinancialActivityAccountsResponse;
+import org.apache.fineract.client.models.GetFinancialActivityAccountsResponse;
 import org.apache.fineract.client.models.GetLoansLoanIdResponse;
-import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.PostFinancialActivityAccountsRequest;
+import org.apache.fineract.client.models.PostFinancialActivityAccountsResponse;
 import org.apache.fineract.client.models.PostLoansLoanIdRequest;
-import org.apache.fineract.client.models.PostLoansRequest;
-import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.models.PutGlobalConfigurationsRequest;
-import 
org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants;
-import org.apache.fineract.integrationtests.common.BusinessDateHelper;
-import org.apache.fineract.integrationtests.common.ClientHelper;
-import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
-import org.apache.fineract.integrationtests.common.CommonConstants;
-import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
+import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase;
+import 
org.apache.fineract.integrationtests.client.feign.helpers.FeignSavingsHelper;
+import 
org.apache.fineract.integrationtests.client.feign.helpers.FeignSavingsProductHelper;
+import 
org.apache.fineract.integrationtests.client.feign.helpers.FeignSavingsTransactionHelper;
+import 
org.apache.fineract.integrationtests.client.feign.modules.ChargeRequestBuilders;
+import 
org.apache.fineract.integrationtests.client.feign.modules.SavingsRequestBuilders;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
 import org.apache.fineract.integrationtests.common.Utils;
 import org.apache.fineract.integrationtests.common.accounting.Account;
-import org.apache.fineract.integrationtests.common.accounting.AccountHelper;
 import 
org.apache.fineract.integrationtests.common.accounting.FinancialActivityAccountHelper;
-import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
 import 
org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
 import 
org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
-import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
-import 
org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
-import 
org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
-import 
org.apache.fineract.integrationtests.common.savings.SavingsStatusChecker;
 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.AfterAll;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
 @Slf4j
-public class LoanChargePaymentWithAdvancedPaymentAllocationTest extends 
BaseLoanIntegrationTest {
+public class LoanChargePaymentWithAdvancedPaymentAllocationTest extends 
FeignLoanTestBase {
 
     private static final String DATETIME_PATTERN = "dd MMMM yyyy";
-    private static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
     private static final DateTimeFormatter DATE_FORMATTER = new 
DateTimeFormatterBuilder().appendPattern(DATETIME_PATTERN).toFormatter();
-    private static RequestSpecification requestSpec;
-    private static ResponseSpecification responseSpec;
-    private static LoanTransactionHelper loanTransactionHelper;
-    private static AccountHelper accountHelper;
-    private static Integer commonLoanProductId;
-    private static PostClientsResponse client;
-    private static BusinessDateHelper businessDateHelper;
-    private static SchedulerJobHelper scheduleJobHelper;
-    private static SavingsAccountHelper savingsAccountHelper;
-    private static SavingsProductHelper savingsProductHelper;
+
+    private static FeignSavingsHelper savingsHelper;
+    private static FeignSavingsProductHelper savingsProductHelper;
+    private static FeignSavingsTransactionHelper savingsTransactionHelper;
     private static FinancialActivityAccountHelper 
financialActivityAccountHelper;
-    private static Integer financialActivityAccountId;
-    private static Account liabilityTransferAccount;
 
     @BeforeAll
-    public static void setup() {
-        Utils.initializeRESTAssured();
-        ClientHelper clientHelper = new ClientHelper(requestSpec, 
responseSpec);
-        requestSpec = new 
RequestSpecBuilder().setContentType(ContentType.JSON).build();
-        requestSpec.header("Authorization", "Basic " + 
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
-        requestSpec.header("Fineract-Platform-TenantId", "default");
-        responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
-
-        loanTransactionHelper = new LoanTransactionHelper(requestSpec, 
responseSpec);
-        accountHelper = new AccountHelper(requestSpec, responseSpec);
-        final Account assetAccount = accountHelper.createAssetAccount();
-        final Account incomeAccount = accountHelper.createIncomeAccount();
-        final Account expenseAccount = accountHelper.createExpenseAccount();
-        final Account overpaymentAccount = 
accountHelper.createLiabilityAccount();
-        client = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest());
-        businessDateHelper = new BusinessDateHelper();
-        scheduleJobHelper = new SchedulerJobHelper(requestSpec);
-        savingsAccountHelper = new SavingsAccountHelper(requestSpec, 
responseSpec);
-        savingsProductHelper = new SavingsProductHelper();
-        commonLoanProductId = createLoanProduct("500", "15", "4", 
assetAccount, incomeAccount, expenseAccount, overpaymentAccount);
-        financialActivityAccountHelper = new 
FinancialActivityAccountHelper(requestSpec);
-
-        List<HashMap> financialActivities = 
financialActivityAccountHelper.getAllFinancialActivityAccounts(responseSpec);
-        if (financialActivities.isEmpty()) {
-            /** Setup liability transfer account **/
-            /** Create a Liability and an Asset Transfer Account **/
-            liabilityTransferAccount = accountHelper.createLiabilityAccount();
-            Assertions.assertNotNull(liabilityTransferAccount);
-
-            /*** Create A Financial Activity to Account Mapping **/
-            financialActivityAccountId = (Integer) 
financialActivityAccountHelper.createFinancialActivityAccount(
-                    LIABILITY_TRANSFER.getValue(), 
liabilityTransferAccount.getAccountID(), responseSpec,
-                    CommonConstants.RESPONSE_RESOURCE_ID);
-            Assertions.assertNotNull(financialActivityAccountId);
-        } else {
-            boolean existFinancialActivity = false;
-            for (HashMap financialActivity : financialActivities) {
-                HashMap financialActivityData = (HashMap) 
financialActivity.get("financialActivityData");
-                if 
(financialActivityData.get("id").equals(FinancialActivityAccountsTest.LIABILITY_TRANSFER_FINANCIAL_ACTIVITY_ID))
 {
-                    HashMap glAccountData = (HashMap) 
financialActivity.get("glAccountData");
-                    liabilityTransferAccount = new Account((Integer) 
glAccountData.get("id"), Account.AccountType.LIABILITY);
-                    financialActivityAccountId = (Integer) 
financialActivity.get("id");
-                    existFinancialActivity = true;
-                    break;
-                }
-            }
-            if (!existFinancialActivity) {
-                liabilityTransferAccount = 
accountHelper.createLiabilityAccount();
-                Assertions.assertNotNull(liabilityTransferAccount);
-
-                /*** Create A Financial Activity to Account Mapping **/
-                financialActivityAccountId = (Integer) 
financialActivityAccountHelper.createFinancialActivityAccount(
-                        LIABILITY_TRANSFER.getValue(), 
liabilityTransferAccount.getAccountID(), responseSpec,
-                        CommonConstants.RESPONSE_RESOURCE_ID);
-                Assertions.assertNotNull(financialActivityAccountId);
-            }
-        }
+    public static void setupSavingsAndFinancialActivityHelpers() {
+        FineractFeignClient client = 
FineractFeignClientHelper.getFineractFeignClient();
+        savingsHelper = new FeignSavingsHelper(client);
+        savingsProductHelper = new FeignSavingsProductHelper(client);
+        savingsTransactionHelper = new FeignSavingsTransactionHelper(client);
+        financialActivityAccountHelper = new 
FinancialActivityAccountHelper(null);
     }
 
-    @AfterAll
-    public static void tearDown() {
-        Integer deletedFinancialActivityAccountId = 
financialActivityAccountHelper
-                .deleteFinancialActivityAccount(financialActivityAccountId, 
responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
-        Assertions.assertNotNull(deletedFinancialActivityAccountId);
-        Assertions.assertEquals(financialActivityAccountId, 
deletedFinancialActivityAccountId);
+    @AfterEach
+    public void tearDownFinancialActivityAccounts() {

Review Comment:
   Addressed all three: moved the cleanup back to a static @AfterAll; dropped 
the unused Long parameter from mapLiabilityTransferFinancialActivity(); and 
restored the 10000.0 minimum opening balance , that field was missing from the 
generated Feign model (a Swagger gap), so I added minRequiredOpeningBalance to 
SavingsProductsApiResourceSwagger and set it via the typed builder. (Left 
FinancialActivityAccountHelper(null) as-is  it's the established Feign-client 
pattern and works.)



-- 
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