From 5712a6125ac65a96c8a4ce58b5f99cdd0fc01ca2 Mon Sep 17 00:00:00 2001
From: ZMai <zmai@slb.com>
Date: Fri, 19 May 2023 10:08:49 -0500
Subject: [PATCH] Add feature flag for augmenter and refactor codes to get
 feature flag for both geoshape decimation and augmenter

---
 .../service/IndexSchemaServiceImpl.java       | 13 ++-
 .../indexer/service/IndexerServiceImpl.java   | 29 ++++---
 .../osdu/indexer/util/AugmenterSetting.java   | 16 ++++
 .../util/BooleanFeatureFlagClient.java        | 81 +++++++++++++++++++
 ...ettingCache.java => FeatureFlagCache.java} |  4 +-
 .../decimator/GeoShapeDecimationSetting.java  | 62 +-------------
 .../service/IndexerSchemaServiceTest.java     |  4 +
 .../service/IndexerServiceImplTest.java       |  4 +
 .../StorageIndexerPayloadMapperTest.java      |  5 +-
 ...java => BooleanFeatureFlagClientTest.java} | 37 ++++++---
 .../decimator/DecimationSettingCacheTest.java |  4 +-
 11 files changed, 169 insertions(+), 90 deletions(-)
 create mode 100644 indexer-core/src/main/java/org/opengroup/osdu/indexer/util/AugmenterSetting.java
 create mode 100644 indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java
 rename indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/{DecimationSettingCache.java => FeatureFlagCache.java} (89%)
 rename indexer-core/src/test/java/org/opengroup/osdu/indexer/util/{geo/decimator/GeoShapeDecimationSettingTest.java => BooleanFeatureFlagClientTest.java} (73%)

diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexSchemaServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexSchemaServiceImpl.java
index 0accc5c08..ab3cebb80 100644
--- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexSchemaServiceImpl.java
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexSchemaServiceImpl.java
@@ -36,6 +36,7 @@ import org.opengroup.osdu.indexer.model.Kind;
 import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations;
 import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
 import org.opengroup.osdu.indexer.schema.converter.interfaces.IVirtualPropertiesSchemaCache;
+import org.opengroup.osdu.indexer.util.AugmenterSetting;
 import org.opengroup.osdu.indexer.util.ElasticClientHandler;
 import org.opengroup.osdu.indexer.util.TypeMapper;
 import org.springframework.stereotype.Service;
@@ -71,6 +72,8 @@ public class IndexSchemaServiceImpl implements IndexSchemaService {
     private IVirtualPropertiesSchemaCache virtualPropertiesSchemaCache;
     @Inject
     private PropertyConfigurationsService propertyConfigurationsService;
+    @Inject
+    private AugmenterSetting augmenterSetting;
 
     public void processSchemaMessages(Map<String, OperationType> schemaMsgs) throws IOException {
         try (RestHighLevelClient restClient = this.elasticClientHandler.createRestClient()) {
@@ -163,10 +166,12 @@ public class IndexSchemaServiceImpl implements IndexSchemaService {
             if (Strings.isNullOrEmpty(schema)) {
                 return this.getEmptySchema(kind);
             } else {
-                // Merge schema of the extended properties if needed
-                PropertyConfigurations propertyConfigurations = propertyConfigurationsService.getPropertyConfigurations(kind);
-                if (propertyConfigurations != null) {
-                    schema = mergeSchemaFromPropertyConfiguration(schema, propertyConfigurations);
+                if(augmenterSetting.isEnabled()) {
+                    // Merge schema of the extended properties if needed
+                    PropertyConfigurations propertyConfigurations = propertyConfigurationsService.getPropertyConfigurations(kind);
+                    if (propertyConfigurations != null) {
+                        schema = mergeSchemaFromPropertyConfiguration(schema, propertyConfigurations);
+                    }
                 }
 
                 IndexSchema flatSchemaObj = cacheAndNormalizeSchema(kind, schema);
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java
index bef400197..cdae2cb43 100644
--- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java
@@ -46,6 +46,7 @@ import org.opengroup.osdu.indexer.logging.AuditLogger;
 import org.opengroup.osdu.indexer.model.BulkRequestResult;
 import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations;
 import org.opengroup.osdu.indexer.provider.interfaces.IPublisher;
+import org.opengroup.osdu.indexer.util.AugmenterSetting;
 import org.opengroup.osdu.indexer.util.ElasticClientHandler;
 import org.opengroup.osdu.indexer.util.IndexerQueueTaskBuilder;
 import org.springframework.context.annotation.Primary;
@@ -106,6 +107,8 @@ public class IndexerServiceImpl implements IndexerService {
     private JobStatus jobStatus;
     @Inject
     private PropertyConfigurationsService propertyConfigurationsService;
+    @Inject
+    private AugmenterSetting augmenterSetting;
 
     private DpsHeaders headers;
 
@@ -154,10 +157,12 @@ public class IndexerServiceImpl implements IndexerService {
                 retryAndEnqueueFailedRecords(recordInfos, retryRecordIds, message);
             }
 
-            Map<String, List<String>> upsertKindIds = getUpsertRecordIdsForConfigurationsEnabledKinds(upsertRecordMap, retryRecordIds);
-            Map<String, List<String>> deleteKindIds = getDeleteRecordIdsForConfigurationsEnabledKinds(deleteRecordMap, retryRecordIds);
-            if (!upsertKindIds.isEmpty() || !deleteKindIds.isEmpty()) {
-                propertyConfigurationsService.updateAssociatedRecords(message, upsertKindIds, deleteKindIds);
+            if(this.augmenterSetting.isEnabled()) {
+                Map<String, List<String>> upsertKindIds = getUpsertRecordIdsForConfigurationsEnabledKinds(upsertRecordMap, retryRecordIds);
+                Map<String, List<String>> deleteKindIds = getDeleteRecordIdsForConfigurationsEnabledKinds(deleteRecordMap, retryRecordIds);
+                if (!upsertKindIds.isEmpty() || !deleteKindIds.isEmpty()) {
+                    propertyConfigurationsService.updateAssociatedRecords(message, upsertKindIds, deleteKindIds);
+                }
             }
         } catch (IOException e) {
             errorMessage = e.getMessage();
@@ -340,14 +345,16 @@ public class IndexerServiceImpl implements IndexerService {
                     this.jobStatus.addOrUpdateRecordStatus(storageRecord.getId(), IndexingStatus.WARN, HttpStatus.SC_NOT_FOUND, message, String.format("record-id: %s | %s", storageRecord.getId(), message));
                 }
 
-                if(propertyConfigurationsService.isPropertyConfigurationsEnabled(storageRecord.getKind())) {
-                    PropertyConfigurations propertyConfigurations = propertyConfigurationsService.getPropertyConfigurations(storageRecord.getKind());
-                    if (propertyConfigurations != null) {
-                        // Merge extended properties
-                        dataMap = mergeDataFromPropertyConfiguration(storageRecord.getId(), dataMap, propertyConfigurations);
+                if(this.augmenterSetting.isEnabled()) {
+                    if(propertyConfigurationsService.isPropertyConfigurationsEnabled(storageRecord.getKind())) {
+                        PropertyConfigurations propertyConfigurations = propertyConfigurationsService.getPropertyConfigurations(storageRecord.getKind());
+                        if (propertyConfigurations != null) {
+                            // Merge extended properties
+                            dataMap = mergeDataFromPropertyConfiguration(storageRecord.getId(), dataMap, propertyConfigurations);
+                        }
+                        // We cache the dataMap in case the update of this object will trigger update of the related objects.
+                        propertyConfigurationsService.cacheDataRecord(storageRecord.getId(), storageRecord.getKind(), dataMap);
                     }
-                    // We cache the dataMap in case the update of this object will trigger update of the related objects.
-                    propertyConfigurationsService.cacheDataRecord(storageRecord.getId(), storageRecord.getKind(), dataMap);
                 }
 
                 document.setData(dataMap);
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/AugmenterSetting.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/AugmenterSetting.java
new file mode 100644
index 000000000..d11d41cc3
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/AugmenterSetting.java
@@ -0,0 +1,16 @@
+package org.opengroup.osdu.indexer.util;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AugmenterSetting {
+    private static final String PROPERTY_NAME =  "index-augmenter-enabled";
+
+    @Autowired
+    private BooleanFeatureFlagClient booleanFeatureFlagClient;
+
+    public boolean isEnabled() {
+        return booleanFeatureFlagClient.isEnabled(PROPERTY_NAME, false);
+    }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java
new file mode 100644
index 000000000..a27ec91cd
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java
@@ -0,0 +1,81 @@
+package org.opengroup.osdu.indexer.util;
+
+import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
+import org.opengroup.osdu.core.common.model.http.DpsHeaders;
+import org.opengroup.osdu.core.common.partition.*;
+import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient;
+import org.opengroup.osdu.indexer.util.geo.decimator.FeatureFlagCache;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BooleanFeatureFlagClient {
+    private static final String TOKEN_PREFIX = "Bearer ";
+
+    @Lazy
+    @Autowired
+    private FeatureFlagCache cache;
+
+    @Autowired
+    private JaxRsDpsLog logger;
+
+    @Autowired
+    private DpsHeaders headers;
+
+    @Autowired
+    private IPartitionFactory factory;
+
+    @Autowired
+    private IServiceAccountJwtClient tokenService;
+
+    public boolean isEnabled(String featureName, boolean defaultValue) {
+        String dataPartitionId = headers.getPartitionId();
+        String cacheKey = String.format("%s-%s", dataPartitionId, featureName);
+        if (cache != null && cache.containsKey(cacheKey))
+            return cache.get(cacheKey);
+
+        boolean isEnabled = defaultValue;
+        try {
+            PartitionInfo partitionInfo = getPartitionInfo(dataPartitionId);
+            isEnabled = getFeatureValue(partitionInfo, featureName, defaultValue);
+        } catch (Exception e) {
+            this.logger.error(String.format("PartitionService: Error getting %s for dataPartition with Id: %s. Turn on the feature flag by default.", featureName, dataPartitionId), e);
+        }
+        this.cache.put(cacheKey, isEnabled);
+        return isEnabled;
+    }
+
+    private PartitionInfo getPartitionInfo(String dataPartitionId) throws PartitionException {
+        try {
+            DpsHeaders partitionHeaders = DpsHeaders.createFromMap(headers.getHeaders());
+            partitionHeaders.put(DpsHeaders.AUTHORIZATION, this.getAuthorization(dataPartitionId));
+
+            IPartitionProvider partitionProvider = this.factory.create(partitionHeaders);
+            PartitionInfo partitionInfo = partitionProvider.get(dataPartitionId);
+            return partitionInfo;
+        } catch (PartitionException e) {
+            logger.error(String.format("Error getting partition info for data-partition: %s", dataPartitionId), e);
+            throw e;
+        }
+    }
+
+    private String getAuthorization(String dataPartitionId) {
+        String authorization = this.tokenService.getIdToken(dataPartitionId);
+        if(!authorization.startsWith(TOKEN_PREFIX)) {
+            authorization = TOKEN_PREFIX + authorization;
+        }
+        return authorization;
+    }
+
+    private boolean getFeatureValue(PartitionInfo partitionInfo, String featureName, boolean defaultValue) {
+        if(partitionInfo == null || partitionInfo.getProperties() == null)
+            return defaultValue;
+
+        if(partitionInfo.getProperties().containsKey(featureName)) {
+            Property property = partitionInfo.getProperties().get(featureName);
+            return Boolean.parseBoolean((String)property.getValue());
+        }
+        return defaultValue;
+    }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/DecimationSettingCache.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/FeatureFlagCache.java
similarity index 89%
rename from indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/DecimationSettingCache.java
rename to indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/FeatureFlagCache.java
index 127d9e707..c24d200b7 100644
--- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/DecimationSettingCache.java
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/FeatureFlagCache.java
@@ -19,8 +19,8 @@ import org.opengroup.osdu.core.common.cache.VmCache;
 import org.springframework.stereotype.Component;
 
 @Component
-public class DecimationSettingCache extends VmCache<String, Boolean> {
-    public DecimationSettingCache() {
+public class FeatureFlagCache extends VmCache<String, Boolean> {
+    public FeatureFlagCache() {
         super(300, 1000);
     }
 
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/GeoShapeDecimationSetting.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/GeoShapeDecimationSetting.java
index a062c1ac6..ddab10f01 100644
--- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/GeoShapeDecimationSetting.java
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/geo/decimator/GeoShapeDecimationSetting.java
@@ -15,74 +15,18 @@
 
 package org.opengroup.osdu.indexer.util.geo.decimator;
 
-import org.apache.http.HttpStatus;
-import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
-import org.opengroup.osdu.core.common.model.http.AppException;
-import org.opengroup.osdu.core.common.model.http.DpsHeaders;
-import org.opengroup.osdu.core.common.partition.*;
-import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient;
+import org.opengroup.osdu.indexer.util.BooleanFeatureFlagClient;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Component;
 
 @Component
 public class GeoShapeDecimationSetting {
     private static final String PROPERTY_NAME =  "indexer-decimation-enabled";
 
-    @Lazy
     @Autowired
-    private DecimationSettingCache cache;
-
-    @Autowired
-    private JaxRsDpsLog logger;
-
-    @Autowired
-    private DpsHeaders headers;
-
-    @Autowired
-    private IPartitionFactory factory;
-
-    @Autowired
-    private IServiceAccountJwtClient tokenService;
+    private BooleanFeatureFlagClient booleanFeatureFlagClient;
 
     public boolean isDecimationEnabled() {
-        String dataPartitionId = headers.getPartitionId();
-        String cacheKey = String.format("%s-%s", dataPartitionId, PROPERTY_NAME);
-        if (cache != null && cache.containsKey(cacheKey))
-            return cache.get(cacheKey);
-
-        boolean decimationEnabled = true;
-        try {
-            PartitionInfo partitionInfo = getPartitionInfo(dataPartitionId);
-            decimationEnabled = getDecimationSetting(partitionInfo);
-        } catch (Exception e) {
-            this.logger.error(String.format("PartitionService: Error getting %s for dataPartition with Id: %s. Turn on the feature flag by default.", PROPERTY_NAME, dataPartitionId), e);
-        }
-        this.cache.put(cacheKey, decimationEnabled);
-        return decimationEnabled;
-    }
-
-    private PartitionInfo getPartitionInfo(String dataPartitionId) {
-        try {
-            DpsHeaders partitionHeaders = DpsHeaders.createFromMap(headers.getHeaders());
-            partitionHeaders.put(DpsHeaders.AUTHORIZATION, this.tokenService.getIdToken(dataPartitionId));
-
-            IPartitionProvider partitionProvider = this.factory.create(partitionHeaders);
-            PartitionInfo partitionInfo = partitionProvider.get(dataPartitionId);
-            return partitionInfo;
-        } catch (PartitionException e) {
-            throw new AppException(HttpStatus.SC_FORBIDDEN, "Service unavailable", String.format("Error getting partition info for data-partition: %s", dataPartitionId), e);
-        }
-    }
-
-    private boolean getDecimationSetting(PartitionInfo partitionInfo) {
-        if(partitionInfo == null || partitionInfo.getProperties() == null)
-            return true;
-
-        if(partitionInfo.getProperties().containsKey(PROPERTY_NAME)) {
-            Property property = partitionInfo.getProperties().get(PROPERTY_NAME);
-            return Boolean.parseBoolean((String)property.getValue());
-        }
-        return true;
+        return booleanFeatureFlagClient.isEnabled(PROPERTY_NAME, true);
     }
 }
diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java
index ad25654c1..4c488fb13 100644
--- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java
+++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java
@@ -37,6 +37,7 @@ import org.opengroup.osdu.indexer.cache.PartitionSafeSchemaCache;
 import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations;
 import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
 import org.opengroup.osdu.indexer.schema.converter.interfaces.IVirtualPropertiesSchemaCache;
+import org.opengroup.osdu.indexer.util.AugmenterSetting;
 import org.opengroup.osdu.indexer.util.ElasticClientHandler;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.springframework.test.context.junit4.SpringRunner;
@@ -85,6 +86,8 @@ public class IndexerSchemaServiceTest {
     private IVirtualPropertiesSchemaCache virtualPropertiesSchemaCache;
     @Mock
     private PropertyConfigurationsService propertyConfigurationsService;
+    @Mock
+    private AugmenterSetting augmenterSetting;
     @InjectMocks
     private IndexSchemaServiceImpl sut;
 
@@ -93,6 +96,7 @@ public class IndexerSchemaServiceTest {
         initMocks(this);
         RestHighLevelClient restHighLevelClient = mock(RestHighLevelClient.class);
         when(elasticClientHandler.createRestClient()).thenReturn(restHighLevelClient);
+        when(augmenterSetting.isEnabled()).thenReturn(true);
     }
 
     @Test
diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java
index f9764316c..5ab9d69ec 100644
--- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java
+++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndexerServiceImplTest.java
@@ -41,6 +41,7 @@ import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
 import org.opengroup.osdu.indexer.logging.AuditLogger;
 import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations;
 import org.opengroup.osdu.indexer.provider.interfaces.IPublisher;
+import org.opengroup.osdu.indexer.util.AugmenterSetting;
 import org.opengroup.osdu.indexer.util.ElasticClientHandler;
 import org.opengroup.osdu.indexer.util.IndexerQueueTaskBuilder;
 import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -99,6 +100,8 @@ public class IndexerServiceImplTest {
     private PropertyConfigurationsService propertyConfigurationsService;
     @Mock
     private IndexerQueueTaskBuilder indexerQueueTaskBuilder;
+    @Mock
+    private AugmenterSetting augmenterSetting;
 
     private List<RecordInfo> recordInfos = new ArrayList<>();
 
@@ -120,6 +123,7 @@ public class IndexerServiceImplTest {
 
     @Before
     public void setup() throws IOException {
+        when(augmenterSetting.isEnabled()).thenReturn(true);
     }
 
     @Test
diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapperTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapperTest.java
index a8ede574d..f11d6cb80 100644
--- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapperTest.java
+++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapperTest.java
@@ -21,6 +21,7 @@ import org.opengroup.osdu.indexer.service.mock.PartitionFactoryMock;
 import org.opengroup.osdu.indexer.service.mock.PartitionProviderMock;
 import org.opengroup.osdu.indexer.service.mock.ServiceAccountJwtClientMock;
 import org.opengroup.osdu.indexer.service.mock.VirtualPropertiesSchemaCacheMock;
+import org.opengroup.osdu.indexer.util.BooleanFeatureFlagClient;
 import org.opengroup.osdu.indexer.util.geo.decimator.*;
 import org.opengroup.osdu.indexer.util.parser.BooleanParser;
 import org.opengroup.osdu.indexer.util.parser.DateTimeParser;
@@ -45,8 +46,8 @@ import static org.junit.Assert.*;
 @RunWith(SpringRunner.class)
 @SpringBootTest(classes = {StorageIndexerPayloadMapper.class, AttributeParsingServiceImpl.class, NumberParser.class,
         BooleanParser.class, DateTimeParser.class, GeoShapeParser.class, DouglasPeuckerReducer.class, GeoShapeDecimator.class,
-        GeometryDecimator.class, GeometryConversionService.class, DecimationSettingCache.class,
-        GeoShapeDecimationSetting.class, DpsHeaders.class, JobStatus.class, SchemaConverterPropertiesConfig.class, JaxRsDpsLog.class,
+        GeometryDecimator.class, GeometryConversionService.class, FeatureFlagCache.class,
+        GeoShapeDecimationSetting.class, BooleanFeatureFlagClient.class,DpsHeaders.class, JobStatus.class, SchemaConverterPropertiesConfig.class, JaxRsDpsLog.class,
         PartitionFactoryMock.class, PartitionProviderMock.class, ServiceAccountJwtClientMock.class, VirtualPropertiesSchemaCacheMock.class, })
 public class StorageIndexerPayloadMapperTest {
 
diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/geo/decimator/GeoShapeDecimationSettingTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClientTest.java
similarity index 73%
rename from indexer-core/src/test/java/org/opengroup/osdu/indexer/util/geo/decimator/GeoShapeDecimationSettingTest.java
rename to indexer-core/src/test/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClientTest.java
index 82fc83db7..10e73df39 100644
--- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/geo/decimator/GeoShapeDecimationSettingTest.java
+++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClientTest.java
@@ -13,7 +13,7 @@
  * limitations under the License.
  */
 
-package org.opengroup.osdu.indexer.util.geo.decimator;
+package org.opengroup.osdu.indexer.util;
 
 import org.junit.Assert;
 import org.junit.Before;
@@ -25,6 +25,7 @@ import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
 import org.opengroup.osdu.core.common.model.http.DpsHeaders;
 import org.opengroup.osdu.core.common.partition.*;
 import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient;
+import org.opengroup.osdu.indexer.util.geo.decimator.FeatureFlagCache;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.util.HashMap;
@@ -34,14 +35,14 @@ import static org.mockito.ArgumentMatchers.anyString;
 import static org.powermock.api.mockito.PowerMockito.when;
 
 @RunWith(SpringRunner.class)
-public class GeoShapeDecimationSettingTest {
+public class BooleanFeatureFlagClientTest {
     private static final String PROPERTY_NAME =  "indexer-decimation-enabled";
 
     @InjectMocks
-    private GeoShapeDecimationSetting sut;
+    private BooleanFeatureFlagClient sut;
 
     @Mock
-    private DecimationSettingCache cache;
+    private FeatureFlagCache cache;
 
     @Mock
     private JaxRsDpsLog logger;
@@ -74,7 +75,12 @@ public class GeoShapeDecimationSettingTest {
         property.setValue("true");
         partitionInfo.getProperties().put(PROPERTY_NAME, property);
         when(this.partitionProvider.get(anyString())).thenReturn(partitionInfo);
-        boolean enabled = sut.isDecimationEnabled();
+
+        // Default value won't take any effect
+        boolean enabled = sut.isEnabled(PROPERTY_NAME, true);
+        Assert.assertTrue(enabled);
+
+        enabled = sut.isEnabled(PROPERTY_NAME, false);
         Assert.assertTrue(enabled);
     }
 
@@ -86,25 +92,36 @@ public class GeoShapeDecimationSettingTest {
         property.setValue("false");
         partitionInfo.getProperties().put(PROPERTY_NAME, property);
         when(this.partitionProvider.get(anyString())).thenReturn(partitionInfo);
-        boolean enabled = sut.isDecimationEnabled();
+
+        // Default value won't take any effect
+        boolean enabled = sut.isEnabled(PROPERTY_NAME, true);
+        Assert.assertFalse(enabled);
+
+        enabled = sut.isEnabled(PROPERTY_NAME, false);
         Assert.assertFalse(enabled);
     }
 
     @Test
-    public void isDecimationEnabled_return_true_when_property_does_not_exist() throws PartitionException {
+    public void isDecimationEnabled_return_default_value_when_property_does_not_exist() throws PartitionException {
         // The feature flag is enabled by default
         PartitionInfo partitionInfo = new PartitionInfo();
         when(this.partitionProvider.get(anyString())).thenReturn(partitionInfo);
-        boolean enabled = sut.isDecimationEnabled();
+        boolean enabled = sut.isEnabled(PROPERTY_NAME, true);;
         Assert.assertTrue(enabled);
+
+        enabled = sut.isEnabled(PROPERTY_NAME, false);;
+        Assert.assertFalse(enabled);
     }
 
     @Test
-    public void isDecimationEnabled_return_true_when_partitionProvider_throws_exception() throws PartitionException {
+    public void isDecimationEnabled_return_default_value_when_partitionProvider_throws_exception() throws PartitionException {
         // The feature flag is enabled by default
         when(this.partitionProvider.get(anyString())).thenThrow(PartitionException.class);
-        boolean enabled = sut.isDecimationEnabled();
+        boolean enabled = sut.isEnabled(PROPERTY_NAME, true);;
         Assert.assertTrue(enabled);
+
+        enabled = sut.isEnabled(PROPERTY_NAME, false);;
+        Assert.assertFalse(enabled);
     }
 
 }
diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/geo/decimator/DecimationSettingCacheTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/geo/decimator/DecimationSettingCacheTest.java
index e850126fe..c32159b5e 100644
--- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/geo/decimator/DecimationSettingCacheTest.java
+++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/util/geo/decimator/DecimationSettingCacheTest.java
@@ -25,11 +25,11 @@ import org.springframework.test.context.junit4.SpringRunner;
 public class DecimationSettingCacheTest {
     private static final String VALID_KEY = "Tenant1-indexer-decimation-enabled";
     private static final String INVALID_KEY = "Tenant2-indexer-decimation-enabled";
-    DecimationSettingCache cache;
+    FeatureFlagCache cache;
 
     @Before
     public void setup() {
-        cache = new DecimationSettingCache();
+        cache = new FeatureFlagCache();
         cache.put(VALID_KEY, true);
     }
 
-- 
GitLab