diff options
Diffstat (limited to 'aai-schema-ingest/src/test')
27 files changed, 1617 insertions, 0 deletions
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<String, EdgeRule> 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<String, EdgeRule> results = ei.getRules(q); + assertTrue(results.size() == 1); + assertTrue(results.containsKey("dog|puppy")); + Collection<EdgeRule> 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<String, EdgeRule> 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<String, EdgeRule> results = ei.getCousinRules("dog"); + assertTrue(results.size() == 2); + assertTrue(results.containsKey("dog|puppy")); + assertTrue(results.containsKey("dog|foo")); + } + + @Test + public void getCousinRulesWithVersionTest() { + Multimap<String, EdgeRule> 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<String, EdgeRule> 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<String, EdgeRule> 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<String, EdgeRule> 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<String, EdgeRule> 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<String, EdgeRule> 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<String, EdgeRule> results = ei.getParentRules("baz", Version.V10); + assertTrue(results.size() == 1); + assertTrue(results.containsKey("baz|foo")); + } + + @Test + public void getParentRulesNoneInVersionTest() { + Multimap<String, EdgeRule> 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<String, EdgeRule> res = ei.getAllCurrentRules(); + assertTrue(res.size() == 18); + } + + @Test + public void getAllRulesTest() throws EdgeRuleNotFoundException { + Multimap<String, EdgeRule> 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<String, EdgeRule> 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<Object> 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<Object> 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<Object> 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<Object> 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<Object> results = testRules.read(readStart, q.getFilter()); + assertTrue(results.size() == 4); + + //there are 2 bar rules + EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bar").build(); + List<Object> 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<Object> 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<Object> results = testRules.read(readStart, q.getFilter()); + assertTrue(results.size() == 2); + + EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("foo", "bar").edgeType(EdgeType.COUSIN).label("eats").build(); + List<Object> 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<Object> results3 = testRules.read(readStart, q3.getFilter()); + assertTrue(results3.isEmpty()); + } + + @Test + public void testTree() { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.TREE).build(); + List<Object> 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<Version, List<String>> 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<Version, List<String>> 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<Version, List<String>> getNodeFiles() { + String f = bean.getNodeDirectory() + "test_business_v10.xml"; + List<String> files = new ArrayList<>(); + files.add(f); + Map<Version, List<String>> mp = new EnumMap<>(Version.class); + mp.put(Version.V10, files); + return mp; + } + + @Override + public Map<Version, List<String>> getEdgeFiles() { + String f = bean.getEdgeDirectory() + "test.json"; + List<String> files = new ArrayList<>(); + files.add(f); + Map<Version, List<String>> 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<Version, List<String>> getNodeFiles() { + List<String> files10 = new ArrayList<>(); + files10.add("src/test/resources/oxm/test_network_v10.xml"); + files10.add("src/test/resources/oxm/test_business_v10.xml"); + + List<String> files11 = new ArrayList<>(); + files11.add("src/test/resources/oxm/test_network_v11.xml"); + files11.add("src/test/resources/oxm/test_business_v11.xml"); + + Map<Version, List<String>> input = new EnumMap<>(Version.class); + input.put(Version.V10, files10); + input.put(Version.V11, files11); + return input; + } + + @Override + public Map<Version, List<String>> getEdgeFiles() { + List<String> 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<Version, List<String>> input = new EnumMap<>(Version.class); + input.put(Version.getLatest(), files); + + List<String> files2 = new ArrayList<>(); + files2.add("src/test/resources/edgeRules/test.json"); + input.put(Version.V10, files2); + + List<String> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + + + <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"> + <property name="schemaConfigLocation" value="fromXML" /> + <property name="nodeDirectory" value="whatAnXML" /> + <property name="edgeDirectory" value="XMLwiringYAY" /> + </bean> + +</beans>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + 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-3.0.xsd"> + + + <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"> + <property name="schemaConfigLocation" value="${schemaConfig}" /> + <property name="nodeDirectory" value="${nodeDir}" /> + <property name="edgeDirectory" value="${edgeDir}" /> + </bean> + + <context:property-placeholder location="classpath:forWiringTests/schemaIngestForXMLTest.properties" ignore-unresolvable="true" /> + +</beans>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + ============LICENSE_START======================================================= + org.openecomp.aai + ================================================================================ + Copyright (C) 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========================================================= + --> + +<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true"> + <xml-schema element-form-default="QUALIFIED"> + <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" /> + </xml-schema> + <java-types> + + <java-type name="Bar"> + <xml-root-element name="bar" /> + <java-attributes> + <xml-element java-attribute="barId" name="bar-id" required="true" type="java.lang.String" xml-key="true"> + <xml-properties> + <xml-property name="description" value="Unique id of Bar This is unique across the graph." /> + </xml-properties> + </xml-element> + <xml-element java-attribute="quantity" name="quantity" required="false" type="java.lang.Integer"> + <xml-properties> + <xml-property name="description" value="How many." /> + </xml-properties> + </xml-element> + + </java-attributes> + <xml-properties> + <xml-property name="description" value="General purpose metasyntactic variable" /> + <xml-property name="uniqueProps" value="bar-id" /> + </xml-properties> + </java-type> + + </java-types> +</xml-bindings>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + ============LICENSE_START======================================================= + org.openecomp.aai + ================================================================================ + Copyright (C) 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========================================================= + --> + +<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true"> + <xml-schema element-form-default="QUALIFIED"> + <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" /> + </xml-schema> + <java-types> + + <java-type name="Bar"> + <xml-root-element name="bar" /> + <java-attributes> + <xml-element java-attribute="barId" name="bar-id" required="true" type="java.lang.String" xml-key="true"> + <xml-properties> + <xml-property name="description" value="Unique id of Bar This is unique across the graph." /> + </xml-properties> + </xml-element> + + </java-attributes> + <xml-properties> + <xml-property name="description" value="General purpose metasyntactic variable" /> + <xml-property name="uniqueProps" value="bar-id" /> + </xml-properties> + </java-type> + + </java-types> +</xml-bindings>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + ============LICENSE_START======================================================= + org.openecomp.aai + ================================================================================ + Copyright (C) 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========================================================= + --> + +<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true"> + <xml-schema element-form-default="QUALIFIED"> + <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" /> + </xml-schema> + <java-types> + + <java-type name="Foo"> + <xml-root-element name="foo" /> + <java-attributes> + <xml-element java-attribute="fooId" name="foo-id" required="true" type="java.lang.String" xml-key="true"> + <xml-properties> + <xml-property name="description" value="Unique id of Foo. This is unique across the graph." /> + </xml-properties> + </xml-element> + <xml-element java-attribute="fooName" name="foo-name" required="true" type="java.lang.String"> + <xml-properties> + <xml-property name="description" value="Name of Foo." /> + </xml-properties> + </xml-element> + + </java-attributes> + <xml-properties> + <xml-property name="description" value="General purpose metasyntactic variable" /> + <xml-property name="nameProps" value="foo-name" /> + <xml-property name="uniqueProps" value="foo-id" /> + </xml-properties> + </java-type> + + </java-types> +</xml-bindings>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + ============LICENSE_START======================================================= + org.openecomp.aai + ================================================================================ + Copyright (C) 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========================================================= + --> + +<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true"> + <xml-schema element-form-default="QUALIFIED"> + <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" /> + </xml-schema> + <java-types> + + <java-type name="Foo"> + <xml-root-element name="foo" /> + <java-attributes> + <xml-element java-attribute="fooId" name="foo-id" required="true" type="java.lang.String" xml-key="true"> + <xml-properties> + <xml-property name="description" value="Unique id of Foo. This is unique across the graph." /> + </xml-properties> + </xml-element> + <xml-element java-attribute="fooName" name="foo-name" required="true" type="java.lang.String"> + <xml-properties> + <xml-property name="description" value="Name of Foo." /> + </xml-properties> + </xml-element> + <xml-element java-attribute="quantity" name="quantity" required="false" type="java.lang.String"> + <xml-properties> + <xml-property name="description" value="How many." /> + </xml-properties> + </xml-element> + + </java-attributes> + <xml-properties> + <xml-property name="description" value="General purpose metasyntactic variable" /> + <xml-property name="nameProps" value="foo-name" /> + <xml-property name="uniqueProps" value="foo-id" /> + </xml-properties> + </java-type> + + <java-type name="Quux"> + <xml-root-element name="quux" /> + <java-attributes> + <xml-element java-attribute="qManagerName" name="q-manager-name" required="true" type="java.lang.String" xml-key="true"> + <xml-properties> + <xml-property name="description" value="Unique id of Quux owner. This is unique across the graph." /> + </xml-properties> + </xml-element> + <xml-element java-attribute="color" name="color" required="false" type="java.lang.String"> + <xml-properties> + <xml-property name="description" value="color" /> + </xml-properties> + </xml-element> + + </java-attributes> + <xml-properties> + <xml-property name="description" value="General purpose metasyntactic variable" /> + </xml-properties> + </java-type> + + </java-types> +</xml-bindings>
\ 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 |