Aman-Mittal commented on code in PR #6084:
URL: https://github.com/apache/fineract/pull/6084#discussion_r3520872186


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/DelinquencyAndChargebackIntegrationTest.java:
##########
@@ -24,300 +24,218 @@
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-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.format.DateTimeFormatter;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.stream.Stream;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.fineract.client.models.AdvancedPaymentData;
-import org.apache.fineract.client.models.DelinquencyBucketResponse;
 import org.apache.fineract.client.models.DelinquencyRangeData;
-import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
 import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod;
 import org.apache.fineract.client.models.GetLoansLoanIdRepaymentSchedule;
 import org.apache.fineract.client.models.GetLoansLoanIdResponse;
-import org.apache.fineract.client.models.PaymentAllocationOrder;
+import org.apache.fineract.client.models.PostLoanProductsRequest;
 import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
+import org.apache.fineract.client.models.PostLoansRequest;
 import org.apache.fineract.client.models.PutGlobalConfigurationsRequest;
-import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
 import 
org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
-import org.apache.fineract.integrationtests.common.BusinessDateHelper;
-import org.apache.fineract.integrationtests.common.ClientHelper;
-import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
+import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase;
+import 
org.apache.fineract.integrationtests.client.feign.modules.LoanRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
 import org.apache.fineract.integrationtests.common.Utils;
-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.products.DelinquencyBucketsHelper;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
-import 
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
-import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Named;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
 
 @Slf4j
-public class DelinquencyAndChargebackIntegrationTest extends 
BaseLoanIntegrationTest {
+public class DelinquencyAndChargebackIntegrationTest extends FeignLoanTestBase 
{
 
-    private ResponseSpecification responseSpec;
-    private RequestSpecification requestSpec;
-    private LoanTransactionHelper loanTransactionHelper;
     private static final String principalAmount = "1200.00";
     private static final Double doubleZERO = Double.valueOf("0.00");
-
-    @BeforeEach
-    public void setup() {
-        Utils.initializeRESTAssured();
-
-        requestSpec = new 
RequestSpecBuilder().setContentType(ContentType.JSON).build();
-        requestSpec.header("Authorization", "Basic " + 
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
-        responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
-
-        loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, 
this.responseSpec);
-    }
+    private static final DateTimeFormatter BUSINESS_DATE_FORMAT = 
DateTimeFormatter.ofPattern(LoanTestData.DATETIME_PATTERN);
 
     @ParameterizedTest
     @MethodSource("loanProductFactory")
-    public void testLoanClassificationStepAsPartOfCOB(LoanProductTestBuilder 
loanProductTestBuilder) {
+    public void testLoanClassificationStepAsPartOfCOB(String strategyCode, 
boolean advancedAllocation) {
         try {
-            
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
+            
updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
                     new PutGlobalConfigurationsRequest().enabled(true));
 
             final LocalDate todaysDate = Utils.getDateAsLocalDate("01 April 
2012");
             LocalDate businessDate = todaysDate.minusMonths(3);
             log.info("Current Business date {}", businessDate);
-            
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE, 
businessDate);
+            updateBusinessDate("BUSINESS_DATE", 
formatBusinessDate(businessDate));
 
-            final SchedulerJobHelper schedulerJobHelper = new 
SchedulerJobHelper(requestSpec);
-            // Delinquency Bucket
             final Long delinquencyBucketId = 
DelinquencyBucketsHelper.createDefaultBucket();
-            final DelinquencyBucketResponse delinquencyBucket = 
DelinquencyBucketsHelper.getBucket(delinquencyBucketId);
-
-            // Client and Loan account creation
-            final Integer clientId = 
ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 
2012");
-            final GetLoanProductsProductIdResponse 
getLoanProductsProductResponse = createLoanProduct(loanTransactionHelper,
-                    delinquencyBucket.getId(), loanProductTestBuilder);
-            assertNotNull(getLoanProductsProductResponse);
+            final Long clientId = createClient("01 January 2012");
+            final Long loanProductId = createLoanProduct(strategyCode, 
advancedAllocation, delinquencyBucketId);
 
-            // Older date to have more than one overdue installment
-            String operationDate = Utils.dateFormatter.format(businessDate);
+            String operationDate = formatBusinessDate(businessDate);
             log.info("Operation date  {}", businessDate);
 
-            // Create Loan Account
-            final Integer loanId = createLoanAccount(loanTransactionHelper, 
clientId.toString(),
-                    getLoanProductsProductResponse.getId().toString(), 
operationDate, "12",
-                    
loanProductTestBuilder.getTransactionProcessingStrategyCode());
+            final Long loanId = createLoanAccount(clientId, loanProductId, 
operationDate, "12", strategyCode);
 
-            // Move the Business date 1 month to apply the first repayment
             businessDate = businessDate.plusMonths(1);
-            
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE, 
businessDate);
+            updateBusinessDate("BUSINESS_DATE", 
formatBusinessDate(businessDate));
             log.info("Current Business date {}", businessDate);
 
             String amountVal = "100.00";
-            Float transactionAmount = Float.valueOf(amountVal);
-            operationDate = Utils.dateFormatter.format(businessDate);
-            PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = 
loanTransactionHelper.makeLoanRepayment(operationDate,
-                    transactionAmount, loanId);
+            operationDate = formatBusinessDate(businessDate);
+            PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = 
makeLoanRepayment(loanId, "Repayment", operationDate,
+                    Double.valueOf(amountVal));
             assertNotNull(loanIdTransactionsResponse);
             Long transactionId = loanIdTransactionsResponse.getResourceId();
-            loanTransactionHelper.reviewLoanTransactionRelations(loanId, 
transactionId, 0);
+            reviewLoanTransactionRelations(loanId, transactionId, 0);
 
-            // Move the Business date 1 month more to apply the second 
repayment
             businessDate = businessDate.plusMonths(1);
-            
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE, 
businessDate);
+            updateBusinessDate("BUSINESS_DATE", 
formatBusinessDate(businessDate));
             log.info("Current Business date {}", businessDate);
 
-            operationDate = Utils.dateFormatter.format(businessDate);
-            loanIdTransactionsResponse = 
loanTransactionHelper.makeLoanRepayment(operationDate, transactionAmount, 
loanId);
+            operationDate = formatBusinessDate(businessDate);
+            loanIdTransactionsResponse = makeLoanRepayment(loanId, 
"Repayment", operationDate, Double.valueOf(amountVal));
             assertNotNull(loanIdTransactionsResponse);
             transactionId = loanIdTransactionsResponse.getResourceId();
-            loanTransactionHelper.reviewLoanTransactionRelations(loanId, 
transactionId, 0);
+            reviewLoanTransactionRelations(loanId, transactionId, 0);
 
-            // Get loan details expecting to have not a delinquency 
classification and 1,000 as Outstanding
-            GetLoansLoanIdResponse getLoansLoanIdResponse = 
loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
+            GetLoansLoanIdResponse getLoansLoanIdResponse = 
getLoanDetails(loanId);
             validateLoanAccount(getLoansLoanIdResponse, "0.00", "1000.00", 0, 
doubleZERO);
 
-            // Move the Business date n days to apply the chargeback for the 
previous repayment
             businessDate = businessDate.plusDays(21);
-            
BusinessDateHelper.updateBusinessDate(BusinessDateType.BUSINESS_DATE, 
businessDate);
+            updateBusinessDate("BUSINESS_DATE", 
formatBusinessDate(businessDate));

Review Comment:
   same as above use existing



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientLoanCreditBalanceRefundandRepaymentTypeIntegrationTest.java:
##########
@@ -520,296 +501,266 @@ public void 
paymentRefundWillCloseTheLoanCorrectly(LoanProductTestBuilder loanPr
     @ParameterizedTest
     @MethodSource("loanProductFactory")
     public void 
newGoodwillCreditCreatesCorrectJournalEntriesForPeriodicAccrualsTest(LoanProductTestBuilder
 loanProductTestBuilder) {
-
-        disburseLoanOfAccountingRule(ACCRUAL_PERIODIC, loanProductTestBuilder);
-        HashMap loanSummaryMap = 
this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, 
disbursedLoanID);
-
-        // pay off all of principal, interest (no fees or penalties)
-        final Float principalOutstanding = (Float) 
loanSummaryMap.get("principalOutstanding");
-        final Float interestOutstanding = (Float) 
loanSummaryMap.get("interestOutstanding");
-        final Float totalOutstanding = (Float) 
loanSummaryMap.get("totalOutstanding");
-        final Float overpaidAmount = 159.00f;
-        final Float goodwillAmount = totalOutstanding + overpaidAmount;
-        final Float goodwillAmountInExpense = principalOutstanding + 
overpaidAmount;
-        final String goodwillDate = "09 January 2022";
-        HashMap loanStatusHashMap = (HashMap) 
this.loanTransactionHelper.makeRepaymentTypePayment(GOODWILL_CREDIT, 
goodwillDate,
-                goodwillAmount, this.disbursedLoanID, "");
-
-        // only a single credit for principal and interest as test sets up 
same GL account for both (summed up)
-        this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, 
goodwillDate,
-                new JournalEntry(totalOutstanding, 
JournalEntry.TransactionType.CREDIT));
-        
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount,
 goodwillDate,
-                new JournalEntry(overpaidAmount, 
JournalEntry.TransactionType.CREDIT));
-        
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, 
goodwillDate,
-                new JournalEntry(goodwillAmountInExpense, 
JournalEntry.TransactionType.DEBIT));
-
+        runJanuary2022(() -> {
+            disburseLoanOfAccountingRule(ACCRUAL_PERIODIC, 
loanProductTestBuilder);
+            GetLoansLoanIdSummary loanSummary = 
getLoanDetails(disbursedLoanID).getSummary();
+
+            final Float principalOutstanding = 
Utils.getDoubleValue(loanSummary.getPrincipalOutstanding()).floatValue();
+            final Float interestOutstanding = 
Utils.getDoubleValue(loanSummary.getInterestOutstanding()).floatValue();
+            final Float totalOutstanding = 
Utils.getDoubleValue(loanSummary.getTotalOutstanding()).floatValue();
+            final Float overpaidAmount = 159.00f;
+            final Float goodwillAmount = totalOutstanding + overpaidAmount;
+            final Float goodwillAmountInExpense = principalOutstanding + 
overpaidAmount;
+            final String goodwillDate = "09 January 2022";
+            makeRepaymentTypePayment(GOODWILL_CREDIT, goodwillDate, 
goodwillAmount.doubleValue(), disbursedLoanID);
+
+            
checkJournalEntryForAssetAccount(getAccounts().getLoansReceivableAccount(), 
goodwillDate,
+                    journalEntry(totalOutstanding, 
getAccounts().getLoansReceivableAccount(), "CREDIT"));
+            
checkJournalEntryForLiabilityAccount(getAccounts().getOverpaymentAccount(), 
goodwillDate,
+                    journalEntry(overpaidAmount, 
getAccounts().getOverpaymentAccount(), "CREDIT"));
+            
checkJournalEntryForExpenseAccount(getAccounts().getGoodwillExpenseAccount(), 
goodwillDate,
+                    journalEntry(goodwillAmountInExpense, 
getAccounts().getGoodwillExpenseAccount(), "DEBIT"));
+        });
     }
 
     @ParameterizedTest
     @MethodSource("loanProductFactory")
     public void 
newGoodwillCreditCreatesCorrectJournalEntriesForCashAccountingTest(LoanProductTestBuilder
 loanProductTestBuilder) {
-
-        disburseLoanOfAccountingRule(CASH_BASED, loanProductTestBuilder);
-        HashMap loanSummaryMap = 
this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, 
disbursedLoanID);
-
-        // pay off all of principal, interest (no fees or penalties)
-        final Float principalOutstanding = (Float) 
loanSummaryMap.get("principalOutstanding");
-        final Float interestOutstanding = (Float) 
loanSummaryMap.get("interestOutstanding");
-        final Float totalOutstanding = (Float) 
loanSummaryMap.get("totalOutstanding");
-        final Float overpaidAmount = 159.00f;
-        final Float goodwillAmount = totalOutstanding + overpaidAmount;
-        final Float goodwillAmountInExpense = principalOutstanding + 
overpaidAmount;
-        final String goodwillDate = "09 January 2022";
-        HashMap loanStatusHashMap = (HashMap) 
this.loanTransactionHelper.makeRepaymentTypePayment(GOODWILL_CREDIT, 
goodwillDate,
-                goodwillAmount, this.disbursedLoanID, "");
-
-        this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, 
goodwillDate,
-                new JournalEntry(principalOutstanding, 
JournalEntry.TransactionType.CREDIT));
-        
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, 
goodwillDate,
-                new JournalEntry(interestOutstanding, 
JournalEntry.TransactionType.CREDIT));
-
-        
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount,
 goodwillDate,
-                new JournalEntry(overpaidAmount, 
JournalEntry.TransactionType.CREDIT));
-        
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, 
goodwillDate,
-                new JournalEntry(goodwillAmountInExpense, 
JournalEntry.TransactionType.DEBIT));
-
+        runJanuary2022(() -> {
+            disburseLoanOfAccountingRule(CASH_BASED, loanProductTestBuilder);
+            GetLoansLoanIdSummary loanSummary = 
getLoanDetails(disbursedLoanID).getSummary();
+
+            final Float principalOutstanding = 
Utils.getDoubleValue(loanSummary.getPrincipalOutstanding()).floatValue();
+            final Float interestOutstanding = 
Utils.getDoubleValue(loanSummary.getInterestOutstanding()).floatValue();
+            final Float totalOutstanding = 
Utils.getDoubleValue(loanSummary.getTotalOutstanding()).floatValue();
+            final Float overpaidAmount = 159.00f;
+            final Float goodwillAmount = totalOutstanding + overpaidAmount;
+            final Float goodwillAmountInExpense = principalOutstanding + 
overpaidAmount;
+            final String goodwillDate = "09 January 2022";
+            makeRepaymentTypePayment(GOODWILL_CREDIT, goodwillDate, 
goodwillAmount.doubleValue(), disbursedLoanID);
+
+            
checkJournalEntryForAssetAccount(getAccounts().getLoansReceivableAccount(), 
goodwillDate,
+                    journalEntry(principalOutstanding, 
getAccounts().getLoansReceivableAccount(), "CREDIT"));

Review Comment:
   JournalEntry.TransactionType.CREDIT use existing enums



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java:
##########
@@ -43,170 +37,91 @@
 import 
org.apache.fineract.client.models.GetLoanPaymentChannelToFundSourceMappings;
 import org.apache.fineract.client.models.GetLoanTransactionRelation;
 import org.apache.fineract.client.models.GetLoansLoanIdResponse;
+import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
 import 
org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse;
 import org.apache.fineract.client.models.JournalEntryTransactionItem;
 import org.apache.fineract.client.models.LoanProductChargeData;
 import org.apache.fineract.client.models.LoanProductChargeToGLAccountMapper;
 import org.apache.fineract.client.models.PaymentTypeCreateRequest;
-import org.apache.fineract.client.models.PostClientsResponse;
 import org.apache.fineract.client.models.PostLoanProductsRequest;
-import org.apache.fineract.client.models.PostLoanProductsResponse;
 import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
 import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
-import org.apache.fineract.integrationtests.common.BusinessDateHelper;
+import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
 import org.apache.fineract.integrationtests.common.ClientHelper;
 import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
 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.JournalEntryHelper;
-import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
-import org.apache.fineract.integrationtests.common.funds.FundsHelper;
 import org.apache.fineract.integrationtests.common.funds.FundsResourceHandler;
 import 
org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
-import org.apache.fineract.integrationtests.common.loans.LoanProductHelper;
-import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
 import 
org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper;
-import org.apache.fineract.integrationtests.common.system.CodeHelper;
 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.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-public class LoanAccountChargeOffWithAdvancedPaymentAllocationTest extends 
BaseLoanIntegrationTest {
+public class LoanAccountChargeOffWithAdvancedPaymentAllocationTest extends 
FeignLoanTestBase {
 
     private static final DateTimeFormatter DATE_FORMATTER = new 
DateTimeFormatterBuilder().appendPattern("dd MMMM yyyy").toFormatter();
-    private ResponseSpecification responseSpec;
-    private RequestSpecification requestSpec;
-    private ClientHelper clientHelper;
-    private LoanTransactionHelper loanTransactionHelper;
-    private JournalEntryHelper journalEntryHelper;
-    private AccountHelper accountHelper;
-    private LoanProductHelper loanProductHelper;
-    private PaymentTypeHelper paymentTypeHelper;
-    private final BusinessDateHelper businessDateHelper = new 
BusinessDateHelper();
-    private static final String DATETIME_PATTERN = "dd MMMM yyyy";
-    // asset
-    private Account loansReceivable;
-    private Account interestFeeReceivable;
-    private Account suspenseAccount;
-    private Account fundReceivables;
-    // liability
-    private Account suspenseClearingAccount;
-    private Account overpaymentAccount;
-    // income
-    private Account interestIncome;
-    private Account feeIncome;
-    private Account feeChargeOff;
-    private Account recoveries;
-    private Account interestIncomeChargeOff;
-    // expense
-    private Account creditLossBadDebt;
-    private Account creditLossBadDebtFraud;
-    private Account writtenOff;
-    private Account goodwillExpenseAccount;
-
-    @BeforeEach
-    public void setup() {
-        Utils.initializeRESTAssured();
-        this.requestSpec = new 
RequestSpecBuilder().setContentType(ContentType.JSON).build();
-        this.requestSpec.header("Authorization", "Basic " + 
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
-        this.responseSpec = new 
ResponseSpecBuilder().expectStatusCode(200).build();
-        this.loanTransactionHelper = new 
LoanTransactionHelper(this.requestSpec, this.responseSpec);
-        this.accountHelper = new AccountHelper(this.requestSpec, 
this.responseSpec);
-        this.loanProductHelper = new LoanProductHelper();
-        this.paymentTypeHelper = new PaymentTypeHelper();
-
-        // Asset
-        this.loansReceivable = this.accountHelper.createAssetAccount();
-        this.interestFeeReceivable = this.accountHelper.createAssetAccount();
-        this.suspenseAccount = this.accountHelper.createAssetAccount();
-        this.fundReceivables = this.accountHelper.createAssetAccount();
-
-        // Liability
-        this.suspenseClearingAccount = 
this.accountHelper.createLiabilityAccount();
-        this.overpaymentAccount = this.accountHelper.createLiabilityAccount();
-
-        // income
-        this.interestIncome = this.accountHelper.createIncomeAccount();
-        this.feeIncome = this.accountHelper.createIncomeAccount();
-        this.feeChargeOff = this.accountHelper.createIncomeAccount();
-        this.recoveries = this.accountHelper.createIncomeAccount();
-        this.interestIncomeChargeOff = 
this.accountHelper.createIncomeAccount();
-
-        // expense
-        this.creditLossBadDebt = this.accountHelper.createExpenseAccount();
-        this.creditLossBadDebtFraud = 
this.accountHelper.createExpenseAccount();
-        this.writtenOff = this.accountHelper.createExpenseAccount();
-        this.goodwillExpenseAccount = 
this.accountHelper.createExpenseAccount();
-
-        this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, 
this.responseSpec);
-        this.clientHelper = new ClientHelper(this.requestSpec, 
this.responseSpec);
-    }
 
     // Charge-off accounting and balances
     @Test
     public void loanChargeOffWithAdvancedPaymentStrategyTest() {
         runAt("10 September 2022", () -> {
             String loanExternalIdStr = UUID.randomUUID().toString();
-            final Integer loanProductID = 
createLoanProductWithPeriodicAccrualAccountingAndAdvancedPaymentAllocationStrategy();
-            final Integer clientId = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId().intValue();
-            final Integer loanId = createLoanAccount(clientId, loanProductID, 
loanExternalIdStr);
+            final Long loanProductId = 
createLoanProductWithPeriodicAccrualAccountingAndAdvancedPaymentAllocationStrategy();
+            final Long clientId = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+            final Long loanId = createLoanAccount(clientId, loanProductId, 
loanExternalIdStr);
 
             // apply charges
-            Integer feeCharge = ChargesHelper.createCharges(requestSpec, 
responseSpec,
-                    
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT,
 "10", false));
+            Long feeCharge = createLoanSpecifiedDueDateCharge(10.0);
 
             LocalDate targetDate = LocalDate.of(2022, 9, 5);
             final String feeCharge1AddedDate = 
DATE_FORMATTER.format(targetDate);
-            Integer feeLoanChargeId = 
loanTransactionHelper.addChargesForLoan(loanId,
-                    
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(feeCharge),
 feeCharge1AddedDate, "10"));
+            addLoanCharge(loanId, feeCharge, feeCharge1AddedDate, 10.0);
 
             // apply penalty
-            Integer penalty = ChargesHelper.createCharges(requestSpec, 
responseSpec,
-                    
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT,
 "10", true));
-
+            Long penalty = createLoanSpecifiedDueDateCharge(10.0);
             final String penaltyCharge1AddedDate = 
DATE_FORMATTER.format(targetDate);
-
-            Integer penalty1LoanChargeId = 
this.loanTransactionHelper.addChargesForLoan(loanId,
-                    
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(penalty),
 penaltyCharge1AddedDate, "10"));
+            addCharge(loanId, true, 10.0, penaltyCharge1AddedDate);
 
             // make Repayment
-            final PostLoansLoanIdTransactionsResponse repaymentTransaction = 
loanTransactionHelper.makeLoanRepayment(loanExternalIdStr,
-                    new PostLoansLoanIdTransactionsRequest().dateFormat("dd 
MMMM yyyy").transactionDate("9 September 2022").locale("en")
-                            .transactionAmount(10.0));
+            makeLoanRepayment(loanExternalIdStr, new 
PostLoansLoanIdTransactionsRequest().dateFormat(LoanTestData.DATETIME_PATTERN)
+                    .transactionDate("9 September 
2022").locale(LoanTestData.LOCALE).transactionAmount(10.0));
 
-            GetLoansLoanIdResponse loanDetails = 
this.loanTransactionHelper.getLoanDetails((long) loanId);
+            GetLoansLoanIdResponse loanDetails = getLoanDetails(loanId);
             assertTrue(loanDetails.getStatus().getActive());
 
             // set loan as chargeoff
             String randomText = Utils.randomStringGenerator("en", 5) + 
Utils.randomNumberGenerator(6)
                     + Utils.randomStringGenerator("is", 5);
-            Integer chargeOffReasonId = 
CodeHelper.createChargeOffCodeValue(requestSpec, responseSpec, randomText, 1);
+            Long chargeOffReasonId = 
codeHelper.createChargeOffCodeValue(randomText, 1);
             String transactionExternalId = UUID.randomUUID().toString();
-            PostLoansLoanIdTransactionsResponse chargeOffTransaction = 
this.loanTransactionHelper.chargeOffLoan((long) loanId,
-                    new 
PostLoansLoanIdTransactionsRequest().transactionDate("10 September 
2022").locale("en").dateFormat("dd MMMM yyyy")
-                            
.externalId(transactionExternalId).chargeOffReasonId((long) chargeOffReasonId));
+            PostLoansLoanIdTransactionsResponse chargeOffTransaction = 
chargeOffLoan(loanId,
+                    new 
PostLoansLoanIdTransactionsRequest().transactionDate("10 September 
2022").locale(LoanTestData.LOCALE)
+                            
.dateFormat(LoanTestData.DATETIME_PATTERN).externalId(transactionExternalId)
+                            .chargeOffReasonId(chargeOffReasonId));
 
-            loanDetails = this.loanTransactionHelper.getLoanDetails((long) 
loanId);
+            loanDetails = getLoanDetails(loanId);
             assertTrue(loanDetails.getStatus().getActive());
             assertTrue(loanDetails.getChargedOff());
 
             // verify amounts for charge-off transaction
             verifyTransaction(LocalDate.of(2022, 9, 10), 1010.0f, 1000.0f, 
0.0f, 10.0f, 0.0f, loanId, "chargeoff");
             // verify journal entries
-            GetJournalEntriesTransactionIdResponse journalEntriesForChargeOff 
= journalEntryHelper
-                    .getJournalEntries("L" + 
chargeOffTransaction.getResourceId().toString());
+            GetJournalEntriesTransactionIdResponse journalEntriesForChargeOff 
= getJournalEntries(
+                    "L" + chargeOffTransaction.getResourceId().toString());
 
             assertNotNull(journalEntriesForChargeOff);
 
             List<JournalEntryTransactionItem> journalEntries = 
journalEntriesForChargeOff.getPageItems();
             assertEquals(4, journalEntries.size());
-            verifyJournalEntry(journalEntries.get(3), 1000.0, 
LocalDate.of(2022, 9, 10), loansReceivable, "CREDIT");
-            verifyJournalEntry(journalEntries.get(2), 10.0, LocalDate.of(2022, 
9, 10), interestFeeReceivable, "CREDIT");
-            verifyJournalEntry(journalEntries.get(1), 1000.0, 
LocalDate.of(2022, 9, 10), creditLossBadDebt, "DEBIT");
-            verifyJournalEntry(journalEntries.get(0), 10.0, LocalDate.of(2022, 
9, 10), feeChargeOff, "DEBIT");
+            verifyJournalEntry(journalEntries.get(3), 1000.0, 
LocalDate.of(2022, 9, 10), getAccounts().getLoansReceivableAccount(),
+                    "CREDIT");
+            verifyJournalEntry(journalEntries.get(2), 10.0, LocalDate.of(2022, 
9, 10), getAccounts().getFeeReceivableAccount(), "CREDIT");
+            verifyJournalEntry(journalEntries.get(1), 1000.0, 
LocalDate.of(2022, 9, 10), getAccounts().getChargeOffExpenseAccount(),

Review Comment:
   Use java.time.Month as sonar flags this as maintainability issue



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/LoanRequestBuilders.java:
##########
@@ -116,6 +128,64 @@ public static PostLoansLoanIdRequest disburseLoan(Double 
disbursedAmount, String
                 .dateFormat(LoanTestData.DATETIME_PATTERN);
     }
 
+    public static String disburseLoanWithRepaymentRescheduleJson(String 
disbursedOnDate, String adjustRepaymentDate) {
+        Map<String, String> map = new LinkedHashMap<>();
+        map.put("locale", LoanTestData.LOCALE);
+        map.put("dateFormat", LoanTestData.DATETIME_PATTERN);
+        map.put("actualDisbursementDate", disbursedOnDate);

Review Comment:
   same as above



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/helpers/FeignGroupCenterHelper.java:
##########
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests.client.feign.helpers;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.Utils;
+
+public final class FeignGroupCenterHelper {
+
+    private static final Gson GSON = new Gson();
+
+    private FeignGroupCenterHelper() {}
+
+    public static Long createGroup(int officeId) {
+        Map<String, Object> map = new HashMap<>();

Review Comment:
   You can maintain constants for frequently used magic strings



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