From 1fc5ce5b48f8c270d5d044356843b8a8566bdccc Mon Sep 17 00:00:00 2001 From: "Threefoot, Jane (jt6620)" Date: Wed, 14 Mar 2018 14:48:10 -0400 Subject: added new aai-schema-ingest library New, lightweight, configurable library for OXM and edge rules json ingest. Allows for broken-up OXM and json for increased model-driven capabilities. Issue-ID: AAI-875 Change-Id: I987c7dc2ad9a68ef3ccaac8da8d3b5b0205dc264 Signed-off-by: Threefoot, Jane (jt6620) --- .../java/org/onap/aai/edges/EdgeIngestorTest.java | 306 +++++++++++++++++++++ .../org/onap/aai/edges/EdgeIngestorWiringTest.java | 58 ++++ .../java/org/onap/aai/edges/EdgeRuleQueryTest.java | 135 +++++++++ .../java/org/onap/aai/nodes/NodeIngestorTest.java | 84 ++++++ .../org/onap/aai/nodes/NodeIngestorWiringTest.java | 57 ++++ .../onap/aai/setup/ConfigTranslatorWiringTest.java | 61 ++++ .../SchemaLocationsBeanDefaultInjectionTest.java | 46 ++++ .../SchemaLocationsBeanEnvVarInjectionTest.java | 48 ++++ .../setup/SchemaLocationsBeanXMLSetterTest.java | 46 ++++ ...hemaLocationsBeanXMLSetterWithPropFileTest.java | 46 ++++ .../testutils/ConfigTranslatorForWiringTest.java | 60 ++++ .../aai/testutils/TestUtilConfigTranslator.java | 76 +++++ .../test/resources/edgeRules/defaultEdgesTest.json | 52 ++++ .../test/resources/edgeRules/otherTestRules.json | 136 +++++++++ .../src/test/resources/edgeRules/test.json | 48 ++++ .../src/test/resources/edgeRules/test2.json | 27 ++ .../src/test/resources/edgeRules/test3.json | 64 +++++ .../forWiringTests/schemaIngest2.properties | 3 + .../schemaIngestForXMLTest.properties | 3 + .../schemaIngestWiringTest.properties | 3 + .../test/resources/forWiringTests/testContext.xml | 14 + .../forWiringTests/testUsingPropFileContext.xml | 19 ++ .../src/test/resources/oxm/test_business_v10.xml | 50 ++++ .../src/test/resources/oxm/test_business_v11.xml | 45 +++ .../src/test/resources/oxm/test_network_v10.xml | 51 ++++ .../src/test/resources/oxm/test_network_v11.xml | 76 +++++ .../src/test/resources/schemaIngest.properties | 3 + 27 files changed, 1617 insertions(+) create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test2.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test3.json create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml create mode 100644 aai-schema-ingest/src/test/resources/schemaIngest.properties (limited to 'aai-schema-ingest/src/test') diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java new file mode 100644 index 00000000..9f6d67a1 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java @@ -0,0 +1,306 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.edges; + +import static org.junit.Assert.*; + +import java.util.Collection; + +import org.apache.tinkerpop.gremlin.structure.Direction; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.onap.aai.edges.enums.AAIDirection; +import org.onap.aai.edges.enums.MultiplicityRule; +import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException; +import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.Version; +import org.onap.aai.testutils.TestUtilConfigTranslator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.google.common.collect.Multimap; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {SchemaLocationsBean.class, TestUtilConfigTranslator.class, EdgeIngestor.class}) +@SpringBootTest +public class EdgeIngestorTest { + @Autowired + EdgeIngestor ei; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void getRulesTest1() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); + Multimap results = ei.getRules(q); + assertTrue(results.size() == 5); + assertTrue(results.containsKey("bar|foo")); + + assertTrue(2 == results.get("bar|foo").size()); + boolean seenLabel1 = false; + boolean seenLabel2 = false; + for(EdgeRule r : results.get("bar|foo")) { + if ("eats".equals(r.getLabel())) { + seenLabel1 = true; + } + if ("eatz".equals(r.getLabel())) { + seenLabel2 = true; + } + } + assertTrue(seenLabel1 && seenLabel2); + + assertTrue(results.containsKey("baz|foo")); + assertTrue(results.containsKey("foo|quux")); + assertTrue(results.containsKey("dog|foo")); + } + + @Test + public void getRulesTest2() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("puppy", "dog").build(); + Multimap results = ei.getRules(q); + assertTrue(results.size() == 1); + assertTrue(results.containsKey("dog|puppy")); + Collection cr = results.get("dog|puppy"); + for (EdgeRule r : cr) { + assertTrue("dog".equals(r.getFrom())); + assertTrue("puppy".equals(r.getTo())); + assertTrue("caresFor".equals(r.getLabel())); + assertTrue(Direction.OUT.equals(r.getDirection())); + assertTrue("One2Many".equalsIgnoreCase(r.getMultiplicityRule().toString())); + assertTrue("NONE".equals(r.getContains())); + assertTrue("OUT".equals(r.getDeleteOtherV())); + assertTrue("NONE".equals(r.getPreventDelete())); + assertTrue(r.isDefault()); + } + } + + @Test + public void getRulesTest3() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").version(Version.V11).build(); + Multimap results = ei.getRules(q); + assertTrue(results.size() == 4); + assertTrue(results.containsKey("lag-interface|l-interface")); + assertTrue(results.containsKey("l-interface|logical-link")); + assertTrue(results.get("l-interface|logical-link").size() == 3); + } + + @Test + public void getRulesNoneFound() throws EdgeRuleNotFoundException { + thrown.expect(EdgeRuleNotFoundException.class); + thrown.expectMessage("No rules found for"); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").build(); + ei.getRules(q); + } + + @Test + public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("notation", "parent").build(); + EdgeRule result = ei.getRule(q); + assertTrue("parent".equals(result.getFrom())); + assertTrue("notation".equals(result.getTo())); + assertTrue("has".equals(result.getLabel())); + assertTrue(Direction.OUT.equals(result.getDirection())); + assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule())); + assertTrue(AAIDirection.OUT.toString().equals(result.getContains())); + assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV())); + assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete())); + assertTrue("parent contains notation".equals(result.getDescription())); + } + + @Test + public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(Version.V11).build(); + EdgeRule res = ei.getRule(q); + assertTrue(res.isDefault()); + assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel())); + } + + @Test + public void getRuleWithNonDefault() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").label("org.onap.relationships.inventory.Source").version(Version.V11).build(); + EdgeRule res = ei.getRule(q); + assertFalse(res.isDefault()); + assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel())); + } + + @Test + public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + thrown.expect(EdgeRuleNotFoundException.class); + thrown.expectMessage("No rule found for"); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","nonexistent").build(); + ei.getRule(q); + } + + @Test + public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + thrown.expect(AmbiguousRuleChoiceException.class); + thrown.expectMessage("No way to select single rule from these pairs:"); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); + ei.getRule(q); + } + + @Test + public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + thrown.expect(AmbiguousRuleChoiceException.class); + thrown.expectMessage("Multiple defaults found."); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed","plant").version(Version.V11).build(); + ei.getRule(q); + } + + @Test + public void getRuleNoDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + thrown.expect(AmbiguousRuleChoiceException.class); + thrown.expectMessage("No default found."); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(Version.V11).build(); + ei.getRule(q); + } + + @Test + public void hasRuleTest() { + assertTrue(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").version(Version.V11).build())); + assertFalse(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); + } + + @Test + public void getCousinRulesTest() { + Multimap results = ei.getCousinRules("dog"); + assertTrue(results.size() == 2); + assertTrue(results.containsKey("dog|puppy")); + assertTrue(results.containsKey("dog|foo")); + } + + @Test + public void getCousinRulesWithVersionTest() { + Multimap results = ei.getCousinRules("foo", Version.V10); + assertTrue(results.size() == 2); + assertTrue(results.containsKey("bar|foo")); + assertTrue(results.get("bar|foo").size() == 2); + } + + @Test + public void getCousinsNoneInVersionTest() { + Multimap results = ei.getCousinRules("foo", Version.V11); + assertTrue(results.isEmpty()); + } + + @Test + public void hasCousinTest() { + assertTrue(ei.hasCousinRule("foo")); + assertTrue(ei.hasCousinRule("foo", Version.V10)); + assertFalse(ei.hasCousinRule("parent")); + assertFalse(ei.hasCousinRule("foo", Version.V11)); + } + + @Test + public void getChildRulesTest() { + Multimap results = ei.getChildRules("parent"); + assertTrue(results.size() == 6); + assertTrue(results.containsKey("notation|parent")); + assertTrue(results.containsKey("not-notation|parent")); + assertTrue(results.containsKey("out-out|parent")); + assertTrue(results.containsKey("in-in|parent")); + assertTrue(results.containsKey("in-out|parent")); + assertTrue(results.containsKey("out-in|parent")); + } + + @Test + public void getChildRulesWithVersionTest() { + Multimap results = ei.getChildRules("foo", Version.V10); + assertTrue(results.size() == 2); + assertTrue(results.containsKey("baz|foo")); + assertTrue(results.containsKey("foo|quux")); + } + + @Test + public void getChildRulesNoneInVersionTest() { + Multimap results = ei.getChildRules("foo", Version.V11); + assertTrue(results.isEmpty()); + } + + @Test + public void hasChildTest() { + assertTrue(ei.hasChildRule("foo")); + assertTrue(ei.hasChildRule("foo", Version.V10)); + assertFalse(ei.hasChildRule("puppy")); + assertFalse(ei.hasChildRule("foo", Version.V11)); + } + + @Test + public void getParentRulesTest() { + Multimap results = ei.getParentRules("parent"); + assertTrue(results.size() == 6); + assertTrue(results.containsKey("grandparent1|parent")); + assertTrue(results.containsKey("grandparent2|parent")); + assertTrue(results.containsKey("grandparent3|parent")); + assertTrue(results.containsKey("grandparent4|parent")); + assertTrue(results.containsKey("grandparent5|parent")); + assertTrue(results.containsKey("grandparent6|parent")); + } + + @Test + public void getParentRulesWithVersionTest() { + Multimap results = ei.getParentRules("baz", Version.V10); + assertTrue(results.size() == 1); + assertTrue(results.containsKey("baz|foo")); + } + + @Test + public void getParentRulesNoneInVersionTest() { + Multimap results = ei.getParentRules("baz", Version.V11); + assertTrue(results.isEmpty()); + } + + @Test + public void hasParentTest() { + assertTrue(ei.hasParentRule("parent")); + assertTrue(ei.hasParentRule("quux", Version.V10)); + assertFalse(ei.hasParentRule("puppy")); + assertFalse(ei.hasParentRule("foo", Version.V11)); + } + + @Test + public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException { + Multimap res = ei.getAllCurrentRules(); + assertTrue(res.size() == 18); + } + + @Test + public void getAllRulesTest() throws EdgeRuleNotFoundException { + Multimap res = ei.getAllRules(Version.V10); + assertTrue(res.size() == 4); + assertTrue(res.containsKey("bar|foo")); + assertTrue(res.get("bar|foo").size() == 2); + assertTrue(res.containsKey("baz|foo")); + assertTrue(res.containsKey("foo|quux")); + + thrown.expect(EdgeRuleNotFoundException.class); + thrown.expectMessage("No rules found for version V9."); + ei.getAllRules(Version.V9); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java new file mode 100644 index 00000000..74aceb51 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java @@ -0,0 +1,58 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.edges; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.Version; +import org.onap.aai.testutils.ConfigTranslatorForWiringTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.google.common.collect.Multimap; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {SchemaLocationsBean.class, ConfigTranslatorForWiringTest.class, EdgeIngestor.class}) +@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngestWiringTest.properties"}) +@SpringBootTest +public class EdgeIngestorWiringTest { + @Autowired + EdgeIngestor ei; + + @Test + public void test() throws EdgeRuleNotFoundException { + assertNotNull(ei); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").label("dancesWith").version(Version.V10).build(); + Multimap results = ei.getRules(q); + assertTrue(results.size() == 1); + assertTrue(results.containsKey("foo|quux")); + } + +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java new file mode 100644 index 00000000..f21246cb --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java @@ -0,0 +1,135 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.edges; + +import static org.junit.Assert.*; + +import java.io.InputStream; +import java.util.List; +import java.util.Scanner; + +import org.junit.Before; +import org.junit.Test; +import org.onap.aai.edges.enums.EdgeType; + +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; + +public class EdgeRuleQueryTest { + private DocumentContext testRules; + private String readStart = "$.rules.[?]"; + + /* **** DATA SETUP **** */ + @Before + public void setup() { + InputStream is = getClass().getResourceAsStream("/edgeRules/test.json"); + + Scanner scanner = new Scanner(is); + String json = scanner.useDelimiter("\\Z").next(); + scanner.close(); + + this.testRules = JsonPath.parse(json); + } + + /* **** TESTS **** */ + @Test + public void testFromToSingle() { + //rule defined from quux to foo + EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").build(); + List results = testRules.read(readStart, q.getFilter()); + + assertTrue(results.size() == 1); + } + + @Test + public void testToFromSingle() { + //rule defined from quux to foo, this is flipped + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "quux").build(); + List results = testRules.read(readStart, q.getFilter()); + + assertTrue(results.size() == 1); + } + + @Test + public void testFromToMultiple() { + //rules have two from foo to bar + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "bar").build(); + List results = testRules.read(readStart, q.getFilter()); + assertTrue(results.size() == 2); + } + + @Test + public void testToFromMultiple() { + //rules have two from foo to bar + EdgeRuleQuery q = new EdgeRuleQuery.Builder("bar", "foo").build(); + List results = testRules.read(readStart, q.getFilter()); + + assertTrue(results.size() == 2); + assertTrue(!(results.get(0).toString().equals(results.get(1).toString()))); + } + + @Test + public void testJustFrom() { + //there are 4 foo rules (foo>bar, foo>bar, foo>baz, quux>foo) + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); + List results = testRules.read(readStart, q.getFilter()); + assertTrue(results.size() == 4); + + //there are 2 bar rules + EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bar").build(); + List results2 = testRules.read(readStart, q2.getFilter()); + assertTrue(results2.size() == 2); + } + + @Test + public void testWithLabel() { + //there are foo >eats> bar and foo >eatz> bar + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo","bar").label("eatz").build(); + List results = testRules.read(readStart, q.getFilter()); + assertTrue(results.size() == 1); + assertTrue(results.get(0).toString().contains("eatz")); + } + + @Test + public void testCousin() { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.COUSIN).build(); + List results = testRules.read(readStart, q.getFilter()); + assertTrue(results.size() == 2); + + EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("foo", "bar").edgeType(EdgeType.COUSIN).label("eats").build(); + List results2 = testRules.read(readStart, q2.getFilter()); + assertTrue(results2.size() == 1); + assertTrue(results2.get(0).toString().contains("eats")); + + EdgeRuleQuery q3 = new EdgeRuleQuery.Builder("foo","quux").edgeType(EdgeType.COUSIN).build(); + List results3 = testRules.read(readStart, q3.getFilter()); + assertTrue(results3.isEmpty()); + } + + @Test + public void testTree() { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.TREE).build(); + List results = testRules.read(readStart, q.getFilter()); + assertTrue(results.size() == 2); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java new file mode 100644 index 00000000..08507a34 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java @@ -0,0 +1,84 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.nodes; + +import static org.junit.Assert.*; + +import org.eclipse.persistence.dynamic.DynamicEntity; +import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.Version; +import org.onap.aai.testutils.TestUtilConfigTranslator; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {SchemaLocationsBean.class, TestUtilConfigTranslator.class, NodeIngestor.class}) +@SpringBootTest +public class NodeIngestorTest { + @Autowired + NodeIngestor ni; + + //set thrown.expect to whatever a specific test needs + //this establishes a default of expecting no exceptions to be thrown + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void test() { + DynamicJAXBContext ctx10 = ni.getContextForVersion(Version.V10); + + //should work bc Foo is valid in test_network_v10 schema + DynamicEntity foo10 = ctx10.newDynamicEntity("Foo"); + foo10.set("fooId","bar"); + assertTrue("bar".equals(foo10.get("fooId"))); + + //should work bc Bar is valid in test_business_v10 schema + DynamicEntity bar10 = ctx10.newDynamicEntity("Bar"); + bar10.set("barId","bar2"); + assertTrue("bar2".equals(bar10.get("barId"))); + + + DynamicJAXBContext ctx11 = ni.getContextForVersion(Version.V11); + + //should work bc Foo.quantity is valid in test_network_v11 schema + DynamicEntity foo11 = ctx11.newDynamicEntity("Foo"); + foo11.set("quantity","12"); + assertTrue("12".equals(foo11.get("quantity"))); + + DynamicEntity quux11 = ctx11.newDynamicEntity("Quux"); + quux11.set("qManagerName","some guy"); + assertTrue("some guy".equals(quux11.get("qManagerName"))); + + + thrown.expect(IllegalArgumentException.class); + //should fail bc Quux not in v10 test schema + ctx10.newDynamicEntity("Quux"); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java new file mode 100644 index 00000000..e62cc6ab --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.nodes; + +import static org.junit.Assert.*; + +import org.eclipse.persistence.dynamic.DynamicEntity; +import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.Version; +import org.onap.aai.testutils.ConfigTranslatorForWiringTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {SchemaLocationsBean.class, ConfigTranslatorForWiringTest.class, NodeIngestor.class}) +@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngestWiringTest.properties"}) +@SpringBootTest +public class NodeIngestorWiringTest { + @Autowired + NodeIngestor ni; + + @Test + public void test() { + DynamicJAXBContext ctx10 = ni.getContextForVersion(Version.V10); + + //should work bc Bar is valid in test_business_v10 schema + DynamicEntity bar10 = ctx10.newDynamicEntity("Bar"); + bar10.set("barId","bar2"); + assertTrue("bar2".equals(bar10.get("barId"))); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java new file mode 100644 index 00000000..9d66551b --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java @@ -0,0 +1,61 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.setup; + +import static org.junit.Assert.*; + +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.testutils.ConfigTranslatorForWiringTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {SchemaLocationsBean.class, ConfigTranslatorForWiringTest.class}) +@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngestWiringTest.properties"}) +@SpringBootTest +public class ConfigTranslatorWiringTest { + @Autowired + ConfigTranslator ct; + + @Test + public void test() { + assertNotNull(ct); + Map> nodes = ct.getNodeFiles(); + assertTrue(nodes.containsKey(Version.V10)); + assertTrue(1 == nodes.get(Version.V10).size()); + assertTrue("src/test/resources/oxm/test_business_v10.xml".equals(nodes.get(Version.V10).get(0))); + + Map> edges = ct.getEdgeFiles(); + assertTrue(edges.containsKey(Version.V10)); + assertTrue(1 == edges.get(Version.V10).size()); + assertTrue("src/test/resources/edgeRules/test.json".equals(edges.get(Version.V10).get(0))); + } + +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java new file mode 100644 index 00000000..5074f913 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java @@ -0,0 +1,46 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.setup; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {SchemaLocationsBean.class}) +public class SchemaLocationsBeanDefaultInjectionTest { + @Autowired + SchemaLocationsBean bean; + + @Test + public void test() { + assertNotNull(bean); + assertTrue("foo".equals(bean.getSchemaConfigLocation())); + assertTrue("bar".equals(bean.getNodeDirectory())); + assertTrue("quux".equals(bean.getEdgeDirectory())); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java new file mode 100644 index 00000000..f9d6b620 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java @@ -0,0 +1,48 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.setup; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {SchemaLocationsBean.class}) +@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngest2.properties"}) +public class SchemaLocationsBeanEnvVarInjectionTest { + @Autowired + SchemaLocationsBean bean; + + @Test + public void test() { + assertNotNull(bean); + assertTrue("testConfig.json".equals(bean.getSchemaConfigLocation())); + assertTrue("bloop/blap".equals(bean.getNodeDirectory())); + assertTrue("different".equals(bean.getEdgeDirectory())); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java new file mode 100644 index 00000000..0a22bbb0 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java @@ -0,0 +1,46 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.setup; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:forWiringTests/testContext.xml"}) +public class SchemaLocationsBeanXMLSetterTest { + @Autowired + SchemaLocationsBean bean; + + @Test + public void test() { + assertNotNull(bean); + assertTrue("fromXML".equals(bean.getSchemaConfigLocation())); + assertTrue("whatAnXML".equals(bean.getNodeDirectory())); + assertTrue("XMLwiringYAY".equals(bean.getEdgeDirectory())); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java new file mode 100644 index 00000000..4604b045 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java @@ -0,0 +1,46 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.setup; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath:forWiringTests/testUsingPropFileContext.xml"}) +public class SchemaLocationsBeanXMLSetterWithPropFileTest { + @Autowired + SchemaLocationsBean bean; + + @Test + public void test() { + assertNotNull(bean); + assertTrue("imatest".equals(bean.getSchemaConfigLocation())); + assertTrue("andIMalittleteapot".equals(bean.getNodeDirectory())); + assertTrue("meh".equals(bean.getEdgeDirectory())); + } +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java new file mode 100644 index 00000000..5e1b6c82 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java @@ -0,0 +1,60 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.testutils; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.Version; + +public class ConfigTranslatorForWiringTest extends ConfigTranslator { + + public ConfigTranslatorForWiringTest(SchemaLocationsBean bean) { + super(bean); + } + + @Override + public Map> getNodeFiles() { + String f = bean.getNodeDirectory() + "test_business_v10.xml"; + List files = new ArrayList<>(); + files.add(f); + Map> mp = new EnumMap<>(Version.class); + mp.put(Version.V10, files); + return mp; + } + + @Override + public Map> getEdgeFiles() { + String f = bean.getEdgeDirectory() + "test.json"; + List files = new ArrayList<>(); + files.add(f); + Map> mp = new EnumMap<>(Version.class); + mp.put(Version.V10, files); + return mp; + } + +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java new file mode 100644 index 00000000..785b7403 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java @@ -0,0 +1,76 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. 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 is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.aai.testutils; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.Version; + +public class TestUtilConfigTranslator extends ConfigTranslator { + + public TestUtilConfigTranslator(SchemaLocationsBean bean) { + super(bean); + } + + @Override + public Map> getNodeFiles() { + List files10 = new ArrayList<>(); + files10.add("src/test/resources/oxm/test_network_v10.xml"); + files10.add("src/test/resources/oxm/test_business_v10.xml"); + + List files11 = new ArrayList<>(); + files11.add("src/test/resources/oxm/test_network_v11.xml"); + files11.add("src/test/resources/oxm/test_business_v11.xml"); + + Map> input = new EnumMap<>(Version.class); + input.put(Version.V10, files10); + input.put(Version.V11, files11); + return input; + } + + @Override + public Map> getEdgeFiles() { + List files = new ArrayList<>(); + files.add("src/test/resources/edgeRules/test.json"); + files.add("src/test/resources/edgeRules/test2.json"); + files.add("src/test/resources/edgeRules/otherTestRules.json"); + Map> input = new EnumMap<>(Version.class); + input.put(Version.getLatest(), files); + + List files2 = new ArrayList<>(); + files2.add("src/test/resources/edgeRules/test.json"); + input.put(Version.V10, files2); + + List files3 = new ArrayList<>(); + files3.add("src/test/resources/edgeRules/test3.json"); + files3.add("src/test/resources/edgeRules/defaultEdgesTest.json"); + input.put(Version.V11, files3); + + return input; + } +} diff --git a/aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json b/aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json new file mode 100644 index 00000000..2f4baed6 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json @@ -0,0 +1,52 @@ +{ + "rules": [ + { + "from": "apple", + "to": "orange", + "label": "sitsBy", + "direction": "OUT", + "multiplicity": "MANY2MANY", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "default": "false", + "description":"for testing pairs with no default" + }, + { + "from": "apple", + "to": "orange", + "label": "makesSaladWith", + "direction": "OUT", + "multiplicity": "MANY2MANY", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "default": "false", + "description":"for testing pairs with no default" + }, + { + "from": "seed", + "to": "plant", + "label": "grows", + "direction": "OUT", + "multiplicity": "MANY2MANY", + "contains-other-v": "NONE", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "default": "true", + "description":"" + }, + { + "from": "seed", + "to": "plant", + "label": "becomes", + "direction": "OUT", + "multiplicity": "MANY2MANY", + "contains-other-v": "OUT", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "default": "true", + "description":"" + } + ] +} \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json b/aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json new file mode 100644 index 00000000..881239f6 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json @@ -0,0 +1,136 @@ +{ + "rules": [ + { + "from": "parent", + "to": "notation", + "label": "has", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "${direction}", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contains notation" + }, + { + "from": "not-notation", + "to": "parent", + "label": "contains", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "!${direction}", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contains not-notation" + }, + { + "from": "parent", + "to": "out-out", + "label": "eats", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "OUT", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contains out-out" + }, + { + "from": "parent", + "to": "in-in", + "label": "verbs", + "direction": "IN", + "multiplicity": "Many2Many", + "contains-other-v": "IN", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contains in-in" + }, + { + "from": "out-in", + "to": "parent", + "label": "alarms", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "IN", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contains out-in" + }, + { + "from": "in-out", + "to": "parent", + "label": "befriends", + "direction": "IN", + "multiplicity": "Many2Many", + "contains-other-v": "OUT", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contains in-out" + }, + { + "from": "parent", + "to": "grandparent1", + "label": "has", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "!${direction}", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contained by grandparent1" + }, + { + "from": "grandparent2", + "to": "parent", + "label": "contains", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "${direction}", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contained by grandparent2" + }, + { + "from": "parent", + "to": "grandparent3", + "label": "eats", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "IN", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contained by grandparent3" + }, + { + "from": "parent", + "to": "grandparent4", + "label": "verbs", + "direction": "IN", + "multiplicity": "Many2Many", + "contains-other-v": "OUT", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contained by grandparent4" + }, + { + "from": "grandparent5", + "to": "parent", + "label": "alarms", + "direction": "OUT", + "multiplicity": "Many2Many", + "contains-other-v": "OUT", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contained by grandparent5" + }, + { + "from": "grandparent6", + "to": "parent", + "label": "befriends", + "direction": "IN", + "multiplicity": "Many2Many", + "contains-other-v": "IN", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "description": "parent contained by grandparent6" + } + ] +} \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test.json b/aai-schema-ingest/src/test/resources/edgeRules/test.json new file mode 100644 index 00000000..66691ebf --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test.json @@ -0,0 +1,48 @@ +{ + "rules": [ + { + "from": "foo", + "to": "bar", + "label": "eats", + "direction": "OUT", + "multiplicity": "One2Many", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "description": "Hard to describe" + }, + { + "from": "foo", + "to": "bar", + "label": "eatz", + "direction": "IN", + "multiplicity": "One2Many", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "description": "Hard to describe" + }, + { + "from": "foo", + "to": "baz", + "label": "isVeryHappyAbout", + "direction": "OUT", + "multiplicity": "One2Many", + "contains-other-v": "${direction}", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "description": "Hard to describe" + }, + { + "from": "quux", + "to": "foo", + "label": "dancesWith", + "direction": "IN", + "multiplicity": "One2Many", + "contains-other-v": "!${direction}", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "description": "Hard to describe" + } + ] +} \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test2.json b/aai-schema-ingest/src/test/resources/edgeRules/test2.json new file mode 100644 index 00000000..7d94e41c --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test2.json @@ -0,0 +1,27 @@ +{ + "rules": [ + { + "from": "foo", + "to": "dog", + "label": "pets", + "direction": "OUT", + "multiplicity": "One2Many", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "description": "Hard to describe" + }, + { + "from": "dog", + "to": "puppy", + "label": "caresFor", + "direction": "OUT", + "multiplicity": "One2Many", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "description": "Hard to describe", + "default": "true" + } + ] +} \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test3.json b/aai-schema-ingest/src/test/resources/edgeRules/test3.json new file mode 100644 index 00000000..916efdcc --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test3.json @@ -0,0 +1,64 @@ +{ + "rules": [ + { + "from": "l-interface", + "to": "logical-link", + "label": "tosca.relationships.network.LinksTo", + "direction": "OUT", + "multiplicity": "MANY2MANY", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "default": "true", + "description":"" + }, + { + "from": "logical-link", + "to": "l-interface", + "label": "org.onap.relationships.inventory.Source", + "direction": "OUT", + "multiplicity": "ONE2MANY", + "contains-other-v": "NONE", + "delete-other-v": "!${direction}", + "prevent-delete": "NONE", + "default": "false", + "description":"" + }, + { + "from": "logical-link", + "to": "l-interface", + "label": "org.onap.relationships.inventory.Destination", + "direction": "OUT", + "multiplicity": "ONE2MANY", + "contains-other-v": "NONE", + "delete-other-v": "!${direction}", + "prevent-delete": "NONE", + "default": "false", + "description":"" + }, + { + "from": "l-interface", + "to": "lag-interface", + "label": "org.onap.relationships.inventory.BelongsTo", + "direction": "OUT", + "multiplicity": "MANY2ONE", + "contains-other-v": "!${direction}", + "delete-other-v": "!${direction}", + "prevent-delete": "NONE", + "default": "true", + "description":"" + }, + { + "from": "lag-interface", + "to": "logical-link", + "label": "org.onap.relationships.inventory.Uses", + "direction": "OUT", + "multiplicity": "MANY2MANY", + "contains-other-v": "NONE", + "delete-other-v": "${direction}", + "prevent-delete": "NONE", + "default": "true", + "description":"" + } + ] +} \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties new file mode 100644 index 00000000..fb20eba2 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties @@ -0,0 +1,3 @@ +schemaConfig=testConfig.json +nodeDir=bloop/blap +edgeDir=different \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties new file mode 100644 index 00000000..11e5fb47 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties @@ -0,0 +1,3 @@ +schemaConfig=imatest +nodeDir=andIMalittleteapot +edgeDir=meh \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties new file mode 100644 index 00000000..8bff7d4d --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties @@ -0,0 +1,3 @@ +schemaConfig=NA +nodeDir=src/test/resources/oxm/ +edgeDir=src/test/resources/edgeRules/ \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml b/aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml new file mode 100644 index 00000000..592c2661 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml b/aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml new file mode 100644 index 00000000..7c3302f0 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml b/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml new file mode 100644 index 00000000..5ead4178 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml b/aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml new file mode 100644 index 00000000..39a3ca9b --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml b/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml new file mode 100644 index 00000000..e7d77ac9 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml b/aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml new file mode 100644 index 00000000..9ede62d4 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-schema-ingest/src/test/resources/schemaIngest.properties b/aai-schema-ingest/src/test/resources/schemaIngest.properties new file mode 100644 index 00000000..3112c994 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/schemaIngest.properties @@ -0,0 +1,3 @@ +schemaConfig=foo +nodeDir=bar +edgeDir=quux \ No newline at end of file -- cgit 1.2.3-korg