FINERACT-2120: Add new global configuration - enable payment hub integration (#4043)
This commit is contained in:
+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