diff options
author | 2018-09-21 16:16:12 -0400 | |
---|---|---|
committer | 2018-09-24 09:17:55 -0400 | |
commit | 3a50e4c2dd8bdfca4b4c834316abee075448f27e (patch) | |
tree | 47cb1dbf125d56b91b1a58e1572285c1af5d5b1f /src/test | |
parent | e234ce76b9eee92b2a16450f773e4a99013d0178 (diff) |
router-core 1.3.0 changes
Issue-ID: AAI-1670
Change-Id: Id42ece47c5c5972b471576f9c5f7fb2614196512
Signed-off-by: rv871f <richard.vondadelszen@amdocs.com>
Diffstat (limited to 'src/test')
17 files changed, 177 insertions, 67 deletions
diff --git a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java index adf8ce2..b76e7ee 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java @@ -20,7 +20,8 @@ */ package org.onap.aai.datarouter.policy; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyString; @@ -32,67 +33,80 @@ import org.apache.camel.Message; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; -import org.onap.aai.datarouter.policy.EntityEventPolicy; -import org.onap.aai.datarouter.policy.EntityEventPolicyConfig; +import org.junit.runner.RunWith; import org.onap.aai.datarouter.util.NodeUtils; -import org.onap.aai.datarouter.util.SearchServiceAgent; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersions; import org.powermock.api.mockito.PowerMockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") public class EntityEventPolicyTest { - private EntityEventPolicy policy; - private String eventJson; - private InMemorySearchDatastore searchDb; - - @SuppressWarnings("unchecked") - @Before - public void init() throws Exception { - EntityEventPolicyConfig config = PowerMockito.mock(EntityEventPolicyConfig.class); - PowerMockito.when(config.getSearchKeystorePwd()).thenReturn("password"); - PowerMockito.when(config.getSourceDomain()).thenReturn("JUNIT"); - - searchDb = new InMemorySearchDatastore(); - policy = new EntityEventPolicyStubbed(config).withSearchDb(searchDb); - - FileInputStream event = new FileInputStream( new File("src/test/resources/aai_event.json")); - eventJson = IOUtils.toString(event, "UTF-8"); - - } - - @Test - public void testProcess() throws Exception { - policy.process(getExchangeEvent("event1","create")); - policy.process(getExchangeEvent("event2","create")); - - assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1"))); - assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2"))); - - policy.process(getExchangeEvent("event1","update")); - policy.process(getExchangeEvent("event2","update")); - assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1"))); - assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2"))); - - policy.process(getExchangeEvent("event2","delete")); - assertNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2"))); - } - - private Exchange getExchangeEvent(String link,String action){ - Object obj = eventJson.replace("$LINK",link ).replace("$ACTION",action) ; - Exchange exchange = PowerMockito.mock(Exchange.class); - Message inMessage = PowerMockito.mock(Message.class); - Message outMessage = PowerMockito.mock(Message.class); - PowerMockito.when(exchange.getIn()).thenReturn(inMessage); - PowerMockito.when(inMessage.getBody()).thenReturn(obj); - - PowerMockito.when(exchange.getOut()).thenReturn(outMessage); - PowerMockito.doNothing().when(outMessage).setBody(anyObject()); - PowerMockito.doNothing().when(outMessage).setHeader(anyString(), anyObject()); - - return exchange; - - } - - + private EntityEventPolicyConfig eventPolicyConfig; + private EntityEventPolicy policy; + private String eventJson; + private InMemorySearchDatastore searchDb; + + @Autowired + private SchemaVersions schemaVersions; + @Autowired + private SchemaLocationsBean schemaLocationsBean; + + @SuppressWarnings("unchecked") + @Before + public void init() throws Exception { + eventPolicyConfig = new EntityEventPolicyConfig(); + eventPolicyConfig.setSearchKeystorePwd("password"); + eventPolicyConfig.setSourceDomain("JUNIT"); + + eventPolicyConfig.setSchemaVersions(schemaVersions); + eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); + + searchDb = new InMemorySearchDatastore(); + policy = new EntityEventPolicyStubbed(eventPolicyConfig).withSearchDb(searchDb); + + FileInputStream event = new FileInputStream(new File("src/test/resources/aai_event.json")); + eventJson = IOUtils.toString(event, "UTF-8"); + + } + + @Test + public void testProcess() throws Exception { + policy.process(getExchangeEvent("event1", "create")); + policy.process(getExchangeEvent("event2", "create")); + + assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1"))); + assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2"))); + + policy.process(getExchangeEvent("event1", "update")); + policy.process(getExchangeEvent("event2", "update")); + assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1"))); + assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2"))); + + policy.process(getExchangeEvent("event2", "delete")); + assertNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2"))); + } + + private Exchange getExchangeEvent(String link, String action) { + Object obj = eventJson.replace("$LINK", link).replace("$ACTION", action); + Exchange exchange = PowerMockito.mock(Exchange.class); + Message inMessage = PowerMockito.mock(Message.class); + Message outMessage = PowerMockito.mock(Message.class); + PowerMockito.when(exchange.getIn()).thenReturn(inMessage); + PowerMockito.when(inMessage.getBody()).thenReturn(obj); + + PowerMockito.when(exchange.getOut()).thenReturn(outMessage); + PowerMockito.doNothing().when(outMessage).setBody(anyObject()); + PowerMockito.doNothing().when(outMessage).setHeader(anyString(), anyObject()); + + return exchange; + + } + + } diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java index 03970bd..cf9f013 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java @@ -33,21 +33,38 @@ import org.apache.camel.Message; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.onap.aai.datarouter.util.NodeUtils; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersions; import org.powermock.api.mockito.PowerMockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") public class SpikeAggregateGenericVnfProcessorTest { + private SpikeEventPolicyConfig eventPolicyConfig; private SpikeAggregateGenericVnfProcessor policy; private InMemorySearchDatastore searchDb; + @Autowired + private SchemaVersions schemaVersions; + @Autowired + private SchemaLocationsBean schemaLocationsBean; + @Before public void init() throws Exception { - SpikeEventPolicyConfig config = PowerMockito.mock(SpikeEventPolicyConfig.class); - PowerMockito.when(config.getSearchKeystorePwd()).thenReturn("password"); - PowerMockito.when(config.getSourceDomain()).thenReturn("JUNIT"); + eventPolicyConfig = new SpikeEventPolicyConfig(); + eventPolicyConfig.setSearchKeystorePwd("password"); + eventPolicyConfig.setSourceDomain("JUNIT"); + + eventPolicyConfig.setSchemaVersions(schemaVersions); + eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); searchDb = new InMemorySearchDatastore(); - policy = new SpikeAggregateGenericVnfProcessorStubbed(config).withSearchDb(searchDb); + policy = new SpikeAggregateGenericVnfProcessorStubbed(eventPolicyConfig).withSearchDb(searchDb); } @Test diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java index c49f17b..6791ac3 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java @@ -33,14 +33,27 @@ import org.apache.camel.Message; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.onap.aai.datarouter.util.NodeUtils; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersions; import org.powermock.api.mockito.PowerMockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") public class SpikeAutosuggestProcessorTest { private SpikeEventPolicyConfig eventPolicyConfig; private SpikeAutosuggestIndexProcessor policy; private InMemorySearchDatastore searchDb; + @Autowired + private SchemaVersions schemaVersions; + @Autowired + private SchemaLocationsBean schemaLocationsBean; + @Before public void init() throws Exception { @@ -48,6 +61,9 @@ public class SpikeAutosuggestProcessorTest { eventPolicyConfig.setSearchKeystorePwd("password"); eventPolicyConfig.setSourceDomain("JUNIT"); + eventPolicyConfig.setSchemaVersions(schemaVersions); + eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); + searchDb = new InMemorySearchDatastore(); policy = new SpikeAutosuggestProcessorStubbed(eventPolicyConfig).withSearchDb(searchDb); diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java index 68edb74..b78ba0e 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java @@ -20,7 +20,8 @@ */ package org.onap.aai.datarouter.policy; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyString; @@ -32,14 +33,26 @@ import org.apache.camel.Message; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.onap.aai.datarouter.util.NodeUtils; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersions; import org.powermock.api.mockito.PowerMockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") public class SpikeEntityEventPolicyTest { private SpikeEntityEventPolicyConfig eventPolicyConfig; private SpikeEntityEventPolicy policy; private InMemorySearchDatastore searchDb; + @Autowired + private SchemaVersions schemaVersions; + @Autowired + private SchemaLocationsBean schemaLocationsBean; @Before public void init() throws Exception { @@ -47,6 +60,9 @@ public class SpikeEntityEventPolicyTest { eventPolicyConfig = new SpikeEntityEventPolicyConfig(); eventPolicyConfig.setSearchKeystorePwd("password"); eventPolicyConfig.setSourceDomain("JUNIT"); + + eventPolicyConfig.setSchemaVersions(schemaVersions); + eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); searchDb = new InMemorySearchDatastore(); policy = new SpikeEntityEventPolicyStubbed(eventPolicyConfig).withSearchDb(searchDb); diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java index 5b40c1a..56af3ea 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java @@ -33,22 +33,39 @@ import org.apache.camel.Message; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.onap.aai.datarouter.util.NodeUtils; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersions; import org.powermock.api.mockito.PowerMockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") public class SpikeEntitySearchProcessorTest { + private SpikeEventPolicyConfig eventPolicyConfig; private SpikeEntitySearchProcessor policy; private String eventJson; private InMemorySearchDatastore searchDb; + @Autowired + private SchemaVersions schemaVersions; + @Autowired + private SchemaLocationsBean schemaLocationsBean; + @Before public void init() throws Exception { - SpikeEventPolicyConfig config = PowerMockito.mock(SpikeEventPolicyConfig.class); - PowerMockito.when(config.getSearchKeystorePwd()).thenReturn("password"); - PowerMockito.when(config.getSourceDomain()).thenReturn("JUNIT"); + eventPolicyConfig = new SpikeEventPolicyConfig(); + eventPolicyConfig.setSearchKeystorePwd("password"); + eventPolicyConfig.setSourceDomain("JUNIT"); + + eventPolicyConfig.setSchemaVersions(schemaVersions); + eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); searchDb = new InMemorySearchDatastore(); - policy = new SpikeEntitySearchProcessorStubbed(config).withSearchDb(searchDb); + policy = new SpikeEntitySearchProcessorStubbed(eventPolicyConfig).withSearchDb(searchDb); } diff --git a/src/test/resources/config/schemaIngest.properties b/src/test/resources/config/schemaIngest.properties new file mode 100644 index 0000000..3c51c3d --- /dev/null +++ b/src/test/resources/config/schemaIngest.properties @@ -0,0 +1,16 @@ +# Properties for the SchemaLocationsBean +# Properties required by the aai-common - aai-schema-ingest lib as of 1.3.0 +schema.configuration.location=N/A +schema.nodes.location=src/test/resources/oxm-reader/oxm +schema.edges.location= +# These versions need to exist if they are included in the list +schema.version.list=v8,v9,v10,v11,v12,v13 +# Decalares the oxm version to load +schema.version.api.default=v13 + +# Don't use these properties in our application, need to be set to prevent an exception on startup (see SchemaVersions bean) +schema.version.depth.start=v13 +schema.version.related.link.start=v13 +schema.version.app.root.start=v13 +schema.version.namespace.change.start=v13 +schema.version.edge.label.start=v13
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v11.xml b/src/test/resources/oxm-reader/multiple-oxm/v11/aai_oxm_v11.xml index 90d023c..90d023c 100644 --- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v11.xml +++ b/src/test/resources/oxm-reader/multiple-oxm/v11/aai_oxm_v11.xml diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v12.xml b/src/test/resources/oxm-reader/multiple-oxm/v12/aai_oxm_v12.xml index d9fbcca..d9fbcca 100644 --- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v12.xml +++ b/src/test/resources/oxm-reader/multiple-oxm/v12/aai_oxm_v12.xml diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_a_v13.xml b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_a_v13.xml index 334d32d..334d32d 100644 --- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_a_v13.xml +++ b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_a_v13.xml diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_b_v13.xml b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_b_v13.xml index 368fcc7..368fcc7 100644 --- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_b_v13.xml +++ b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_b_v13.xml diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v10.xml b/src/test/resources/oxm-reader/oxm/v10/aai_oxm_v10.xml index 51eaa34..51eaa34 100644 --- a/src/test/resources/oxm-reader/oxm/aai_oxm_v10.xml +++ b/src/test/resources/oxm-reader/oxm/v10/aai_oxm_v10.xml diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v11.xml b/src/test/resources/oxm-reader/oxm/v11/aai_oxm_v11.xml index 90d023c..90d023c 100644 --- a/src/test/resources/oxm-reader/oxm/aai_oxm_v11.xml +++ b/src/test/resources/oxm-reader/oxm/v11/aai_oxm_v11.xml diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v12.xml b/src/test/resources/oxm-reader/oxm/v12/aai_oxm_v12.xml index d9fbcca..d9fbcca 100644 --- a/src/test/resources/oxm-reader/oxm/aai_oxm_v12.xml +++ b/src/test/resources/oxm-reader/oxm/v12/aai_oxm_v12.xml diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v13.xml b/src/test/resources/oxm-reader/oxm/v13/aai_oxm_v13.xml index 2dfc4f0..2dfc4f0 100644 --- a/src/test/resources/oxm-reader/oxm/aai_oxm_v13.xml +++ b/src/test/resources/oxm-reader/oxm/v13/aai_oxm_v13.xml diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v8.xml b/src/test/resources/oxm-reader/oxm/v8/aai_oxm_v8.xml index d666b73..d666b73 100644 --- a/src/test/resources/oxm-reader/oxm/aai_oxm_v8.xml +++ b/src/test/resources/oxm-reader/oxm/v8/aai_oxm_v8.xml diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v9.xml b/src/test/resources/oxm-reader/oxm/v9/aai_oxm_v9.xml index ecffb2f..ecffb2f 100644 --- a/src/test/resources/oxm-reader/oxm/aai_oxm_v9.xml +++ b/src/test/resources/oxm-reader/oxm/v9/aai_oxm_v9.xml diff --git a/src/test/resources/spring-beans/data-router-oxm.xml b/src/test/resources/spring-beans/data-router-oxm.xml new file mode 100644 index 0000000..90e7e97 --- /dev/null +++ b/src/test/resources/spring-beans/data-router-oxm.xml @@ -0,0 +1,14 @@ +<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" + xmlns:task="http://www.springframework.org/schema/task" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd + http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"> + + <context:property-placeholder location="file:src/test/resources/config/schemaIngest.properties" ignore-unresolvable="true" /> + + <bean id="schemaVersions" class="org.onap.aai.setup.SchemaVersions"/> + + <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"/> + +</beans> |