FINERACT-2120: Add new global configuration - enable payment hub integration (#4043)
This commit is contained in:
@@ -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>
|
||||
|
||||
+42
@@ -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>
|
||||
+42
@@ -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);
|
||||
|
||||
+24
-2
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user