galovics commented on code in PR #4595:
URL: https://github.com/apache/fineract/pull/4595#discussion_r2048406490


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/loan/LoanApiIntegrationTest.java:
##########
@@ -0,0 +1,142 @@
+/**
+ * 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.loan;
+
+import java.math.BigDecimal;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.fineract.client.models.*;
+import org.apache.fineract.integrationtests.BaseLoanIntegrationTest;
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.junit.jupiter.api.Test;
+
+public class LoanApiIntegrationTest extends BaseLoanIntegrationTest {
+
+    @Test
+    public void test_retrieveLoansByClientId_Works() {
+        AtomicLong createdLoanId = new AtomicLong();
+        AtomicLong createdLoanId2 = new AtomicLong();
+        Long clientId = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+        Long clientId2 = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+
+        runAt("01 January 2023", () -> {
+            // Create Client
+
+            int numberOfRepayments = 3;
+            int repaymentEvery = 1;
+
+            // Create Loan Products
+            PostLoanProductsRequest product = 
createOnePeriod30DaysLongNoInterestPeriodicAccrualProduct() //
+                    .numberOfRepayments(numberOfRepayments) //
+                    .repaymentEvery(repaymentEvery) //
+                    .installmentAmountInMultiplesOf(null) //
+                    
.repaymentFrequencyType(RepaymentFrequencyType.MONTHS.longValue()) //
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    .interestRatePerPeriod(10.0)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY)//
+                    
.interestRecalculationCompoundingMethod(InterestRecalculationCompoundingMethod.NONE)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.ADJUST_LAST_UNPAID_PERIOD)//
+                    .isInterestRecalculationEnabled(true)//
+                    .recalculationRestFrequencyInterval(1)//
+                    
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.REDUCE_EMI_AMOUNT)//
+                    .allowPartialPeriodInterestCalcualtion(false)//
+                    .disallowExpectedDisbursements(false)//
+                    .allowApprovedDisbursedAmountsOverApplied(false)//
+                    .overAppliedNumber(null)//
+                    .overAppliedCalculationType(null)//
+                    .multiDisburseLoan(null);//
+
+            PostLoanProductsResponse loanProductResponse = 
loanProductHelper.createLoanProduct(product);
+            Long loanProductId = loanProductResponse.getResourceId();
+
+            PostLoanProductsRequest product2 = 
createOnePeriod30DaysLongNoInterestPeriodicAccrualProduct() //
+                    .numberOfRepayments(numberOfRepayments) //
+                    .repaymentEvery(repaymentEvery) //
+                    .installmentAmountInMultiplesOf(null) //
+                    
.repaymentFrequencyType(RepaymentFrequencyType.MONTHS.longValue()) //
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    .interestRatePerPeriod(10.0)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY)//
+                    
.interestRecalculationCompoundingMethod(InterestRecalculationCompoundingMethod.NONE)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.ADJUST_LAST_UNPAID_PERIOD)//
+                    .isInterestRecalculationEnabled(true)//
+                    .recalculationRestFrequencyInterval(1)//
+                    
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.REDUCE_EMI_AMOUNT)//
+                    .allowPartialPeriodInterestCalcualtion(false)//
+                    .disallowExpectedDisbursements(false)//
+                    .allowApprovedDisbursedAmountsOverApplied(false)//
+                    .overAppliedNumber(null)//
+                    .overAppliedCalculationType(null)//
+                    .multiDisburseLoan(null);//
+
+            PostLoanProductsResponse loanProductResponse2 = 
loanProductHelper.createLoanProduct(product2);
+            Long loanProductId2 = loanProductResponse2.getResourceId();
+
+            // Apply and Approve Loan
+            double amount = 5000.0;
+
+            PostLoansRequest applicationRequest = applyLoanRequest(clientId, 
loanProductId, "01 January 2023", amount, numberOfRepayments)//
+                    .repaymentEvery(repaymentEvery)//
+                    .interestRatePerPeriod(BigDecimal.valueOf(10.0))//
+                    .loanTermFrequency(numberOfRepayments)//
+                    .repaymentFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .loanTermFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY);//
+
+            PostLoansRequest applicationRequest2 = applyLoanRequest(clientId2, 
loanProductId2, "01 January 2023", amount,
+                    numberOfRepayments)//
+                    .repaymentEvery(repaymentEvery)//
+                    .interestRatePerPeriod(BigDecimal.valueOf(10.0))//
+                    .loanTermFrequency(numberOfRepayments)//
+                    .repaymentFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .loanTermFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY);//
+
+            PostLoansResponse postLoansResponse = 
loanTransactionHelper.applyLoan(applicationRequest);
+            PostLoansResponse postLoansResponse2 = 
loanTransactionHelper.applyLoan(applicationRequest2);
+
+            PostLoansLoanIdResponse approvedLoanResult = 
loanTransactionHelper.approveLoan(postLoansResponse.getResourceId(),
+                    approveLoanRequest(amount, "01 January 2023"));
+
+            PostLoansLoanIdResponse approvedLoanResult2 = 
loanTransactionHelper.approveLoan(postLoansResponse2.getResourceId(),
+                    approveLoanRequest(amount, "01 January 2023"));
+
+            Long loanId = approvedLoanResult.getLoanId();
+            Long loanId2 = approvedLoanResult2.getLoanId();
+            createdLoanId.getAndSet(loanId);
+            createdLoanId2.getAndSet(loanId2);
+
+            // disburse Loan
+            disburseLoan(loanId, BigDecimal.valueOf(amount), "01 January 
2023");
+            disburseLoan(loanId2, BigDecimal.valueOf(amount), "01 January 
2023");
+        });
+        runAt("01 February 2023", () -> {
+            long loanId = createdLoanId.get();
+            GetLoansLoanIdResponse loanResponse = 
loanTransactionHelper.getLoanDetails(loanId);
+            GetLoansResponse loansLoanIdResponse = 
loanTransactionHelper.retrieveAllLoans(loanResponse.getAccountNo(), clientId);

Review Comment:
   Since this case case is about client Id filtering, can you pls skip using 
the accountNo as an additional filter criteria?



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java:
##########
@@ -44,51 +44,7 @@
 import java.util.Locale;
 import java.util.Map;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.fineract.client.models.AdvancedPaymentData;
-import 
org.apache.fineract.client.models.DeleteLoansLoanIdChargesChargeIdResponse;
-import org.apache.fineract.client.models.DeleteLoansLoanIdResponse;
-import org.apache.fineract.client.models.GetDelinquencyActionsResponse;
-import org.apache.fineract.client.models.GetDelinquencyTagHistoryResponse;
-import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
-import org.apache.fineract.client.models.GetLoanProductsResponse;
-import org.apache.fineract.client.models.GetLoansApprovalTemplateResponse;
-import org.apache.fineract.client.models.GetLoansLoanIdChargesChargeIdResponse;
-import org.apache.fineract.client.models.GetLoansLoanIdChargesTemplateResponse;
-import org.apache.fineract.client.models.GetLoansLoanIdDelinquencySummary;
-import org.apache.fineract.client.models.GetLoansLoanIdDisbursementDetails;
-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.GetLoansLoanIdSummary;
-import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
-import org.apache.fineract.client.models.GetLoansLoanIdTransactionsResponse;
-import 
org.apache.fineract.client.models.GetLoansLoanIdTransactionsTemplateResponse;
-import 
org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse;
-import org.apache.fineract.client.models.PaymentTypeData;
-import org.apache.fineract.client.models.PostLoanProductsRequest;
-import org.apache.fineract.client.models.PostLoanProductsResponse;
-import org.apache.fineract.client.models.PostLoansDelinquencyActionRequest;
-import org.apache.fineract.client.models.PostLoansDelinquencyActionResponse;
-import org.apache.fineract.client.models.PostLoansLoanIdChargesChargeIdRequest;
-import 
org.apache.fineract.client.models.PostLoansLoanIdChargesChargeIdResponse;
-import org.apache.fineract.client.models.PostLoansLoanIdChargesRequest;
-import org.apache.fineract.client.models.PostLoansLoanIdChargesResponse;
-import org.apache.fineract.client.models.PostLoansLoanIdRequest;
-import org.apache.fineract.client.models.PostLoansLoanIdResponse;
-import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
-import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
-import 
org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest;
-import org.apache.fineract.client.models.PostLoansRequest;
-import org.apache.fineract.client.models.PostLoansResponse;
-import org.apache.fineract.client.models.PutChargeTransactionChangesRequest;
-import org.apache.fineract.client.models.PutChargeTransactionChangesResponse;
-import org.apache.fineract.client.models.PutLoanProductsProductIdRequest;
-import org.apache.fineract.client.models.PutLoanProductsProductIdResponse;
-import org.apache.fineract.client.models.PutLoansLoanIdChargesChargeIdRequest;
-import org.apache.fineract.client.models.PutLoansLoanIdChargesChargeIdResponse;
-import org.apache.fineract.client.models.PutLoansLoanIdRequest;
-import org.apache.fineract.client.models.PutLoansLoanIdResponse;
-import org.apache.fineract.client.models.TransactionType;
+import org.apache.fineract.client.models.*;

Review Comment:
   Did you run spotlessApply before opening the PR? I think spotless will 
unwrap this since Fineract is not using wildcard imports.



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/loan/LoanApiIntegrationTest.java:
##########
@@ -0,0 +1,142 @@
+/**
+ * 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.loan;
+
+import java.math.BigDecimal;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.fineract.client.models.*;
+import org.apache.fineract.integrationtests.BaseLoanIntegrationTest;
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.junit.jupiter.api.Test;
+
+public class LoanApiIntegrationTest extends BaseLoanIntegrationTest {
+
+    @Test
+    public void test_retrieveLoansByClientId_Works() {
+        AtomicLong createdLoanId = new AtomicLong();
+        AtomicLong createdLoanId2 = new AtomicLong();
+        Long clientId = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+        Long clientId2 = 
clientHelper.createClient(ClientHelper.defaultClientCreationRequest()).getClientId();
+
+        runAt("01 January 2023", () -> {
+            // Create Client
+
+            int numberOfRepayments = 3;
+            int repaymentEvery = 1;
+
+            // Create Loan Products
+            PostLoanProductsRequest product = 
createOnePeriod30DaysLongNoInterestPeriodicAccrualProduct() //
+                    .numberOfRepayments(numberOfRepayments) //
+                    .repaymentEvery(repaymentEvery) //
+                    .installmentAmountInMultiplesOf(null) //
+                    
.repaymentFrequencyType(RepaymentFrequencyType.MONTHS.longValue()) //
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    .interestRatePerPeriod(10.0)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY)//
+                    
.interestRecalculationCompoundingMethod(InterestRecalculationCompoundingMethod.NONE)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.ADJUST_LAST_UNPAID_PERIOD)//
+                    .isInterestRecalculationEnabled(true)//
+                    .recalculationRestFrequencyInterval(1)//
+                    
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.REDUCE_EMI_AMOUNT)//
+                    .allowPartialPeriodInterestCalcualtion(false)//
+                    .disallowExpectedDisbursements(false)//
+                    .allowApprovedDisbursedAmountsOverApplied(false)//
+                    .overAppliedNumber(null)//
+                    .overAppliedCalculationType(null)//
+                    .multiDisburseLoan(null);//
+
+            PostLoanProductsResponse loanProductResponse = 
loanProductHelper.createLoanProduct(product);
+            Long loanProductId = loanProductResponse.getResourceId();
+
+            PostLoanProductsRequest product2 = 
createOnePeriod30DaysLongNoInterestPeriodicAccrualProduct() //
+                    .numberOfRepayments(numberOfRepayments) //
+                    .repaymentEvery(repaymentEvery) //
+                    .installmentAmountInMultiplesOf(null) //
+                    
.repaymentFrequencyType(RepaymentFrequencyType.MONTHS.longValue()) //
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    .interestRatePerPeriod(10.0)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY)//
+                    
.interestRecalculationCompoundingMethod(InterestRecalculationCompoundingMethod.NONE)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.ADJUST_LAST_UNPAID_PERIOD)//
+                    .isInterestRecalculationEnabled(true)//
+                    .recalculationRestFrequencyInterval(1)//
+                    
.recalculationRestFrequencyType(RecalculationRestFrequencyType.DAILY)//
+                    
.rescheduleStrategyMethod(RescheduleStrategyMethod.REDUCE_EMI_AMOUNT)//
+                    .allowPartialPeriodInterestCalcualtion(false)//
+                    .disallowExpectedDisbursements(false)//
+                    .allowApprovedDisbursedAmountsOverApplied(false)//
+                    .overAppliedNumber(null)//
+                    .overAppliedCalculationType(null)//
+                    .multiDisburseLoan(null);//
+
+            PostLoanProductsResponse loanProductResponse2 = 
loanProductHelper.createLoanProduct(product2);
+            Long loanProductId2 = loanProductResponse2.getResourceId();
+
+            // Apply and Approve Loan
+            double amount = 5000.0;
+
+            PostLoansRequest applicationRequest = applyLoanRequest(clientId, 
loanProductId, "01 January 2023", amount, numberOfRepayments)//
+                    .repaymentEvery(repaymentEvery)//
+                    .interestRatePerPeriod(BigDecimal.valueOf(10.0))//
+                    .loanTermFrequency(numberOfRepayments)//
+                    .repaymentFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .loanTermFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY);//
+
+            PostLoansRequest applicationRequest2 = applyLoanRequest(clientId2, 
loanProductId2, "01 January 2023", amount,
+                    numberOfRepayments)//
+                    .repaymentEvery(repaymentEvery)//
+                    .interestRatePerPeriod(BigDecimal.valueOf(10.0))//
+                    .loanTermFrequency(numberOfRepayments)//
+                    .repaymentFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .loanTermFrequencyType(RepaymentFrequencyType.MONTHS)//
+                    .interestType(InterestType.DECLINING_BALANCE)//
+                    
.interestCalculationPeriodType(InterestCalculationPeriodType.DAILY);//
+
+            PostLoansResponse postLoansResponse = 
loanTransactionHelper.applyLoan(applicationRequest);
+            PostLoansResponse postLoansResponse2 = 
loanTransactionHelper.applyLoan(applicationRequest2);
+
+            PostLoansLoanIdResponse approvedLoanResult = 
loanTransactionHelper.approveLoan(postLoansResponse.getResourceId(),
+                    approveLoanRequest(amount, "01 January 2023"));
+
+            PostLoansLoanIdResponse approvedLoanResult2 = 
loanTransactionHelper.approveLoan(postLoansResponse2.getResourceId(),
+                    approveLoanRequest(amount, "01 January 2023"));
+
+            Long loanId = approvedLoanResult.getLoanId();
+            Long loanId2 = approvedLoanResult2.getLoanId();
+            createdLoanId.getAndSet(loanId);
+            createdLoanId2.getAndSet(loanId2);
+
+            // disburse Loan
+            disburseLoan(loanId, BigDecimal.valueOf(amount), "01 January 
2023");
+            disburseLoan(loanId2, BigDecimal.valueOf(amount), "01 January 
2023");
+        });
+        runAt("01 February 2023", () -> {
+            long loanId = createdLoanId.get();
+            GetLoansLoanIdResponse loanResponse = 
loanTransactionHelper.getLoanDetails(loanId);
+            GetLoansResponse loansLoanIdResponse = 
loanTransactionHelper.retrieveAllLoans(loanResponse.getAccountNo(), clientId);
+            assert loansLoanIdResponse.getPageItems() != null;

Review Comment:
   the language asserts won't do anything for you, they have to be enabled. If 
you wanna check against a null PageItems, use AssertJ.



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