From 1a56229bc5e425476b36a43f7f18c216998fbe4d Mon Sep 17 00:00:00 2001
From: Sviatoslav Nekhaienko <snekhaienko@slb.com>
Date: Tue, 22 Dec 2020 12:27:45 +0200
Subject: [PATCH] move settings to IndexerConfigurationProperties

---
 .../indexer/config/IndexerConfigurationProperties.java     | 1 +
 .../osdu/indexer/service/impl/SchemaServiceImpl.java       | 7 ++++---
 .../osdu/indexer/service/impl/SchemaServiceImplTest.java   | 4 ++++
 .../osdu/indexer/azure/service/SchemaServiceTest.java      | 3 +++
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java
index a139637e7..13ed75f28 100644
--- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java
@@ -47,6 +47,7 @@ public class IndexerConfigurationProperties {
 	private String storageQueryRecordHost;
 	private Integer storageRecordsBatchSize;
 	private String storageSchemaHost;
+	private String schemaHost;
 	private String entitlementsHost;
 	private String entitlementTargetAudience;
 	private String indexerQueueHost;
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java
index a6d115db8..c8eb8057e 100644
--- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java
@@ -22,6 +22,7 @@ import org.opengroup.osdu.core.common.http.IUrlFetchService;
 import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
 import org.opengroup.osdu.core.common.model.http.HttpResponse;
 import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
+import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
 import org.opengroup.osdu.indexer.schema.converter.interfaces.SchemaToStorageFormat;
 import org.opengroup.osdu.indexer.service.SchemaService;
 import org.opengroup.osdu.indexer.service.StorageService;
@@ -47,8 +48,8 @@ public class SchemaServiceImpl implements SchemaService {
     @Inject
     private IUrlFetchService urlFetchService;
 
-    @Value("${SCHEMA_HOST}")
-    private String SCHEMA_HOST;
+    @Inject
+    private IndexerConfigurationProperties configurationProperties;
 
     @Inject
     private IRequestInfo requestInfo;
@@ -95,7 +96,7 @@ public class SchemaServiceImpl implements SchemaService {
     }
 
     protected HttpResponse getSchemaServiceResponse(String kind) throws UnsupportedEncodingException, URISyntaxException {
-        String url = String.format("%s/%s", SCHEMA_HOST, URLEncoder.encode(kind, StandardCharsets.UTF_8.toString()));
+        String url = String.format("%s/%s", configurationProperties.getSchemaHost(), URLEncoder.encode(kind, StandardCharsets.UTF_8.toString()));
         FetchServiceHttpRequest request = FetchServiceHttpRequest.builder()
                 .httpMethod(HttpMethods.GET)
                 .headers(this.requestInfo.getHeadersMap())
diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java
index b95b152c5..69d19a8e1 100644
--- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java
+++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java
@@ -24,6 +24,7 @@ import org.mockito.Spy;
 import org.opengroup.osdu.core.common.http.IUrlFetchService;
 import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
 import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
+import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
 import org.opengroup.osdu.indexer.schema.converter.SchemaToStorageFormatImpl;
 import org.opengroup.osdu.indexer.service.StorageService;
 import org.opengroup.osdu.indexer.service.impl.SchemaServiceImpl;
@@ -55,6 +56,9 @@ public class SchemaServiceImplTest {
     @Mock
     private StorageService storageService;
 
+    @Mock
+    private IndexerConfigurationProperties configurationProperties;
+
     @InjectMocks
     private SchemaServiceImpl sut;
 
diff --git a/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/SchemaServiceTest.java b/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/SchemaServiceTest.java
index d683fe78b..40dc8d8f9 100644
--- a/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/SchemaServiceTest.java
+++ b/provider/indexer-azure/src/test/java/org/opengroup/osdu/indexer/azure/service/SchemaServiceTest.java
@@ -24,6 +24,7 @@ import org.opengroup.osdu.core.common.http.IUrlFetchService;
 import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
 import org.opengroup.osdu.core.common.model.http.HttpResponse;
 import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
+import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
 import org.opengroup.osdu.indexer.schema.converter.SchemaToStorageFormatImpl;
 import org.opengroup.osdu.indexer.service.StorageService;
 import org.opengroup.osdu.indexer.service.impl.SchemaServiceImpl;
@@ -54,6 +55,8 @@ public class SchemaServiceTest {
     private IRequestInfo requestInfo;
     @Mock
     private StorageService storageService;
+    @Mock
+    private IndexerConfigurationProperties configurationProperties;
 
     @InjectMocks
     private SchemaServiceImpl sut;
-- 
GitLab