This is an automated email from the ASF dual-hosted git repository.
manojvm pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new a6e35170a FINERACT-2120: Add new global configuration - enable payment
hub integration (#4043)
a6e35170a is described below
commit a6e35170a7b48c37bd0fd108929f9e2c41389d66
Author: kaibalya-fynarfin <[email protected]>
AuthorDate: Wed Sep 4 12:54:01 2024 +0530
FINERACT-2120: Add new global configuration - enable payment hub
integration (#4043)
---
.../db/changelog/tenant/changelog-tenant.xml | 1 +
.../parts/0147_enable_payment_hub_integration.xml | 42 ++++++++++++++++++++++
.../integrationtests/GlobalConfigurationTest.java | 42 ++++++++++++++++++++++
.../common/GlobalConfigurationHelper.java | 26 ++++++++++++--
4 files changed, 109 insertions(+), 2 deletions(-)
diff --git
a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
index cf753dc26..6d9c8aaf1 100644
---
a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
+++
b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml
@@ -165,4 +165,5 @@
<include file="parts/0143_add_accrual_activity_posting_job.xml"
relativeToChangelogFile="true" />
<include
file="parts/0144_transaction_summary_with_asset_owner_report_unc_allocation_fix.xml"
relativeToChangelogFile="true" />
<include file="parts/0145_job_short_name.xml"
relativeToChangelogFile="true" />
+ <include file="parts/0147_enable_payment_hub_integration.xml"
relativeToChangelogFile="true" />
</databaseChangeLog>
diff --git
a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0147_enable_payment_hub_integration.xml
b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0147_enable_payment_hub_integration.xml
new file mode 100644
index 000000000..cac890a89
--- /dev/null
+++
b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0147_enable_payment_hub_integration.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
+ <changeSet author="fineract" id="1" context="postgresql">
+ <sql>
+ SELECT SETVAL('c_configuration_id_seq', COALESCE(MAX(id), 0)+1,
false ) FROM c_configuration;
+ </sql>
+ </changeSet>
+ <changeSet author="fineract" id="2">
+ <insert tableName="c_configuration">
+ <column name="id" valueNumeric="60"/>
+ <column name="name" value="enable-payment-hub-integration"/>
+ <column name="value" valueNumeric="0"/>
+ <column name="date_value"/>
+ <column name="string_value" value="enable payment hub
integration"/>
+ <column name="enabled" valueBoolean="false"/>
+ <column name="is_trap_door" valueBoolean="false"/>
+ <column name="description" value="Use payment hub api's for
account withdrawal and loan disbursement to linked interop account"/>
+ </insert>
+ </changeSet>
+</databaseChangeLog>
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java
index 51d6a15de..d536a396a 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GlobalConfigurationTest.java
@@ -111,6 +111,48 @@ public class GlobalConfigurationTest {
}
}
+ @Test
+ public void testGlobalConfigurationsEnableDisable() {
+ this.globalConfigurationHelper = new
GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
+
+ // Retrieving All Global Configuration details
+ final ArrayList<HashMap> globalConfig =
GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
this.responseSpec);
+ Assertions.assertNotNull(globalConfig);
+ String configName = "enable_payment_hub_integration";
+ for (Integer configIndex = 0; configIndex < globalConfig.size() - 1;
configIndex++) {
+ if (globalConfig.get(configIndex).get("name").equals(configName)) {
+ Integer configId = (Integer)
globalConfig.get(configIndex).get("id");
+ Assertions.assertNotNull(configId);
+
+ HashMap configDataBefore =
GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec,
this.responseSpec,
+ configId.toString());
+ Assertions.assertNotNull(configDataBefore);
+
+ Integer value = (Integer) configDataBefore.get("value") + 1;
+
+ // Updating Enabled Flag for use-payment-hub Global
+ // Configuration
+ Boolean enabled = (Boolean)
globalConfig.get(configIndex).get("enabled");
+
+ if (enabled == true) {
+ enabled = false;
+ } else {
+ enabled = true;
+ }
+
+ configId =
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec,
this.responseSpec,
+ configId.toString(), enabled);
+
+ HashMap configDataAfter =
GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec,
this.responseSpec,
+ configId.toString());
+
+ // Verifying Enabled Flag for use-payment-hub after Updation
+ Assertions.assertEquals(enabled,
configDataAfter.get("enabled"), "Verifying Enabled Flag Global Config after
Updation");
+ break;
+ }
+ }
+ }
+
@Test
public void testGlobalConfigurationIsCacheEnabled() {
this.globalConfigurationHelper = new
GlobalConfigurationHelper(this.requestSpec, this.responseSpec);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
index 1e49b10ae..98049242c 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java
@@ -119,8 +119,8 @@ public class GlobalConfigurationHelper {
ArrayList<HashMap> expectedGlobalConfigurations =
getAllDefaultGlobalConfigurations();
ArrayList<HashMap> actualGlobalConfigurations =
getAllGlobalConfigurations(requestSpec, responseSpec);
- Assertions.assertEquals(54, expectedGlobalConfigurations.size());
- Assertions.assertEquals(54, actualGlobalConfigurations.size());
+ Assertions.assertEquals(55, expectedGlobalConfigurations.size());
+ Assertions.assertEquals(55, actualGlobalConfigurations.size());
for (int i = 0; i < expectedGlobalConfigurations.size(); i++) {
@@ -590,6 +590,15 @@ public class GlobalConfigurationHelper {
nextPaymentDateConfigForLoan.put("string_value",
"earliest-unpaid-date");
defaults.add(nextPaymentDateConfigForLoan);
+ HashMap<String, Object> enablePaymentHubIntegrationConfig = new
HashMap<>();
+ enablePaymentHubIntegrationConfig.put("id", 60);
+ enablePaymentHubIntegrationConfig.put("name",
"enable-payment-hub-integration");
+ enablePaymentHubIntegrationConfig.put("value", 0);
+ enablePaymentHubIntegrationConfig.put("enabled", false);
+ enablePaymentHubIntegrationConfig.put("trapDoor", false);
+ enablePaymentHubIntegrationConfig.put("string_value", "enable payment
hub integration");
+ defaults.add(enablePaymentHubIntegrationConfig);
+
return defaults;
}
@@ -735,4 +744,17 @@ public class GlobalConfigurationHelper {
}
+ public static Integer updateEnablePaymentHubIntegrationConfiguration(final
RequestSpecification requestSpec,
+ final ResponseSpecification responseSpec, final String
stringValue) {
+ long configId = 60;
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("stringValue", stringValue);
+ log.info("map : {}", map);
+ final String configValue = GSON.toJson(map);
+ final String GLOBAL_CONFIG_UPDATE_URL =
"/fineract-provider/api/v1/configurations/" + configId + "?" +
Utils.TENANT_IDENTIFIER;
+ log.info("---------------------------------UPDATE VALUE FOR GLOBAL
CONFIG---------------------------------------------");
+ return Utils.performServerPut(requestSpec, responseSpec,
GLOBAL_CONFIG_UPDATE_URL, configValue, "resourceId");
+
+ }
+
}