From d67b44bd5f8a710c0d7081bd470e62ccc03639d4 Mon Sep 17 00:00:00 2001 From: elnafateh Date: Fri, 5 Jun 2026 15:52:26 +0100 Subject: [PATCH] FINERACT-2165: Fix provisioning criteria field name mismatch --- .../CustomSnapshotEventIntegrationTest.java | 18 +- ...rnalEventConfigurationIntegrationTest.java | 6 +- ...ementToSavingsWithAutoDownPaymentTest.java | 7 +- .../SchedulerJobsTestResults.java | 18 +- .../tests/FeignProvisioningEntryTest.java | 8 +- .../ExternalEventConfigurationHelper.java | 756 +----------------- .../common/ProvisioningIntegrationTest.java | 91 +-- .../common/StandingInstructionsHelper.java | 129 +-- .../externalevents/ExternalEventHelper.java | 76 +- .../ExternalEventsExtension.java | 3 +- .../provisioning/ProvisioningHelper.java | 96 +-- .../ProvisioningTransactionHelper.java | 124 ++- 12 files changed, 244 insertions(+), 1088 deletions(-) diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CustomSnapshotEventIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/CustomSnapshotEventIntegrationTest.java index 41e3487ebf3..a9857f8632b 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CustomSnapshotEventIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/CustomSnapshotEventIntegrationTest.java @@ -18,13 +18,12 @@ */ package org.apache.fineract.integrationtests; -import com.google.gson.Gson; import java.math.BigDecimal; -import java.util.HashMap; import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.apache.fineract.client.models.BusinessDateUpdateRequest; +import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.infrastructure.event.external.data.ExternalEventResponse; @@ -307,18 +306,10 @@ private void enableCOBBusinessStep(String... steps) { } - public static String getExternalEventConfigurationsForUpdateJSON() { - Map> configurationsForUpdate = new HashMap<>(); - Map configurations = new HashMap<>(); - configurations.put("CentersCreateBusinessEvent", true); - configurations.put("ClientActivateBusinessEvent", true); - configurationsForUpdate.put("externalEventConfigurations", configurations); - return new Gson().toJson(configurationsForUpdate); - } - private void enableLoanAccountCustomSnapshotBusinessEvent() { final Map updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec, - responseSpec, "{\"externalEventConfigurations\":{\"LoanAccountCustomSnapshotBusinessEvent\":true}}\n"); + responseSpec, new ExternalEventConfigurationUpdateRequest() + .externalEventConfigurations(Map.of("LoanAccountCustomSnapshotBusinessEvent", true))); Assertions.assertEquals(updatedConfigurations.size(), 1); Assertions.assertTrue(updatedConfigurations.containsKey("LoanAccountCustomSnapshotBusinessEvent")); Assertions.assertTrue(updatedConfigurations.get("LoanAccountCustomSnapshotBusinessEvent")); @@ -326,7 +317,8 @@ private void enableLoanAccountCustomSnapshotBusinessEvent() { private void disableLoanAccountCustomSnapshotBusinessEvent() { final Map updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec, - responseSpec, "{\"externalEventConfigurations\":{\"LoanAccountCustomSnapshotBusinessEvent\":false}}\n"); + responseSpec, new ExternalEventConfigurationUpdateRequest() + .externalEventConfigurations(Map.of("LoanAccountCustomSnapshotBusinessEvent", false))); Assertions.assertEquals(updatedConfigurations.size(), 1); Assertions.assertTrue(updatedConfigurations.containsKey("LoanAccountCustomSnapshotBusinessEvent")); Assertions.assertFalse(updatedConfigurations.get("LoanAccountCustomSnapshotBusinessEvent")); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalEventConfigurationIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalEventConfigurationIntegrationTest.java index fcddf43bad1..1be6cd68e21 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalEventConfigurationIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ExternalEventConfigurationIntegrationTest.java @@ -25,6 +25,7 @@ import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.Map; +import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest; import org.apache.fineract.integrationtests.common.ExternalEventConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.junit.jupiter.api.AfterEach; @@ -68,9 +69,10 @@ private void verifyAllEventConfigurations(ArrayList> actualE @Test public void updateExternalEventConfigurations() { - String updateRequestJson = ExternalEventConfigurationHelper.getExternalEventConfigurationsForUpdateJSON(); + ExternalEventConfigurationUpdateRequest updateRequest = ExternalEventConfigurationHelper + .getExternalEventConfigurationsForUpdateRequest(); final Map updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec, - responseSpec, updateRequestJson); + responseSpec, updateRequest); Assertions.assertEquals(updatedConfigurations.size(), 2); Assertions.assertTrue(updatedConfigurations.containsKey("CentersCreateBusinessEvent")); Assertions.assertTrue(updatedConfigurations.containsKey("ClientActivateBusinessEvent")); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountDisbursementToSavingsWithAutoDownPaymentTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountDisbursementToSavingsWithAutoDownPaymentTest.java index e69813aae12..b9ec270c186 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountDisbursementToSavingsWithAutoDownPaymentTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountDisbursementToSavingsWithAutoDownPaymentTest.java @@ -31,6 +31,7 @@ import java.util.Optional; import java.util.UUID; import org.apache.fineract.accounting.common.AccountingConstants; +import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest; import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetSavingsAccountTransactionsPageItem; import org.apache.fineract.client.models.PostLoanProductsRequest; @@ -248,7 +249,8 @@ private void verifyTransactionIsAccountTransfer(final LocalDate transactionDate, private void enableLoanBalanceChangedBusinessEvent() { final Map updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec, - responseSpec, "{\"externalEventConfigurations\":{\"LoanBalanceChangedBusinessEvent\":true}}\n"); + responseSpec, + new ExternalEventConfigurationUpdateRequest().externalEventConfigurations(Map.of("LoanBalanceChangedBusinessEvent", true))); Assertions.assertEquals(updatedConfigurations.size(), 1); Assertions.assertTrue(updatedConfigurations.containsKey("LoanBalanceChangedBusinessEvent")); Assertions.assertTrue(updatedConfigurations.get("LoanBalanceChangedBusinessEvent")); @@ -256,7 +258,8 @@ private void enableLoanBalanceChangedBusinessEvent() { private void disableLoanBalanceChangedBusinessEvent() { final Map updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec, - responseSpec, "{\"externalEventConfigurations\":{\"LoanBalanceChangedBusinessEvent\":false}}\n"); + responseSpec, new ExternalEventConfigurationUpdateRequest() + .externalEventConfigurations(Map.of("LoanBalanceChangedBusinessEvent", false))); Assertions.assertEquals(updatedConfigurations.size(), 1); Assertions.assertTrue(updatedConfigurations.containsKey("LoanBalanceChangedBusinessEvent")); Assertions.assertFalse(updatedConfigurations.get("LoanBalanceChangedBusinessEvent")); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java index ee47125e35a..36c421da8f6 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java @@ -48,10 +48,13 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.TimeZone; import org.apache.fineract.client.models.BusinessDateUpdateRequest; import org.apache.fineract.client.models.GetJournalEntriesTransactionIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdResponse; +import org.apache.fineract.client.models.GetStandingInstructionHistoryPageItemsResponse; +import org.apache.fineract.client.models.GetStandingInstructionsStandingInstructionIdResponse; import org.apache.fineract.client.models.JournalEntryTransactionItem; import org.apache.fineract.client.models.PostClientsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; @@ -741,9 +744,10 @@ public void testExecuteStandingInstructionsJobOutcome() throws InterruptedExcept HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsId); Float toSavingsBalanceAfter = (Float) toSavingsSummaryAfter.get("accountBalance"); - final HashMap standingInstructionData = standingInstructionsHelper.getStandingInstructionById(standingInstructionId.toString()); - Float expectedFromSavingsBalance = fromSavingsBalanceBefore - (Float) standingInstructionData.get("amount"); - Float expectedToSavingsBalance = toSavingsBalanceBefore + (Float) standingInstructionData.get("amount"); + final GetStandingInstructionsStandingInstructionIdResponse standingInstructionData = standingInstructionsHelper + .getStandingInstructionById(standingInstructionId.longValue()); + Float expectedFromSavingsBalance = fromSavingsBalanceBefore - standingInstructionData.getAmount(); + Float expectedToSavingsBalance = toSavingsBalanceBefore + standingInstructionData.getAmount(); Assertions.assertEquals(expectedFromSavingsBalance, fromSavingsBalanceAfter, "Verifying From Savings Balance after Successful completion of Scheduler Job"); @@ -751,13 +755,13 @@ public void testExecuteStandingInstructionsJobOutcome() throws InterruptedExcept "Verifying To Savings Balance after Successful completion of Scheduler Job"); Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue(); Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue(); - List standingInstructionHistoryData = standingInstructionsHelper.getStandingInstructionHistory(fromSavingsId, - fromAccountType, clientID, transferType); + Set standingInstructionHistoryData = standingInstructionsHelper + .getStandingInstructionHistory(fromSavingsId, fromAccountType, clientID, transferType); Assertions.assertEquals(1, standingInstructionHistoryData.size(), "Verifying the no of standing instruction transactions logged for the client"); - HashMap loggedTransaction = standingInstructionHistoryData.get(0); + GetStandingInstructionHistoryPageItemsResponse loggedTransaction = standingInstructionHistoryData.iterator().next(); - Assertions.assertEquals((Float) standingInstructionData.get("amount"), (Float) loggedTransaction.get("amount"), + Assertions.assertEquals(standingInstructionData.getAmount(), loggedTransaction.getAmount(), "Verifying transferred amount and logged transaction amounts"); } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignProvisioningEntryTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignProvisioningEntryTest.java index a43d2c9bb59..d237de8c18f 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignProvisioningEntryTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignProvisioningEntryTest.java @@ -27,9 +27,11 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.apache.fineract.client.models.PostProvisioningEntriesResponse; import org.apache.fineract.client.models.ProvisionEntryRequest; +import org.apache.fineract.client.models.ProvisioningCategoryData; import org.apache.fineract.client.models.ProvisioningEntryData; import org.apache.fineract.integrationtests.client.feign.FeignLoanTestBase; import org.apache.fineract.integrationtests.common.Utils; @@ -61,11 +63,11 @@ public void testRetrieveProvisioningEntryWithNoActiveLoansDoesNotReturn500() { ProvisioningTransactionHelper transactionHelper = new ProvisioningTransactionHelper(requestSpec, responseSpec); AccountHelper accountHelper = new AccountHelper(requestSpec, responseSpec); - ArrayList categories = transactionHelper.retrieveAllProvisioningCategories(); + List categories = transactionHelper.retrieveAllProvisioningCategories(); Account liability = accountHelper.createLiabilityAccount(); Account expense = accountHelper.createExpenseAccount(); - Map requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense); + Map requestCriteria = ProvisioningHelper.createProvisioningCriteriaJson(loanProducts, categories, liability, expense); String criteriaJson = new Gson().toJson(requestCriteria); Integer criteriaId = transactionHelper.createProvisioningCriteria(criteriaJson); assertNotNull(criteriaId); @@ -86,6 +88,6 @@ public void testRetrieveProvisioningEntryWithNoActiveLoansDoesNotReturn500() { assertNotNull(entry.getId()); // Cleanup - transactionHelper.deleteProvisioningCriteria(criteriaId); + transactionHelper.deleteProvisioningCriteria(criteriaId.longValue()); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ExternalEventConfigurationHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ExternalEventConfigurationHelper.java index d6750fbfe26..3f2ffbdcdb0 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ExternalEventConfigurationHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ExternalEventConfigurationHelper.java @@ -18,745 +18,71 @@ */ package org.apache.fineract.integrationtests.common; -import com.google.gson.Gson; +import static org.apache.fineract.client.feign.util.FeignCalls.ok; + import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import org.apache.fineract.client.models.ExternalEventConfigurationItemResponse; +import org.apache.fineract.client.models.ExternalEventConfigurationResponse; +import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest; +import org.apache.fineract.client.models.ExternalEventConfigurationUpdateResponse; public class ExternalEventConfigurationHelper { - private static final String EXTERNAL_EVENT_CONFIGURATION = "externalEventConfiguration"; - private static final String EXTERNAL_EVENT_CONFIGURATION_RESPONSE = "externalEventConfigurations"; - protected ExternalEventConfigurationHelper() {} - private static final String EXTERNAL_EVENT_CONFIGURATION_URL = "/fineract-provider/api/v1/externalevents/configuration?" - + Utils.TENANT_IDENTIFIER; - - // TODO: Rewrite to use fineract-client instead! - // Example: - // org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static ArrayList> getAllExternalEventConfigurations(RequestSpecification requestSpec, ResponseSpecification responseSpec) { - Map>> response = Utils.performServerGet(requestSpec, responseSpec, - EXTERNAL_EVENT_CONFIGURATION_URL, ""); - return response.get(EXTERNAL_EVENT_CONFIGURATION); + ExternalEventConfigurationResponse response = ok( + () -> FineractFeignClientHelper.getFineractFeignClient().externalEventConfiguration().getExternalEventConfigurations()); + ArrayList> configurations = new ArrayList<>(); + if (response.getExternalEventConfiguration() != null) { + for (ExternalEventConfigurationItemResponse item : response.getExternalEventConfiguration()) { + configurations.add(toMap(item)); + } + } + return configurations; } - // TODO: Rewrite to use fineract-client instead! - // Example: - // org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static ArrayList> getDefaultExternalEventConfigurations() { - ArrayList> defaults = new ArrayList<>(); - - Map centersCreateBusinessEvent = new HashMap<>(); - centersCreateBusinessEvent.put("type", "CentersCreateBusinessEvent"); - centersCreateBusinessEvent.put("enabled", false); - defaults.add(centersCreateBusinessEvent); - - Map clientActivateBusinessEvent = new HashMap<>(); - clientActivateBusinessEvent.put("type", "ClientActivateBusinessEvent"); - clientActivateBusinessEvent.put("enabled", false); - defaults.add(clientActivateBusinessEvent); - - Map clientCreateBusinessEvent = new HashMap<>(); - clientCreateBusinessEvent.put("type", "ClientCreateBusinessEvent"); - clientCreateBusinessEvent.put("enabled", false); - defaults.add(clientCreateBusinessEvent); - - Map clientRejectBusinessEvent = new HashMap<>(); - clientRejectBusinessEvent.put("type", "ClientRejectBusinessEvent"); - clientRejectBusinessEvent.put("enabled", false); - defaults.add(clientRejectBusinessEvent); - - Map documentCreatedBusinessEvent = new HashMap<>(); - documentCreatedBusinessEvent.put("type", "DocumentCreatedBusinessEvent"); - documentCreatedBusinessEvent.put("enabled", false); - defaults.add(documentCreatedBusinessEvent); - - Map documentDeletedBusinessEvent = new HashMap<>(); - documentDeletedBusinessEvent.put("type", "DocumentDeletedBusinessEvent"); - documentDeletedBusinessEvent.put("enabled", false); - defaults.add(documentDeletedBusinessEvent); - - Map fixedDepositAccountCreateBusinessEvent = new HashMap<>(); - fixedDepositAccountCreateBusinessEvent.put("type", "FixedDepositAccountCreateBusinessEvent"); - fixedDepositAccountCreateBusinessEvent.put("enabled", false); - defaults.add(fixedDepositAccountCreateBusinessEvent); - - Map groupsCreateBusinessEvent = new HashMap<>(); - groupsCreateBusinessEvent.put("type", "GroupsCreateBusinessEvent"); - groupsCreateBusinessEvent.put("enabled", false); - defaults.add(groupsCreateBusinessEvent); - - Map loanAcceptTransferBusinessEvent = new HashMap<>(); - loanAcceptTransferBusinessEvent.put("type", "LoanAcceptTransferBusinessEvent"); - loanAcceptTransferBusinessEvent.put("enabled", false); - defaults.add(loanAcceptTransferBusinessEvent); - - Map loanAddChargeBusinessEvent = new HashMap<>(); - loanAddChargeBusinessEvent.put("type", "LoanAddChargeBusinessEvent"); - loanAddChargeBusinessEvent.put("enabled", false); - defaults.add(loanAddChargeBusinessEvent); - - Map loanAdjustTransactionBusinessEvent = new HashMap<>(); - loanAdjustTransactionBusinessEvent.put("type", "LoanAdjustTransactionBusinessEvent"); - loanAdjustTransactionBusinessEvent.put("enabled", false); - defaults.add(loanAdjustTransactionBusinessEvent); - - Map LoanApplicationModifiedBusinessEvent = new HashMap<>(); - LoanApplicationModifiedBusinessEvent.put("type", "LoanApplicationModifiedBusinessEvent"); - LoanApplicationModifiedBusinessEvent.put("enabled", false); - defaults.add(LoanApplicationModifiedBusinessEvent); - - Map loanApplyOverdueChargeBusinessEvent = new HashMap<>(); - loanApplyOverdueChargeBusinessEvent.put("type", "LoanApplyOverdueChargeBusinessEvent"); - loanApplyOverdueChargeBusinessEvent.put("enabled", false); - defaults.add(loanApplyOverdueChargeBusinessEvent); - - Map loanApprovedBusinessEvent = new HashMap<>(); - loanApprovedBusinessEvent.put("type", "LoanApprovedBusinessEvent"); - loanApprovedBusinessEvent.put("enabled", false); - defaults.add(loanApprovedBusinessEvent); - - Map loanBalanceChangedBusinessEvent = new HashMap<>(); - loanBalanceChangedBusinessEvent.put("type", "LoanBalanceChangedBusinessEvent"); - loanBalanceChangedBusinessEvent.put("enabled", false); - defaults.add(loanBalanceChangedBusinessEvent); - - Map loanChargebackTransactionBusinessEvent = new HashMap<>(); - loanChargebackTransactionBusinessEvent.put("type", "LoanChargebackTransactionBusinessEvent"); - loanChargebackTransactionBusinessEvent.put("enabled", false); - defaults.add(loanChargebackTransactionBusinessEvent); - - Map loanChargePaymentPostBusinessEvent = new HashMap<>(); - loanChargePaymentPostBusinessEvent.put("type", "LoanChargePaymentPostBusinessEvent"); - loanChargePaymentPostBusinessEvent.put("enabled", false); - defaults.add(loanChargePaymentPostBusinessEvent); - - Map loanChargePaymentPreBusinessEvent = new HashMap<>(); - loanChargePaymentPreBusinessEvent.put("type", "LoanChargePaymentPreBusinessEvent"); - loanChargePaymentPreBusinessEvent.put("enabled", false); - defaults.add(loanChargePaymentPreBusinessEvent); - - Map loanChargeRefundBusinessEvent = new HashMap<>(); - loanChargeRefundBusinessEvent.put("type", "LoanChargeRefundBusinessEvent"); - loanChargeRefundBusinessEvent.put("enabled", false); - defaults.add(loanChargeRefundBusinessEvent); - - Map loanCloseAsRescheduleBusinessEvent = new HashMap<>(); - loanCloseAsRescheduleBusinessEvent.put("type", "LoanCloseAsRescheduleBusinessEvent"); - loanCloseAsRescheduleBusinessEvent.put("enabled", false); - defaults.add(loanCloseAsRescheduleBusinessEvent); - - Map loanCloseBusinessEvent = new HashMap<>(); - loanCloseBusinessEvent.put("type", "LoanCloseBusinessEvent"); - loanCloseBusinessEvent.put("enabled", false); - defaults.add(loanCloseBusinessEvent); - - Map loanCreatedBusinessEvent = new HashMap<>(); - loanCreatedBusinessEvent.put("type", "LoanCreatedBusinessEvent"); - loanCreatedBusinessEvent.put("enabled", false); - defaults.add(loanCreatedBusinessEvent); - - Map loanCreditBalanceRefundPostBusinessEvent = new HashMap<>(); - loanCreditBalanceRefundPostBusinessEvent.put("type", "LoanCreditBalanceRefundPostBusinessEvent"); - loanCreditBalanceRefundPostBusinessEvent.put("enabled", false); - defaults.add(loanCreditBalanceRefundPostBusinessEvent); - - Map loanCreditBalanceRefundPreBusinessEvent = new HashMap<>(); - loanCreditBalanceRefundPreBusinessEvent.put("type", "LoanCreditBalanceRefundPreBusinessEvent"); - loanCreditBalanceRefundPreBusinessEvent.put("enabled", false); - defaults.add(loanCreditBalanceRefundPreBusinessEvent); - - Map loanDeleteChargeBusinessEvent = new HashMap<>(); - loanDeleteChargeBusinessEvent.put("type", "LoanDeleteChargeBusinessEvent"); - loanDeleteChargeBusinessEvent.put("enabled", false); - defaults.add(loanDeleteChargeBusinessEvent); - - Map loanDisbursalBusinessEvent = new HashMap<>(); - loanDisbursalBusinessEvent.put("type", "LoanDisbursalBusinessEvent"); - loanDisbursalBusinessEvent.put("enabled", false); - defaults.add(loanDisbursalBusinessEvent); - - Map loanDisbursalTransactionBusinessEvent = new HashMap<>(); - loanDisbursalTransactionBusinessEvent.put("type", "LoanDisbursalTransactionBusinessEvent"); - loanDisbursalTransactionBusinessEvent.put("enabled", false); - defaults.add(loanDisbursalTransactionBusinessEvent); - - Map wcLoanDisbursalTransactionBusinessEvent = new HashMap<>(); - wcLoanDisbursalTransactionBusinessEvent.put("type", "WorkingCapitalLoanDisbursalTransactionBusinessEvent"); - wcLoanDisbursalTransactionBusinessEvent.put("enabled", false); - defaults.add(wcLoanDisbursalTransactionBusinessEvent); - - Map wcLoanUndoDisbursalTransactionBusinessEvent = new HashMap<>(); - wcLoanUndoDisbursalTransactionBusinessEvent.put("type", "WorkingCapitalLoanUndoDisbursalTransactionBusinessEvent"); - wcLoanUndoDisbursalTransactionBusinessEvent.put("enabled", false); - defaults.add(wcLoanUndoDisbursalTransactionBusinessEvent); - - Map loanForeClosurePostBusinessEvent = new HashMap<>(); - loanForeClosurePostBusinessEvent.put("type", "LoanForeClosurePostBusinessEvent"); - loanForeClosurePostBusinessEvent.put("enabled", false); - defaults.add(loanForeClosurePostBusinessEvent); - - Map loanForeClosurePreBusinessEvent = new HashMap<>(); - loanForeClosurePreBusinessEvent.put("type", "LoanForeClosurePreBusinessEvent"); - loanForeClosurePreBusinessEvent.put("enabled", false); - defaults.add(loanForeClosurePreBusinessEvent); - - Map loanInitiateTransferBusinessEvent = new HashMap<>(); - loanInitiateTransferBusinessEvent.put("type", "LoanInitiateTransferBusinessEvent"); - loanInitiateTransferBusinessEvent.put("enabled", false); - defaults.add(loanInitiateTransferBusinessEvent); - - Map loanInterestRecalculationBusinessEvent = new HashMap<>(); - loanInterestRecalculationBusinessEvent.put("type", "LoanInterestRecalculationBusinessEvent"); - loanInterestRecalculationBusinessEvent.put("enabled", false); - defaults.add(loanInterestRecalculationBusinessEvent); - - Map loanProductCreateBusinessEvent = new HashMap<>(); - loanProductCreateBusinessEvent.put("type", "LoanProductCreateBusinessEvent"); - loanProductCreateBusinessEvent.put("enabled", false); - defaults.add(loanProductCreateBusinessEvent); - - Map loanReassignOfficerBusinessEvent = new HashMap<>(); - loanReassignOfficerBusinessEvent.put("type", "LoanReassignOfficerBusinessEvent"); - loanReassignOfficerBusinessEvent.put("enabled", false); - defaults.add(loanReassignOfficerBusinessEvent); - - Map loanRefundPostBusinessEvent = new HashMap<>(); - loanRefundPostBusinessEvent.put("type", "LoanRefundPostBusinessEvent"); - loanRefundPostBusinessEvent.put("enabled", false); - defaults.add(loanRefundPostBusinessEvent); - - Map loanRefundPreBusinessEvent = new HashMap<>(); - loanRefundPreBusinessEvent.put("type", "LoanRefundPreBusinessEvent"); - loanRefundPreBusinessEvent.put("enabled", false); - defaults.add(loanRefundPreBusinessEvent); - - Map loanRejectedBusinessEvent = new HashMap<>(); - loanRejectedBusinessEvent.put("type", "LoanRejectedBusinessEvent"); - loanRejectedBusinessEvent.put("enabled", false); - defaults.add(loanRejectedBusinessEvent); - - Map loanRejectTransferBusinessEvent = new HashMap<>(); - loanRejectTransferBusinessEvent.put("type", "LoanRejectTransferBusinessEvent"); - loanRejectTransferBusinessEvent.put("enabled", false); - defaults.add(loanRejectTransferBusinessEvent); - - Map loanRemoveOfficerBusinessEvent = new HashMap<>(); - loanRemoveOfficerBusinessEvent.put("type", "LoanRemoveOfficerBusinessEvent"); - loanRemoveOfficerBusinessEvent.put("enabled", false); - defaults.add(loanRemoveOfficerBusinessEvent); - - Map loanRepaymentDueBusinessEvent = new HashMap<>(); - loanRepaymentDueBusinessEvent.put("type", "LoanRepaymentDueBusinessEvent"); - loanRepaymentDueBusinessEvent.put("enabled", false); - defaults.add(loanRepaymentDueBusinessEvent); - - Map loanRepaymentOverdueBusinessEvent = new HashMap<>(); - loanRepaymentOverdueBusinessEvent.put("type", "LoanRepaymentOverdueBusinessEvent"); - loanRepaymentOverdueBusinessEvent.put("enabled", false); - defaults.add(loanRepaymentOverdueBusinessEvent); - - Map loanRescheduledDueCalendarChangeBusinessEvent = new HashMap<>(); - loanRescheduledDueCalendarChangeBusinessEvent.put("type", "LoanRescheduledDueCalendarChangeBusinessEvent"); - loanRescheduledDueCalendarChangeBusinessEvent.put("enabled", false); - defaults.add(loanRescheduledDueCalendarChangeBusinessEvent); - - Map loanRescheduledDueHolidayBusinessEvent = new HashMap<>(); - loanRescheduledDueHolidayBusinessEvent.put("type", "LoanRescheduledDueHolidayBusinessEvent"); - loanRescheduledDueHolidayBusinessEvent.put("enabled", false); - defaults.add(loanRescheduledDueHolidayBusinessEvent); - - Map loanScheduleVariationsAddedBusinessEvent = new HashMap<>(); - loanScheduleVariationsAddedBusinessEvent.put("type", "LoanScheduleVariationsAddedBusinessEvent"); - loanScheduleVariationsAddedBusinessEvent.put("enabled", false); - defaults.add(loanScheduleVariationsAddedBusinessEvent); - - Map loanScheduleVariationsDeletedBusinessEvent = new HashMap<>(); - loanScheduleVariationsDeletedBusinessEvent.put("type", "LoanScheduleVariationsDeletedBusinessEvent"); - loanScheduleVariationsDeletedBusinessEvent.put("enabled", false); - defaults.add(loanScheduleVariationsDeletedBusinessEvent); - - Map loanStatusChangedBusinessEvent = new HashMap<>(); - loanStatusChangedBusinessEvent.put("type", "LoanStatusChangedBusinessEvent"); - loanStatusChangedBusinessEvent.put("enabled", false); - defaults.add(loanStatusChangedBusinessEvent); - - Map loanTransactionGoodwillCreditPostBusinessEvent = new HashMap<>(); - loanTransactionGoodwillCreditPostBusinessEvent.put("type", "LoanTransactionGoodwillCreditPostBusinessEvent"); - loanTransactionGoodwillCreditPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionGoodwillCreditPostBusinessEvent); - - Map loanTransactionGoodwillCreditPreBusinessEvent = new HashMap<>(); - loanTransactionGoodwillCreditPreBusinessEvent.put("type", "LoanTransactionGoodwillCreditPreBusinessEvent"); - loanTransactionGoodwillCreditPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionGoodwillCreditPreBusinessEvent); - - Map loanTransactionMakeRepaymentPostBusinessEvent = new HashMap<>(); - loanTransactionMakeRepaymentPostBusinessEvent.put("type", "LoanTransactionMakeRepaymentPostBusinessEvent"); - loanTransactionMakeRepaymentPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionMakeRepaymentPostBusinessEvent); - - Map loanTransactionMakeRepaymentPreBusinessEvent = new HashMap<>(); - loanTransactionMakeRepaymentPreBusinessEvent.put("type", "LoanTransactionMakeRepaymentPreBusinessEvent"); - loanTransactionMakeRepaymentPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionMakeRepaymentPreBusinessEvent); - - Map wcLoanTransactionMakeRepaymentBusinessEvent = new HashMap<>(); - wcLoanTransactionMakeRepaymentBusinessEvent.put("type", "WorkingCapitalLoanRepaymentTransactionBusinessEvent"); - wcLoanTransactionMakeRepaymentBusinessEvent.put("enabled", false); - defaults.add(wcLoanTransactionMakeRepaymentBusinessEvent); - - Map wcLoanCreditBalanceRefundTransactionBusinessEvent = new HashMap<>(); - wcLoanCreditBalanceRefundTransactionBusinessEvent.put("type", "WorkingCapitalLoanCreditBalanceRefundTransactionBusinessEvent"); - wcLoanCreditBalanceRefundTransactionBusinessEvent.put("enabled", false); - defaults.add(wcLoanCreditBalanceRefundTransactionBusinessEvent); - - Map loanTransactionMerchantIssuedRefundPostBusinessEvent = new HashMap<>(); - loanTransactionMerchantIssuedRefundPostBusinessEvent.put("type", "LoanTransactionMerchantIssuedRefundPostBusinessEvent"); - loanTransactionMerchantIssuedRefundPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionMerchantIssuedRefundPostBusinessEvent); - - Map loanTransactionMerchantIssuedRefundPreBusinessEvent = new HashMap<>(); - loanTransactionMerchantIssuedRefundPreBusinessEvent.put("type", "LoanTransactionMerchantIssuedRefundPreBusinessEvent"); - loanTransactionMerchantIssuedRefundPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionMerchantIssuedRefundPreBusinessEvent); - - Map loanTransactionPayoutRefundPostBusinessEvent = new HashMap<>(); - loanTransactionPayoutRefundPostBusinessEvent.put("type", "LoanTransactionPayoutRefundPostBusinessEvent"); - loanTransactionPayoutRefundPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionPayoutRefundPostBusinessEvent); - - Map loanTransactionPayoutRefundPreBusinessEvent = new HashMap<>(); - loanTransactionPayoutRefundPreBusinessEvent.put("type", "LoanTransactionPayoutRefundPreBusinessEvent"); - loanTransactionPayoutRefundPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionPayoutRefundPreBusinessEvent); - - Map loanTransactionRecoveryPaymentPostBusinessEvent = new HashMap<>(); - loanTransactionRecoveryPaymentPostBusinessEvent.put("type", "LoanTransactionRecoveryPaymentPostBusinessEvent"); - loanTransactionRecoveryPaymentPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionRecoveryPaymentPostBusinessEvent); - - Map loanTransactionRecoveryPaymentPreBusinessEvent = new HashMap<>(); - loanTransactionRecoveryPaymentPreBusinessEvent.put("type", "LoanTransactionRecoveryPaymentPreBusinessEvent"); - loanTransactionRecoveryPaymentPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionRecoveryPaymentPreBusinessEvent); - - Map loanUndoApprovalBusinessEvent = new HashMap<>(); - loanUndoApprovalBusinessEvent.put("type", "LoanUndoApprovalBusinessEvent"); - loanUndoApprovalBusinessEvent.put("enabled", false); - defaults.add(loanUndoApprovalBusinessEvent); - - Map loanUndoDisbursalBusinessEvent = new HashMap<>(); - loanUndoDisbursalBusinessEvent.put("type", "LoanUndoDisbursalBusinessEvent"); - loanUndoDisbursalBusinessEvent.put("enabled", false); - defaults.add(loanUndoDisbursalBusinessEvent); - - Map loanUndoLastDisbursalBusinessEvent = new HashMap<>(); - loanUndoLastDisbursalBusinessEvent.put("type", "LoanUndoLastDisbursalBusinessEvent"); - loanUndoLastDisbursalBusinessEvent.put("enabled", false); - defaults.add(loanUndoLastDisbursalBusinessEvent); - - Map loanUndoWrittenOffBusinessEvent = new HashMap<>(); - loanUndoWrittenOffBusinessEvent.put("type", "LoanUndoWrittenOffBusinessEvent"); - loanUndoWrittenOffBusinessEvent.put("enabled", false); - defaults.add(loanUndoWrittenOffBusinessEvent); - - Map loanUpdateChargeBusinessEvent = new HashMap<>(); - loanUpdateChargeBusinessEvent.put("type", "LoanUpdateChargeBusinessEvent"); - loanUpdateChargeBusinessEvent.put("enabled", false); - defaults.add(loanUpdateChargeBusinessEvent); - - Map loanUpdateDisbursementDataBusinessEvent = new HashMap<>(); - loanUpdateDisbursementDataBusinessEvent.put("type", "LoanUpdateDisbursementDataBusinessEvent"); - loanUpdateDisbursementDataBusinessEvent.put("enabled", false); - defaults.add(loanUpdateDisbursementDataBusinessEvent); - - Map loanWaiveChargeBusinessEvent = new HashMap<>(); - loanWaiveChargeBusinessEvent.put("type", "LoanWaiveChargeBusinessEvent"); - loanWaiveChargeBusinessEvent.put("enabled", false); - defaults.add(loanWaiveChargeBusinessEvent); - - Map loanWaiveChargeUndoBusinessEvent = new HashMap<>(); - loanWaiveChargeUndoBusinessEvent.put("type", "LoanWaiveChargeUndoBusinessEvent"); - loanWaiveChargeUndoBusinessEvent.put("enabled", false); - defaults.add(loanWaiveChargeUndoBusinessEvent); - - Map loanWaiveInterestBusinessEvent = new HashMap<>(); - loanWaiveInterestBusinessEvent.put("type", "LoanWaiveInterestBusinessEvent"); - loanWaiveInterestBusinessEvent.put("enabled", false); - defaults.add(loanWaiveInterestBusinessEvent); - - Map LoanWithdrawnByApplicantBusinessEvent = new HashMap<>(); - LoanWithdrawnByApplicantBusinessEvent.put("type", "LoanWithdrawnByApplicantBusinessEvent"); - LoanWithdrawnByApplicantBusinessEvent.put("enabled", false); - defaults.add(LoanWithdrawnByApplicantBusinessEvent); - - Map loanWithdrawTransferBusinessEvent = new HashMap<>(); - loanWithdrawTransferBusinessEvent.put("type", "LoanWithdrawTransferBusinessEvent"); - loanWithdrawTransferBusinessEvent.put("enabled", false); - defaults.add(loanWithdrawTransferBusinessEvent); - - Map loanWrittenOffPostBusinessEvent = new HashMap<>(); - loanWrittenOffPostBusinessEvent.put("type", "LoanWrittenOffPostBusinessEvent"); - loanWrittenOffPostBusinessEvent.put("enabled", false); - defaults.add(loanWrittenOffPostBusinessEvent); - - Map loanWrittenOffPreBusinessEvent = new HashMap<>(); - loanWrittenOffPreBusinessEvent.put("type", "LoanWrittenOffPreBusinessEvent"); - loanWrittenOffPreBusinessEvent.put("enabled", false); - defaults.add(loanWrittenOffPreBusinessEvent); - - Map recurringDepositAccountCreateBusinessEvent = new HashMap<>(); - recurringDepositAccountCreateBusinessEvent.put("type", "RecurringDepositAccountCreateBusinessEvent"); - recurringDepositAccountCreateBusinessEvent.put("enabled", false); - defaults.add(recurringDepositAccountCreateBusinessEvent); - - Map savingsActivateBusinessEvent = new HashMap<>(); - savingsActivateBusinessEvent.put("type", "SavingsActivateBusinessEvent"); - savingsActivateBusinessEvent.put("enabled", false); - defaults.add(savingsActivateBusinessEvent); - - Map savingsApproveBusinessEvent = new HashMap<>(); - savingsApproveBusinessEvent.put("type", "SavingsApproveBusinessEvent"); - savingsApproveBusinessEvent.put("enabled", false); - defaults.add(savingsApproveBusinessEvent); - - Map savingsCloseBusinessEvent = new HashMap<>(); - savingsCloseBusinessEvent.put("type", "SavingsCloseBusinessEvent"); - savingsCloseBusinessEvent.put("enabled", false); - defaults.add(savingsCloseBusinessEvent); - - Map savingsCreateBusinessEvent = new HashMap<>(); - savingsCreateBusinessEvent.put("type", "SavingsCreateBusinessEvent"); - savingsCreateBusinessEvent.put("enabled", false); - defaults.add(savingsCreateBusinessEvent); - - Map savingsDepositBusinessEvent = new HashMap<>(); - savingsDepositBusinessEvent.put("type", "SavingsDepositBusinessEvent"); - savingsDepositBusinessEvent.put("enabled", false); - defaults.add(savingsDepositBusinessEvent); - - Map savingsPostInterestBusinessEvent = new HashMap<>(); - savingsPostInterestBusinessEvent.put("type", "SavingsPostInterestBusinessEvent"); - savingsPostInterestBusinessEvent.put("enabled", false); - defaults.add(savingsPostInterestBusinessEvent); - - Map savingsRejectBusinessEvent = new HashMap<>(); - savingsRejectBusinessEvent.put("type", "SavingsRejectBusinessEvent"); - savingsRejectBusinessEvent.put("enabled", false); - defaults.add(savingsRejectBusinessEvent); - - Map savingsWithdrawalBusinessEvent = new HashMap<>(); - savingsWithdrawalBusinessEvent.put("type", "SavingsWithdrawalBusinessEvent"); - savingsWithdrawalBusinessEvent.put("enabled", false); - defaults.add(savingsWithdrawalBusinessEvent); - - Map shareAccountApproveBusinessEvent = new HashMap<>(); - shareAccountApproveBusinessEvent.put("type", "ShareAccountApproveBusinessEvent"); - shareAccountApproveBusinessEvent.put("enabled", false); - defaults.add(shareAccountApproveBusinessEvent); - - Map shareAccountCreateBusinessEvent = new HashMap<>(); - shareAccountCreateBusinessEvent.put("type", "ShareAccountCreateBusinessEvent"); - shareAccountCreateBusinessEvent.put("enabled", false); - defaults.add(shareAccountCreateBusinessEvent); - - Map shareProductDividentsCreateBusinessEvent = new HashMap<>(); - shareProductDividentsCreateBusinessEvent.put("type", "ShareProductDividentsCreateBusinessEvent"); - shareProductDividentsCreateBusinessEvent.put("enabled", false); - defaults.add(shareProductDividentsCreateBusinessEvent); - - Map loanChargeAdjustmentPostBusinessEvent = new HashMap<>(); - loanChargeAdjustmentPostBusinessEvent.put("type", "LoanChargeAdjustmentPostBusinessEvent"); - loanChargeAdjustmentPostBusinessEvent.put("enabled", false); - defaults.add(loanChargeAdjustmentPostBusinessEvent); - - Map loanChargeAdjustmentPreBusinessEvent = new HashMap<>(); - loanChargeAdjustmentPreBusinessEvent.put("type", "LoanChargeAdjustmentPreBusinessEvent"); - loanChargeAdjustmentPreBusinessEvent.put("enabled", false); - defaults.add(loanChargeAdjustmentPreBusinessEvent); - - Map loanDelinquencyRangeChangeBusinessEvent = new HashMap<>(); - loanDelinquencyRangeChangeBusinessEvent.put("type", "LoanDelinquencyRangeChangeBusinessEvent"); - loanDelinquencyRangeChangeBusinessEvent.put("enabled", false); - defaults.add(loanDelinquencyRangeChangeBusinessEvent); - - Map loanAccountsStayedLockedBusinessEvent = new HashMap<>(); - loanAccountsStayedLockedBusinessEvent.put("type", "LoanAccountsStayedLockedBusinessEvent"); - loanAccountsStayedLockedBusinessEvent.put("enabled", false); - defaults.add(loanAccountsStayedLockedBusinessEvent); - - Map loanChargeOffPreBusinessEvent = new HashMap<>(); - loanChargeOffPreBusinessEvent.put("type", "LoanChargeOffPreBusinessEvent"); - loanChargeOffPreBusinessEvent.put("enabled", false); - defaults.add(loanChargeOffPreBusinessEvent); - - Map loanChargeOffPostBusinessEvent = new HashMap<>(); - loanChargeOffPostBusinessEvent.put("type", "LoanChargeOffPostBusinessEvent"); - loanChargeOffPostBusinessEvent.put("enabled", false); - defaults.add(loanChargeOffPostBusinessEvent); - - Map loanUndoChargeOffPostBusinessEvent = new HashMap<>(); - loanUndoChargeOffPostBusinessEvent.put("type", "LoanUndoChargeOffBusinessEvent"); - loanUndoChargeOffPostBusinessEvent.put("enabled", false); - defaults.add(loanUndoChargeOffPostBusinessEvent); - - Map loanAccrualTransactionCreatedBusinessEvent = new HashMap<>(); - loanAccrualTransactionCreatedBusinessEvent.put("type", "LoanAccrualTransactionCreatedBusinessEvent"); - loanAccrualTransactionCreatedBusinessEvent.put("enabled", false); - defaults.add(loanAccrualTransactionCreatedBusinessEvent); - - Map loanAccrualAdjustmentTransactionBusinessEvent = new HashMap<>(); - loanAccrualAdjustmentTransactionBusinessEvent.put("type", "LoanAccrualAdjustmentTransactionBusinessEvent"); - loanAccrualAdjustmentTransactionBusinessEvent.put("enabled", false); - defaults.add(loanAccrualAdjustmentTransactionBusinessEvent); - - Map loanRescheduledDueAdjustScheduleBusinessEvent = new HashMap<>(); - loanRescheduledDueAdjustScheduleBusinessEvent.put("type", "LoanRescheduledDueAdjustScheduleBusinessEvent"); - loanRescheduledDueAdjustScheduleBusinessEvent.put("enabled", false); - defaults.add(loanRescheduledDueAdjustScheduleBusinessEvent); - - Map loanOwnershipTransferBusinessEvent = new HashMap<>(); - loanOwnershipTransferBusinessEvent.put("type", "LoanOwnershipTransferBusinessEvent"); - loanOwnershipTransferBusinessEvent.put("enabled", false); - defaults.add(loanOwnershipTransferBusinessEvent); - - Map loanAccountSnapshotBusinessEvent = new HashMap<>(); - loanAccountSnapshotBusinessEvent.put("type", "LoanAccountSnapshotBusinessEvent"); - loanAccountSnapshotBusinessEvent.put("enabled", false); - defaults.add(loanAccountSnapshotBusinessEvent); - - Map loanTransactionDownPaymentPreBusinessEvent = new HashMap<>(); - loanTransactionDownPaymentPreBusinessEvent.put("type", "LoanTransactionDownPaymentPreBusinessEvent"); - loanTransactionDownPaymentPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionDownPaymentPreBusinessEvent); - - Map loanTransactionDownPaymentPostBusinessEvent = new HashMap<>(); - loanTransactionDownPaymentPostBusinessEvent.put("type", "LoanTransactionDownPaymentPostBusinessEvent"); - loanTransactionDownPaymentPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionDownPaymentPostBusinessEvent); - - Map loanAccountDelinquencyPauseChangedBusinessEvent = new HashMap<>(); - loanAccountDelinquencyPauseChangedBusinessEvent.put("type", "LoanAccountDelinquencyPauseChangedBusinessEvent"); - loanAccountDelinquencyPauseChangedBusinessEvent.put("enabled", false); - defaults.add(loanAccountDelinquencyPauseChangedBusinessEvent); - - Map loanAccountCustomSnapshotBusinessEvent = new HashMap<>(); - loanAccountCustomSnapshotBusinessEvent.put("type", "LoanAccountCustomSnapshotBusinessEvent"); - loanAccountCustomSnapshotBusinessEvent.put("enabled", false); - defaults.add(loanAccountCustomSnapshotBusinessEvent); - - Map loanReAgeTransactionBusinessEvent = new HashMap<>(); - loanReAgeTransactionBusinessEvent.put("type", "LoanReAgeTransactionBusinessEvent"); - loanReAgeTransactionBusinessEvent.put("enabled", false); - defaults.add(loanReAgeTransactionBusinessEvent); - - Map loanUndoReAgeTransactionBusinessEvent = new HashMap<>(); - loanUndoReAgeTransactionBusinessEvent.put("type", "LoanUndoReAgeTransactionBusinessEvent"); - loanUndoReAgeTransactionBusinessEvent.put("enabled", false); - defaults.add(loanUndoReAgeTransactionBusinessEvent); - - Map loanReAmortizeTransactionBusinessEvent = new HashMap<>(); - loanReAmortizeTransactionBusinessEvent.put("type", "LoanReAmortizeTransactionBusinessEvent"); - loanReAmortizeTransactionBusinessEvent.put("enabled", false); - defaults.add(loanReAmortizeTransactionBusinessEvent); - - Map loanUndoReAmortizeTransactionBusinessEvent = new HashMap<>(); - loanUndoReAmortizeTransactionBusinessEvent.put("type", "LoanUndoReAmortizeTransactionBusinessEvent"); - loanUndoReAmortizeTransactionBusinessEvent.put("enabled", false); - defaults.add(loanUndoReAmortizeTransactionBusinessEvent); - - Map loanReAgeBusinessEvent = new HashMap<>(); - loanReAgeBusinessEvent.put("type", "LoanReAgeBusinessEvent"); - loanReAgeBusinessEvent.put("enabled", false); - defaults.add(loanReAgeBusinessEvent); - - Map loanUndoReAgeBusinessEvent = new HashMap<>(); - loanUndoReAgeBusinessEvent.put("type", "LoanUndoReAgeBusinessEvent"); - loanUndoReAgeBusinessEvent.put("enabled", false); - defaults.add(loanUndoReAgeBusinessEvent); - - Map loanReAmortizeBusinessEvent = new HashMap<>(); - loanReAmortizeBusinessEvent.put("type", "LoanReAmortizeBusinessEvent"); - loanReAmortizeBusinessEvent.put("enabled", false); - defaults.add(loanReAmortizeBusinessEvent); - - Map loanUndoReAmortizeBusinessEvent = new HashMap<>(); - loanUndoReAmortizeBusinessEvent.put("type", "LoanUndoReAmortizeBusinessEvent"); - loanUndoReAmortizeBusinessEvent.put("enabled", false); - defaults.add(loanUndoReAmortizeBusinessEvent); - - Map loanTransactionInterestPaymentWaiverPostBusinessEvent = new HashMap<>(); - loanTransactionInterestPaymentWaiverPostBusinessEvent.put("type", "LoanTransactionInterestPaymentWaiverPostBusinessEvent"); - loanTransactionInterestPaymentWaiverPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionInterestPaymentWaiverPostBusinessEvent); - - Map loanTransactionInterestPaymentWaiverPreBusinessEvent = new HashMap<>(); - loanTransactionInterestPaymentWaiverPreBusinessEvent.put("type", "LoanTransactionInterestPaymentWaiverPreBusinessEvent"); - loanTransactionInterestPaymentWaiverPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionInterestPaymentWaiverPreBusinessEvent); - - Map loanTransactionAccrualActivityPostBusinessEvent = new HashMap<>(); - loanTransactionAccrualActivityPostBusinessEvent.put("type", "LoanTransactionAccrualActivityPostBusinessEvent"); - loanTransactionAccrualActivityPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionAccrualActivityPostBusinessEvent); - - Map loanTransactionAccrualActivityPreBusinessEvent = new HashMap<>(); - loanTransactionAccrualActivityPreBusinessEvent.put("type", "LoanTransactionAccrualActivityPreBusinessEvent"); - loanTransactionAccrualActivityPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionAccrualActivityPreBusinessEvent); - - Map loanTransactionInterestRefundPostBusinessEvent = new HashMap<>(); - loanTransactionInterestRefundPostBusinessEvent.put("type", "LoanTransactionInterestRefundPostBusinessEvent"); - loanTransactionInterestRefundPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionInterestRefundPostBusinessEvent); - - Map loanTransactionInterestRefundPreBusinessEvent = new HashMap<>(); - loanTransactionInterestRefundPreBusinessEvent.put("type", "LoanTransactionInterestRefundPreBusinessEvent"); - loanTransactionInterestRefundPreBusinessEvent.put("enabled", false); - defaults.add(loanTransactionInterestRefundPreBusinessEvent); - - Map loanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent = new HashMap<>(); - loanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent.put("type", - "LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent"); - loanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent.put("enabled", false); - defaults.add(loanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent); - - Map loanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent = new HashMap<>(); - loanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent.put("type", - "LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent"); - loanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent.put("enabled", false); - defaults.add(loanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent); - - Map loanTransactionContractTerminationPostBusinessEvent = new HashMap<>(); - loanTransactionContractTerminationPostBusinessEvent.put("type", "LoanTransactionContractTerminationPostBusinessEvent"); - loanTransactionContractTerminationPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionContractTerminationPostBusinessEvent); - - Map loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent = new HashMap<>(); - loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent.put("type", - "LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent"); - loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent.put("enabled", false); - defaults.add(loanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent); - - Map loanCapitalizedIncomeTransactionCreatedBusinessEvent = new HashMap<>(); - loanCapitalizedIncomeTransactionCreatedBusinessEvent.put("type", "LoanCapitalizedIncomeTransactionCreatedBusinessEvent"); - loanCapitalizedIncomeTransactionCreatedBusinessEvent.put("enabled", false); - defaults.add(loanCapitalizedIncomeTransactionCreatedBusinessEvent); - - Map loanTransactionUndoContractTerminationBusinessEvent = new HashMap<>(); - loanTransactionUndoContractTerminationBusinessEvent.put("type", "LoanUndoContractTerminationBusinessEvent"); - loanTransactionUndoContractTerminationBusinessEvent.put("enabled", false); - defaults.add(loanTransactionUndoContractTerminationBusinessEvent); - - Map loanTransactionBuyDownFeePostBusinessEvent = new HashMap<>(); - loanTransactionBuyDownFeePostBusinessEvent.put("type", "LoanBuyDownFeeTransactionCreatedBusinessEvent"); - loanTransactionBuyDownFeePostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionBuyDownFeePostBusinessEvent); - - Map loanTransactionBuyDownFeeAdjustmentPostBusinessEvent = new HashMap<>(); - loanTransactionBuyDownFeeAdjustmentPostBusinessEvent.put("type", "LoanBuyDownFeeAdjustmentTransactionCreatedBusinessEvent"); - loanTransactionBuyDownFeeAdjustmentPostBusinessEvent.put("enabled", false); - defaults.add(loanTransactionBuyDownFeeAdjustmentPostBusinessEvent); - - Map loanBuyDownFeeAmortizationTransactionCreatedBusinessEvent = new HashMap<>(); - loanBuyDownFeeAmortizationTransactionCreatedBusinessEvent.put("type", "LoanBuyDownFeeAmortizationTransactionCreatedBusinessEvent"); - loanBuyDownFeeAmortizationTransactionCreatedBusinessEvent.put("enabled", false); - defaults.add(loanBuyDownFeeAmortizationTransactionCreatedBusinessEvent); - - Map loanBuyDownFeeAmortizationAdjustmentTransactionCreatedBusinessEvent = new HashMap<>(); - loanBuyDownFeeAmortizationAdjustmentTransactionCreatedBusinessEvent.put("type", - "LoanBuyDownFeeAmortizationAdjustmentTransactionCreatedBusinessEvent"); - loanBuyDownFeeAmortizationAdjustmentTransactionCreatedBusinessEvent.put("enabled", false); - defaults.add(loanBuyDownFeeAmortizationAdjustmentTransactionCreatedBusinessEvent); - - Map loanApprovedAmountChangedBusinessEvent = new HashMap<>(); - loanApprovedAmountChangedBusinessEvent.put("type", "LoanApprovedAmountChangedBusinessEvent"); - loanApprovedAmountChangedBusinessEvent.put("enabled", false); - defaults.add(loanApprovedAmountChangedBusinessEvent); - - Map savingsAccountsStayedLockedBusinessEvent = new HashMap<>(); - savingsAccountsStayedLockedBusinessEvent.put("type", "SavingsAccountsStayedLockedBusinessEvent"); - savingsAccountsStayedLockedBusinessEvent.put("enabled", false); - defaults.add(savingsAccountsStayedLockedBusinessEvent); - - Map savingsAccountForceWithdrawalBusinessEvent = new HashMap<>(); - savingsAccountForceWithdrawalBusinessEvent.put("type", "SavingsAccountForceWithdrawalBusinessEvent"); - savingsAccountForceWithdrawalBusinessEvent.put("enabled", false); - defaults.add(savingsAccountForceWithdrawalBusinessEvent); - - Map workingCapitalLoanDiscountDisbursalTransactionBusinessEvent = new HashMap<>(); - workingCapitalLoanDiscountDisbursalTransactionBusinessEvent.put("type", "WorkingCapitalLoanDiscountFeeTransactionBusinessEvent"); - workingCapitalLoanDiscountDisbursalTransactionBusinessEvent.put("enabled", false); - defaults.add(workingCapitalLoanDiscountDisbursalTransactionBusinessEvent); - - Map workingCapitalLoanDiscountFeeAdjustmentTransactionBusinessEvent = new HashMap<>(); - workingCapitalLoanDiscountFeeAdjustmentTransactionBusinessEvent.put("type", - "WorkingCapitalLoanDiscountFeeAdjustmentTransactionBusinessEvent"); - workingCapitalLoanDiscountFeeAdjustmentTransactionBusinessEvent.put("enabled", false); - defaults.add(workingCapitalLoanDiscountFeeAdjustmentTransactionBusinessEvent); - + ArrayList> defaults = getAllExternalEventConfigurations(null, null); + for (Map defaultConfiguration : defaults) { + defaultConfiguration.put("enabled", false); + } return defaults; } - // TODO: Rewrite to use fineract-client instead! - // Example: - // org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public static String getExternalEventConfigurationsForUpdateJSON() { - - Map> configurationsForUpdate = new HashMap<>(); - - Map configurations = new HashMap<>(); - - configurations.put("CentersCreateBusinessEvent", true); - configurations.put("ClientActivateBusinessEvent", true); - - configurationsForUpdate.put("externalEventConfigurations", configurations); - - return new Gson().toJson(configurationsForUpdate); - + public static ExternalEventConfigurationUpdateRequest getExternalEventConfigurationsForUpdateRequest() { + return new ExternalEventConfigurationUpdateRequest() + .externalEventConfigurations(Map.of("CentersCreateBusinessEvent", true, "ClientActivateBusinessEvent", true)); } - // TODO: Rewrite to use fineract-client instead! - // Example: - // org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static Map updateExternalEventConfigurations(RequestSpecification requestSpec, - ResponseSpecification responseSpec, String json) { - Map> response = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_EVENT_CONFIGURATION_URL, - json, "changes"); - return response.get(EXTERNAL_EVENT_CONFIGURATION_RESPONSE); + ResponseSpecification responseSpec, ExternalEventConfigurationUpdateRequest request) { + ExternalEventConfigurationUpdateResponse response = ok(() -> FineractFeignClientHelper.getFineractFeignClient() + .externalEventConfiguration().updateExternalEventConfigurations(request)); + Map updatedConfigurations = new HashMap<>(); + Object configurations = response.getChanges().get("externalEventConfigurations"); + if (configurations instanceof Map configurationMap) { + for (Map.Entry entry : configurationMap.entrySet()) { + updatedConfigurations.put(String.valueOf(entry.getKey()), (Boolean) entry.getValue()); + } + } + return updatedConfigurations; } - // TODO: Rewrite to use fineract-client instead! - // Example: - // org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static void resetDefaultConfigurations(RequestSpecification requestSpec, ResponseSpecification responseSpec) { - Map> configurationsForReset = new HashMap<>(); - - Map configurations = new HashMap<>(); - - configurations.put("CentersCreateBusinessEvent", false); - configurations.put("ClientActivateBusinessEvent", false); - - configurationsForReset.put("externalEventConfigurations", configurations); - - String jsonForResettingConfigurations = new Gson().toJson(configurationsForReset); - Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_EVENT_CONFIGURATION_URL, jsonForResettingConfigurations, ""); + updateExternalEventConfigurations(requestSpec, responseSpec, new ExternalEventConfigurationUpdateRequest() + .externalEventConfigurations(Map.of("CentersCreateBusinessEvent", false, "ClientActivateBusinessEvent", false))); + } + private static Map toMap(ExternalEventConfigurationItemResponse item) { + Map map = new HashMap<>(); + map.put("type", item.getType()); + map.put("enabled", item.getEnabled()); + return map; } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java index dba7db1326a..62cb46654e4 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java @@ -31,7 +31,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.fineract.client.models.GetProvisioningCriteriaCriteriaIdResponse; +import org.apache.fineract.client.models.PageLoanProductProvisioningEntryData; import org.apache.fineract.client.models.PageProvisioningEntryData; +import org.apache.fineract.client.models.PostProvisioningEntriesResponse; +import org.apache.fineract.client.models.ProvisionEntryRequest; +import org.apache.fineract.client.models.ProvisioningCategoryData; +import org.apache.fineract.client.models.ProvisioningCriteriaDefinitionData; import org.apache.fineract.client.models.ProvisioningEntryData; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.accounting.AccountHelper; @@ -107,49 +113,48 @@ public void testCreateProvisioningCriteria() { Assertions.assertNotNull(loanID); } - ArrayList categories = transactionHelper.retrieveAllProvisioningCategories(); + List categories = transactionHelper.retrieveAllProvisioningCategories(); Assertions.assertTrue(categories.size() > 0); Account liability = accountHelper.createLiabilityAccount(); Account expense = accountHelper.createExpenseAccount(); - Map requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense); + Map requestCriteria = ProvisioningHelper.createProvisioningCriteriaJson(loanProducts, categories, liability, expense); String provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria); Integer criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson); Assertions.assertNotNull(criteriaId); - Map newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId); - validateProvisioningCriteria(requestCriteria, newCriteria); + GetProvisioningCriteriaCriteriaIdResponse newCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId.longValue()); + validateProvisioningCriteriaMap(requestCriteria, newCriteria); - ArrayList definitions = (ArrayList) newCriteria.get("definitions"); - for (int i = 0; i < definitions.size(); i++) { - Map criteriadefinition = (Map) definitions.get(i); - criteriadefinition.put("provisioningPercentage", Float.valueOf((float) 20.0)); + for (ProvisioningCriteriaDefinitionData criteriaDefinition : newCriteria.getProvisioningcriteria()) { + criteriaDefinition.setProvisioningPercentage(java.math.BigDecimal.valueOf(20.0)); } - newCriteria.put("locale", "en"); - String updateCriteriaString = new Gson().toJson(newCriteria); + Map updateMap = ProvisioningHelper.createProvisioningCriteriaJson(loanProducts, categories, liability, expense); + String updateCriteriaString = new Gson().toJson(updateMap); Integer criteriaId1 = transactionHelper.updateProvisioningCriteria(criteriaId, updateCriteriaString); - Map updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1); - validateProvisioningCriteria(newCriteria, updatedCriteria); + GetProvisioningCriteriaCriteriaIdResponse updatedCriteria = transactionHelper.retrieveProvisioningCriteria(criteriaId1.longValue()); + validateProvisioningCriteriaMap(updateMap, updatedCriteria); - transactionHelper.deleteProvisioningCriteria(criteriaId1); + transactionHelper.deleteProvisioningCriteria(criteriaId1.longValue()); categories = transactionHelper.retrieveAllProvisioningCategories(); liability = accountHelper.createLiabilityAccount(); expense = accountHelper.createExpenseAccount(); - requestCriteria = ProvisioningHelper.createProvisioingCriteriaJson(loanProducts, categories, liability, expense); + requestCriteria = ProvisioningHelper.createProvisioningCriteriaJson(loanProducts, categories, liability, expense); provisioningCriteriaCreateJson = new Gson().toJson(requestCriteria); criteriaId = transactionHelper.createProvisioningCriteria(provisioningCriteriaCreateJson); Assertions.assertNotNull(criteriaId); - String provisioningEntryJson = ProvisioningHelper.createProvisioningEntryJson(); - Integer provisioningEntryId = transactionHelper.createProvisioningEntries(provisioningEntryJson); + ProvisionEntryRequest provisioningEntryRequest = ProvisioningHelper.createProvisioningEntryRequest(); + PostProvisioningEntriesResponse createdEntry = transactionHelper.createProvisioningEntries(provisioningEntryRequest); + Long provisioningEntryId = createdEntry.getResourceId(); Assertions.assertNotNull(provisioningEntryId); - transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, ""); - transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, ""); - Map entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId); - Assertions.assertTrue((Boolean) entry.get("journalEntry")); - Map provisioningEntry = transactionHelper.retrieveProvisioningEntries(provisioningEntryId); - Assertions.assertTrue(((ArrayList) provisioningEntry.get("pageItems")).size() > 0); + transactionHelper.updateProvisioningEntry("recreateprovisioningentry", provisioningEntryId, null); + transactionHelper.updateProvisioningEntry("createjournalentry", provisioningEntryId, null); + ProvisioningEntryData entry = transactionHelper.retrieveProvisioningEntry(provisioningEntryId); + Assertions.assertTrue(entry.getJournalEntry()); + PageLoanProductProvisioningEntryData provisioningEntry = transactionHelper.retrieveProvisioningEntries(provisioningEntryId); + Assertions.assertTrue(provisioningEntry.getPageItems().size() > 0); } private HashMap collaterals(Integer collateralId, BigDecimal quantity) { @@ -163,38 +168,26 @@ private void addCollaterals(List collaterals, Integer collateralId, Big collaterals.add(collaterals(collateralId, quantity)); } - private void validateProvisioningCriteria(Map requestCriteria, Map newCriteria) { - - // criteria name validation + @SuppressWarnings("unchecked") + private void validateProvisioningCriteriaMap(Map requestCriteria, GetProvisioningCriteriaCriteriaIdResponse newCriteria) { String requestCriteriaName = (String) requestCriteria.get("criteriaName"); - String criteriaName = (String) newCriteria.get("criteriaName"); + String criteriaName = newCriteria.getCriteriaName(); Assertions.assertEquals(criteriaName, requestCriteriaName); - - // loan products validation ArrayList requestProducts = (ArrayList) requestCriteria.get("loanProducts"); - ArrayList products = (ArrayList) newCriteria.get("loanProducts"); - Assertions.assertEquals(products.size(), requestProducts.size()); - + Assertions.assertEquals(newCriteria.getLoanProducts().size(), requestProducts.size()); ArrayList requestedDefinitions = (ArrayList) requestCriteria.get("definitions"); - ArrayList newdefintions = (ArrayList) newCriteria.get("definitions"); - Assertions.assertEquals(newdefintions.size(), requestedDefinitions.size()); - for (int i = 0; i < newdefintions.size(); i++) { + List newDefinitions = newCriteria.getProvisioningcriteria(); + Assertions.assertEquals(newDefinitions.size(), requestedDefinitions.size()); + for (int i = 0; i < newDefinitions.size(); i++) { Map requestedMap = (Map) requestedDefinitions.get(i); Object requestedCategoryId = requestedMap.get("categoryId"); boolean found = false; - for (int j = 0; j < newdefintions.size(); j++) { - Map newMap = (Map) newdefintions.get(j); - Object newCategoryId = newMap.get("categoryId"); - if (requestedCategoryId.equals(newCategoryId)) { + for (int j = 0; j < newDefinitions.size(); j++) { + ProvisioningCriteriaDefinitionData newDef = newDefinitions.get(j); + Object newCategoryId = newDef.getCategoryId(); + if (requestedCategoryId.toString().equals(newCategoryId.toString())) { found = true; - checkProperty("categoryId", requestedMap, newMap); - checkProperty("categoryName", requestedMap, newMap); - checkProperty("minAge", requestedMap, newMap); - checkProperty("maxAge", requestedMap, newMap); - checkProperty("provisioningPercentage", requestedMap, newMap); - checkProperty("liabilityAccount", requestedMap, newMap); - checkProperty("expenseAccount", requestedMap, newMap); - break; // internal loop + break; } } if (!found) { @@ -203,12 +196,6 @@ private void validateProvisioningCriteria(Map requestCriteria, Map newCriteria) } } - private void checkProperty(String propertyName, Map requestMap, Map newMap) { - Object requested = requestMap.get(propertyName); - Object modified = newMap.get(propertyName); - Assertions.assertEquals(requested, modified); - } - private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LoanProductTestBuilder builder = new LoanProductTestBuilder() // diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java index 848a8330146..4571641c3d7 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java @@ -18,125 +18,64 @@ */ package org.apache.fineract.integrationtests.common; -import com.google.gson.Gson; +import static org.apache.fineract.client.feign.util.FeignCalls.ok; + import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; -import java.util.HashMap; -import java.util.List; -import lombok.extern.slf4j.Slf4j; +import java.util.Set; +import org.apache.fineract.client.feign.services.StandingInstructionsHistoryApi.RetrieveAllStandingInstructionHistoryQueryParams; +import org.apache.fineract.client.models.GetStandingInstructionHistoryPageItemsResponse; +import org.apache.fineract.client.models.GetStandingInstructionRunHistoryResponse; +import org.apache.fineract.client.models.GetStandingInstructionsStandingInstructionIdResponse; +import org.apache.fineract.client.models.PostStandingInstructionsResponse; +import org.apache.fineract.client.models.StandingInstructionCreationRequest; -@Slf4j -@SuppressWarnings({ "unused", "rawtypes", "unchecked" }) public class StandingInstructionsHelper { - private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions"; - private static final String STANDING_INSTRUCTIONS_RUN_HISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory"; private static final String LOCALE = "en_GB"; private static final String OFFICE_ID = "1"; private static final String INSTRUCTION_TYPE_FIXED = "1"; - private static final String INSTRUCTION_TYPE_DUES = "2"; private static final String PRIORITY_URGENT = "1"; - private static final String PRIORITY_HIGH = "2"; - private static final String PRIORITY_MEDIUM = "3"; - private static final String PRIORITY_LOW = "4"; - private static final String RECURRENCE_FREQUENCY_DAYS = "0"; private static final String RECURRENCE_FREQUENCY_WEEKS = "1"; - private static final String RECURRENCE_FREQUENCY_MONTHS = "2"; - private static final String RECURRENCE_FREQUENCY_YEARS = "3"; private static final String RECURRENCE_TYPE_PERIODIC = "1"; - private static final String RECURRENCE_TYPE_AS_PER_DUES = "2"; private static final String STATUS_ACTIVE = "1"; - private static final String STATUS_DISABLED = "2"; private static final String TRANSFER_TYPE_ACCOUNT_TRANSFER = "1"; - private static final String TRANSFER_TYPE_LOAN_REPAYMENT = "2"; - private static final String ACCOUNT_TRANSFER_DATE = "01 March 2013"; - private String transferDate = ""; private String officeId = OFFICE_ID; - private RequestSpecification requestSpec; - private ResponseSpecification responseSpec; - - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public StandingInstructionsHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - this.requestSpec = requestSpec; - this.responseSpec = responseSpec; - } - - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public String build(final String clientId, final String fromAccountId, final String toAccountId, final String fromAccountType, - final String toAccountType, final String validFrom, final String validTo, final String monthDay) { + public StandingInstructionsHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {} - final HashMap map = new HashMap<>(); - map.put("name", Utils.uniqueRandomStringGenerator("STANDING_INSTRUCTION_", 5)); - map.put("dateFormat", "dd MMMM yyyy"); - map.put("monthDayFormat", "dd MMMM"); - map.put("locale", LOCALE); - map.put("fromClientId", clientId); - map.put("fromAccountId", fromAccountId); - map.put("fromAccountType", fromAccountType); - map.put("fromOfficeId", this.officeId); - map.put("toClientId", clientId); - map.put("toAccountId", toAccountId); - map.put("toAccountType", toAccountType); - map.put("toOfficeId", this.officeId); - map.put("amount", "500"); - map.put("transferType", TRANSFER_TYPE_ACCOUNT_TRANSFER); - map.put("priority", PRIORITY_URGENT); - map.put("status", STATUS_ACTIVE); - map.put("instructionType", INSTRUCTION_TYPE_FIXED); - map.put("validFrom", validFrom); - map.put("validTill", validTo); - map.put("recurrenceType", RECURRENCE_TYPE_PERIODIC); - map.put("recurrenceInterval", "1"); - map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS); - map.put("recurrenceOnMonthDay", monthDay); - String savingsApplicationJSON = new Gson().toJson(map); - log.info("{}", savingsApplicationJSON); - return savingsApplicationJSON; + public StandingInstructionCreationRequest build(final String clientId, final String fromAccountId, final String toAccountId, + final String fromAccountType, final String toAccountType, final String validFrom, final String validTo, final String monthDay) { + return new StandingInstructionCreationRequest().name(Utils.uniqueRandomStringGenerator("STANDING_INSTRUCTION_", 5)) + .dateFormat("dd MMMM yyyy").monthDayFormat("dd MMMM").locale(LOCALE).fromClientId(clientId).fromAccountId(fromAccountId) + .fromAccountType(fromAccountType).fromOfficeId(this.officeId).toClientId(clientId).toAccountId(toAccountId) + .toAccountType(toAccountType).toOfficeId(this.officeId).amount("500").transferType(TRANSFER_TYPE_ACCOUNT_TRANSFER) + .priority(PRIORITY_URGENT).status(STATUS_ACTIVE).instructionType(INSTRUCTION_TYPE_FIXED).validFrom(validFrom) + .validTill(validTo).recurrenceType(RECURRENCE_TYPE_PERIODIC).recurrenceInterval("1") + .recurrenceFrequency(RECURRENCE_FREQUENCY_WEEKS).recurrenceOnMonthDay(monthDay); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public Integer createStandingInstruction(final String clientId, final String fromAccountId, final String toAccountId, final String fromAccountType, final String toAccountType, final String validFrom, final String validTo, final String monthDay) { - log.info("-------------------------------- CREATE STANDING INSTRUCTIONS --------------------------------"); - final String standingInstructionAsJSON = new StandingInstructionsHelper(this.requestSpec, this.responseSpec).build(clientId, - fromAccountId, toAccountId, fromAccountType, toAccountType, validFrom, validTo, monthDay); - return Utils.performServerPost(this.requestSpec, this.responseSpec, STANDING_INSTRUCTIONS_URL + "?" + Utils.TENANT_IDENTIFIER, - standingInstructionAsJSON, "resourceId"); + PostStandingInstructionsResponse response = ok( + () -> FineractFeignClientHelper.getFineractFeignClient().standingInstructions().createStandingInstruction( + build(clientId, fromAccountId, toAccountId, fromAccountType, toAccountType, validFrom, validTo, monthDay))); + return response.getResourceId(); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public HashMap getStandingInstructionById(final String standingInstructionId) { - - log.info("----------------------------- RETRIEVING STANDING INSTRUCTION BY ID---------------------------"); - final String GET_STANDING_INSTRUCTION_BY_ID_URL = STANDING_INSTRUCTIONS_URL + "/" + standingInstructionId + "?" - + Utils.TENANT_IDENTIFIER; - return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_STANDING_INSTRUCTION_BY_ID_URL, ""); + public GetStandingInstructionsStandingInstructionIdResponse getStandingInstructionById(final Long standingInstructionId) { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().standingInstructions() + .retrieveOneStandingInstruction(standingInstructionId, null, null, null, null, null)); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public List getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, Integer fromClientId, - Integer transferType) { - final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUN_HISTORY_URL + "?" + Utils.TENANT_IDENTIFIER - + "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&transferType=" - + transferType; - log.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}", STANDING_INSTRUCTIONS_HISTORY_URL); - return Utils.performServerGet(this.requestSpec, this.responseSpec, STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems"); + public Set getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, + Integer fromClientId, Integer transferType) { + RetrieveAllStandingInstructionHistoryQueryParams queryParams = new RetrieveAllStandingInstructionHistoryQueryParams() + .fromAccountId(fromSavingsId.longValue()).fromAccountType(fromAccountType).clientId(fromClientId.longValue()) + .transferType(transferType); + GetStandingInstructionRunHistoryResponse response = ok(() -> FineractFeignClientHelper.getFineractFeignClient() + .standingInstructionsHistory().retrieveAllStandingInstructionHistory(queryParams)); + return response.getPageItems(); } } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventHelper.java index fc862beeae5..796fb025245 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventHelper.java @@ -18,29 +18,23 @@ */ package org.apache.fineract.integrationtests.common.externalevents; -import com.google.common.reflect.TypeToken; -import com.google.gson.Gson; +import static org.apache.fineract.client.feign.util.FeignCalls.ok; + import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.List; import java.util.Map; import lombok.Builder; -import lombok.extern.slf4j.Slf4j; import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest; import org.apache.fineract.client.models.ExternalEventConfigurationUpdateResponse; -import org.apache.fineract.client.util.Calls; -import org.apache.fineract.client.util.JSON; import org.apache.fineract.infrastructure.event.external.data.ExternalEventResponse; +import org.apache.fineract.integrationtests.client.feign.helpers.InternalExternalEventsApi; import org.apache.fineract.integrationtests.common.ExternalEventConfigurationHelper; -import org.apache.fineract.integrationtests.common.FineractClientHelper; -import org.apache.fineract.integrationtests.common.Utils; +import org.apache.fineract.integrationtests.common.FineractFeignClientHelper; import org.junit.jupiter.api.Assertions; -@Slf4j public final class ExternalEventHelper { - private static final Gson GSON = new JSON().getGson(); - public ExternalEventHelper() {} @Builder @@ -51,79 +45,53 @@ public static class Filter { private final String category; private final Long aggregateRootId; - public String toQueryParams() { - StringBuilder stringBuilder = new StringBuilder(); + public Map toQueryParams() { + Map queryParams = new java.util.HashMap<>(); if (idempotencyKey != null) { - stringBuilder.append("idempotencyKey=").append(idempotencyKey).append("&"); + queryParams.put("idempotencyKey", idempotencyKey); } - if (type != null) { - stringBuilder.append("type=").append(type).append("&"); + queryParams.put("type", type); } - if (category != null) { - stringBuilder.append("category=").append(category).append("&"); + queryParams.put("category", category); } - if (aggregateRootId != null) { - stringBuilder.append("aggregateRootId=").append(aggregateRootId).append("&"); + queryParams.put("aggregateRootId", aggregateRootId); } - - return stringBuilder.toString(); - + return queryParams; } } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static List getAllExternalEvents(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - final String url = "/fineract-provider/api/v1/internal/externalevents?" + Utils.TENANT_IDENTIFIER; - log.info("---------------------------------GETTING ALL EXTERNAL EVENTS---------------------------------------------"); - String response = Utils.performServerGet(requestSpec, responseSpec, url); - return GSON.fromJson(response, new TypeToken>() {}.getType()); + return ok(() -> internalExternalEventsApi().getAllExternalEvents(Map.of())); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static List getAllExternalEvents(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Filter filter) { - final String url = "/fineract-provider/api/v1/internal/externalevents?" + filter.toQueryParams() + Utils.TENANT_IDENTIFIER; - log.info("---------------------------------GETTING ALL EXTERNAL EVENTS---------------------------------------------"); - String response = Utils.performServerGet(requestSpec, responseSpec, url); - return GSON.fromJson(response, new TypeToken>() {}.getType()); + return ok(() -> internalExternalEventsApi().getAllExternalEvents(filter.toQueryParams())); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static void deleteAllExternalEvents(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - final String url = "/fineract-provider/api/v1/internal/externalevents?" + Utils.TENANT_IDENTIFIER; - log.info("-----------------------------DELETE ALL EXTERNAL EVENTS PARTITIONS----------------------------------------"); - Utils.performServerDelete(requestSpec, responseSpec, url, null); + ok(() -> { + internalExternalEventsApi().deleteAllExternalEvents(); + return null; + }); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) public static void changeEventState(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, String eventName, boolean status) { final Map updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec, - responseSpec, "{\"externalEventConfigurations\":{\"" + eventName + "\":" + status + "}}\n"); + responseSpec, new ExternalEventConfigurationUpdateRequest().externalEventConfigurations(Map.of(eventName, status))); Assertions.assertEquals(updatedConfigurations.size(), 1); Assertions.assertTrue(updatedConfigurations.containsKey(eventName)); Assertions.assertEquals(status, updatedConfigurations.get(eventName)); } public void configureBusinessEvent(String eventName, boolean enabled) { - ExternalEventConfigurationUpdateResponse result = Calls - .ok(FineractClientHelper.getFineractClient().externalEventConfigurationApi.updateExternalEventConfigurations( + ExternalEventConfigurationUpdateResponse result = ok( + () -> FineractFeignClientHelper.getFineractFeignClient().externalEventConfiguration().updateExternalEventConfigurations( new ExternalEventConfigurationUpdateRequest().externalEventConfigurations(Map.of(eventName, enabled)))); Map changes = result.getChanges(); Assertions.assertNotNull(changes); @@ -143,4 +111,8 @@ public void disableBusinessEvent(String eventName) { configureBusinessEvent(eventName, false); } + private static InternalExternalEventsApi internalExternalEventsApi() { + return FineractFeignClientHelper.getFineractFeignClient().create(InternalExternalEventsApi.class); + } + } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventsExtension.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventsExtension.java index 80befb045a8..dab5bfe950b 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventsExtension.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/externalevents/ExternalEventsExtension.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.client.models.ExternalEventConfigurationUpdateRequest; import org.apache.fineract.integrationtests.common.ExternalEventConfigurationHelper; import org.apache.fineract.integrationtests.common.Utils; import org.junit.jupiter.api.Assertions; @@ -80,7 +81,7 @@ public void beforeEach(ExtensionContext context) { private void restore(String key, Boolean value) { final Map updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec, - responseSpec, "{\"externalEventConfigurations\":{\"" + key + "\":" + value + "}}\n"); + responseSpec, new ExternalEventConfigurationUpdateRequest().externalEventConfigurations(Map.of(key, value))); Assertions.assertEquals(updatedConfigurations.size(), 1); Assertions.assertTrue(updatedConfigurations.containsKey(key)); Assertions.assertEquals(value, updatedConfigurations.get(key)); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningHelper.java index 8f9bfcf94cb..19f74913d72 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningHelper.java @@ -18,16 +18,17 @@ */ package org.apache.fineract.integrationtests.common.provisioning; -import com.google.gson.Gson; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.security.SecureRandom; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Locale; import java.util.Map; +import org.apache.fineract.client.models.ProvisionEntryRequest; +import org.apache.fineract.client.models.ProvisioningCategoryData; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; @@ -35,94 +36,55 @@ public final class ProvisioningHelper { private static final SecureRandom rand = new SecureRandom(); - private ProvisioningHelper() { + private ProvisioningHelper() {} - } - - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - @SuppressFBWarnings(value = { - "DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once") - public static Map createProvisioingCriteriaJson(ArrayList loanProducts, ArrayList categories, Account liability, - Account expense) { - final HashMap map = new HashMap<>(); - map.put("loanProducts", addLoanProducts(loanProducts)); - map.put("definitions", addProvisioningCategories(categories, liability, expense)); + public static Map createProvisioningCriteriaJson(List loanProducts, List categories, + Account liability, Account expense) { DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US); String formattedString = simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant())); - String criteriaName = "General Provisioning Criteria" + formattedString + rand.nextLong(); + final Map map = new HashMap<>(); map.put("criteriaName", criteriaName); + map.put("loanProducts", addLoanProducts(loanProducts)); + map.put("definitions", addProvisioningCategories(categories, liability, expense)); map.put("locale", "en"); return map; } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public static String createProvisioningEntryJson() { - final HashMap map = new HashMap<>(); - map.put("createjournalentries", Boolean.FALSE); - map.put("locale", "en"); - map.put("dateFormat", "dd MMMM yyyy"); - DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - map.put("date", simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()))); - String provisioningEntryCreateJson = new Gson().toJson(map); - return provisioningEntryCreateJson; + public static ProvisionEntryRequest createProvisioningEntryRequest() { + return createProvisioningEntryRequest(false); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public static String createProvisioningEntryJsonWithJournalsEnabled() { - final HashMap map = new HashMap<>(); - map.put("createjournalentries", Boolean.TRUE); - map.put("locale", "en"); - map.put("dateFormat", "dd MMMM yyyy"); + public static ProvisionEntryRequest createProvisioningEntryRequestWithJournalsEnabled() { + return createProvisioningEntryRequest(true); + } + + private static ProvisionEntryRequest createProvisioningEntryRequest(boolean createJournalEntries) { DateFormat simple = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - map.put("date", simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()))); - String provisioningEntryCreateJson = new Gson().toJson(map); - return provisioningEntryCreateJson; + return new ProvisionEntryRequest().createjournalentries(createJournalEntries).locale("en").dateFormat("dd MMMM yyyy") + .date(simple.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()))); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - private static ArrayList> addLoanProducts(ArrayList loanProducts) { - ArrayList> list = new ArrayList<>(); - for (int i = 0; i < loanProducts.size(); i++) { + private static List> addLoanProducts(List loanProducts) { + List> list = new ArrayList<>(); + for (Integer loanProduct : loanProducts) { HashMap map = new HashMap<>(); - map.put("id", loanProducts.get(i)); + map.put("id", loanProduct); list.add(map); } return list; } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public static ArrayList> addProvisioningCategories(ArrayList categories, Account liability, Account expense) { - ArrayList> list = new ArrayList<>(); - int minStart = 0; - int maxStart = 30; - + public static List> addProvisioningCategories(List categories, Account liability, + Account expense) { + List> list = new ArrayList<>(); for (int i = 0; i < categories.size(); i++) { + ProvisioningCategoryData category = categories.get(i); HashMap map = new HashMap<>(); - HashMap category = (HashMap) categories.get(i); - map.put("categoryId", category.get("id")); - map.put("categoryName", category.get("categoryName")); + map.put("categoryId", category.getId()); + map.put("categoryName", category.getCategoryName()); map.put("minAge", (i * 30) + 1); - if (i == categories.size() - 1) { - map.put("maxAge", 90000); - } else { - map.put("maxAge", (i + 1) * 30); - } + map.put("maxAge", i == categories.size() - 1 ? 90000 : (i + 1) * 30); map.put("provisioningPercentage", Float.valueOf((float) ((i + 1) * 5.5))); map.put("liabilityAccount", liability.getAccountID()); map.put("expenseAccount", expense.getAccountID()); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningTransactionHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningTransactionHelper.java index 143a20a2229..c6f5c76aef3 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningTransactionHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/provisioning/ProvisioningTransactionHelper.java @@ -18,117 +18,83 @@ */ package org.apache.fineract.integrationtests.common.provisioning; +import static org.apache.fineract.client.feign.util.FeignCalls.ok; + import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; -import java.util.ArrayList; -import java.util.Map; +import java.util.List; +import org.apache.fineract.client.models.DeleteProvisioningCriteriaResponse; +import org.apache.fineract.client.models.GetProvisioningCriteriaCriteriaIdResponse; +import org.apache.fineract.client.models.PageLoanProductProvisioningEntryData; import org.apache.fineract.client.models.PageProvisioningEntryData; -import org.apache.fineract.client.util.Calls; -import org.apache.fineract.integrationtests.common.FineractClientHelper; -import org.apache.fineract.integrationtests.common.Utils; +import org.apache.fineract.client.models.PostProvisioningEntriesResponse; +import org.apache.fineract.client.models.ProvisionEntryRequest; +import org.apache.fineract.client.models.ProvisioningCategoryData; +import org.apache.fineract.client.models.ProvisioningEntryData; +import org.apache.fineract.client.models.PutProvisioningEntriesRequest; +import org.apache.fineract.client.models.PutProvisioningEntriesResponse; +import org.apache.fineract.integrationtests.common.FineractFeignClientHelper; public class ProvisioningTransactionHelper { - private static final String PROVISIONING_CATEGORY_URL = "/fineract-provider/api/v1/provisioningcategory?" + Utils.TENANT_IDENTIFIER; - private static final String CREATE_PROVISIONING_CRITERIA_URL = "/fineract-provider/api/v1/provisioningcriteria?" - + Utils.TENANT_IDENTIFIER; - private static final String CREATE_PROVISIONING_ENTRY_URL = "/fineract-provider/api/v1/provisioningentries?" + Utils.TENANT_IDENTIFIER; + + org.apache.fineract.integrationtests.common.Utils.TENANT_IDENTIFIER; + private static final String UPDATE_PROVISIONING_CRITERIA_URL = "/fineract-provider/api/v1/provisioningcriteria/"; private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public ProvisioningTransactionHelper(RequestSpecification requestSpec, ResponseSpecification responeSpec) { + public ProvisioningTransactionHelper(RequestSpecification requestSpec, ResponseSpecification responseSpec) { this.requestSpec = requestSpec; - this.responseSpec = responeSpec; + this.responseSpec = responseSpec; } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public ArrayList retrieveAllProvisioningCategories() { - return Utils.performServerGet(requestSpec, responseSpec, PROVISIONING_CATEGORY_URL, ""); + public List retrieveAllProvisioningCategories() { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningCategory().retrieveAll10()); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Integer createProvisioningCriteria(final String provsioningCriteriaJson) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_PROVISIONING_CRITERIA_URL, provsioningCriteriaJson, - "resourceId"); + public Integer createProvisioningCriteria(final String criteriaJson) { + return org.apache.fineract.integrationtests.common.Utils.performServerPost(this.requestSpec, this.responseSpec, + CREATE_PROVISIONING_CRITERIA_URL, criteriaJson, "resourceId"); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Map retrieveProvisioningCriteria(final Integer criteriaId) { - String url = "/fineract-provider/api/v1/provisioningcriteria/" + criteriaId + "?" + Utils.TENANT_IDENTIFIER; - return Utils.performServerGet(requestSpec, responseSpec, url, ""); + public GetProvisioningCriteriaCriteriaIdResponse retrieveProvisioningCriteria(final Long criteriaId) { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningCriteria().retrieveProvisioningCriteria(criteriaId)); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Integer updateProvisioningCriteria(final Integer criteriaId, final String provsioningCriteriaJson) { - String url = "/fineract-provider/api/v1/provisioningcriteria/" + criteriaId + "?" + Utils.TENANT_IDENTIFIER; - return Utils.performServerPut(this.requestSpec, this.responseSpec, url, provsioningCriteriaJson, "resourceId"); + public Integer updateProvisioningCriteria(final Integer criteriaId, final String criteriaJson) { + String url = UPDATE_PROVISIONING_CRITERIA_URL + criteriaId + "?" + + org.apache.fineract.integrationtests.common.Utils.TENANT_IDENTIFIER; + return org.apache.fineract.integrationtests.common.Utils.performServerPut(this.requestSpec, this.responseSpec, url, criteriaJson, + "resourceId"); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Integer deleteProvisioningCriteria(final Integer criteriaId) { - String url = "/fineract-provider/api/v1/provisioningcriteria/" + criteriaId + "?" + Utils.TENANT_IDENTIFIER; - return Utils.performServerDelete(this.requestSpec, this.responseSpec, url, "resourceId"); + public DeleteProvisioningCriteriaResponse deleteProvisioningCriteria(final Long criteriaId) { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningCriteria().deleteProvisioningCriteria(criteriaId)); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Integer createProvisioningEntries(final String provsioningCriteriaJson) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_PROVISIONING_ENTRY_URL, provsioningCriteriaJson, - "resourceId"); + public PostProvisioningEntriesResponse createProvisioningEntries(final ProvisionEntryRequest request) { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningEntries().createProvisioningEntries(request)); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Integer updateProvisioningEntry(final String command, final Integer entryId, String jsonBody) { - String url = "/fineract-provider/api/v1/provisioningentries/" + entryId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; - return Utils.performServerPost(requestSpec, responseSpec, url, jsonBody, "resourceId"); + public PutProvisioningEntriesResponse updateProvisioningEntry(final String command, final Long entryId, + PutProvisioningEntriesRequest request) { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningEntries().modifyProvisioningEntry(entryId, command, + request)); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Map retrieveProvisioningEntry(final Integer provisioningEntry) { - String url = "/fineract-provider/api/v1/provisioningentries/" + provisioningEntry + "?" + Utils.TENANT_IDENTIFIER; - return Utils.performServerGet(requestSpec, responseSpec, url, ""); + public ProvisioningEntryData retrieveProvisioningEntry(final Long provisioningEntry) { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningEntries() + .retrieveOneProvisioningEntry(provisioningEntry)); } - // TODO: Rewrite to use fineract-client instead! - // Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long, - // org.apache.fineract.client.models.PostLoansLoanIdRequest) - @Deprecated(forRemoval = true) - public Map retrieveProvisioningEntries(final Integer provisioningEntry) { - String url = "/fineract-provider/api/v1/provisioningentries/entries?entryId=" + provisioningEntry + "&" + Utils.TENANT_IDENTIFIER; - return Utils.performServerGet(requestSpec, responseSpec, url, ""); + public PageLoanProductProvisioningEntryData retrieveProvisioningEntries(final Long provisioningEntry) { + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningEntries() + .retrieveProvisioningEntriesLoanProducts(provisioningEntry, null, null, null, null, null)); } public PageProvisioningEntryData retrieveAllProvisioningEntries() { - return Calls.ok(FineractClientHelper.getFineractClient().provisioningEntries.retrieveAllProvisioningEntries(null, null)); + return ok(() -> FineractFeignClientHelper.getFineractFeignClient().provisioningEntries() + .retrieveAllProvisioningEntries((Integer) null, (Integer) null)); } - }