diff options
author | da490c <dave.adams@amdocs.com> | 2018-06-20 15:29:48 -0400 |
---|---|---|
committer | da490c <dave.adams@amdocs.com> | 2018-06-20 17:08:31 -0400 |
commit | 8eed25b1f4f0ab8306b10c5b77e34143e75d07e8 (patch) | |
tree | a5069c46a0a965546015f44d09d6775f92422bbb /sparkybe-onap-service/src/test/java | |
parent | 3c54febdf3d6e49bd50c7aeca5b4476becfdd027 (diff) |
Add multi-oxm support to sparky-be
Issue-ID: AAI-1232
Change-Id: Ib26fe496f022baf680884ebcee6a02e8eb18c985
Signed-off-by: da490c <dave.adams@amdocs.com>
Diffstat (limited to 'sparkybe-onap-service/src/test/java')
17 files changed, 335 insertions, 268 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 index 71eefe5..e9f03ba 100644 --- 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 @@ -12,9 +12,12 @@ 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; @@ -27,9 +30,18 @@ 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(); @@ -39,12 +51,21 @@ public class HistoricalEntitySummarizerTest { private ElasticSearchSchemaConfig esSchemaConfig; private NetworkStatisticsConfig aaiStatConfig; private NetworkStatisticsConfig esStatConfig; - private OxmEntityLookup oxmEntityLookup; + private SearchableEntityLookup searchableEntityLookup; private ElasticSearchAdapter esAdapter; private ActiveInventoryAdapter aaiAdapter; + + @Inject + private NodeIngestor nodeInjest; + + + @Inject + private OxmEntityLookup oxmEntityLookup; + + @Before public void init() throws Exception { @@ -160,11 +181,11 @@ public class HistoricalEntitySummarizerTest { searchableEntityLookup = new SearchableEntityLookup(); processors.add(searchableEntityLookup); + Version v = Version.V11; + OxmModelLoader oxmModelLoader = new OxmModelLoader(v, processors,nodeInjest); + oxmModelLoader.loadModel(); - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); - - // suggestionEntityLookup.setSuggestionSearchEntityDescriptors(suggestionEntityDescriptors); + } @Test @@ -233,9 +254,9 @@ public class HistoricalEntitySummarizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -315,9 +336,9 @@ public class HistoricalEntitySummarizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -348,4 +369,4 @@ public class HistoricalEntitySummarizerTest { } -} +}
\ 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 6ba2cb5..4471390 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 @@ -5,16 +5,20 @@ 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 javax.inject.Inject; + 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; @@ -30,11 +34,21 @@ 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; +@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 AutosuggestionSynchronizerTest { + private static ObjectMapper mapper = new ObjectMapper(); private AutosuggestionSynchronizer suggestionSynchronizer; @@ -42,16 +56,33 @@ public class AutosuggestionSynchronizerTest { private ElasticSearchSchemaConfig esSchemaConfig; private NetworkStatisticsConfig aaiStatConfig; private NetworkStatisticsConfig esStatConfig; - private OxmEntityLookup oxmEntityLookup; - private SuggestionEntityLookup suggestionEntityLookup; + + private ElasticSearchAdapter esAdapter; private ActiveInventoryAdapter aaiAdapter; - + @Inject private FiltersConfig filtersConfig; + + + private OxmModelLoader oxmModelLoader; + + @Inject + private NodeIngestor nodeInjest; + + @Inject + private Set<OxmModelProcessor> processors; + + @Inject + private OxmEntityLookup oxmEntityLookup; + + + private SuggestionEntityLookup suggestionEntityLookup; + + @Before public void init() throws Exception { @@ -120,17 +151,32 @@ public class AutosuggestionSynchronizerTest { 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); + + FiltersDetailsConfig filtersDetailsConfig = mapper.readValue( + TestResourceLoader.getTestResourceDataJson("/filters/aaiui_filters_testConfig.json"), + FiltersDetailsConfig.class); + FiltersForViewsConfig filtersForViewsConfig = mapper.readValue( + TestResourceLoader.getTestResourceDataJson("/filters/aaiui_views_testConfig.json"), + FiltersForViewsConfig.class); + filtersConfig.setFiltersConfig(filtersDetailsConfig); + filtersConfig.setViewsConfig(filtersForViewsConfig); + + suggestionEntityLookup = new SuggestionEntityLookup(filtersConfig); + processors.add(suggestionEntityLookup); + Version v = Version.V11; + OxmModelLoader oxmModelLoader = new OxmModelLoader(v, processors,nodeInjest); + oxmModelLoader.loadModel(); + + Map<String, OxmEntityDescriptor> oxmEntityDescriptors = new HashMap<String, OxmEntityDescriptor>(); @@ -145,27 +191,15 @@ public class AutosuggestionSynchronizerTest { oxmEntityDescriptors.put("generic-vnf", genericVnfDescriptor); - oxmEntityLookup.setEntityDescriptors(oxmEntityDescriptors); - + - Map<String, SuggestionEntityDescriptor> suggestionEntityDescriptors = - new HashMap<String, SuggestionEntityDescriptor>(); + SuggestionEntityDescriptor genericVnfSuggestionDescriptor = new SuggestionEntityDescriptor(); genericVnfSuggestionDescriptor.setEntityName("generic-vnf"); genericVnfSuggestionDescriptor.setPrimaryKeyAttributeNames(pkeyNames); - filtersConfig = new FiltersConfig(null, null, null); - - FiltersDetailsConfig filtersDetailsConfig = mapper.readValue( - TestResourceLoader.getTestResourceDataJson("/filters/aaiui_filters_testConfig.json"), - FiltersDetailsConfig.class); - FiltersForViewsConfig filtersForViewsConfig = mapper.readValue( - TestResourceLoader.getTestResourceDataJson("/filters/aaiui_views_testConfig.json"), - FiltersForViewsConfig.class); - filtersConfig.setFiltersConfig(filtersDetailsConfig); - filtersConfig.setViewsConfig(filtersForViewsConfig); /* * SuggestionSearchEntity sse = new SuggestionSearchEntity(filtersConfig); @@ -177,14 +211,7 @@ public class AutosuggestionSynchronizerTest { * suggestionEntityDescriptors.put("generic-vnf", genericVnfSuggestionDescriptor); */ - suggestionEntityLookup = new SuggestionEntityLookup(filtersConfig); - - processors.add(suggestionEntityLookup); - - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); - - // suggestionEntityLookup.setSuggestionSearchEntityDescriptors(suggestionEntityDescriptors); + } @Test @@ -222,29 +249,37 @@ public class AutosuggestionSynchronizerTest { Mockito.when(aaiAdapter.getSelfLinksByEntityType("generic-vnf")) .thenReturn(genericVnfSelfLinks); - Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-1"), Mockito.anyString())) + 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())) + 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())) + 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"))); + .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"))); + .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"), @@ -253,9 +288,9 @@ public class AutosuggestionSynchronizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -304,29 +339,37 @@ public class AutosuggestionSynchronizerTest { Mockito.when(aaiAdapter.getSelfLinksByEntityType("generic-vnf")) .thenReturn(genericVnfSelfLinks); - Mockito.when(aaiAdapter.repairSelfLink(Matchers.contains("generic-vnf-1"), Mockito.anyString())) + 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())) + 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())) + 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"))); + .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"))); + .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"), @@ -335,9 +378,9 @@ public class AutosuggestionSynchronizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -368,4 +411,4 @@ public class AutosuggestionSynchronizerTest { } -} +}
\ No newline at end of file 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 e9bb4ec..1a14256 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 @@ -175,9 +175,7 @@ public class VnfAliasSuggestionSynchronizerTest { processors.add(geoEntityLookup); - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); - + // suggestionEntityLookup.setSuggestionSearchEntityDescriptors(suggestionEntityDescriptors); } @@ -247,9 +245,9 @@ public class VnfAliasSuggestionSynchronizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -329,9 +327,9 @@ public class VnfAliasSuggestionSynchronizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -362,4 +360,4 @@ public class VnfAliasSuggestionSynchronizerTest { } -} +}
\ No newline at end of file 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 c6c999a..c085ca4 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 @@ -19,7 +19,6 @@ import org.onap.aai.restclient.client.OperationResult; import org.onap.aai.sparky.config.oxm.CrossEntityReferenceLookup; 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.dal.ActiveInventoryAdapter; @@ -149,8 +148,7 @@ public class CrossEntityReferenceSynchronizerTest { searchableEntityLookup = new SearchableEntityLookup(); processors.add(searchableEntityLookup); - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); + aaiRestEndPointConfig = new RestEndpointConfig(); aaiRestEndPointConfig.setNumRequestRetries(5); @@ -451,9 +449,9 @@ public class CrossEntityReferenceSynchronizerTest { Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString())) - .thenReturn("http://localhost:9200/myindex/mytype/doc1", - "http://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -755,9 +753,9 @@ public class CrossEntityReferenceSynchronizerTest { Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString())) - .thenReturn("http://localhost:9200/myindex/mytype/doc1", - "http://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -985,9 +983,9 @@ public class CrossEntityReferenceSynchronizerTest { Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString())) - .thenReturn("http://localhost:9200/myindex/mytype/doc1", - "http://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 return 200 ok with a found entity document requiring a doc update @@ -1032,4 +1030,4 @@ public class CrossEntityReferenceSynchronizerTest { -} +}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java index af441c7..b8c78d6 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import org.junit.Before; import org.junit.Test; import org.onap.aai.restclient.enums.RestAuthenticationMode; +import org.onap.aai.setup.Version; import org.onap.aai.sparky.config.oxm.OxmEntityLookup; import org.onap.aai.sparky.config.oxm.OxmModelLoader; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; @@ -19,11 +20,12 @@ public class ActiveInventoryAdapterTest { private RestEndpointConfig endpointConfig; private ActiveInventoryAdapter aaiAdapter; private ArrayList<String> queryParams; + private Version version; @Before public void init() throws Exception { - - oxmModelLoader = new OxmModelLoader(); + version= Version.V11; + oxmModelLoader = new OxmModelLoader(version,null,null); oxmEntityLookup = new OxmEntityLookup(); endpointConfig = new RestEndpointConfig(); queryParams = new ArrayList<String>(); @@ -53,4 +55,4 @@ public class ActiveInventoryAdapterTest { } -} +}
\ No newline at end of file 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 index 870451c..33d57ae 100644 --- 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 @@ -6,12 +6,10 @@ import javax.ws.rs.core.MediaType; import org.junit.Before; import org.junit.Test; -import org.junit.Ignore; import org.onap.aai.restclient.enums.RestAuthenticationMode; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; import org.onap.aai.sparky.dal.ElasticSearchAdapter; -@Ignore public class ElasticSearchAdapterTest { @@ -30,13 +28,13 @@ public class ElasticSearchAdapterTest { @Test public void updateValues() { - assertNotNull(elasticSearchAdapter.doPost("https://10.247.40.25:8000","{maxResults:10, queryStr: f}",MediaType.APPLICATION_JSON_TYPE)); - assertNotNull(elasticSearchAdapter.doGet("https://10.247.40.25:8000",MediaType.APPLICATION_JSON_TYPE)); - assertNotNull(elasticSearchAdapter.doHead("https://10.247.40.25:8000",MediaType.APPLICATION_JSON_TYPE)); - assertNotNull(elasticSearchAdapter.doPut("https://10.247.40.25:8000","{maxResults:10, queryStr: f}",MediaType.APPLICATION_JSON_TYPE)); - assertNotNull(elasticSearchAdapter.doPatch("https://10.247.40.25:8000","{maxResults:10, queryStr: f}",MediaType.APPLICATION_JSON_TYPE)); - assertNotNull(elasticSearchAdapter.doDelete("https://10.247.40.25:8000",MediaType.APPLICATION_JSON_TYPE)); - assertNotNull(elasticSearchAdapter.doBulkOperation("https://10.247.40.25:8000","{maxResults:10, queryStr: f}")); + 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("","")); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java index b17b6fb..95c3320 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java @@ -5,20 +5,31 @@ import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.Test; +import org.onap.aai.nodes.NodeIngestor; import org.onap.aai.restclient.enums.RestAuthenticationMode; +import org.onap.aai.setup.Version; import org.onap.aai.sparky.config.oxm.OxmModelLoader; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; +import org.springframework.test.context.ContextConfiguration; + + +@ContextConfiguration(locations = { "classpath:oxm-reader/test-service-beans.xml" }) public class GizmoAdapterTest { private OxmModelLoader oxmModelLoader; private RestEndpointConfig endpointConfig; private GizmoAdapter gizmoAdapter; + private Version version; + @Before public void init() throws Exception { - oxmModelLoader = new OxmModelLoader(); + + + version = Version.V11; + oxmModelLoader = new OxmModelLoader(version,null,null); endpointConfig = new RestEndpointConfig(); endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC); endpointConfig.setEndpointIpAddress("10.147.110.199"); @@ -57,4 +68,4 @@ public class GizmoAdapterTest { gizmoAdapter.setEndpointConfig(endpointConfig); assertNotNull(gizmoAdapter.getEndpointConfig()); } -} +}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java index 3dbc36b..3d2c9f3 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java @@ -2,8 +2,8 @@ * ============LICENSE_START=================================================== * SPARKY (AAI UI service) * ============================================================================ - * Copyright © 2017 AT&T Intellectual Property. - * Copyright © 2017 Amdocs + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs * All rights reserved. * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,11 +37,11 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; 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.dal.ActiveInventoryAdapter; -import org.onap.aai.sparky.editattributes.AttributeUpdater; import org.onap.aai.sparky.editattributes.AttributeUpdater.AaiEditObject; @@ -74,11 +74,12 @@ public class AttributeUpdaterTest { OxmEntityDescriptor desc = new OxmEntityDescriptor(); desc.addPrimaryKeyName("hostname"); desc.setEntityName("pserver"); - + Version version = Version.V11; OxmEntityLookup entityLookup = new OxmEntityLookup(); entityLookup.addEntityDescriptor("pserver", desc); - AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter); + AttributeUpdater updater = + new AttributeUpdater(new OxmModelLoader(version, null, null), entityLookup, aaiAdapter); Map<String, Object> attributes = new HashMap<>(); attributes.put("prov-status", "PREPROV"); attributes.put("in-maint", "true"); @@ -96,9 +97,9 @@ public class AttributeUpdaterTest { */ @Test(expected = NullPointerException.class) public void testGetEditObjectFromUri() throws Exception { + Version version = Version.V11; + OxmModelLoader loader = new OxmModelLoader(version, null, null); - OxmModelLoader loader = new OxmModelLoader(); - loader.setLatestVersionNum(11); OxmEntityDescriptor desc = new OxmEntityDescriptor(); desc.addPrimaryKeyName("hostname"); @@ -121,7 +122,8 @@ public class AttributeUpdaterTest { entityLookup.setEntityTypeLookup(typeLookup); - AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter); + AttributeUpdater updater = + new AttributeUpdater(new OxmModelLoader(version, null, null), entityLookup, aaiAdapter); AaiEditObject result = updater.getEditObjectFromUri(null); assertEquals("Pserver", result.getObjectType()); assertEquals("pserver", result.getRootElement()); @@ -145,7 +147,7 @@ public class AttributeUpdaterTest { OxmEntityLookup entityLookup = new OxmEntityLookup(); entityLookup.addEntityDescriptor("pserver", desc); - AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter); + AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(null,null), entityLookup, aaiAdapter); // Test entity uri without "/aai/version/" String result = updater.getRelativeUri("cloud-infrastructure/pservers/pserver/mtznjtax101"); assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result); @@ -162,4 +164,4 @@ public class AttributeUpdaterTest { assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result); } -} +}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/TestUserValidator.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/TestUserValidator.java index e20defa..df41a5e 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/TestUserValidator.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/TestUserValidator.java @@ -32,7 +32,6 @@ import static org.mockito.Mockito.when; import java.io.File; import java.nio.file.Paths; -import org.apache.log4j.BasicConfigurator; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -64,7 +63,6 @@ public class TestUserValidator { */ @BeforeClass public static void setUpBeforeClass() throws Exception { - BasicConfigurator.configure(); userAuthFile = Paths.get(TestData.USER_AUTH_FILE.getFilename()).toFile(); missingUserAuthFile = Paths.get(TestData.MISSING_USER_AUTH_FILE.getFilename()).toFile(); } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java index 4eb670f..ca7eab9 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java @@ -8,12 +8,10 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.onap.aai.restclient.enums.RestAuthenticationMode; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; -@Ignore public class SearchServiceAdapterTest { private SearchServiceAdapter searchServiceAdapter; @@ -35,12 +33,12 @@ public class SearchServiceAdapterTest { assertNotNull(searchServiceAdapter.getServiceApiVersion()); searchServiceAdapter.setEndpointConfig(endpointConfig); assertNotNull(searchServiceAdapter.getEndpointConfig()); - assertNotNull(searchServiceAdapter.doPost("https://10.247.40.25:8000", + assertNotNull(searchServiceAdapter.doPost("https://aai.search.service:8000", "{maxResults:10, queryStr: f}", "application/json")); - assertNotNull(searchServiceAdapter.doGet("https://10.247.40.25:8000", "application/json")); - assertNotNull(searchServiceAdapter.doPut("https://10.247.40.25:8000", + assertNotNull(searchServiceAdapter.doGet("https://aai.search.service:8000", "application/json")); + assertNotNull(searchServiceAdapter.doPut("https://aai.search.service:8000", "{maxResults:10, queryStr: f}", "application/json")); - assertNotNull(searchServiceAdapter.doDelete("https://10.247.40.25:8000", "application/json")); + assertNotNull(searchServiceAdapter.doDelete("https://aai.search.service:8000", "application/json")); assertNotNull(searchServiceAdapter.getTxnHeader()); assertNotNull(searchServiceAdapter.buildSearchServiceQueryUrl("searchentity-localhost")); assertNotNull( 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 index 35dd0bd..a0dc071 100644 --- 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 @@ -24,7 +24,7 @@ public class ElasticSearchEndpointConfigTest { @Test public void updateValues() { - elasticSearchEndpointConfig.setEsIpAddress("10.247.25.26"); + elasticSearchEndpointConfig.setEsIpAddress("aai.es.service"); assertNotNull(elasticSearchEndpointConfig.getEsIpAddress()); elasticSearchEndpointConfig.setEsServerPort("6585"); assertNotNull(elasticSearchEndpointConfig.getEsServerPort()); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java index 5ea5280..cb73077 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java @@ -16,6 +16,7 @@ import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.restclient.client.OperationResult; import org.onap.aai.restclient.enums.RestAuthenticationMode; +import org.onap.aai.setup.Version; import org.onap.aai.sparky.config.oxm.OxmModelLoader; import org.onap.aai.sparky.dal.GizmoAdapter; import org.onap.aai.sparky.dal.exception.ElasticSearchOperationException; @@ -46,7 +47,7 @@ public class GizmoEntitySummarizer { public GizmoEntitySummarizer() throws ElasticSearchOperationException, IOException, RestClientConstructionException { - OxmModelAndProcessorHelper.API_VERSION_OVERRIDE = 11; + OxmModelAndProcessorHelper.API_VERSION_OVERRIDE = Version.V11; this.gizmoExecutor = NodeUtils.createNamedExecutor("GIZMO-WORKER", 5, logger); 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 index 9b1e8c7..8cc5626 100644 --- 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 @@ -18,7 +18,6 @@ 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.OxmModelLoader; import org.onap.aai.sparky.config.oxm.OxmModelProcessor; import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor; import org.onap.aai.sparky.dal.ActiveInventoryAdapter; @@ -160,10 +159,7 @@ public class GeoSynchronizerTest { geoEntityLookup = new GeoEntityLookup(); processors.add(geoEntityLookup); - - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); - + // suggestionEntityLookup.setSuggestionSearchEntityDescriptors(suggestionEntityDescriptors); } @@ -234,8 +230,8 @@ public class GeoSynchronizerTest { Mockito.when(esAdapter.buildElasticSearchGetDocUrl(Mockito.anyString(), Mockito.anyString())) .thenReturn("http://localhost:9200/myindex/mytype/doc1", - "http://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + "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 @@ -315,9 +311,9 @@ public class GeoSynchronizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -348,4 +344,4 @@ public class GeoSynchronizerTest { } -} +}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/OxmModelAndProcessorHelper.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/OxmModelAndProcessorHelper.java index cebb494..a30d9d1 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/OxmModelAndProcessorHelper.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/OxmModelAndProcessorHelper.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; +import org.onap.aai.setup.Version; import org.onap.aai.sparky.config.SparkyResourceLoader; import org.onap.aai.sparky.config.oxm.CrossEntityReferenceLookup; import org.onap.aai.sparky.config.oxm.GeoEntityLookup; @@ -18,7 +19,7 @@ import org.springframework.core.io.DefaultResourceLoader; public class OxmModelAndProcessorHelper { - public static int API_VERSION_OVERRIDE = -1; + public static Version API_VERSION_OVERRIDE = Version.V11; private OxmModelLoader modelLoader; private Set<OxmModelProcessor> processors; @@ -56,9 +57,8 @@ public class OxmModelAndProcessorHelper { processors.add(searchableEntityLookup); processors.add(suggestionEntityLookup); processors.add(oxmEntityContainerLookup); - - this.modelLoader = new OxmModelLoader(API_VERSION_OVERRIDE, processors); - modelLoader.loadLatestOxmModel(); + this.modelLoader = new OxmModelLoader(API_VERSION_OVERRIDE, processors, null); + } public static OxmModelAndProcessorHelper getInstance() throws IOException { @@ -140,4 +140,4 @@ public class OxmModelAndProcessorHelper { this.oxmEntityContainerLookup = oxmEntityContainerLookup; } -} +}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java index ed7caeb..94050be 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java @@ -1,41 +1,25 @@ package org.onap.aai.sparky.viewandinspect.services; 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.security.SecureRandom; import java.util.ArrayList; import java.util.HashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; -import org.hamcrest.Matcher; import org.junit.Before; import org.junit.Test; -import org.mockito.Matchers; import org.mockito.Mockito; 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.OxmEntityLookup; -import org.onap.aai.sparky.config.oxm.OxmModelLoader; import org.onap.aai.sparky.config.oxm.OxmModelProcessor; -import org.onap.aai.sparky.dal.ActiveInventoryAdapter; import org.onap.aai.sparky.dal.GizmoAdapter; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; -import org.onap.aai.sparky.sync.entity.SearchableEntity; import org.onap.aai.sparky.util.NodeUtils; -import org.onap.aai.sparky.util.StringCollectionContainsMatcher; -import org.onap.aai.sparky.util.TestResourceLoader; import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs; -import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode; -import org.onap.aai.sparky.viewandinspect.entity.QueryParams; -import org.onap.aai.sparky.viewandinspect.enumeration.NodeProcessingState; public class BaseGizmoVisualizationContextTest { @@ -79,8 +63,6 @@ public class BaseGizmoVisualizationContextTest { processors.add(oxmEntityLookup); - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); gizmoRestEndPointConfig = new RestEndpointConfig(); gizmoRestEndPointConfig.setNumRequestRetries(5); @@ -88,7 +70,7 @@ public class BaseGizmoVisualizationContextTest { Mockito.when(gizmoAdapter.getEndpointConfig()).thenReturn(gizmoRestEndPointConfig); MdcContext.initialize("" + secureRandom.nextLong(), "AAI-UI", "", "partner-name", - "localhost:4242"); + "server.proxy:4242"); } @@ -107,4 +89,4 @@ public class BaseGizmoVisualizationContextTest { -} +}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java index 09ca3a3..1934207 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java @@ -3,17 +3,23 @@ package org.onap.aai.sparky.viewandinspect.services; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import java.io.InputStream; import java.security.SecureRandom; import java.util.ArrayList; -import java.util.HashSet; +import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.ExecutorService; +import javax.inject.Inject; + +import org.eclipse.persistence.jaxb.JAXBContextProperties; +import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; +import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory; import org.hamcrest.Matcher; 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.cl.api.Logger; @@ -21,8 +27,6 @@ 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.OxmEntityLookup; -import org.onap.aai.sparky.config.oxm.OxmModelLoader; -import org.onap.aai.sparky.config.oxm.OxmModelProcessor; import org.onap.aai.sparky.dal.ActiveInventoryAdapter; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; import org.onap.aai.sparky.sync.entity.SearchableEntity; @@ -33,22 +37,34 @@ import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs; import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode; import org.onap.aai.sparky.viewandinspect.entity.QueryParams; import org.onap.aai.sparky.viewandinspect.enumeration.NodeProcessingState; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + + + +@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 BaseVisualizationContextTest { - + private static SecureRandom secureRandom = new SecureRandom(); - private static Logger LOG = LoggerFactory.getInstance().getLogger(BaseVisualizationContextTest.class); + private static Logger LOG = + LoggerFactory.getInstance().getLogger(BaseVisualizationContextTest.class); private BaseVisualizationContext baseVisualizationContext; private ExecutorService aaiExecutorService; - private VisualizationConfigs visualizationConfig; + private VisualizationConfigs visualizationConfig; + private ActiveInventoryAdapter aaiAdapter; + private RestEndpointConfig aaiRestEndPointConfig; + + @Inject private OxmEntityLookup oxmEntityLookup; - private ActiveInventoryAdapter aaiAdapter; - private RestEndpointConfig aaiRestEndPointConfig; - @Before public void init() throws Exception { @@ -59,20 +75,10 @@ public class BaseVisualizationContextTest { shallowEntities.add("cloud-region"); visualizationConfig.setShallowEntities(shallowEntities); - visualizationConfig.setMaxSelfLinkTraversalDepth(2); - - oxmEntityLookup = new OxmEntityLookup(); + visualizationConfig.setMaxSelfLinkTraversalDepth(2); - aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class); - - Set<OxmModelProcessor> processors = new HashSet<OxmModelProcessor>(); - - processors.add(oxmEntityLookup); - - - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); + aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class); aaiRestEndPointConfig = new RestEndpointConfig(); aaiRestEndPointConfig.setNumRequestRetries(5); @@ -87,7 +93,7 @@ public class BaseVisualizationContextTest { } - + private Matcher<List<String>> listContainsValue(String expectedValue) { return new StringCollectionContainsMatcher(expectedValue); } @@ -97,14 +103,14 @@ public class BaseVisualizationContextTest { public void validateBasicConstruction() throws Exception { long contextId = secureRandom.nextLong(); - + baseVisualizationContext = new BaseVisualizationContext(contextId, aaiAdapter, aaiExecutorService, visualizationConfig, oxmEntityLookup); - + assertEquals(contextId, baseVisualizationContext.getContextId()); } - + @Test public void validateSmallGraphAssembly() throws Exception { @@ -141,76 +147,72 @@ public class BaseVisualizationContextTest { queryParams.setSearchTargetNodeId(customerNodeId); queryParams.setSearchTargetPrimaryKeyValues("customer-4"); - // aai customer resource dip + // aai customer resource dip Mockito - .when(aaiAdapter.queryActiveInventoryWithRetries( - Matchers.contains("customer-4"), Mockito.anyString(), - Mockito.anyInt())) - .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( - "/sync/aai/aai-resources/customer/customer-4.json"))); + .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("customer-4"), + Mockito.anyString(), Mockito.anyInt())) + .thenReturn(new OperationResult(200, TestResourceLoader + .getTestResourceDataJson("/sync/aai/aai-resources/customer/customer-4.json"))); - // aai tenant resource dip + // aai tenant resource dip Mockito - .when(aaiAdapter.queryActiveInventoryWithRetries( - Matchers.contains("tenant/tenant-1"), Mockito.anyString(), - Mockito.anyInt())) - .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( - "/sync/aai/aai-resources/tenant/tenant-1.json"))); - + .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("tenant/tenant-1"), + Mockito.anyString(), Mockito.anyInt())) + .thenReturn(new OperationResult(200, TestResourceLoader + .getTestResourceDataJson("/sync/aai/aai-resources/tenant/tenant-1.json"))); + // generic-queries for service-subscription - + Mockito - .when(aaiAdapter.getGenericQueryForSelfLink(Matchers.contains("service-subscription"), - Matchers.argThat(listContainsValue("service-subscription.service-type:service-subscription-2")))) - .thenReturn( - "https://server.proxy:8443/aai/v11/search/generic-query/service-subscription-2"); + .when(aaiAdapter.getGenericQueryForSelfLink(Matchers.contains("service-subscription"), + Matchers.argThat( + listContainsValue("service-subscription.service-type:service-subscription-2")))) + .thenReturn( + "https://server.proxy:8443/aai/v11/search/generic-query/service-subscription-2"); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( - Matchers.contains("generic-query/service-subscription-2"), Mockito.anyString(), Mockito.anyInt())) - .thenReturn(new OperationResult(200, TestResourceLoader - .getTestResourceDataJson("/sync/aai/aai-traversal/generic-query/service-subscription/service-subscription-2.json"))); - + Matchers.contains("generic-query/service-subscription-2"), Mockito.anyString(), + Mockito.anyInt())) + .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( + "/sync/aai/aai-traversal/generic-query/service-subscription/service-subscription-2.json"))); + // generic-queries for service-instance-1 - + Mockito .when(aaiAdapter.getGenericQueryForSelfLink(Matchers.contains("service-instance"), - Matchers.argThat( - listContainsValue("service-instance-id:service-instance-54")))) + Matchers.argThat(listContainsValue("service-instance-id:service-instance-54")))) .thenReturn( "https://server.proxy:8443/aai/v11/search/generic-query/service-instance-id/service-instance-54"); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( - Matchers - .contains("generic-query/service-instance-id/service-instance-54"), + Matchers.contains("generic-query/service-instance-id/service-instance-54"), Mockito.anyString(), Mockito.anyInt())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance/service-instance-54.json"))); // generic-queries for service-instance-2 - + Mockito .when(aaiAdapter.getGenericQueryForSelfLink(Matchers.contains("service-instance"), - Matchers.argThat( - listContainsValue("service-instance-id:service-instance-55")))) + Matchers.argThat(listContainsValue("service-instance-id:service-instance-55")))) .thenReturn( "https://server.proxy:8443/aai/v11/search/generic-query/service-instance-id/service-instance-55"); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( - Matchers - .contains("generic-query/service-instance-id/service-instance-55"), + Matchers.contains("generic-query/service-instance-id/service-instance-55"), Mockito.anyString(), Mockito.anyInt())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( - "/sync/aai/aai-traversal/generic-query/service-instance/service-instance-55.json"))); - - - + "/sync/aai/aai-traversal/generic-query/service-instance/service-instance-55.json"))); + + + // start the test - + baseVisualizationContext.processSelfLinks(searchableEntity, queryParams); /* @@ -223,51 +225,70 @@ public class BaseVisualizationContextTest { assertEquals(5, nodeCache.size()); assertNotNull(nodeCache.get(customerNodeId)); assertEquals("customer", nodeCache.get(customerNodeId).getEntityType()); - + // verify node collection nodes - - ActiveInventoryNode customerNode = nodeCache.get("da4101ad19b3c380a1c12ffeda8ab390e1489fb4a22a392c9a1939db63c3dec5"); - ActiveInventoryNode ssNode = nodeCache.get("f4ceaf19459993c4fc9438a7579dd20d786109f4455e38682c579045b7ae615e"); - ActiveInventoryNode tenantNode = nodeCache.get("4735439b29e446b339535668238076e4b392eaa3eec218936e12f735179bc55e"); - ActiveInventoryNode s1 = nodeCache.get("f975ab453b142197af5d0173e0a9cf2aa22d10502f8ad655c8d17de81b066e8f"); - ActiveInventoryNode s2 = nodeCache.get("de77ef8f76dd6f19662b163527ff839891b9596cac655e3143fdd7ad39e2e4e3"); - - assertNotNull( customerNode ); - assertNotNull( ssNode ); - assertNotNull( tenantNode ); - assertNotNull( s1 ); - assertNotNull( s2 ); - + + ActiveInventoryNode customerNode = + nodeCache.get("da4101ad19b3c380a1c12ffeda8ab390e1489fb4a22a392c9a1939db63c3dec5"); + ActiveInventoryNode ssNode = + nodeCache.get("f4ceaf19459993c4fc9438a7579dd20d786109f4455e38682c579045b7ae615e"); + ActiveInventoryNode tenantNode = + nodeCache.get("4735439b29e446b339535668238076e4b392eaa3eec218936e12f735179bc55e"); + ActiveInventoryNode s1 = + nodeCache.get("f975ab453b142197af5d0173e0a9cf2aa22d10502f8ad655c8d17de81b066e8f"); + ActiveInventoryNode s2 = + nodeCache.get("de77ef8f76dd6f19662b163527ff839891b9596cac655e3143fdd7ad39e2e4e3"); + + assertNotNull(customerNode); + assertNotNull(ssNode); + assertNotNull(tenantNode); + assertNotNull(s1); + assertNotNull(s2); + // verify node depths - - assertEquals( 0, customerNode.getNodeDepth() ); - assertEquals( 1, ssNode.getNodeDepth() ); - + + assertEquals(0, customerNode.getNodeDepth()); + assertEquals(1, ssNode.getNodeDepth()); + /* * I think there is a bug in the way the node depth is represented due to the enforcement of * bidirectional links being disabled. We may have to circle back to this behavior at some point * and re-verify that the behavior works properly. */ - - assertEquals( 2, tenantNode.getNodeDepth() ); - assertEquals( 2, s1.getNodeDepth() ); - assertEquals( 2, s2.getNodeDepth() ); + + assertEquals(2, tenantNode.getNodeDepth()); + assertEquals(2, s1.getNodeDepth()); + assertEquals(2, s2.getNodeDepth()); // verify node states - - assertEquals( NodeProcessingState.READY, customerNode.getState() ); - assertEquals( NodeProcessingState.READY, ssNode.getState() ); - + + assertEquals(NodeProcessingState.READY, customerNode.getState()); + assertEquals(NodeProcessingState.READY, ssNode.getState()); + /* * these nodes have a NEIGHBORS_UNPROCESSED state because the max traversal depth was hit before - * processing all the nested relationships. I think what we should look at is advancing the state - * to READY if in fact there are no relationships to process, which I think could be the case - * sometimes. + * processing all the nested relationships. I think what we should look at is advancing the + * state to READY if in fact there are no relationships to process, which I think could be the + * case sometimes. */ - assertEquals( NodeProcessingState.NEIGHBORS_UNPROCESSED, tenantNode.getState() ); - assertEquals( NodeProcessingState.NEIGHBORS_UNPROCESSED, s1.getState() ); - assertEquals( NodeProcessingState.NEIGHBORS_UNPROCESSED, s2.getState() ); + assertEquals(NodeProcessingState.NEIGHBORS_UNPROCESSED, tenantNode.getState()); + assertEquals(NodeProcessingState.NEIGHBORS_UNPROCESSED, s1.getState()); + assertEquals(NodeProcessingState.NEIGHBORS_UNPROCESSED, s2.getState()); - } - -} + } + + protected DynamicJAXBContext createVersionedOxm() { + Map<String, Object> properties = new HashMap<>(); + ClassLoader classLoader = null; + InputStream iStream = classLoader.getResourceAsStream("example/resources/eclipselink/eclipselink-oxm.xml"); + + properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, iStream); + try{ + return DynamicJAXBContextFactory.createContextFromOXM(this.getClass().getClassLoader(), properties); + } catch (Exception e) { + return null; + } + } + + +}
\ No newline at end of file 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 685feaf..2bf7856 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 @@ -158,9 +158,7 @@ public class ViewInspectEntitySynchronizerTest { processors.add(searchableEntityLookup); - OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors); - oxmModelLoader.loadLatestOxmModel(); - + // suggestionEntityLookup.setSuggestionSearchEntityDescriptors(suggestionEntityDescriptors); } @@ -230,9 +228,9 @@ public class ViewInspectEntitySynchronizerTest { .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://localhost:9200/myindex/mytype/doc2", - "http://localhost:9200/myindex/mytype/doc3"); + .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 @@ -345,4 +343,4 @@ public class ViewInspectEntitySynchronizerTest { } -} +}
\ No newline at end of file |