summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'sparkybe-onap-service/src/test/java')
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizerTest.java372
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java16
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java34
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java34
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java52
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ElasticSearchAdapterTest.java50
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilderTest.java34
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java121
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/entity/TopographicalEntityTest.java50
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityCountHistoryProcessorTest.java118
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AbstractEntitySynchronizerTest.java12
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java58
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/ElasticSearchIndexCleanerTest.java122
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/ElasticSearchEndpointConfigTest.java39
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/topology/sync/GeoSynchronizerTest.java347
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java14
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java34
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoEntitySynchronizer.java792
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoSyncController.java107
19 files changed, 119 insertions, 2287 deletions
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizerTest.java
deleted file mode 100644
index e9f03ba..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizerTest.java
+++ /dev/null
@@ -1,372 +0,0 @@
-package org.onap.aai.sparky.aggregation.sync;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.setup.Version;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
-import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
-import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.util.TestResourceLoader;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import javax.inject.Inject;
-
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(properties = {
-"schemaIngestPropLoc = src/test/resources/oxm-reader/schema-ingest-single-oxm.properties" })
-@ContextConfiguration(locations = { "classpath:oxm-reader/oxm-reader-bean.xml" })
-public class HistoricalEntitySummarizerTest {
-
- private static ObjectMapper mapper = new ObjectMapper();
-
- private HistoricalEntitySummarizer historicalSummarizer;
-
- private ElasticSearchSchemaConfig esSchemaConfig;
- private NetworkStatisticsConfig aaiStatConfig;
- private NetworkStatisticsConfig esStatConfig;
-
- private SearchableEntityLookup searchableEntityLookup;
- private ElasticSearchAdapter esAdapter;
- private ActiveInventoryAdapter aaiAdapter;
-
-
-
- @Inject
- private NodeIngestor nodeInjest;
-
-
- @Inject
- private OxmEntityLookup oxmEntityLookup;
-
-
-
- @Before
- public void init() throws Exception {
-
- esSchemaConfig = new ElasticSearchSchemaConfig();
- esSchemaConfig.setIndexDocType("default");
- esSchemaConfig.setIndexMappingsFileName(null);
- esSchemaConfig.setIndexName("aggregation-index-name");
- esSchemaConfig.setIndexSettingsFileName(null);
-
-
- aaiStatConfig = new NetworkStatisticsConfig();
-
- aaiStatConfig.setNumSamplesPerThreadForRunningAverage(100);
-
- aaiStatConfig.setBytesHistogramLabel("[Response Size In Bytes]");
- aaiStatConfig.setBytesHistogramMaxYAxis(1000000L);
- aaiStatConfig.setBytesHistogramNumBins(20);
- aaiStatConfig.setBytesHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setQueueLengthHistogramLabel("[Queue Item Length]");
- aaiStatConfig.setQueueLengthHistogramMaxYAxis(20000);
- aaiStatConfig.setQueueLengthHistogramNumBins(20);
- aaiStatConfig.setQueueLengthHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setTaskAgeHistogramLabel("[Task Age In Ms]");
- aaiStatConfig.setTaskAgeHistogramMaxYAxis(600000L);
- aaiStatConfig.setTaskAgeHistogramNumBins(20);
- aaiStatConfig.setTaskAgeHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setResponseTimeHistogramLabel("[Response Time In Ms]");
- aaiStatConfig.setResponseTimeHistogramMaxYAxis(1000L);
- aaiStatConfig.setResponseTimeHistogramNumBins(20);
- aaiStatConfig.setResponseTimeHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setTpsHistogramLabel("[Transactions Per Second]");
- aaiStatConfig.setTpsHistogramMaxYAxis(100);
- aaiStatConfig.setTpsHistogramNumBins(20);
- aaiStatConfig.setTpsHistogramNumDecimalPoints(2);
-
- esStatConfig = new NetworkStatisticsConfig();
-
- esStatConfig.setNumSamplesPerThreadForRunningAverage(100);
-
- esStatConfig.setBytesHistogramLabel("[Response Size In Bytes]");
- esStatConfig.setBytesHistogramMaxYAxis(1000000L);
- esStatConfig.setBytesHistogramNumBins(20);
- esStatConfig.setBytesHistogramNumDecimalPoints(2);
-
- esStatConfig.setQueueLengthHistogramLabel("[Queue Item Length]");
- esStatConfig.setQueueLengthHistogramMaxYAxis(20000);
- esStatConfig.setQueueLengthHistogramNumBins(20);
- esStatConfig.setQueueLengthHistogramNumDecimalPoints(2);
-
- esStatConfig.setTaskAgeHistogramLabel("[Task Age In Ms]");
- esStatConfig.setTaskAgeHistogramMaxYAxis(600000L);
- esStatConfig.setTaskAgeHistogramNumBins(20);
- esStatConfig.setTaskAgeHistogramNumDecimalPoints(2);
-
- esStatConfig.setResponseTimeHistogramLabel("[Response Time In Ms]");
- esStatConfig.setResponseTimeHistogramMaxYAxis(10000L);
- esStatConfig.setResponseTimeHistogramNumBins(20);
- esStatConfig.setResponseTimeHistogramNumDecimalPoints(2);
-
- esStatConfig.setTpsHistogramLabel("[Transactions Per Second]");
- esStatConfig.setTpsHistogramMaxYAxis(100);
- esStatConfig.setTpsHistogramNumBins(20);
- esStatConfig.setTpsHistogramNumDecimalPoints(2);
-
- oxmEntityLookup = new OxmEntityLookup();
-
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
- aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
-
-
- Set<OxmModelProcessor> processors = new HashSet<OxmModelProcessor>();
-
- processors.add(oxmEntityLookup);
-
-
-
- Map<String, OxmEntityDescriptor> oxmEntityDescriptors =
- new HashMap<String, OxmEntityDescriptor>();
-
- OxmEntityDescriptor genericVnfDescriptor = new OxmEntityDescriptor();
- genericVnfDescriptor.setEntityName("generic-vnf");
- List<String> pkeyNames = new ArrayList<String>();
- pkeyNames.add("vnf-name");
-
- genericVnfDescriptor.setPrimaryKeyAttributeNames(pkeyNames);
-
- oxmEntityDescriptors.put("generic-vnf", genericVnfDescriptor);
-
-
- oxmEntityLookup.setEntityDescriptors(oxmEntityDescriptors);
-
- SuggestionEntityDescriptor genericVnfSuggestionDescriptor = new SuggestionEntityDescriptor();
- genericVnfSuggestionDescriptor.setEntityName("generic-vnf");
- genericVnfSuggestionDescriptor.setPrimaryKeyAttributeNames(pkeyNames);
-
-
-
- /*
- * SuggestionSearchEntity sse = new SuggestionSearchEntity(filtersConfig);
- *
- * sse.setEntityType("generic-vnf"); sse.setSuggestionPropertyTypes( Arrays.asList("vnf-name"));
- *
- * genericVnfSuggestionDescriptor.setSuggestionSearchEntity(sse);
- *
- * suggestionEntityDescriptors.put("generic-vnf", genericVnfSuggestionDescriptor);
- */
-
- searchableEntityLookup = new SearchableEntityLookup();
-
- processors.add(searchableEntityLookup);
- Version v = Version.V11;
- OxmModelLoader oxmModelLoader = new OxmModelLoader(v, processors,nodeInjest);
- oxmModelLoader.loadModel();
-
-
- }
-
- @Test
- public void validateBasicConstruction() throws Exception {
-
- historicalSummarizer = new HistoricalEntitySummarizer(esSchemaConfig, 5, 5, 5, aaiStatConfig,
- esStatConfig, searchableEntityLookup);
-
- historicalSummarizer.setAaiAdapter(aaiAdapter);
- historicalSummarizer.setElasticSearchAdapter(esAdapter);
-
- assertNotNull(historicalSummarizer.getAaiAdapter());
- assertNotNull(historicalSummarizer.getElasticSearchAdapter());
-
- }
-
- @Test
- public void validateSmallSync() throws Exception {
-
- historicalSummarizer = new HistoricalEntitySummarizer(esSchemaConfig, 5, 5, 5, aaiStatConfig,
- esStatConfig, searchableEntityLookup);
-
-
- historicalSummarizer.setAaiAdapter(aaiAdapter);
- historicalSummarizer.setElasticSearchAdapter(esAdapter);
-
- String nodesQueryResponse = TestResourceLoader
- .getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
-
- OperationResult genericVnfSelfLinks = new OperationResult();
-
- genericVnfSelfLinks.setResultCode(200);
- genericVnfSelfLinks.setResult(nodesQueryResponse);
-
- Mockito.when(aaiAdapter.getSelfLinksByEntityType("generic-vnf"))
- .thenReturn(genericVnfSelfLinks);
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-1"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-1");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-2"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-2");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-3"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-3");
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
-
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
- .thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
- "http://server.proxy:9200/myindex/mytype/doc2",
- "http://server.proxy:9200/myindex/mytype/doc3");
-
- /*
- * Our initial gets from elastic search should be record-not-found
- */
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
-
-
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
- .thenReturn(new OperationResult(200, null));
-
- OperationState syncState = historicalSummarizer.doSync();
- assertEquals(OperationState.OK, syncState);
-
- assertNotNull(historicalSummarizer.getStatReport(false));
- assertNotNull(historicalSummarizer.getStatReport(true));
-
- historicalSummarizer.clearCache();
- historicalSummarizer.shutdown();
-
-
- }
-
- @Test
- public void validateSmallSyncWithRetries() throws Exception {
-
- historicalSummarizer = new HistoricalEntitySummarizer(esSchemaConfig, 5, 5, 5, aaiStatConfig,
- esStatConfig, searchableEntityLookup);
-
-
- historicalSummarizer.setAaiAdapter(aaiAdapter);
- historicalSummarizer.setElasticSearchAdapter(esAdapter);
-
- String nodesQueryResponse = TestResourceLoader
- .getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
-
- OperationResult genericVnfSelfLinks = new OperationResult();
-
- genericVnfSelfLinks.setResultCode(200);
- genericVnfSelfLinks.setResult(nodesQueryResponse);
-
- Mockito.when(aaiAdapter.getSelfLinksByEntityType("generic-vnf"))
- .thenReturn(genericVnfSelfLinks);
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-1"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-1");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-2"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-2");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-3"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-3");
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
-
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
- .thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
- "http://server.proxy:9200/myindex/mytype/doc2",
- "http://server.proxy:9200/myindex/mytype/doc3");
-
- /*
- * Our initial gets from elastic search should be record-not-found
- */
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
-
-
- /*
- * Elastic Search puts always fail with a version conflict = 409
- */
-
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
- .thenReturn(new OperationResult(409, null));
-
- OperationState syncState = historicalSummarizer.doSync();
- assertEquals(OperationState.OK, syncState);
-
- assertNotNull(historicalSummarizer.getStatReport(false));
- assertNotNull(historicalSummarizer.getStatReport(true));
-
- historicalSummarizer.clearCache();
- historicalSummarizer.shutdown();
-
-
- }
-} \ No newline at end of file
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java
deleted file mode 100644
index 9527520..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.onap.aai.sparky.aggregation.sync;
-
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class HistoricalEntitySyncControllerTest {
-
- @Test
- public void shouldConvertMinutesToMs() {
- assertEquals(60000, HistoricalEntitySyncController.getTaskFrequencyInMs(1));
- assertEquals(120000, HistoricalEntitySyncController.getTaskFrequencyInMs(2));
- }
-
-} \ No newline at end of file
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java
index 4471390..8c13ebc 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java
@@ -26,7 +26,7 @@ import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor;
import org.onap.aai.sparky.config.oxm.SuggestionEntityLookup;
import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.search.filters.config.FiltersConfig;
import org.onap.aai.sparky.search.filters.config.FiltersDetailsConfig;
import org.onap.aai.sparky.search.filters.config.FiltersForViewsConfig;
@@ -58,7 +58,7 @@ public class AutosuggestionSynchronizerTest {
private NetworkStatisticsConfig esStatConfig;
- private ElasticSearchAdapter esAdapter;
+ private SearchServiceAdapter searchServiceAdapter;
private ActiveInventoryAdapter aaiAdapter;
@Inject
@@ -153,7 +153,7 @@ public class AutosuggestionSynchronizerTest {
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
+ searchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
@@ -221,10 +221,10 @@ public class AutosuggestionSynchronizerTest {
esStatConfig, oxmEntityLookup, suggestionEntityLookup, filtersConfig);
suggestionSynchronizer.setAaiAdapter(aaiAdapter);
- suggestionSynchronizer.setElasticSearchAdapter(esAdapter);
+ suggestionSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
assertNotNull(suggestionSynchronizer.getAaiAdapter());
- assertNotNull(suggestionSynchronizer.getElasticSearchAdapter());
+ assertNotNull(suggestionSynchronizer.getSearchServiceAdapter());
}
@@ -236,7 +236,7 @@ public class AutosuggestionSynchronizerTest {
suggestionSynchronizer.setAaiAdapter(aaiAdapter);
- suggestionSynchronizer.setElasticSearchAdapter(esAdapter);
+ suggestionSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
@@ -287,7 +287,7 @@ public class AutosuggestionSynchronizerTest {
.thenReturn(new OperationResult(200, TestResourceLoader
.getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -295,15 +295,15 @@ public class AutosuggestionSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
OperationState syncState = suggestionSynchronizer.doSync();
@@ -326,7 +326,7 @@ public class AutosuggestionSynchronizerTest {
suggestionSynchronizer.setAaiAdapter(aaiAdapter);
- suggestionSynchronizer.setElasticSearchAdapter(esAdapter);
+ suggestionSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
@@ -377,7 +377,7 @@ public class AutosuggestionSynchronizerTest {
.thenReturn(new OperationResult(200, TestResourceLoader
.getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -385,11 +385,11 @@ public class AutosuggestionSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
@@ -397,7 +397,7 @@ public class AutosuggestionSynchronizerTest {
* Elastic Search puts always fail with a version conflict = 409
*/
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(409, null));
OperationState syncState = suggestionSynchronizer.doSync();
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java
index 1a14256..e72b0df 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java
@@ -22,7 +22,7 @@ import org.onap.aai.sparky.config.oxm.OxmModelLoader;
import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor;
import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.search.filters.config.FiltersConfig;
import org.onap.aai.sparky.search.filters.config.FiltersDetailsConfig;
import org.onap.aai.sparky.search.filters.config.FiltersForViewsConfig;
@@ -44,7 +44,7 @@ public class VnfAliasSuggestionSynchronizerTest {
private NetworkStatisticsConfig esStatConfig;
private OxmEntityLookup oxmEntityLookup;
private GeoEntityLookup geoEntityLookup;
- private ElasticSearchAdapter esAdapter;
+ private SearchServiceAdapter searchServiceAdapter;
private ActiveInventoryAdapter aaiAdapter;
private FiltersConfig filtersConfig;
@@ -120,7 +120,7 @@ public class VnfAliasSuggestionSynchronizerTest {
oxmEntityLookup = new OxmEntityLookup();
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
+ searchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
@@ -186,10 +186,10 @@ public class VnfAliasSuggestionSynchronizerTest {
aaiStatConfig, esStatConfig, filtersConfig);
vnfAliasSuggestionSynchronizer.setAaiAdapter(aaiAdapter);
- vnfAliasSuggestionSynchronizer.setElasticSearchAdapter(esAdapter);
+ vnfAliasSuggestionSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
assertNotNull(vnfAliasSuggestionSynchronizer.getAaiAdapter());
- assertNotNull(vnfAliasSuggestionSynchronizer.getElasticSearchAdapter());
+ assertNotNull(vnfAliasSuggestionSynchronizer.getSearchServiceAdapter());
}
@@ -201,7 +201,7 @@ public class VnfAliasSuggestionSynchronizerTest {
vnfAliasSuggestionSynchronizer.setAaiAdapter(aaiAdapter);
- vnfAliasSuggestionSynchronizer.setElasticSearchAdapter(esAdapter);
+ vnfAliasSuggestionSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
@@ -244,7 +244,7 @@ public class VnfAliasSuggestionSynchronizerTest {
.thenReturn(new OperationResult(200, TestResourceLoader
.getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -252,15 +252,15 @@ public class VnfAliasSuggestionSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
OperationState syncState = vnfAliasSuggestionSynchronizer.doSync();
@@ -283,7 +283,7 @@ public class VnfAliasSuggestionSynchronizerTest {
vnfAliasSuggestionSynchronizer.setAaiAdapter(aaiAdapter);
- vnfAliasSuggestionSynchronizer.setElasticSearchAdapter(esAdapter);
+ vnfAliasSuggestionSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
@@ -326,7 +326,7 @@ public class VnfAliasSuggestionSynchronizerTest {
.thenReturn(new OperationResult(200, TestResourceLoader
.getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -334,11 +334,11 @@ public class VnfAliasSuggestionSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
@@ -346,7 +346,7 @@ public class VnfAliasSuggestionSynchronizerTest {
* Elastic Search puts always fail with a version conflict = 409
*/
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(409, null));
OperationState syncState = vnfAliasSuggestionSynchronizer.doSync();
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java
index c085ca4..b275813 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java
@@ -22,7 +22,7 @@ import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
@@ -43,7 +43,7 @@ public class CrossEntityReferenceSynchronizerTest {
private NetworkStatisticsConfig esStatConfig;
private OxmEntityLookup oxmEntityLookup;
private SearchableEntityLookup searchableEntityLookup;
- private ElasticSearchAdapter esAdapter;
+ private SearchServiceAdapter searchServiceAdapter;
private ActiveInventoryAdapter aaiAdapter;
private CrossEntityReferenceLookup cerLookup;
private RestEndpointConfig aaiRestEndPointConfig;
@@ -118,7 +118,7 @@ public class CrossEntityReferenceSynchronizerTest {
oxmEntityLookup = new OxmEntityLookup();
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
+ searchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
@@ -164,10 +164,10 @@ public class CrossEntityReferenceSynchronizerTest {
esStatConfig, cerLookup, oxmEntityLookup, searchableEntityLookup);
cerSynchronizer.setAaiAdapter(aaiAdapter);
- cerSynchronizer.setElasticSearchAdapter(esAdapter);
+ cerSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
assertNotNull(cerSynchronizer.getAaiAdapter());
- assertNotNull(cerSynchronizer.getElasticSearchAdapter());
+ assertNotNull(cerSynchronizer.getSearchServiceAdapter());
}
@@ -182,7 +182,7 @@ public class CrossEntityReferenceSynchronizerTest {
esStatConfig, cerLookup, oxmEntityLookup, searchableEntityLookup);
cerSynchronizer.setAaiAdapter(aaiAdapter);
- cerSynchronizer.setElasticSearchAdapter(esAdapter);
+ cerSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_service-subscription_nodesQuery_response.json");
@@ -448,7 +448,7 @@ public class CrossEntityReferenceSynchronizerTest {
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -456,15 +456,15 @@ public class CrossEntityReferenceSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
OperationState syncState = cerSynchronizer.doSync();
@@ -486,7 +486,7 @@ public class CrossEntityReferenceSynchronizerTest {
esStatConfig, cerLookup, oxmEntityLookup, searchableEntityLookup);
cerSynchronizer.setAaiAdapter(aaiAdapter);
- cerSynchronizer.setElasticSearchAdapter(esAdapter);
+ cerSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_service-subscription_nodesQuery_response.json");
@@ -752,7 +752,7 @@ public class CrossEntityReferenceSynchronizerTest {
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -760,11 +760,11 @@ public class CrossEntityReferenceSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
@@ -772,7 +772,7 @@ public class CrossEntityReferenceSynchronizerTest {
* Cause version conflict errors on every put to test retry flow
*/
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(409, null));
OperationState syncState = cerSynchronizer.doSync();
@@ -798,7 +798,7 @@ public class CrossEntityReferenceSynchronizerTest {
esStatConfig, cerLookup, oxmEntityLookup, searchableEntityLookup);
cerSynchronizer.setAaiAdapter(aaiAdapter);
- cerSynchronizer.setElasticSearchAdapter(esAdapter);
+ cerSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_service-subscription_nodesQuery_response.json");
@@ -982,7 +982,7 @@ public class CrossEntityReferenceSynchronizerTest {
"/sync/aai/aai-traversal/generic-query/service-instance-56.json")));
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -990,27 +990,27 @@ public class CrossEntityReferenceSynchronizerTest {
/*
* Our initial gets from elastic search return 200 ok with a found entity document requiring a doc update
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch1.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch2.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch3.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch4.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch5.json")));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
OperationState syncState = cerSynchronizer.doSync();
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ElasticSearchAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ElasticSearchAdapterTest.java
deleted file mode 100644
index 33d57ae..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ElasticSearchAdapterTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.onap.aai.sparky.dal;
-
-import static org.junit.Assert.assertNotNull;
-
-import javax.ws.rs.core.MediaType;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.aai.restclient.enums.RestAuthenticationMode;
-import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-
-public class ElasticSearchAdapterTest {
-
-
- private ElasticSearchAdapter elasticSearchAdapter;
- private RestEndpointConfig endpointConfig;
-
- @Before
- public void init() throws Exception {
-
- endpointConfig = new RestEndpointConfig();
- endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
- elasticSearchAdapter = new ElasticSearchAdapter(endpointConfig);
- }
-
-
- @Test
- public void updateValues() {
-
- assertNotNull(elasticSearchAdapter.doPost("https://es.onap.server:9200","{maxResults:10, queryStr: f}",MediaType.APPLICATION_JSON_TYPE));
- assertNotNull(elasticSearchAdapter.doGet("https://es.onap.server:9200",MediaType.APPLICATION_JSON_TYPE));
- assertNotNull(elasticSearchAdapter.doHead("https://es.onap.server:9200",MediaType.APPLICATION_JSON_TYPE));
- assertNotNull(elasticSearchAdapter.doPut("https://es.onap.server:9200","{maxResults:10, queryStr: f}",MediaType.APPLICATION_JSON_TYPE));
- assertNotNull(elasticSearchAdapter.doPatch("https://es.onap.server:9200","{maxResults:10, queryStr: f}",MediaType.APPLICATION_JSON_TYPE));
- assertNotNull(elasticSearchAdapter.doDelete("https://es.onap.server:9200",MediaType.APPLICATION_JSON_TYPE));
- assertNotNull(elasticSearchAdapter.doBulkOperation("https://es.onap.server:9200","{maxResults:10, queryStr: f}"));
- assertNotNull(elasticSearchAdapter.buildBulkImportOperationRequest("","","","",""));
- assertNotNull(elasticSearchAdapter.retrieveEntityById("","","","",""));
- assertNotNull(elasticSearchAdapter.buildElasticSearchUrlForApi("",""));
- assertNotNull(elasticSearchAdapter.buildElasticSearchUrl("",""));
- assertNotNull(elasticSearchAdapter.buildElasticSearchGetDocUrl("","",""));
- assertNotNull(elasticSearchAdapter.buildElasticSearchGetDocUrl("",""));
- assertNotNull(elasticSearchAdapter.buildElasticSearchPostUrl(""));
- assertNotNull(elasticSearchAdapter.getBulkUrl());
-
- }
-
-
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilderTest.java
deleted file mode 100644
index 9cd7781..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilderTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.onap.aai.sparky.inventory;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-//import java.security.SecureRandom;
-
-import org.junit.Before;
-import org.junit.Test;
-//import org.openecomp.sparky.analytics.HistoricalCounter;
-import org.onap.aai.sparky.inventory.EntityHistoryQueryBuilder;
-
-public class EntityHistoryQueryBuilderTest {
-
- private EntityHistoryQueryBuilder entityHistoryQueryBuilder;
-
- @Before
- public void init() throws Exception {
- entityHistoryQueryBuilder = new EntityHistoryQueryBuilder();
- }
-
- @SuppressWarnings("static-access")
- @Test
- public void successfullBuild() {
- entityHistoryQueryBuilder.getQuery("table");
- assertNotNull(entityHistoryQueryBuilder.createTableQuery());
- entityHistoryQueryBuilder.getQuery("graph");
- assertNotNull(entityHistoryQueryBuilder.createGraphQuery());
- entityHistoryQueryBuilder.getQuery("tree");
- assertNull(entityHistoryQueryBuilder.getQuery("tree"));
-
- }
-
-} \ No newline at end of file
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java
deleted file mode 100644
index 2e39725..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * ============LICENSE_START===================================================
- * SPARKY (AAI UI service)
- * ============================================================================
- * Copyright © 2017 AT&T Intellectual Property.
- * Copyright © 2017 Amdocs
- * All rights reserved.
- * ============================================================================
- * Licensed 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.
- * ============LICENSE_END=====================================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- */
-
-package org.onap.aai.sparky.inventory;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.aai.sparky.inventory.entity.GeoIndexDocument;
-
-/**
- * The Class GeoIndexDocumentTest.
- */
-@RunWith(MockitoJUnitRunner.class)
-public class GeoIndexDocumentTest {
-
- /**
- * Inits the.
- *
- * @throws Exception the exception
- */
- @Before
- public void init() throws Exception {}
-
- /**
- * Checks if is valid geo index document success path.
- */
- @Test
- public void isValidGeoIndexDocument_successPath() {
-
- GeoIndexDocument geoDoc = new GeoIndexDocument();
-
- geoDoc.setEntityPrimaryKeyName("pkeyName");
- geoDoc.setEntityPrimaryKeyValue("pkeyValue");
- geoDoc.setEntityType("type");
- geoDoc.setId("12312");
- geoDoc.setLatitude("-45.123");
- geoDoc.setLongitude("181.321");
- geoDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
-
- assertTrue(geoDoc.isValidGeoDocument());
-
- }
-
- /**
- * Checks if is valid geo index document fail no geo coordinates.
- */
- @Test
- public void isValidGeoIndexDocument_fail_no_geoCoordinates() {
-
- GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
-
- geoIndexDoc.setEntityPrimaryKeyName("pkeyName");
- geoIndexDoc.setEntityPrimaryKeyValue("pkeyValue");
- geoIndexDoc.setEntityType("type");
- geoIndexDoc.setId("12312");
- geoIndexDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
-
- assertFalse(geoIndexDoc.isValidGeoDocument());
-
- }
-
- /**
- * Checks if is valid geo index document fail invalid geo coordinates.
- */
- @Test
- public void isValidGeoIndexDocument_fail_invalid_geoCoordinates() {
-
- GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
-
- geoIndexDoc.setEntityPrimaryKeyName("pkeyName");
- geoIndexDoc.setEntityPrimaryKeyValue("pkeyValue");
- geoIndexDoc.setEntityType("type");
- geoIndexDoc.setId("12312");
- geoIndexDoc.setLatitude("not_a_valid");
- geoIndexDoc.setLongitude("geo point");
-
- geoIndexDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
-
- assertFalse(geoIndexDoc.isValidGeoDocument());
-
- }
-
- /**
- * Checks if is valid geo index document fail nothing set.
- */
- @Test
- public void isValidGeoIndexDocument_fail_nothing_set() {
-
- GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
-
- assertFalse(geoIndexDoc.isValidGeoDocument());
-
- }
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/entity/TopographicalEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/entity/TopographicalEntityTest.java
deleted file mode 100644
index c878077..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/inventory/entity/TopographicalEntityTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.onap.aai.sparky.inventory.entity;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
-
-public class TopographicalEntityTest {
-
- private TopographicalEntity topographicalEntity;
-
-
- @Before
- public void init() throws Exception {
- topographicalEntity = new TopographicalEntity();
- }
-
-
- @SuppressWarnings("static-access")
- @Test
- public void updateValues() {
-
- topographicalEntity.setEntityType("");
- assertNotNull(topographicalEntity.getEntityType());
- topographicalEntity.setEntityPrimaryKeyValue("");
- assertNotNull(topographicalEntity.getEntityPrimaryKeyValue());
- topographicalEntity.setEntityPrimaryKeyName("");
- assertNotNull(topographicalEntity.getEntityPrimaryKeyName());
- topographicalEntity.setLatitude("");
- assertNotNull(topographicalEntity.getLatitude());
- topographicalEntity.setLongitude("");
- assertNotNull(topographicalEntity.getLongitude());
- topographicalEntity.setSelfLink("");
- assertNotNull(topographicalEntity.getSelfLink());
- topographicalEntity.setId("");
- assertNotNull(topographicalEntity.getId());
- assertNotNull(topographicalEntity.getSerialversionuid());
- assertNotNull(topographicalEntity.toString());
-
- //assertNotNull(topographicalEntity.getAsJson());
- //assertNotNull(topographicalEntity.generateUniqueShaDigest("","",""));
- }
-
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityCountHistoryProcessorTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityCountHistoryProcessorTest.java
deleted file mode 100644
index c74e4e5..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/EntityCountHistoryProcessorTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.onap.aai.sparky.search;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.component.restlet.RestletConstants;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.search.EntityCountHistoryProcessor;
-import org.onap.aai.sparky.util.RestletUtils;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.data.ClientInfo;
-import org.restlet.data.Reference;
-import org.restlet.data.Status;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class EntityCountHistoryProcessorTest {
- private EntityCountHistoryProcessor entityCountHistoryProcessor;
- private Exchange mockExchange;
- private Message mockRequestMessage;
- private Message mockResponseMessage;
- private Request mockRestletRequest;
- private Response mockRestletResponse;
- private ClientInfo requestClientInfo;
- private RestletUtils mockRestletUtils;
- private ElasticSearchAdapter mockElasticSearchAdapter;
-
- @Before
- public void init() throws Exception {
- mockExchange = Mockito.mock(Exchange.class);
- mockRequestMessage = Mockito.mock(Message.class);
- mockResponseMessage = Mockito.mock(Message.class);
- mockRestletRequest = Mockito.mock(Request.class);
- mockRestletResponse = Mockito.mock(Response.class);
- mockRestletUtils = Mockito.mock(RestletUtils.class);
- mockElasticSearchAdapter = Mockito.mock(ElasticSearchAdapter.class);
-
- entityCountHistoryProcessor = new EntityCountHistoryProcessor(mockElasticSearchAdapter,
- "pserver", "vnf", "entityCount-index");
- entityCountHistoryProcessor.setRestletUtils(mockRestletUtils);
-
- requestClientInfo = new ClientInfo();
-
- Mockito.when(mockRestletRequest.getClientInfo()).thenReturn(requestClientInfo);
-
- Mockito.when(mockRequestMessage.getHeader(RestletConstants.RESTLET_REQUEST, Request.class))
- .thenReturn(mockRestletRequest);
- Mockito.when(mockRequestMessage.getHeader(RestletConstants.RESTLET_RESPONSE, Response.class))
- .thenReturn(mockRestletResponse);
- Mockito.when(mockExchange.getIn()).thenReturn(mockRequestMessage);
- Mockito.when(mockExchange.getOut()).thenReturn(mockResponseMessage);
- }
-
- public String getStubbedData_getEntityCountHistory_success() {
- ObjectMapper mapper = new ObjectMapper();
- ObjectNode entityCountEntry = mapper.createObjectNode();
-
- entityCountEntry.put("doc_count", 2069);
- entityCountEntry.put("key", "complex");
-
- ArrayNode arrayNode = mapper.createArrayNode();
- arrayNode.add(entityCountEntry);
-
- ObjectNode resultNode = mapper.createObjectNode();
- resultNode.set("result", arrayNode);
-
- return resultNode.toString();
- }
-
- @Test
- public void testGetEntityCountHistory_success() {
- EntityCountHistoryProcessor spyEntityCountHistoryProcessor =
- Mockito.spy(entityCountHistoryProcessor);
- OperationResult operationResult = new OperationResult();
-
- String result = getStubbedData_getEntityCountHistory_success();
-
- operationResult.setResult(Status.SUCCESS_OK.getCode(), result);
-
- Mockito.when(mockExchange.getIn().getHeader("CamelHttpQuery", String.class)).thenReturn("");
-
- Mockito.doReturn("table").when(spyEntityCountHistoryProcessor).getTypeParameter(Mockito.any());
- Mockito.doReturn(operationResult).when(spyEntityCountHistoryProcessor).getResults(Mockito.any(),
- Mockito.any());
-
-
- }
-
- @Test
- public void testGetEntityCountHistory_failure_noTypeParameter() {
- Mockito.when(mockRestletRequest.getOriginalRef()).thenReturn(new Reference());
-
- EntityCountHistoryProcessor spyEntityCountHistoryProcessor =
- Mockito.spy(entityCountHistoryProcessor);
- OperationResult operationResult = new OperationResult();
-
- String result = getStubbedData_getEntityCountHistory_success();
-
- operationResult.setResult(Status.SUCCESS_OK.getCode(), result);
-
- Mockito.when(mockExchange.getIn().getHeader("CamelHttpQuery", String.class)).thenReturn("");
-
- Mockito.doReturn("").when(spyEntityCountHistoryProcessor).getTypeParameter(Mockito.any());
- Mockito.doReturn(operationResult).when(spyEntityCountHistoryProcessor).getResults(Mockito.any(),
- Mockito.any());
-
-
- }
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AbstractEntitySynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AbstractEntitySynchronizerTest.java
index 3bd4928..c324991 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AbstractEntitySynchronizerTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AbstractEntitySynchronizerTest.java
@@ -20,7 +20,7 @@ import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
import org.onap.aai.sparky.config.oxm.SearchableOxmEntityDescriptor;
import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.dal.NetworkTransaction;
import org.onap.aai.sparky.dal.rest.HttpMethod;
import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
@@ -75,7 +75,7 @@ public class AbstractEntitySynchronizerTest {
private QuantumSynchronizer quantumSync;
private NetworkStatisticsConfig aaiStatConfig;
private NetworkStatisticsConfig esStatConfig;
- private ElasticSearchAdapter esAdapter;
+ private SearchServiceAdapter searchServiceAdapter;
private ActiveInventoryAdapter aaiAdapter;
private SearchableEntityLookup searchableEntityLookup;
@@ -141,7 +141,7 @@ public class AbstractEntitySynchronizerTest {
esStatConfig.setTpsHistogramNumBins(20);
esStatConfig.setTpsHistogramNumDecimalPoints(2);
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
+ searchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
}
@@ -216,12 +216,12 @@ public class AbstractEntitySynchronizerTest {
esStatConfig);
quantumSync.setAaiAdapter(aaiAdapter);
- quantumSync.setElasticSearchAdapter(esAdapter);
+ quantumSync.setSearchServiceAdapter(searchServiceAdapter);
quantumSync.clearCache();
assertNotNull(quantumSync.getAaiAdapter());
- assertNotNull(quantumSync.getElasticSearchAdapter());
+ assertNotNull(quantumSync.getSearchServiceAdapter());
assertEquals("quantum-search-index", quantumSync.getIndexName());
quantumSync.setIndexName("new-search-index-name");
@@ -285,7 +285,7 @@ public class AbstractEntitySynchronizerTest {
esStatConfig);
quantumSync.setAaiAdapter(aaiAdapter);
- quantumSync.setElasticSearchAdapter(esAdapter);
+ quantumSync.setSearchServiceAdapter(searchServiceAdapter);
searchableEntityLookup = new SearchableEntityLookup();
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java
index 65e6e70..8f8beea 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java
@@ -20,7 +20,7 @@ import org.onap.aai.sparky.aggregation.sync.AggregationSynchronizer;
import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
import org.onap.aai.sparky.sync.enumeration.OperationState;
@@ -37,7 +37,7 @@ public class AggregationSynchronizerTest {
private NetworkStatisticsConfig aaiStatConfig;
private NetworkStatisticsConfig esStatConfig;
private OxmEntityLookup oxmEntityLookup;
- private ElasticSearchAdapter esAdapter;
+ private SearchServiceAdapter searchServiceAdapter;
private ActiveInventoryAdapter aaiAdapter;
@@ -112,7 +112,7 @@ public class AggregationSynchronizerTest {
oxmEntityLookup = new OxmEntityLookup();
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
+ searchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
Map<String,OxmEntityDescriptor> oxmEntityDescriptors = new HashMap<String,OxmEntityDescriptor>();
@@ -139,10 +139,10 @@ public class AggregationSynchronizerTest {
esStatConfig, oxmEntityLookup);
aggregationSynchronizer.setAaiAdapter(aaiAdapter);
- aggregationSynchronizer.setElasticSearchAdapter(esAdapter);
+ aggregationSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
assertNotNull(aggregationSynchronizer.getAaiAdapter());
- assertNotNull(aggregationSynchronizer.getElasticSearchAdapter());
+ assertNotNull(aggregationSynchronizer.getSearchServiceAdapter());
}
@@ -153,7 +153,7 @@ public class AggregationSynchronizerTest {
esStatConfig, oxmEntityLookup);
aggregationSynchronizer.setAaiAdapter(aaiAdapter);
- aggregationSynchronizer.setElasticSearchAdapter(esAdapter);
+ aggregationSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_complex_nodesQuery_response.json");
@@ -177,7 +177,7 @@ public class AggregationSynchronizerTest {
}
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString())).thenReturn(
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString())).thenReturn(
"http://localhost:9200/myindex/mytype/doc1", "http://localhost:9200/myindex/mytype/doc2",
"http://localhost:9200/myindex/mytype/doc3", "http://localhost:9200/myindex/mytype/doc4",
"http://localhost:9200/myindex/mytype/doc5");
@@ -185,14 +185,14 @@ public class AggregationSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when( esAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
OperationState syncState = aggregationSynchronizer.doSync();
@@ -215,7 +215,7 @@ public class AggregationSynchronizerTest {
esStatConfig, oxmEntityLookup);
aggregationSynchronizer.setAaiAdapter(aaiAdapter);
- aggregationSynchronizer.setElasticSearchAdapter(esAdapter);
+ aggregationSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_complex_nodesQuery_response.json");
@@ -239,7 +239,7 @@ public class AggregationSynchronizerTest {
}
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString())).thenReturn(
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString())).thenReturn(
"http://localhost:9200/myindex/mytype/doc1", "http://localhost:9200/myindex/mytype/doc2",
"http://localhost:9200/myindex/mytype/doc3", "http://localhost:9200/myindex/mytype/doc4",
"http://localhost:9200/myindex/mytype/doc5");
@@ -247,17 +247,17 @@ public class AggregationSynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when( esAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(404,null));
- Mockito.when( esAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(404,null));
+ Mockito.when( searchServiceAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(404,null));
// 409 is the elastic search version conflict code, which will result in the entries being added
// to our retry queue and re-attempted a couple times.
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(409, null));
OperationState syncState = aggregationSynchronizer.doSync();
@@ -279,7 +279,7 @@ public class AggregationSynchronizerTest {
esStatConfig, oxmEntityLookup);
aggregationSynchronizer.setAaiAdapter(aaiAdapter);
- aggregationSynchronizer.setElasticSearchAdapter(esAdapter);
+ aggregationSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_complex_nodesQuery_response.json");
@@ -303,7 +303,7 @@ public class AggregationSynchronizerTest {
}
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString())).thenReturn(
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString())).thenReturn(
"http://localhost:9200/myindex/mytype/doc1", "http://localhost:9200/myindex/mytype/doc2",
"http://localhost:9200/myindex/mytype/doc3", "http://localhost:9200/myindex/mytype/doc4",
"http://localhost:9200/myindex/mytype/doc5");
@@ -311,22 +311,22 @@ public class AggregationSynchronizerTest {
/*
* Our initial gets from elastic search return 200 ok with a found entity document requiring a doc update
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch1.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch2.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch3.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc4"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch4.json")));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(200,
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc5"), Mockito.any())).thenReturn(new OperationResult(200,
TestResourceLoader.getTestResourceDataJson("/sync/ElasticSearch/docEntityFromElasticSearch5.json")));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
OperationState syncState = aggregationSynchronizer.doSync();
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/ElasticSearchIndexCleanerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/ElasticSearchIndexCleanerTest.java
deleted file mode 100644
index 30394de..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/ElasticSearchIndexCleanerTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.onap.aai.sparky.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.util.TestResourceLoader;
-
-public class ElasticSearchIndexCleanerTest {
-
- private ElasticSearchIndexCleaner esIndexCleaner;
-
- private ElasticSearchAdapter esAdapter;
- private ElasticSearchEndpointConfig esRestEndpointConfig;
- private ElasticSearchSchemaConfig esSchemaConfig;
-
- @Before
- public void init() throws Exception {
-
- esAdapter = Mockito.mock( ElasticSearchAdapter.class);
- esRestEndpointConfig = new ElasticSearchEndpointConfig();
- esSchemaConfig = new ElasticSearchSchemaConfig();
-
- esRestEndpointConfig.setScrollContextBatchRequestSize(5000);
- esRestEndpointConfig.setEsIpAddress("127.0.0.1");
- esRestEndpointConfig.setEsServerPort("9200");
- esRestEndpointConfig.setScrollContextTimeToLiveInMinutes(5);
-
- }
-
- @Test
- public void validateBasicConstruction() throws Exception {
- esIndexCleaner = new ElasticSearchIndexCleaner(esAdapter, esRestEndpointConfig, esSchemaConfig);
- }
-
- @Test
- public void validatePreOperationCollection() throws Exception {
-
- String beforeSyncScrollApiResponse = TestResourceLoader.getTestResourceDataJson(
- "/sync/ElasticSearch/BeforeSync_ElasticSearch_ScrollApi_Successful.json");
-
- OperationResult scrollApiOpResult = new OperationResult();
- scrollApiOpResult.setResultCode(200);
- scrollApiOpResult.setResult(beforeSyncScrollApiResponse);
-
- Mockito.when(esAdapter.doPost(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject()))
- .thenReturn(scrollApiOpResult);
-
- esIndexCleaner = new ElasticSearchIndexCleaner(esAdapter, esRestEndpointConfig, esSchemaConfig);
- OperationState opState = esIndexCleaner.populatePreOperationCollection();
-
- assertEquals(OperationState.OK, opState);
-
- }
-
- @Test
- public void validatePostOperationCollection() throws Exception {
-
- String afterSyncScrollApiResponse = TestResourceLoader.getTestResourceDataJson(
- "/sync/ElasticSearch/AfterSync_ElasticSearch_ScrollApi_Successful.json");
-
- OperationResult scrollApiOpResult = new OperationResult();
- scrollApiOpResult.setResultCode(200);
- scrollApiOpResult.setResult(afterSyncScrollApiResponse);
-
- Mockito.when(esAdapter.doPost(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject()))
- .thenReturn(scrollApiOpResult);
-
- esIndexCleaner = new ElasticSearchIndexCleaner(esAdapter, esRestEndpointConfig, esSchemaConfig);
- OperationState opState = esIndexCleaner.populatePostOperationCollection();
-
- assertEquals(OperationState.OK, opState);
-
- }
-
-
- @Test
- public void validatePerformCleanup() throws Exception {
-
- String beforeSyncScrollApiResponse = TestResourceLoader.getTestResourceDataJson(
- "/sync/ElasticSearch/BeforeSync_ElasticSearch_ScrollApi_Successful.json");
-
- OperationResult beforeScrollApiOpResult = new OperationResult();
- beforeScrollApiOpResult.setResultCode(200);
- beforeScrollApiOpResult.setResult(beforeSyncScrollApiResponse);
-
- String afterSyncScrollApiResponse = TestResourceLoader.getTestResourceDataJson(
- "/sync/ElasticSearch/AfterSync_ElasticSearch_ScrollApi_Successful.json");
-
- OperationResult afterScrollApiOpResult = new OperationResult();
- afterScrollApiOpResult.setResultCode(200);
- afterScrollApiOpResult.setResult(afterSyncScrollApiResponse);
-
- Mockito.when(esAdapter.doPost(Mockito.anyString(), Mockito.anyString(), Mockito.anyObject()))
- .thenReturn(beforeScrollApiOpResult,afterScrollApiOpResult);
-
- esIndexCleaner = new ElasticSearchIndexCleaner(esAdapter, esRestEndpointConfig, esSchemaConfig);
-
- OperationState beforeOpState = esIndexCleaner.populatePreOperationCollection();
- OperationState afterOpState = esIndexCleaner.populatePostOperationCollection();
-
- assertEquals(OperationState.OK, beforeOpState);
- assertEquals(OperationState.OK, afterOpState);
-
- /*
- * Now we can start the test work
- */
-
- OperationState cleanupState = esIndexCleaner.performCleanup();
- assertEquals(OperationState.OK, cleanupState);
-
-
- }
-
-
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/ElasticSearchEndpointConfigTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/ElasticSearchEndpointConfigTest.java
deleted file mode 100644
index a0dc071..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/config/ElasticSearchEndpointConfigTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.onap.aai.sparky.sync.config;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-
-
-
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class ElasticSearchEndpointConfigTest {
-
- private ElasticSearchEndpointConfig elasticSearchEndpointConfig;
-
- @Before
- public void init() throws Exception {
- elasticSearchEndpointConfig = new ElasticSearchEndpointConfig();
-
- }
-
-
- @Test
- public void updateValues() {
-
- elasticSearchEndpointConfig.setEsIpAddress("aai.es.service");
- assertNotNull(elasticSearchEndpointConfig.getEsIpAddress());
- elasticSearchEndpointConfig.setEsServerPort("6585");
- assertNotNull(elasticSearchEndpointConfig.getEsServerPort());
- elasticSearchEndpointConfig.setScrollContextTimeToLiveInMinutes(3);
- assertEquals(3,elasticSearchEndpointConfig.getScrollContextTimeToLiveInMinutes());
- elasticSearchEndpointConfig.setScrollContextBatchRequestSize(3);
- assertEquals(3,elasticSearchEndpointConfig.getScrollContextBatchRequestSize());
-
- }
-
-
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/topology/sync/GeoSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/topology/sync/GeoSynchronizerTest.java
deleted file mode 100644
index 8cc5626..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/topology/sync/GeoSynchronizerTest.java
+++ /dev/null
@@ -1,347 +0,0 @@
-package org.onap.aai.sparky.topology.sync;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.GeoEntityLookup;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
-import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.util.TestResourceLoader;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class GeoSynchronizerTest {
-
- private static ObjectMapper mapper = new ObjectMapper();
-
- private GeoSynchronizer geoSynchronizer;
-
- private ElasticSearchSchemaConfig esSchemaConfig;
- private NetworkStatisticsConfig aaiStatConfig;
- private NetworkStatisticsConfig esStatConfig;
- private OxmEntityLookup oxmEntityLookup;
- private GeoEntityLookup geoEntityLookup;
- private ElasticSearchAdapter esAdapter;
- private ActiveInventoryAdapter aaiAdapter;
-
-
-
- @Before
- public void init() throws Exception {
-
- esSchemaConfig = new ElasticSearchSchemaConfig();
- esSchemaConfig.setIndexDocType("default");
- esSchemaConfig.setIndexMappingsFileName(null);
- esSchemaConfig.setIndexName("aggregation-index-name");
- esSchemaConfig.setIndexSettingsFileName(null);
-
-
- aaiStatConfig = new NetworkStatisticsConfig();
-
- aaiStatConfig.setNumSamplesPerThreadForRunningAverage(100);
-
- aaiStatConfig.setBytesHistogramLabel("[Response Size In Bytes]");
- aaiStatConfig.setBytesHistogramMaxYAxis(1000000L);
- aaiStatConfig.setBytesHistogramNumBins(20);
- aaiStatConfig.setBytesHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setQueueLengthHistogramLabel("[Queue Item Length]");
- aaiStatConfig.setQueueLengthHistogramMaxYAxis(20000);
- aaiStatConfig.setQueueLengthHistogramNumBins(20);
- aaiStatConfig.setQueueLengthHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setTaskAgeHistogramLabel("[Task Age In Ms]");
- aaiStatConfig.setTaskAgeHistogramMaxYAxis(600000L);
- aaiStatConfig.setTaskAgeHistogramNumBins(20);
- aaiStatConfig.setTaskAgeHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setResponseTimeHistogramLabel("[Response Time In Ms]");
- aaiStatConfig.setResponseTimeHistogramMaxYAxis(1000L);
- aaiStatConfig.setResponseTimeHistogramNumBins(20);
- aaiStatConfig.setResponseTimeHistogramNumDecimalPoints(2);
-
- aaiStatConfig.setTpsHistogramLabel("[Transactions Per Second]");
- aaiStatConfig.setTpsHistogramMaxYAxis(100);
- aaiStatConfig.setTpsHistogramNumBins(20);
- aaiStatConfig.setTpsHistogramNumDecimalPoints(2);
-
- esStatConfig = new NetworkStatisticsConfig();
-
- esStatConfig.setNumSamplesPerThreadForRunningAverage(100);
-
- esStatConfig.setBytesHistogramLabel("[Response Size In Bytes]");
- esStatConfig.setBytesHistogramMaxYAxis(1000000L);
- esStatConfig.setBytesHistogramNumBins(20);
- esStatConfig.setBytesHistogramNumDecimalPoints(2);
-
- esStatConfig.setQueueLengthHistogramLabel("[Queue Item Length]");
- esStatConfig.setQueueLengthHistogramMaxYAxis(20000);
- esStatConfig.setQueueLengthHistogramNumBins(20);
- esStatConfig.setQueueLengthHistogramNumDecimalPoints(2);
-
- esStatConfig.setTaskAgeHistogramLabel("[Task Age In Ms]");
- esStatConfig.setTaskAgeHistogramMaxYAxis(600000L);
- esStatConfig.setTaskAgeHistogramNumBins(20);
- esStatConfig.setTaskAgeHistogramNumDecimalPoints(2);
-
- esStatConfig.setResponseTimeHistogramLabel("[Response Time In Ms]");
- esStatConfig.setResponseTimeHistogramMaxYAxis(10000L);
- esStatConfig.setResponseTimeHistogramNumBins(20);
- esStatConfig.setResponseTimeHistogramNumDecimalPoints(2);
-
- esStatConfig.setTpsHistogramLabel("[Transactions Per Second]");
- esStatConfig.setTpsHistogramMaxYAxis(100);
- esStatConfig.setTpsHistogramNumBins(20);
- esStatConfig.setTpsHistogramNumDecimalPoints(2);
-
- oxmEntityLookup = new OxmEntityLookup();
-
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
- aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
-
-
- Set<OxmModelProcessor> processors = new HashSet<OxmModelProcessor>();
-
- processors.add(oxmEntityLookup);
-
-
-
- Map<String, OxmEntityDescriptor> oxmEntityDescriptors =
- new HashMap<String, OxmEntityDescriptor>();
-
- OxmEntityDescriptor genericVnfDescriptor = new OxmEntityDescriptor();
- genericVnfDescriptor.setEntityName("generic-vnf");
- List<String> pkeyNames = new ArrayList<String>();
- pkeyNames.add("vnf-name");
-
- genericVnfDescriptor.setPrimaryKeyAttributeNames(pkeyNames);
-
- oxmEntityDescriptors.put("generic-vnf", genericVnfDescriptor);
-
-
- oxmEntityLookup.setEntityDescriptors(oxmEntityDescriptors);
-
- SuggestionEntityDescriptor genericVnfSuggestionDescriptor = new SuggestionEntityDescriptor();
- genericVnfSuggestionDescriptor.setEntityName("generic-vnf");
- genericVnfSuggestionDescriptor.setPrimaryKeyAttributeNames(pkeyNames);
-
-
-
- /*
- * SuggestionSearchEntity sse = new SuggestionSearchEntity(filtersConfig);
- *
- * sse.setEntityType("generic-vnf"); sse.setSuggestionPropertyTypes( Arrays.asList("vnf-name"));
- *
- * genericVnfSuggestionDescriptor.setSuggestionSearchEntity(sse);
- *
- * suggestionEntityDescriptors.put("generic-vnf", genericVnfSuggestionDescriptor);
- */
-
- geoEntityLookup = new GeoEntityLookup();
-
- processors.add(geoEntityLookup);
-
- // suggestionEntityLookup.setSuggestionSearchEntityDescriptors(suggestionEntityDescriptors);
- }
-
- @Test
- public void validateBasicConstruction() throws Exception {
-
- geoSynchronizer = new GeoSynchronizer(esSchemaConfig, 5, 5, 5, aaiStatConfig, esStatConfig,
- geoEntityLookup, oxmEntityLookup);
-
- geoSynchronizer.setAaiAdapter(aaiAdapter);
- geoSynchronizer.setElasticSearchAdapter(esAdapter);
-
- assertNotNull(geoSynchronizer.getAaiAdapter());
- assertNotNull(geoSynchronizer.getElasticSearchAdapter());
-
- }
-
- @Test
- public void validateSmallSync() throws Exception {
-
- geoSynchronizer = new GeoSynchronizer(esSchemaConfig, 5, 5, 5, aaiStatConfig, esStatConfig,
- geoEntityLookup, oxmEntityLookup);
-
-
- geoSynchronizer.setAaiAdapter(aaiAdapter);
- geoSynchronizer.setElasticSearchAdapter(esAdapter);
-
- String nodesQueryResponse = TestResourceLoader
- .getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
-
- OperationResult genericVnfSelfLinks = new OperationResult();
-
- genericVnfSelfLinks.setResultCode(200);
- genericVnfSelfLinks.setResult(nodesQueryResponse);
-
- Mockito.when(aaiAdapter.getSelfLinksByEntityType("generic-vnf"))
- .thenReturn(genericVnfSelfLinks);
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-1"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-1");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-2"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-2");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-3"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-3");
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
-
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
- .thenReturn("http://localhost:9200/myindex/mytype/doc1",
- "http://server.proxy:9200/myindex/mytype/doc2",
- "http://server.proxy:9200/myindex/mytype/doc3");
-
- /*
- * Our initial gets from elastic search should be record-not-found
- */
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
-
-
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
- .thenReturn(new OperationResult(200, null));
-
- OperationState syncState = geoSynchronizer.doSync();
- assertEquals(OperationState.OK, syncState);
-
- assertNotNull(geoSynchronizer.getStatReport(false));
- assertNotNull(geoSynchronizer.getStatReport(true));
-
- geoSynchronizer.clearCache();
- geoSynchronizer.shutdown();
-
-
- }
-
- @Test
- public void validateSmallSyncWithRetries() throws Exception {
-
- geoSynchronizer = new GeoSynchronizer(esSchemaConfig, 5, 5, 5, aaiStatConfig, esStatConfig,
- geoEntityLookup, oxmEntityLookup);
-
-
- geoSynchronizer.setAaiAdapter(aaiAdapter);
- geoSynchronizer.setElasticSearchAdapter(esAdapter);
-
- String nodesQueryResponse = TestResourceLoader
- .getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
-
- OperationResult genericVnfSelfLinks = new OperationResult();
-
- genericVnfSelfLinks.setResultCode(200);
- genericVnfSelfLinks.setResult(nodesQueryResponse);
-
- Mockito.when(aaiAdapter.getSelfLinksByEntityType("generic-vnf"))
- .thenReturn(genericVnfSelfLinks);
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-1"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-1");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-2"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-2");
-
- Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-3"), Mockito.anyString()))
- .thenReturn(
- "https://server.proxy:8443/aai/v11/network/generic-vnfs/generic-vnf/generic-vnf-3");
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json")));
-
- Mockito
- .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"),
- Mockito.anyString(), Mockito.anyInt()))
- .thenReturn(new OperationResult(200, TestResourceLoader
- .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
-
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
- .thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
- "http://server.proxy:9200/myindex/mytype/doc2",
- "http://server.proxy:9200/myindex/mytype/doc3");
-
- /*
- * Our initial gets from elastic search should be record-not-found
- */
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
- .thenReturn(new OperationResult(404, null));
-
-
- /*
- * Elastic Search puts always fail with a version conflict = 409
- */
-
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
- .thenReturn(new OperationResult(409, null));
-
- OperationState syncState = geoSynchronizer.doSync();
- assertEquals(OperationState.OK, syncState);
-
- assertNotNull(geoSynchronizer.getStatReport(false));
- assertNotNull(geoSynchronizer.getStatReport(true));
-
- geoSynchronizer.clearCache();
- geoSynchronizer.shutdown();
-
-
- }
-} \ No newline at end of file
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java
index e51c629..eeacde1 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java
@@ -8,10 +8,10 @@ import org.mockito.Mockito;
import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
import org.onap.aai.sparky.config.oxm.OxmModelLoader;
import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
import org.onap.aai.sparky.dal.GizmoAdapter;
+import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
-import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
import org.onap.aai.sparky.util.OxmModelAndProcessorHelper;
import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
@@ -21,10 +21,10 @@ import org.onap.aai.sparky.viewandinspect.util.SchemaVisualizationTestDataBuilde
public class BaseVisualizationServiceTest {
private ActiveInventoryAdapter mockAaiAdapter;
- private ElasticSearchAdapter mockEsAdapter;
+ private SearchServiceAdapter mocksearchServiceAdapter;
private VisualizationConfigs visualizationConfigs;
private SubscriptionConfig subConfig;
- private ElasticSearchEndpointConfig endpointEConfig;
+ private RestEndpointConfig endpointEConfig;
private ElasticSearchSchemaConfig schemaEConfig;
private OxmEntityLookup oxmEntityLookup;
private GizmoAdapter mockGizmoAdapter;
@@ -35,18 +35,18 @@ public class BaseVisualizationServiceTest {
public void init() throws Exception {
this.mockAaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
this.mockAaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
- this.mockEsAdapter = Mockito.mock(ElasticSearchAdapter.class);
+ this.mocksearchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
this.mockGizmoAdapter = Mockito.mock(GizmoAdapter.class);
this.visualizationConfigs = new VisualizationConfigs();
this.subConfig = new SubscriptionConfig();
- this.endpointEConfig = new ElasticSearchEndpointConfig();
+ this.endpointEConfig = new RestEndpointConfig();
this.schemaEConfig = new ElasticSearchSchemaConfig();
this.oxmEntityLookup = OxmModelAndProcessorHelper.getInstance().getOxmEntityLookup();
OxmModelLoader modelLoader = OxmModelAndProcessorHelper.getInstance().getModelLoader();
this.baseVisService = new BaseVisualizationService(modelLoader, visualizationConfigs,
- mockAaiAdapter, mockGizmoAdapter, mockEsAdapter, endpointEConfig, schemaEConfig, 1,
+ mockAaiAdapter, mockGizmoAdapter, mocksearchServiceAdapter, endpointEConfig, schemaEConfig, 1,
oxmEntityLookup, subConfig);
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java
index 2bf7856..0fd3bca 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java
@@ -22,7 +22,7 @@ import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor;
import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
import org.onap.aai.sparky.sync.enumeration.OperationState;
@@ -38,7 +38,7 @@ public class ViewInspectEntitySynchronizerTest {
private NetworkStatisticsConfig esStatConfig;
private OxmEntityLookup oxmEntityLookup;
private SearchableEntityLookup searchableEntityLookup;
- private ElasticSearchAdapter esAdapter;
+ private SearchServiceAdapter searchServiceAdapter;
private ActiveInventoryAdapter aaiAdapter;
@@ -113,7 +113,7 @@ public class ViewInspectEntitySynchronizerTest {
oxmEntityLookup = new OxmEntityLookup();
- esAdapter = Mockito.mock(ElasticSearchAdapter.class);
+ searchServiceAdapter = Mockito.mock(SearchServiceAdapter.class);
aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
@@ -169,10 +169,10 @@ public class ViewInspectEntitySynchronizerTest {
aaiStatConfig, esStatConfig, oxmEntityLookup, searchableEntityLookup);
viewInspectSynchronizer.setAaiAdapter(aaiAdapter);
- viewInspectSynchronizer.setElasticSearchAdapter(esAdapter);
+ viewInspectSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
assertNotNull(viewInspectSynchronizer.getAaiAdapter());
- assertNotNull(viewInspectSynchronizer.getElasticSearchAdapter());
+ assertNotNull(viewInspectSynchronizer.getSearchServiceAdapter());
}
@@ -184,7 +184,7 @@ public class ViewInspectEntitySynchronizerTest {
viewInspectSynchronizer.setAaiAdapter(aaiAdapter);
- viewInspectSynchronizer.setElasticSearchAdapter(esAdapter);
+ viewInspectSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
@@ -227,7 +227,7 @@ public class ViewInspectEntitySynchronizerTest {
.thenReturn(new OperationResult(200, TestResourceLoader
.getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://server.proxy:9200/myindex/mytype/doc1",
"http://server.proxy:9200/myindex/mytype/doc2",
"http://server.proxy:9200/myindex/mytype/doc3");
@@ -235,15 +235,15 @@ public class ViewInspectEntitySynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(200, null));
OperationState syncState = viewInspectSynchronizer.doSync();
@@ -266,7 +266,7 @@ public class ViewInspectEntitySynchronizerTest {
viewInspectSynchronizer.setAaiAdapter(aaiAdapter);
- viewInspectSynchronizer.setElasticSearchAdapter(esAdapter);
+ viewInspectSynchronizer.setSearchServiceAdapter(searchServiceAdapter);
String nodesQueryResponse = TestResourceLoader
.getTestResourceDataJson("/sync/aai/activeInventory_generic-vnf_nodesQuery_response.json");
@@ -309,7 +309,7 @@ public class ViewInspectEntitySynchronizerTest {
.thenReturn(new OperationResult(200, TestResourceLoader
.getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json")));
- Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString()))
+ Mockito.when(searchServiceAdapter.buildSearchServiceDocUrl(Mockito.anyString(), Mockito.anyString()))
.thenReturn("http://localhost:9200/myindex/mytype/doc1",
"http://localhost:9200/myindex/mytype/doc2",
"http://localhost:9200/myindex/mytype/doc3");
@@ -317,11 +317,11 @@ public class ViewInspectEntitySynchronizerTest {
/*
* Our initial gets from elastic search should be record-not-found
*/
- Mockito.when(esAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc1"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc2"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
- Mockito.when(esAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doGet(Matchers.contains("doc3"), Mockito.any()))
.thenReturn(new OperationResult(404, null));
@@ -329,7 +329,7 @@ public class ViewInspectEntitySynchronizerTest {
* Elastic Search puts always fail with a version conflict = 409
*/
- Mockito.when(esAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
+ Mockito.when(searchServiceAdapter.doPut(Matchers.contains("doc"), Mockito.any(), Mockito.any()))
.thenReturn(new OperationResult(409, null));
OperationState syncState = viewInspectSynchronizer.doSync();
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoEntitySynchronizer.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoEntitySynchronizer.java
deleted file mode 100644
index 6d63a8a..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoEntitySynchronizer.java
+++ /dev/null
@@ -1,792 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017 Amdocs
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.onap.aai.sparky.viewandinspect.sync;
-
-import static java.util.concurrent.CompletableFuture.supplyAsync;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.ExecutorService;
-import java.util.function.Supplier;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.OxmEntityContainerLookup;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
-import org.onap.aai.sparky.config.oxm.SearchableOxmEntityDescriptor;
-import org.onap.aai.sparky.dal.GizmoAdapter;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.sync.AbstractEntitySynchronizer;
-import org.onap.aai.sparky.sync.IndexSynchronizer;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.entity.MergableEntity;
-import org.onap.aai.sparky.sync.entity.SearchableEntity;
-import org.onap.aai.sparky.sync.entity.SelfLinkDescriptor;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.sync.enumeration.SynchronizerState;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchPut;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchRetrieval;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchUpdate;
-import org.onap.aai.sparky.sync.task.PerformGizmoRetrieval;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.slf4j.MDC;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-/**
- * The Class SearchableEntitySynchronizer.
- */
-public class ViewInspectGizmoEntitySynchronizer extends AbstractEntitySynchronizer
- implements IndexSynchronizer {
-
- /**
- * The Class RetrySearchableEntitySyncContainer.
- */
- private class RetrySearchableEntitySyncContainer {
- NetworkTransaction txn;
- SearchableEntity se;
-
- /**
- * Instantiates a new retry searchable entity sync container.
- *
- * @param txn the txn
- * @param se the se
- */
- public RetrySearchableEntitySyncContainer(NetworkTransaction txn, SearchableEntity se) {
- this.txn = txn;
- this.se = se;
- }
-
- public NetworkTransaction getNetworkTransaction() {
- return txn;
- }
-
- public SearchableEntity getSearchableEntity() {
- return se;
- }
- }
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(ViewInspectGizmoEntitySynchronizer.class);
-
- private boolean allWorkEnumerated;
- private Deque<SelfLinkDescriptor> selflinks;
- private Deque<RetrySearchableEntitySyncContainer> retryQueue;
- private Map<String, Integer> retryLimitTracker;
- protected ExecutorService esPutExecutor;
- private OxmEntityLookup oxmEntityLookup;
- private SearchableEntityLookup searchableEntityLookup;
- private GizmoAdapter gizmoAdapter;
- private OxmEntityContainerLookup entityContainerLookup;
-
- /**
- * Instantiates a new searchable entity synchronizer.
- *
- * @param indexName the index name
- * @throws Exception the exception
- */
- public ViewInspectGizmoEntitySynchronizer(ElasticSearchSchemaConfig schemaConfig,
- int internalSyncWorkers, int gizmoWorkers, int esWorkers, NetworkStatisticsConfig aaiStatConfig,
- NetworkStatisticsConfig esStatConfig, OxmEntityLookup oxmEntityLookup,
- SearchableEntityLookup searchableEntityLookup, OxmEntityContainerLookup entityContainerLookup) throws Exception {
- super(LOG, "SES", internalSyncWorkers, gizmoWorkers, esWorkers, schemaConfig.getIndexName(),
- aaiStatConfig, esStatConfig);
-
- this.oxmEntityLookup = oxmEntityLookup;
- this.searchableEntityLookup = searchableEntityLookup;
- this.entityContainerLookup = entityContainerLookup;
- this.allWorkEnumerated = false;
- this.selflinks = new ConcurrentLinkedDeque<SelfLinkDescriptor>();
- this.retryQueue = new ConcurrentLinkedDeque<RetrySearchableEntitySyncContainer>();
- this.retryLimitTracker = new ConcurrentHashMap<String, Integer>();
- this.synchronizerName = "Searchable Entity Synchronizer";
- this.esPutExecutor = NodeUtils.createNamedExecutor("SES-ES-PUT", 5, LOG);
- this.aaiEntityStats.intializeEntityCounters(
- searchableEntityLookup.getSearchableEntityDescriptors().keySet());
- this.esEntityStats.intializeEntityCounters(
- searchableEntityLookup.getSearchableEntityDescriptors().keySet());
- this.syncDurationInMs = -1;
- }
-
-
-
- public GizmoAdapter getGizmoAdapter() {
- return gizmoAdapter;
-}
-
-
-
-public void setGizmoAdapter(GizmoAdapter gizmoAdapter) {
- this.gizmoAdapter = gizmoAdapter;
-}
-
-
-
-/**
- * Collect all the work.
- *
- * @return the operation state
- */
- private OperationState collectAllTheWork() {
- final Map<String, String> contextMap = MDC.getCopyOfContextMap();
-
- Collection<String> searchableEntityGroups = entityContainerLookup.getSearchableEntityGroups();
-
- if (searchableEntityGroups.isEmpty()) {
- LOG.error(AaiUiMsgs.ERROR_LOADING_OXM_SEARCHABLE_ENTITIES);
- return OperationState.ERROR;
- }
-
-
- try {
-
- /*
- * launch a parallel async thread to process the documents for each entity-type (to max the
- * of the configured executor anyway)
- */
-
- /*searchableEntityGroups = new ArrayList<String>();
- searchableEntityGroups.add("pservers");*/
-
- aaiWorkOnHand.set(searchableEntityGroups.size());
-
- for (String searchableEntityGroup : searchableEntityGroups) {
-
- supplyAsync(new Supplier<Void>() {
-
- @Override
- public Void get() {
- MDC.setContextMap(contextMap);
- OperationResult typeLinksResult = null;
- try {
- typeLinksResult = gizmoAdapter.getSelfLinksByEntityType(searchableEntityGroup);
- aaiWorkOnHand.decrementAndGet();
- processEntityTypeSelfLinks(typeLinksResult);
- } catch (Exception exc) {
-
- exc.printStackTrace();
- }
-
- return null;
- }
-
- }, aaiExecutor).whenComplete((result, error) -> {
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "An error occurred getting data from AAI. Error = " + error.getMessage());
- }
- });
-
- }
-
- while (aaiWorkOnHand.get() != 0) {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.WAIT_FOR_ALL_SELFLINKS_TO_BE_COLLECTED);
- }
-
- Thread.sleep(1000);
- }
-
- aaiWorkOnHand.set(selflinks.size());
- allWorkEnumerated = true;
- syncEntityTypes();
-
- while (!isSyncDone()) {
- performRetrySync();
- Thread.sleep(1000);
- }
-
- /*
- * Make sure we don't hang on to retries that failed which could cause issues during future
- * syncs
- */
- retryLimitTracker.clear();
-
- } catch (Exception exc) {
- // TODO -> LOG, waht should be logged here?
- }
-
- return OperationState.OK;
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#doSync()
- */
- @Override
- public OperationState doSync() {
- this.syncDurationInMs = -1;
- String txnID = NodeUtils.getRandomTxnId();
- MdcContext.initialize(txnID, "SearchableEntitySynchronizer", "", "Sync", "");
-
- resetCounters();
- this.allWorkEnumerated = false;
- syncStartedTimeStampInMs = System.currentTimeMillis();
- collectAllTheWork();
-
- return OperationState.OK;
- }
-
- /**
- * Process entity type self links.
- *
- * @param operationResult the operation result
- */
- private void processEntityTypeSelfLinks(OperationResult operationResult) {
-
- JsonNode rootNode = null;
-
- final String jsonResult = operationResult.getResult();
-
- if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
-
- try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message = "Could not deserialize JSON (representing operation result) as node tree. "
- + "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
-
- ArrayNode resultDataArrayNode = null;
-
- if (rootNode.isArray()) {
- resultDataArrayNode = (ArrayNode) rootNode;
-
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
-
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
-
- final String id = NodeUtils.getNodeFieldAsText(element, "id");
- final String type = NodeUtils.getNodeFieldAsText(element, "type");
- final String url = NodeUtils.getNodeFieldAsText(element, "url");
-
- String resourceLink;
- try {
- resourceLink = gizmoAdapter.getFullInventoryUrl(type + "/" + id);
- selflinks.add(new SelfLinkDescriptor(NodeUtils.extractRawGizmoPathWithoutVersion(resourceLink), null, type));
- } catch (Exception e) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "ERROR: Failed to determine resource link caused by " + e.getMessage());
- }
-
- }
- }
- }
-
- }
-
- /**
- * Sync entity types.
- */
- private void syncEntityTypes() {
-
- while (selflinks.peek() != null) {
-
- SelfLinkDescriptor linkDescriptor = selflinks.poll();
- aaiWorkOnHand.decrementAndGet();
-
- OxmEntityDescriptor descriptor = null;
-
- if (linkDescriptor.getSelfLink() != null && linkDescriptor.getEntityType() != null) {
-
- descriptor = oxmEntityLookup.getEntityDescriptors().get(linkDescriptor.getEntityType());
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, linkDescriptor.getEntityType());
- continue;
- }
-
- NetworkTransaction txn = new NetworkTransaction();
- txn.setDescriptor(descriptor);
- txn.setLink(linkDescriptor.getSelfLink());
- txn.setOperationType(HttpMethod.GET);
- txn.setEntityType(linkDescriptor.getEntityType());
-
- aaiWorkOnHand.incrementAndGet();
-
- supplyAsync(new PerformGizmoRetrieval(txn, gizmoAdapter), aaiExecutor)
- .whenComplete((result, error) -> {
-
- aaiWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_GENERIC, error.getLocalizedMessage());
- } else {
- if (result == null) {
- LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_FOR_SELF_LINK,
- linkDescriptor.getSelfLink());
- } else {
- updateActiveInventoryCounters(result);
- fetchDocumentForUpsert(result);
- }
- }
- });
- }
-
- }
-
- }
-
- /**
- * Perform document upsert.
- *
- * @param esGetTxn the es get txn
- * @param se the se
- */
- protected void performDocumentUpsert(NetworkTransaction esGetTxn, SearchableEntity se) {
- /**
- * <p>
- * <ul>
- * As part of the response processing we need to do the following:
- * <li>1. Extract the version (if present), it will be the ETAG when we use the
- * Search-Abstraction-Service
- * <li>2. Spawn next task which is to do the PUT operation into elastic with or with the version
- * tag
- * <li>a) if version is null or RC=404, then standard put, no _update with version tag
- * <li>b) if version != null, do PUT with _update?version= versionNumber in the URI to elastic
- * </ul>
- * </p>
- */
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), se.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_LINK_UPSERT, exc.getLocalizedMessage());
- return;
- }
-
- String versionNumber = null;
- boolean wasEntryDiscovered = false;
- if (esGetTxn.getOperationResult().getResultCode() == 404) {
- LOG.info(AaiUiMsgs.ES_SIMPLE_PUT, se.getEntityPrimaryKeyValue());
- } else if (esGetTxn.getOperationResult().getResultCode() == 200) {
- wasEntryDiscovered = true;
- try {
- versionNumber = NodeUtils.extractFieldValueFromObject(
- NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_version");
- } catch (IOException exc) {
- String message =
- "Error extracting version number from response, aborting searchable entity sync of "
- + se.getEntityPrimaryKeyValue() + ". Error - " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ERROR_EXTRACTING_FROM_RESPONSE, message);
- return;
- }
- } else {
- /*
- * Not being a 200 does not mean a failure. eg 201 is returned for created. TODO -> Should we
- * return.
- */
- LOG.error(AaiUiMsgs.ES_OPERATION_RETURN_CODE,
- String.valueOf(esGetTxn.getOperationResult().getResultCode()));
- return;
- }
-
- try {
- String jsonPayload = null;
- if (wasEntryDiscovered) {
- try {
- ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
- NodeUtils.extractObjectsByKey(
- NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_source", sourceObject);
-
- if (!sourceObject.isEmpty()) {
- String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
- MergableEntity me = mapper.readValue(responseSource, MergableEntity.class);
- ObjectReader updater = mapper.readerForUpdating(me);
- MergableEntity merged = updater.readValue(NodeUtils.convertObjectToJson(se,false));
- jsonPayload = mapper.writeValueAsString(merged);
- }
- } catch (IOException exc) {
- String message =
- "Error extracting source value from response, aborting searchable entity sync of "
- + se.getEntityPrimaryKeyValue() + ". Error - " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ERROR_EXTRACTING_FROM_RESPONSE, message);
- return;
- }
- } else {
- jsonPayload = se.getAsJson();
- }
-
- if (wasEntryDiscovered) {
- if (versionNumber != null && jsonPayload != null) {
-
- String requestPayload = elasticSearchAdapter.buildBulkImportOperationRequest(getIndexName(),
- "default", se.getId(), versionNumber, jsonPayload);
-
- NetworkTransaction transactionTracker = new NetworkTransaction();
- transactionTracker.setEntityType(esGetTxn.getEntityType());
- transactionTracker.setDescriptor(esGetTxn.getDescriptor());
- transactionTracker.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- supplyAsync(new PerformElasticSearchUpdate(elasticSearchAdapter.getBulkUrl(),
- requestPayload, elasticSearchAdapter, transactionTracker), esPutExecutor)
- .whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- String message = "Searchable entity sync UPDATE PUT error - "
- + error.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
- } else {
- updateElasticSearchCounters(result);
- processStoreDocumentResult(result, esGetTxn, se);
- }
- });
- }
-
- } else {
-
- if (link != null && jsonPayload != null) {
-
- NetworkTransaction updateElasticTxn = new NetworkTransaction();
- updateElasticTxn.setLink(link);
- updateElasticTxn.setEntityType(esGetTxn.getEntityType());
- updateElasticTxn.setDescriptor(esGetTxn.getDescriptor());
- updateElasticTxn.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- supplyAsync(new PerformElasticSearchPut(jsonPayload, updateElasticTxn, elasticSearchAdapter),
- esPutExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- String message =
- "Searchable entity sync UPDATE PUT error - " + error.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
- } else {
- updateElasticSearchCounters(result);
- processStoreDocumentResult(result, esGetTxn, se);
- }
- });
- }
- }
- } catch (Exception exc) {
- String message = "Exception caught during searchable entity sync PUT operation. Message - "
- + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
- }
- }
-
- /**
- * Populate searchable entity document.
- *
- * @param doc the doc
- * @param result the result
- * @param resultDescriptor the result descriptor
- * @throws JsonProcessingException the json processing exception
- * @throws IOException Signals that an I/O exception has occurred.
- */
- protected void populateSearchableEntityDocument(SearchableEntity doc, String result,
- OxmEntityDescriptor resultDescriptor) throws JsonProcessingException, IOException {
-
- doc.setEntityType(resultDescriptor.getEntityName());
-
- JsonNode entityNode = mapper.readTree(result);
-
- String id = NodeUtils.getNodeFieldAsText(entityNode, "id");
- String type = NodeUtils.getNodeFieldAsText(entityNode, "type");
- String url = NodeUtils.getNodeFieldAsText(entityNode, "url");
-
- JsonNode properties = entityNode.get("properties");
-
- Iterator<String> fieldNames = properties.fieldNames();
-
-
-
- List<String> primaryKeyValues = new ArrayList<String>();
- String pkeyValue = null;
-
- SearchableOxmEntityDescriptor searchableDescriptor = searchableEntityLookup.getSearchableEntityDescriptors().get(resultDescriptor.getEntityName());
-
- for (String keyName : searchableDescriptor.getPrimaryKeyAttributeNames()) {
- pkeyValue = NodeUtils.getNodeFieldAsText(properties, keyName);
- if (pkeyValue != null) {
- primaryKeyValues.add(pkeyValue);
- } else {
- String message = "populateSearchableEntityDocument(), pKeyValue is null for entityType = "
- + resultDescriptor.getEntityName();
- LOG.warn(AaiUiMsgs.WARN_GENERIC, message);
- }
- }
-
- final String primaryCompositeKeyValue = NodeUtils.concatArray(primaryKeyValues, "/");
- doc.setEntityPrimaryKeyValue(primaryCompositeKeyValue);
-
- final List<String> searchTagFields = searchableDescriptor.getSearchableAttributes();
-
- /*
- * Based on configuration, use the configured field names for this entity-Type to build a
- * multi-value collection of search tags for elastic search entity search criteria.
- */
- for (String searchTagField : searchTagFields) {
- String searchTagValue = NodeUtils.getNodeFieldAsText(properties, searchTagField);
- if (searchTagValue != null && !searchTagValue.isEmpty()) {
- doc.addSearchTagWithKey(searchTagValue, searchTagField);
- }
- }
- }
-
- /**
- * Fetch document for upsert.
- *
- * @param txn the txn
- */
- private void fetchDocumentForUpsert(NetworkTransaction txn) {
- if (!txn.getOperationResult().wasSuccessful()) {
- String message = "Self link failure. Result - " + txn.getOperationResult().getResult();
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- return;
- }
-
- SearchableOxmEntityDescriptor searchableDescriptor = searchableEntityLookup
- .getSearchableEntityDescriptors().get(txn.getDescriptor().getEntityName());
-
- try {
- if (searchableDescriptor.hasSearchableAttributes()) {
-
- final String jsonResult = txn.getOperationResult().getResult();
- if (jsonResult != null && jsonResult.length() > 0) {
-
- SearchableEntity se = new SearchableEntity();
- se.setLink( txn.getLink() );
- populateSearchableEntityDocument(se, jsonResult, searchableDescriptor);
- se.deriveFields();
-
-
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), se.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_QUERY, exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction n2 = new NetworkTransaction();
- n2.setLink(link);
- n2.setEntityType(txn.getEntityType());
- n2.setDescriptor(txn.getDescriptor());
- n2.setOperationType(HttpMethod.GET);
-
- esWorkOnHand.incrementAndGet();
-
- supplyAsync(new PerformElasticSearchRetrieval(n2, elasticSearchAdapter), esExecutor)
- .whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, se);
- }
- });
- }
- }
-
- }
- } catch (JsonProcessingException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "Processing error while fetching document for elasticsearch update. Error: " + exc.getMessage() );
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "Processing error while fetching document for elasticsearch update. Error: " + exc.getMessage() );
- }
- }
-
- /**
- * Process store document result.
- *
- * @param esPutResult the es put result
- * @param esGetResult the es get result
- * @param se the se
- */
- private void processStoreDocumentResult(NetworkTransaction esPutResult,
- NetworkTransaction esGetResult, SearchableEntity se) {
-
- OperationResult or = esPutResult.getOperationResult();
-
- if (!or.wasSuccessful()) {
- if (or.getResultCode() == VERSION_CONFLICT_EXCEPTION_CODE) {
-
- if (shouldAllowRetry(se.getId())) {
- esWorkOnHand.incrementAndGet();
-
- RetrySearchableEntitySyncContainer rsc =
- new RetrySearchableEntitySyncContainer(esGetResult, se);
- retryQueue.push(rsc);
-
- String message = "Store document failed during searchable entity synchronization"
- + " due to version conflict. Entity will be re-synced.";
- LOG.warn(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
- }
- } else {
- String message =
- "Store document failed during searchable entity synchronization with result code "
- + or.getResultCode() + " and result message " + or.getResult();
- LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
- }
- }
- }
-
- /**
- * Perform retry sync.
- */
- private void performRetrySync() {
- while (retryQueue.peek() != null) {
-
- RetrySearchableEntitySyncContainer rsc = retryQueue.poll();
- if (rsc != null) {
-
- SearchableEntity se = rsc.getSearchableEntity();
- NetworkTransaction txn = rsc.getNetworkTransaction();
-
- String link = null;
- try {
- /*
- * In this retry flow the se object has already derived its fields
- */
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), se.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_URI, exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction retryTransaction = new NetworkTransaction();
- retryTransaction.setLink(link);
- retryTransaction.setEntityType(txn.getEntityType());
- retryTransaction.setDescriptor(txn.getDescriptor());
- retryTransaction.setOperationType(HttpMethod.GET);
-
- /*
- * IMPORTANT - DO NOT incrementAndGet the esWorkOnHand as this is a retry flow! We already
- * called incrementAndGet when queuing the failed PUT!
- */
-
- supplyAsync(new PerformElasticSearchRetrieval(retryTransaction, elasticSearchAdapter),
- esExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED_RESYNC, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, se);
- }
- });
- }
-
- }
- }
- }
-
- /**
- * Should allow retry.
- *
- * @param id the id
- * @return true, if successful
- */
- private boolean shouldAllowRetry(String id) {
- boolean isRetryAllowed = true;
- if (retryLimitTracker.get(id) != null) {
- Integer currentCount = retryLimitTracker.get(id);
- if (currentCount.intValue() >= RETRY_COUNT_PER_ENTITY_LIMIT.intValue()) {
- isRetryAllowed = false;
- String message = "Searchable entity re-sync limit reached for " + id
- + ", re-sync will no longer be attempted for this entity";
- LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
- } else {
- Integer newCount = new Integer(currentCount.intValue() + 1);
- retryLimitTracker.put(id, newCount);
- }
- } else {
- Integer firstRetryCount = new Integer(1);
- retryLimitTracker.put(id, firstRetryCount);
- }
-
- return isRetryAllowed;
- }
-
- @Override
- public SynchronizerState getState() {
- if (!isSyncDone()) {
- return SynchronizerState.PERFORMING_SYNCHRONIZATION;
- }
-
- return SynchronizerState.IDLE;
-
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#getStatReport(boolean)
- */
- @Override
- public String getStatReport(boolean showFinalReport) {
- syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
- return this.getStatReport(syncDurationInMs, showFinalReport);
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#shutdown()
- */
- @Override
- public void shutdown() {
- this.shutdownExecutors();
- }
-
- @Override
- protected boolean isSyncDone() {
- int totalWorkOnHand = aaiWorkOnHand.get() + esWorkOnHand.get();
-
- if (totalWorkOnHand > 0 || !allWorkEnumerated) {
- return false;
- }
-
- return true;
- }
-
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoSyncController.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoSyncController.java
deleted file mode 100644
index c2a1150..0000000
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectGizmoSyncController.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017 Amdocs
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.onap.aai.sparky.viewandinspect.sync;
-
-import org.onap.aai.sparky.config.oxm.OxmEntityContainerLookup;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.dal.GizmoAdapter;
-import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
-import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
-import org.onap.aai.sparky.sync.IndexCleaner;
-import org.onap.aai.sparky.sync.IndexIntegrityValidator;
-import org.onap.aai.sparky.sync.SyncControllerImpl;
-import org.onap.aai.sparky.sync.SyncControllerRegistrar;
-import org.onap.aai.sparky.sync.SyncControllerRegistry;
-import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.config.SyncControllerConfig;
-
-public class ViewInspectGizmoSyncController extends SyncControllerImpl
- implements SyncControllerRegistrar {
-
- private SyncControllerRegistry syncControllerRegistry;
- //private GizmoAdapter gizmoAdapter;
- //private ElasticSearchAdapter esAdapter;
- //private ElasticSearchSchemaConfig schemaConfig;
- //private ElasticSearchEndpointConfig endpointConfig;
-
- public ViewInspectGizmoSyncController(SyncControllerConfig syncControllerConfig,
- GizmoAdapter gizmoAdapter, ElasticSearchAdapter esAdapter,
- ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
- NetworkStatisticsConfig gizmoStatConfig, NetworkStatisticsConfig esStatConfig,
- OxmEntityLookup oxmEntityLookup,
- SearchableEntityLookup searchableEntityLookup, OxmEntityContainerLookup oxmEntityContainerLookup,
- ElasticSearchSchemaFactory elasticSearchSchemaFactory) throws Exception {
- super(syncControllerConfig);
-
- // final String controllerName = "View and Inspect Entity Synchronizer";
-
- //this.gizmoAdapter = gizmoAdapter;
- //this.esAdapter = esAdapter;
- //this.schemaConfig = schemaConfig;
- //this.endpointConfig = endpointConfig;
-
- IndexIntegrityValidator indexValidator = new IndexIntegrityValidator(esAdapter, schemaConfig,
- endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
-
- registerIndexValidator(indexValidator);
-
- ViewInspectGizmoEntitySynchronizer ses = new ViewInspectGizmoEntitySynchronizer(schemaConfig,
- syncControllerConfig.getNumInternalSyncWorkers(),
- syncControllerConfig.getNumSyncActiveInventoryWorkers(),
- syncControllerConfig.getNumSyncElasticWorkers(), gizmoStatConfig, esStatConfig,
- oxmEntityLookup, searchableEntityLookup, oxmEntityContainerLookup);
-
- ses.setGizmoAdapter(gizmoAdapter);
- ses.setElasticSearchAdapter(esAdapter);
-
- registerEntitySynchronizer(ses);
-
- IndexCleaner indexCleaner =
- new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
-
- registerIndexCleaner(indexCleaner);
-
- }
-
- public SyncControllerRegistry getSyncControllerRegistry() {
- return syncControllerRegistry;
- }
-
- public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
- this.syncControllerRegistry = syncControllerRegistry;
- }
-
- @Override
- public void registerController() {
- if ( syncControllerRegistry != null ) {
- if ( syncControllerConfig.isEnabled()) {
- syncControllerRegistry.registerSyncController(this);
- }
- }
-
- }
-}