From 6a381df7843d6815489fbd58b4b282550447d3d1 Mon Sep 17 00:00:00 2001 From: Marta Jankovics Date: Mon, 21 Oct 2024 15:43:42 +0200 Subject: [PATCH] FINERACT-2081: fix integrationtest init --- .../integrationtests/BaseLoanIntegrationTest.java | 6 +++++- .../LoanTransactionAccrualActivityPostingTest.java | 14 ++++++++++++-- .../common/funds/FundsResourceHandler.java | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java index 7d751155f14..71dc80b44b8 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/BaseLoanIntegrationTest.java @@ -94,6 +94,7 @@ import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; 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.integrationtests.inlinecob.InlineLoanCOBHelper; import org.apache.fineract.integrationtests.useradministration.users.UserHelper; @@ -250,6 +251,9 @@ protected PostLoanProductsRequest createOnePeriod30DaysLongNoInterestPeriodicAcc } protected PostLoanProductsRequest create4IProgressive() { + final Integer delinquencyBucketId = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec, responseSpec); + Assertions.assertNotNull(delinquencyBucketId); + return new PostLoanProductsRequest().name(Utils.uniqueRandomStringGenerator("4I_PROGRESSIVE_", 6))// .shortName(Utils.uniqueRandomStringGenerator("", 4))// .description("4 installment product - progressive")// @@ -342,7 +346,7 @@ protected PostLoanProductsRequest create4IProgressive() { .graceOnPrincipalAndInterestPayment(true)// .graceOnArrearsAgeing(true)// ).isEqualAmortization(false)// - .delinquencyBucketId(1L)// + .delinquencyBucketId(delinquencyBucketId.longValue())// .enableDownPayment(false)// .enableInstallmentLevelDelinquency(false)// .loanScheduleType("PROGRESSIVE")// diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionAccrualActivityPostingTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionAccrualActivityPostingTest.java index 2598ead6818..90bb85c33b4 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionAccrualActivityPostingTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanTransactionAccrualActivityPostingTest.java @@ -18,6 +18,7 @@ */ package org.apache.fineract.integrationtests; +import static org.apache.fineract.integrationtests.common.funds.FundsResourceHandler.createFund; import static org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder.ADVANCED_PAYMENT_ALLOCATION_STRATEGY; import static org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder.DEFAULT_STRATEGY; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -57,12 +58,14 @@ import org.apache.fineract.integrationtests.common.charges.ChargesHelper; import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; +import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper; import org.apache.fineract.integrationtests.inlinecob.InlineLoanCOBHelper; import org.apache.fineract.portfolio.charge.domain.ChargeCalculationType; import org.apache.fineract.portfolio.charge.domain.ChargePaymentMode; import org.apache.fineract.portfolio.charge.domain.ChargeTimeType; import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType; import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -980,13 +983,20 @@ private PostLoanProductsRequest loanProductsRequestInterestDecliningBalanceDaily loanPaymentChannelToFundSourceMappings.fundSourceAccountId(fundSource.getAccountID().longValue()); loanPaymentChannelToFundSourceMappings.paymentTypeId(1L); paymentChannelToFundSourceMappings.add(loanPaymentChannelToFundSourceMappings); + + final Integer fundId = createFund(requestSpec, responseSpec); + Assertions.assertNotNull(fundId); + + final Integer delinquencyBucketId = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec, responseSpec); + Assertions.assertNotNull(delinquencyBucketId); + return new PostLoanProductsRequest()// .name(name)// .enableAccrualActivityPosting(true)// .shortName(shortName)// .description( "LP1 with 12% DECLINING BALANCE interest, interest period: Daily, Interest recalculation-Daily, Compounding:none")// - .fundId(1L)// + .fundId(fundId.longValue())// .startDate(null)// .closeDate(null)// .includeInBorrowerCycle(false)// @@ -1066,7 +1076,7 @@ private PostLoanProductsRequest loanProductsRequestInterestDecliningBalanceDaily .locale("en")// .disallowExpectedDisbursements(false)// .allowApprovedDisbursedAmountsOverApplied(false)// - .delinquencyBucketId(1L)// + .delinquencyBucketId(delinquencyBucketId.longValue())// .paymentChannelToFundSourceMappings(paymentChannelToFundSourceMappings)// .penaltyToIncomeAccountMappings(penaltyToIncomeAccountMappings)// .feeToIncomeAccountMappings(feeToIncomeAccountMappings)// diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/funds/FundsResourceHandler.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/funds/FundsResourceHandler.java index da98f258e03..99f5386ce27 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/funds/FundsResourceHandler.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/funds/FundsResourceHandler.java @@ -24,6 +24,7 @@ import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import java.util.List; +import java.util.UUID; import org.apache.fineract.integrationtests.common.Utils; public final class FundsResourceHandler { @@ -40,6 +41,11 @@ public static Integer createFund(final String fundJSON, final RequestSpecificati return Utils.performServerPost(requestSpec, responseSpec, CREATE_FUNDS_URL, fundJSON, "resourceId"); } + public static Integer createFund(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + FundsHelper fh = FundsHelper.create(Utils.uniqueRandomStringGenerator("", 10)).externalId(UUID.randomUUID().toString()).build(); + return createFund(fh.toJSON(), requestSpec, responseSpec); + } + public static List retrieveAllFunds(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String URL = FUNDS_URL + "?" + Utils.TENANT_IDENTIFIER; List> list = Utils.performServerGet(requestSpec, responseSpec, URL, "");