This is an automated email from the ASF dual-hosted git repository.

adamsaghy 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 1405b28d7 FINERACT-1724: Performance improvement of global 
configuration helper (for integration tests)
1405b28d7 is described below

commit 1405b28d7167c9908c8df32a2217a3d1d8f39427
Author: Adam Saghy <[email protected]>
AuthorDate: Fri Dec 16 13:29:42 2022 +0100

    FINERACT-1724: Performance improvement of global configuration helper (for 
integration tests)
---
 .../common/GlobalConfigurationHelper.java          | 54 ++++++++++++++--------
 1 file changed, 35 insertions(+), 19 deletions(-)

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 8cb12c05b..22192a84f 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
@@ -67,29 +67,45 @@ public class GlobalConfigurationHelper {
     public static void resetAllDefaultGlobalConfigurations(final 
RequestSpecification requestSpec,
             final ResponseSpecification responseSpec) {
 
+        ArrayList<HashMap> actualGlobalConfigurations = 
getAllGlobalConfigurations(requestSpec, responseSpec);
         final ArrayList<HashMap> defaults = 
getAllDefaultGlobalConfigurations();
-        for (HashMap configDefault : defaults) {
-
-            /**
-             * Cannot update trapDoor global configurations because
-             * {@link 
org.apache.fineract.infrastructure.configuration.exception.GlobalConfigurationPropertyCannotBeModfied}
-             * will be thrown.
-             */
-            if ((Boolean) configDefault.get("trapDoor")) {
-                continue;
-            }
+        int changedNo = 0;
+        for (int i = 0; i < actualGlobalConfigurations.size(); i++) {
 
-            // Currently only values and enabled flags are modified by the
-            // integration test suite.
-            // If any other column is modified by the integration test suite in
-            // the future, it needs to be reset here.
-            final Integer configDefaultId = (Integer) configDefault.get("id");
-            final Integer configDefaultValue = (Integer) 
configDefault.get("value");
+            HashMap defaultGlobalConfiguration = defaults.get(i);
+            HashMap actualGlobalConfiguration = 
actualGlobalConfigurations.get(i);
 
-            updateValueForGlobalConfiguration(requestSpec, responseSpec, 
configDefaultId.toString(), configDefaultValue.toString());
-            updateEnabledFlagForGlobalConfiguration(requestSpec, responseSpec, 
configDefaultId.toString(),
-                    (Boolean) configDefault.get("enabled"));
+            if (!isMatching(defaultGlobalConfiguration, 
actualGlobalConfiguration)) {
+
+                /**
+                 * Cannot update trapDoor global configurations because
+                 * {@link 
org.apache.fineract.infrastructure.configuration.exception.GlobalConfigurationPropertyCannotBeModfied}
+                 * will be thrown.
+                 */
+                if ((Boolean) defaultGlobalConfiguration.get("trapDoor")) {
+                    continue;
+                }
+
+                // Currently only values and enabled flags are modified by the
+                // integration test suite.
+                // If any other column is modified by the integration test 
suite in
+                // the future, it needs to be reset here.
+                final Integer configDefaultId = (Integer) 
defaultGlobalConfiguration.get("id");
+                final Integer configDefaultValue = (Integer) 
defaultGlobalConfiguration.get("value");
+
+                updateValueForGlobalConfiguration(requestSpec, responseSpec, 
configDefaultId.toString(), configDefaultValue.toString());
+                updateEnabledFlagForGlobalConfiguration(requestSpec, 
responseSpec, configDefaultId.toString(),
+                        (Boolean) defaultGlobalConfiguration.get("enabled"));
+                changedNo++;
+            }
         }
+        log.info("--------------------------------- UPDATED GLOBAL CONFIG 
ENTRY SIZE: {} ---------------------------------------------",
+                changedNo);
+    }
+
+    private static boolean isMatching(HashMap o1, HashMap o2) {
+        return o1.get("id").equals(o2.get("id")) && 
o1.get("name").equals(o2.get("name")) && o1.get("value").equals(o2.get("value"))
+                && o1.get("enabled").equals(o2.get("enabled")) && 
o1.get("trapDoor").equals(o2.get("trapDoor"));
     }
 
     public static void verifyAllDefaultGlobalConfigurations(final 
RequestSpecification requestSpec,

Reply via email to