From 5948f878fa0ee735e81f1cf648d5d3bdb35048cd Mon Sep 17 00:00:00 2001 From: "Kajur, Harish (vk250x)" Date: Tue, 4 Dec 2018 23:19:04 -0500 Subject: Update schema ingest library call schema service Issue-ID: AAI-1994 Change-Id: Icc9910db0371eeb8289abd4381ae1936a281a5df Signed-off-by: Kajur, Harish (vk250x) --- .../org/onap/aai/edges/EdgeIngestorLocalTest.java | 369 ++ .../java/org/onap/aai/edges/EdgeIngestorTest.java | 197 +- .../org/onap/aai/edges/EdgeIngestorWiringTest.java | 10 +- .../java/org/onap/aai/edges/EdgeRuleQueryTest.java | 1 + .../java/org/onap/aai/edges/JsonIngestorTest.java | 1 - .../org/onap/aai/edges/TypeAlphabetizerTest.java | 1 - .../org/onap/aai/nodes/NodeIngestorLocalTest.java | 176 + .../java/org/onap/aai/nodes/NodeIngestorTest.java | 96 +- .../org/onap/aai/nodes/NodeIngestorWiringTest.java | 10 +- .../java/org/onap/aai/restclient/MockProvider.java | 58 + .../org/onap/aai/restclient/MockRestClient.java | 295 ++ .../org/onap/aai/restclient/RestClientTest.java | 24 + .../onap/aai/restclient/SchemaRestClientTest.java | 67 + .../onap/aai/setup/ConfigTranslatorWiringTest.java | 13 +- .../SchemaLocationsBeanDefaultInjectionTest.java | 5 +- .../SchemaLocationsBeanEnvVarInjectionTest.java | 5 +- .../setup/SchemaLocationsBeanXMLSetterTest.java | 5 +- ...hemaLocationsBeanXMLSetterWithPropFileTest.java | 5 +- .../org/onap/aai/setup/SchemaVersionsBeanTest.java | 87 + .../testutils/BadEdgeConfigForValidationTest.java | 8 +- .../testutils/BadNodeConfigForValidationTest.java | 10 +- .../testutils/ConfigTranslatorForWiringTest.java | 11 +- .../aai/testutils/GoodConfigForValidationTest.java | 7 +- .../aai/testutils/SchemaIncompleteTranslator.java | 11 +- .../aai/testutils/TestUtilConfigTranslator.java | 16 +- .../TestUtilConfigTranslatorforBusiness.java | 11 +- .../validation/VersionValidatorRainyDayTest.java | 9 +- .../validation/VersionValidatorSunnyDayTest.java | 12 +- .../DefaultEdgeFieldsValidationModuleTest.java | 2 - .../edges/EdgeRuleValidatorRainyDayTest.java | 16 +- .../edges/EdgeRuleValidatorSunnyDayTest.java | 16 +- .../edges/NodeTypesValidationModuleTest.java | 10 +- .../nodes/NodeValidatorRainyDayTest.java | 14 +- .../nodes/NodeValidatorSchemaIncompleteTest.java | 22 +- .../nodes/NodeValidatorSunnyDayTest.java | 12 +- .../src/test/resources/edgeRules/test_v10.json | 48 + .../src/test/resources/edgeRules/test_v11.json | 124 + .../src/test/resources/edgeRules/test_v12.json | 71 + .../src/test/resources/edgeRules/test_v13.json | 71 + .../src/test/resources/edgeRules/test_v14.json | 71 + .../src/test/resources/edgeRules/test_v15.json | 275 ++ .../src/test/resources/edgeRules/test_v8.json | 71 + .../src/test/resources/edgeRules/test_v9.json | 4 + .../src/test/resources/edgerequests.json | 50 + .../test/resources/forWiringTests/aai_oxm_v13.xml | 3 +- .../schema-ingest-ss-wiring-test.properties | 20 + ...schema-ingest-wiring-test-local-node.properties | 14 + .../schema-ingest-wiring-test-local.properties | 15 + .../schema-ingest-wiring-test.properties | 16 +- .../src/test/resources/mockrequests.json | 52 + .../src/test/resources/oxm/test_business_v10.xml | 6 +- .../oxm/test_combined_network_business_v10.xml | 83 + .../oxm/test_combined_network_business_v11.xml | 101 + .../oxm/test_combined_network_business_v12.xml | 101 + .../oxm/test_combined_network_business_v13.xml | 101 + .../oxm/test_combined_network_business_v14.xml | 101 + .../oxm/test_combined_network_business_v15.xml | 101 + .../oxm/test_combined_network_business_v8.xml | 101 + .../oxm/test_combined_network_business_v9.xml | 101 + .../src/test/resources/oxm/test_combined_v13.xml | 4629 ++++++++++++++++++++ .../src/test/resources/oxm/test_network_v10.xml | 6 +- .../src/test/resources/payload/versions.json | 18 + .../test/resources/schemaservice-endpoints.json | 9 + 63 files changed, 7732 insertions(+), 243 deletions(-) create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java create mode 100644 aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v10.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v11.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v12.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v13.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v14.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v15.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v8.json create mode 100644 aai-schema-ingest/src/test/resources/edgeRules/test_v9.json create mode 100644 aai-schema-ingest/src/test/resources/edgerequests.json create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties create mode 100644 aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties create mode 100644 aai-schema-ingest/src/test/resources/mockrequests.json create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v10.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v11.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v12.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v13.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v14.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v15.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v8.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v9.xml create mode 100644 aai-schema-ingest/src/test/resources/oxm/test_combined_v13.xml create mode 100644 aai-schema-ingest/src/test/resources/payload/versions.json create mode 100644 aai-schema-ingest/src/test/resources/schemaservice-endpoints.json (limited to 'aai-schema-ingest/src/test') diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java new file mode 100644 index 00000000..3ed7bb79 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java @@ -0,0 +1,369 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-18 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========================================================= + */ + +package org.onap.aai.edges; + +import com.google.common.collect.Multimap; +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.restclient.MockProvider; +import org.onap.aai.config.EdgesConfiguration; +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.SchemaVersion; +import org.onap.aai.testutils.TestUtilConfigTranslator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Collection; + +import static org.junit.Assert.*; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { EdgesConfiguration.class, TestUtilConfigTranslator.class}) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) + +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) +//@TestPropertySource(locations = "/schema-service-rest.properties" ) +@SpringBootTest +public class EdgeIngestorLocalTest { + @Autowired + EdgeIngestor edgeIngestor; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void getRulesTest1() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); + Multimap results = edgeIngestor.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("dog", "puppy").build(); + Multimap results = edgeIngestor.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 getRulesFlippedTypesTest() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); + Multimap results = edgeIngestor.getRules(q); + assertTrue(results.size() == 3); + for (EdgeRule r : results.get("l-interface|logical-link")) { + if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) || + "org.onap.relationships.inventory.Destination".equals(r.getLabel())) { + //these are defined with from=logical-link, to=l-interface, so they must be flipped + assertTrue(Direction.IN.equals(r.getDirection())); + } else if ("tosca.relationships.network.LinksTo".equals(r.getLabel())) { + //this is defined with from=l-interface, to=logical-link, so it shouldn't be flipped + assertTrue(Direction.OUT.equals(r.getDirection())); + } else { + fail("how did you get here"); + } + } + } + + @Test + public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + //getRules, setting from and to + EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build(); + Multimap results = edgeIngestor.getRules(q); + assertTrue(results.size() == 1); + for (EdgeRule r : results.get("bloop|bloop")) { + assertTrue(Direction.IN.equals(r.getDirection())); + } + + //getRule, setting just from + EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build(); + assertTrue(Direction.IN.equals(edgeIngestor.getRule(q2).getDirection())); + + //getChildRules + Multimap child = edgeIngestor.getChildRules("bloop", new SchemaVersion("v11")); + assertTrue(child.size() == 1); + for (EdgeRule r : child.get("bloop|bloop")) { + assertTrue(Direction.IN.equals(r.getDirection())); + } + } + + @Test + public void getRulesTest3() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build(); + Multimap results = edgeIngestor.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(); + edgeIngestor.getRules(q); + } + + @Test + public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("parent", "notation").build(); + EdgeRule result = edgeIngestor.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 getRuleFlippedTypesTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("notation", "parent").build(); + EdgeRule result = edgeIngestor.getRule(q); + assertTrue("parent".equals(result.getFrom())); + assertTrue("notation".equals(result.getTo())); + assertTrue("has".equals(result.getLabel())); + //direction flipped to match input order per old EdgeRules.java API + assertTrue(Direction.IN.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(new SchemaVersion("v11")).build(); +// EdgeRule res = edgeIngestor.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(new SchemaVersion("v11")).build(); +// EdgeRule res = edgeIngestor.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(); + edgeIngestor.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(); +// edgeIngestor.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(new SchemaVersion("v11")).build(); + edgeIngestor.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(new SchemaVersion("v11")).build(); + edgeIngestor.getRule(q); + } + +// @Test +// public void hasRuleTest() { +// assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); +// assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); +// } +// +// @Test +// public void getCousinRulesTest() { +// Multimap results = edgeIngestor.getCousinRules("dog"); +// assertTrue(results.size() == 2); +// assertTrue(results.containsKey("dog|puppy")); +// assertTrue(results.containsKey("dog|foo")); +// } + + @Test + public void getCousinRulesWithVersionTest() { + Multimap results = edgeIngestor.getCousinRules("foo", new SchemaVersion("v10")); + assertTrue(results.size() == 2); + assertTrue(results.containsKey("bar|foo")); + assertTrue(results.get("bar|foo").size() == 2); + } + + @Test + public void getCousinsNoneInVersionTest() { + Multimap results = edgeIngestor.getCousinRules("foo", new SchemaVersion("v11")); + assertTrue(results.isEmpty()); + } + +// @Test +// public void hasCousinTest() { +// assertTrue(edgeIngestor.hasCousinRule("foo")); +// assertTrue(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v10"))); +// assertFalse(edgeIngestor.hasCousinRule("parent")); +// assertFalse(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v11"))); +// } + + @Test + public void getChildRulesTest() { + Multimap results = edgeIngestor.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 = edgeIngestor.getChildRules("foo", new SchemaVersion("v10")); + assertTrue(results.size() == 2); + assertTrue(results.containsKey("baz|foo")); + assertTrue(results.containsKey("foo|quux")); + } + + @Test + public void getChildRulesNoneInVersionTest() { + Multimap results = edgeIngestor.getChildRules("foo", new SchemaVersion("v11")); + assertTrue(results.isEmpty()); + } + +// @Test +// public void hasChildTest() { +// assertTrue(edgeIngestor.hasChildRule("foo")); +// assertTrue(edgeIngestor.hasChildRule("foo", new SchemaVersion("v10"))); +// assertFalse(edgeIngestor.hasChildRule("puppy")); +// assertFalse(edgeIngestor.hasChildRule("foo", new SchemaVersion("v11"))); +// } + + @Test + public void getParentRulesTest() { + Multimap results = edgeIngestor.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 = edgeIngestor.getParentRules("baz", new SchemaVersion("v10")); + assertTrue(results.size() == 1); + assertTrue(results.containsKey("baz|foo")); + } + + @Test + public void getParentRulesNoneInVersionTest() { + Multimap results = edgeIngestor.getParentRules("baz", new SchemaVersion("v11")); + assertTrue(results.isEmpty()); + } + + @Test + public void hasParentTest() { + assertTrue(edgeIngestor.hasParentRule("parent")); + assertTrue(edgeIngestor.hasParentRule("quux", new SchemaVersion("v10"))); + assertFalse(edgeIngestor.hasParentRule("puppy")); + assertFalse(edgeIngestor.hasParentRule("foo", new SchemaVersion("v11"))); + } + +// @Test +// public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException { +// Multimap res = edgeIngestor.getAllCurrentRules(); +// assertTrue(res.size() == 18); +// } + + @Test + public void getAllRulesTest() throws EdgeRuleNotFoundException { + Multimap res = edgeIngestor.getAllRules(new SchemaVersion("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."); + edgeIngestor.getAllRules(new SchemaVersion("v9")); + } +} 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 index 6292da71..ab83e196 100644 --- 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 @@ -1,4 +1,4 @@ -/** +/** * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ @@ -25,20 +25,22 @@ import static org.junit.Assert.*; import java.util.Collection; import org.apache.tinkerpop.gremlin.structure.Direction; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.onap.aai.restclient.MockProvider; +import org.onap.aai.restclient.MockRestClient; +import org.onap.aai.config.EdgesConfiguration; 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.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; -import org.onap.aai.testutils.TestUtilConfigTranslator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -46,23 +48,29 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.google.common.collect.Multimap; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, TestUtilConfigTranslator.class, EdgeIngestor.class}) +@ContextConfiguration(classes = {MockProvider.class, EdgesConfiguration.class}) @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) + +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @SpringBootTest public class EdgeIngestorTest { @Autowired - EdgeIngestor ei; - + EdgeIngestor edgeIngestor; + @Rule public ExpectedException thrown = ExpectedException.none(); - + @Test public void getRulesTest1() throws EdgeRuleNotFoundException { EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); - Multimap results = ei.getRules(q); + Multimap results = edgeIngestor.getRules(q); + System.out.println(results.size()); + for (String key : results.keySet()) { + System.out.println(key); + } assertTrue(results.size() == 5); assertTrue(results.containsKey("bar|foo")); - + assertTrue(2 == results.get("bar|foo").size()); boolean seenLabel1 = false; boolean seenLabel2 = false; @@ -75,16 +83,16 @@ public class EdgeIngestorTest { } } 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("dog", "puppy").build(); - Multimap results = ei.getRules(q); + Multimap results = edgeIngestor.getRules(q); assertTrue(results.size() == 1); assertTrue(results.containsKey("dog|puppy")); Collection cr = results.get("dog|puppy"); @@ -100,11 +108,11 @@ public class EdgeIngestorTest { assertTrue(r.isDefault()); } } - + @Test public void getRulesFlippedTypesTest() throws EdgeRuleNotFoundException { EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); - Multimap results = ei.getRules(q); + Multimap results = edgeIngestor.getRules(q); assertTrue(results.size() == 3); for (EdgeRule r : results.get("l-interface|logical-link")) { if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) || @@ -119,51 +127,51 @@ public class EdgeIngestorTest { } } } - + @Test public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { //getRules, setting from and to EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build(); - Multimap results = ei.getRules(q); + Multimap results = edgeIngestor.getRules(q); assertTrue(results.size() == 1); for (EdgeRule r : results.get("bloop|bloop")) { assertTrue(Direction.IN.equals(r.getDirection())); } - + //getRule, setting just from EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build(); - assertTrue(Direction.IN.equals(ei.getRule(q2).getDirection())); - + assertTrue(Direction.IN.equals(edgeIngestor.getRule(q2).getDirection())); + //getChildRules - Multimap child = ei.getChildRules("bloop", new SchemaVersion("v11")); + Multimap child = edgeIngestor.getChildRules("bloop", new SchemaVersion("v11")); assertTrue(child.size() == 1); for (EdgeRule r : child.get("bloop|bloop")) { assertTrue(Direction.IN.equals(r.getDirection())); } } - + @Test public void getRulesTest3() throws EdgeRuleNotFoundException { EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build(); - Multimap results = ei.getRules(q); + Multimap results = edgeIngestor.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); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("bogus-value").build(); + edgeIngestor.getRules(q); } - + @Test public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { EdgeRuleQuery q = new EdgeRuleQuery.Builder("parent", "notation").build(); - EdgeRule result = ei.getRule(q); + EdgeRule result = edgeIngestor.getRule(q); assertTrue("parent".equals(result.getFrom())); assertTrue("notation".equals(result.getTo())); assertTrue("has".equals(result.getLabel())); @@ -174,11 +182,30 @@ public class EdgeIngestorTest { assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete())); assertTrue("parent contains notation".equals(result.getDescription())); } - +// @Test +// public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { +// EdgeRuleQuery q = new EdgeRuleQuery.Builder("parent", "notation").build(); +// Multimap results = edgeIngestor.getRules(q); +// assertTrue(results.size() == 1); +// // EdgeRule result = edgeIngestor.getRule(q); +// for (EdgeRule result : results.get("parent|notation")) { +// 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 getRuleFlippedTypesTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { EdgeRuleQuery q = new EdgeRuleQuery.Builder("notation", "parent").build(); - EdgeRule result = ei.getRule(q); + EdgeRule result = edgeIngestor.getRule(q); assertTrue("parent".equals(result.getFrom())); assertTrue("notation".equals(result.getTo())); assertTrue("has".equals(result.getLabel())); @@ -190,95 +217,97 @@ public class EdgeIngestorTest { 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(new SchemaVersion("v11")).build(); - EdgeRule res = ei.getRule(q); + EdgeRule res = edgeIngestor.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(new SchemaVersion("v11")).build(); - EdgeRule res = ei.getRule(q); + EdgeRule res = edgeIngestor.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); + edgeIngestor.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); + edgeIngestor.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(new SchemaVersion("v11")).build(); - ei.getRule(q); + edgeIngestor.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(new SchemaVersion("v11")).build(); - ei.getRule(q); + edgeIngestor.getRule(q); } - + @Test public void hasRuleTest() { - assertTrue(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); - assertFalse(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); + assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); + assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v10")).build())); + assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); +// assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); } - + @Test public void getCousinRulesTest() { - Multimap results = ei.getCousinRules("dog"); + Multimap results = edgeIngestor.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", new SchemaVersion("v10")); + Multimap results = edgeIngestor.getCousinRules("foo", new SchemaVersion("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", new SchemaVersion("v11")); + Multimap results = edgeIngestor.getCousinRules("foo", new SchemaVersion("v11")); assertTrue(results.isEmpty()); } - + @Test public void hasCousinTest() { - assertTrue(ei.hasCousinRule("foo")); - assertTrue(ei.hasCousinRule("foo", new SchemaVersion("v10"))); - assertFalse(ei.hasCousinRule("parent")); - assertFalse(ei.hasCousinRule("foo", new SchemaVersion("v11"))); + assertTrue(edgeIngestor.hasCousinRule("foo")); + assertTrue(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v10"))); + assertFalse(edgeIngestor.hasCousinRule("parent")); + assertFalse(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v11"))); } @Test public void getChildRulesTest() { - Multimap results = ei.getChildRules("parent"); + Multimap results = edgeIngestor.getChildRules("parent"); assertTrue(results.size() == 6); assertTrue(results.containsKey("notation|parent")); assertTrue(results.containsKey("not-notation|parent")); @@ -287,32 +316,32 @@ public class EdgeIngestorTest { assertTrue(results.containsKey("in-out|parent")); assertTrue(results.containsKey("out-in|parent")); } - + @Test public void getChildRulesWithVersionTest() { - Multimap results = ei.getChildRules("foo", new SchemaVersion("v10")); + Multimap results = edgeIngestor.getChildRules("foo", new SchemaVersion("v10")); assertTrue(results.size() == 2); assertTrue(results.containsKey("baz|foo")); assertTrue(results.containsKey("foo|quux")); } - + @Test public void getChildRulesNoneInVersionTest() { - Multimap results = ei.getChildRules("foo", new SchemaVersion("v11")); + Multimap results = edgeIngestor.getChildRules("foo", new SchemaVersion("v11")); assertTrue(results.isEmpty()); } - + @Test public void hasChildTest() { - assertTrue(ei.hasChildRule("foo")); - assertTrue(ei.hasChildRule("foo", new SchemaVersion("v10"))); - assertFalse(ei.hasChildRule("puppy")); - assertFalse(ei.hasChildRule("foo", new SchemaVersion("v11"))); + assertTrue(edgeIngestor.hasChildRule("foo")); + assertTrue(edgeIngestor.hasChildRule("foo", new SchemaVersion("v10"))); + assertFalse(edgeIngestor.hasChildRule("puppy")); + assertFalse(edgeIngestor.hasChildRule("foo", new SchemaVersion("v11"))); } - + @Test public void getParentRulesTest() { - Multimap results = ei.getParentRules("parent"); + Multimap results = edgeIngestor.getParentRules("parent"); assertTrue(results.size() == 6); assertTrue(results.containsKey("grandparent1|parent")); assertTrue(results.containsKey("grandparent2|parent")); @@ -321,45 +350,45 @@ public class EdgeIngestorTest { assertTrue(results.containsKey("grandparent5|parent")); assertTrue(results.containsKey("grandparent6|parent")); } - + @Test public void getParentRulesWithVersionTest() { - Multimap results = ei.getParentRules("baz", new SchemaVersion("v10")); + Multimap results = edgeIngestor.getParentRules("baz", new SchemaVersion("v10")); assertTrue(results.size() == 1); assertTrue(results.containsKey("baz|foo")); } - + @Test public void getParentRulesNoneInVersionTest() { - Multimap results = ei.getParentRules("baz", new SchemaVersion("v11")); + Multimap results = edgeIngestor.getParentRules("baz", new SchemaVersion("v11")); assertTrue(results.isEmpty()); } - + @Test public void hasParentTest() { - assertTrue(ei.hasParentRule("parent")); - assertTrue(ei.hasParentRule("quux", new SchemaVersion("v10"))); - assertFalse(ei.hasParentRule("puppy")); - assertFalse(ei.hasParentRule("foo", new SchemaVersion("v11"))); + assertTrue(edgeIngestor.hasParentRule("parent")); + assertTrue(edgeIngestor.hasParentRule("quux", new SchemaVersion("v10"))); + assertFalse(edgeIngestor.hasParentRule("puppy")); + assertFalse(edgeIngestor.hasParentRule("foo", new SchemaVersion("v11"))); } - + @Test public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException { - Multimap res = ei.getAllCurrentRules(); - assertTrue(res.size() == 18); + Multimap res = edgeIngestor.getAllCurrentRules(); + assertTrue(res.size() == 24); } - + @Test public void getAllRulesTest() throws EdgeRuleNotFoundException { - Multimap res = ei.getAllRules(new SchemaVersion("v10")); + Multimap res = edgeIngestor.getAllRules(new SchemaVersion("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(new SchemaVersion("v9")); + edgeIngestor.getAllRules(new SchemaVersion("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 index cae3bf78..395c9cc7 100644 --- 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 @@ -22,12 +22,14 @@ package org.onap.aai.edges; import static org.junit.Assert.*; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.config.EdgesConfiguration; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; -import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.SchemaVersionsBean; + import org.onap.aai.testutils.ConfigTranslatorForWiringTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -38,8 +40,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.google.common.collect.Multimap; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, ConfigTranslatorForWiringTest.class, EdgeIngestor.class}) -@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties"}) +@ContextConfiguration(classes = {EdgesConfiguration.class, ConfigTranslatorForWiringTest.class}) +@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class EdgeIngestorWiringTest { @Autowired 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 index 856ebb70..27c8d6e1 100644 --- 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 @@ -33,6 +33,7 @@ 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.[?]"; diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java index b718c0fd..4475b3f2 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java @@ -23,7 +23,6 @@ package org.onap.aai.edges; import static org.junit.Assert.*; import java.util.*; - import org.junit.Test; import org.onap.aai.setup.SchemaVersion; diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java index 4e3d61dd..3f49428f 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java @@ -21,7 +21,6 @@ package org.onap.aai.edges; import static org.junit.Assert.*; - import org.junit.Test; public class TypeAlphabetizerTest { diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java new file mode 100644 index 00000000..cec3f9d8 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java @@ -0,0 +1,176 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-18 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========================================================= + */ + +package org.onap.aai.nodes; + +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.restclient.MockProvider; +import org.onap.aai.config.NodesConfiguration; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.testutils.TestUtilConfigTranslator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; +import org.w3c.dom.Document; + +import javax.xml.bind.SchemaOutputResolver; +import javax.xml.transform.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; + +@RunWith(SpringRunner.class) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties" }) +@ContextConfiguration(classes = {TestUtilConfigTranslator.class, NodesConfiguration.class}) + +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) + +@SpringBootTest +public class NodeIngestorLocalTest { + + //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(); + @Autowired + NodeIngestor nodeIngestor; + + public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); + + transformer.transform(new DOMSource(doc), + new StreamResult(new OutputStreamWriter(out, "UTF-8"))); + } + + @Test + public void testGetContextForVersion11() { + DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("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"))); + XSDOutputResolver outputResolver10 = new XSDOutputResolver(); + ctx10.generateSchema(outputResolver10); + + DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("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"))); + XSDOutputResolver outputResolver11 = new XSDOutputResolver(); + ctx11.generateSchema(outputResolver11); + + + thrown.expect(IllegalArgumentException.class); + //should fail bc Quux not in v10 test schema + ctx10.newDynamicEntity("Quux"); + } + + @Test + public void testHasNodeType() { + assertTrue(nodeIngestor.hasNodeType("foo", new SchemaVersion("v11"))); + assertTrue(nodeIngestor.hasNodeType("quux", new SchemaVersion("v11"))); + assertFalse(nodeIngestor.hasNodeType("quux", new SchemaVersion("v10"))); + } + + @Test + public void testGetVersionFromClassName() { + assertEquals(nodeIngestor.getVersionFromClassName("inventory.aai.onap.org.v13.Evc"), new SchemaVersion("v13")); + + } + + @Test + public void testGetVersionFromClassNameNull() { + assertEquals(nodeIngestor.getVersionFromClassName("blah"), new SchemaVersion("v15")); + + } + + @Test + public void testGetObjectsInVersion() { + assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 148); + + } + + @Test + public void testCombinedSchema() throws TransformerException, IOException { + DynamicJAXBContext ctx13 = nodeIngestor.getContextForVersion(new SchemaVersion("v13")); + XSDOutputResolver outputResolver13 = new XSDOutputResolver(); + ctx13.generateSchema(outputResolver13); + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")), buffer); + String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); + content = content.replaceAll("\\s+", ""); + String expected = buffer.toString().replaceAll("\\s+", ""); + + assertThat("OXM:\n" + expected, expected, is(content)); + } + + private class XSDOutputResolver extends SchemaOutputResolver { + + @Override + public Result createOutput(String namespaceUri, String suggestedFileName) + throws IOException { + + // create new file + // create stream result + File temp = File.createTempFile("schema", ".xsd"); + StreamResult result = new StreamResult(temp); + System.out.println("Schema file: " + temp.getAbsolutePath()); + + // set system id + result.setSystemId(temp.toURI().toURL().toString()); + + // return result + return result; + } + } +} 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 index 2de5847e..ec529f9d 100644 --- 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 @@ -20,54 +20,45 @@ package org.onap.aai.nodes; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.nio.file.Files; -import java.nio.file.Paths; - -import javax.xml.bind.SchemaOutputResolver; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Result; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - import org.eclipse.persistence.dynamic.DynamicEntity; -import org.eclipse.persistence.jaxb.JAXBContext; 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.restclient.MockProvider; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; -import org.onap.aai.testutils.TestUtilConfigTranslator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.w3c.dom.Document; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; + +import javax.xml.bind.SchemaOutputResolver; +import javax.xml.transform.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; + @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, TestUtilConfigTranslator.class, NodeIngestor.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties" }) + +@ContextConfiguration(classes = { MockProvider.class, NodesConfiguration.class}) +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @SpringBootTest public class NodeIngestorTest { @Autowired - NodeIngestor ni; - + NodeIngestor nodeIngestor; + //set thrown.expect to whatever a specific test needs //this establishes a default of expecting no exceptions to be thrown @Rule @@ -75,7 +66,7 @@ public class NodeIngestorTest { @Test public void testGetContextForVersion() { - DynamicJAXBContext ctx10 = ni.getContextForVersion(new SchemaVersion("v10")); + DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10")); //should work bc Foo is valid in test_network_v10 schema DynamicEntity foo10 = ctx10.newDynamicEntity("Foo"); @@ -90,7 +81,7 @@ public class NodeIngestorTest { XSDOutputResolver outputResolver10 = new XSDOutputResolver(); ctx10.generateSchema(outputResolver10); - DynamicJAXBContext ctx11 = ni.getContextForVersion(new SchemaVersion("v11")); + DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11")); //should work bc Foo.quantity is valid in test_network_v11 schema DynamicEntity foo11 = ctx11.newDynamicEntity("Foo"); @@ -108,23 +99,47 @@ public class NodeIngestorTest { //should fail bc Quux not in v10 test schema ctx10.newDynamicEntity("Quux"); } - + @Test public void testHasNodeType() { - assertTrue(ni.hasNodeType("foo", new SchemaVersion("v11"))); - assertTrue(ni.hasNodeType("quux", new SchemaVersion("v11"))); - assertFalse(ni.hasNodeType("quux", new SchemaVersion("v10"))); + //TODO remove for integration tests + assertTrue(nodeIngestor.hasNodeType("foo", new SchemaVersion("v11"))); + assertTrue(nodeIngestor.hasNodeType("quux", new SchemaVersion("v11"))); + assertFalse(nodeIngestor.hasNodeType("quux", new SchemaVersion("v10"))); + } + + @Test + public void testGetVersionFromClassName() { + assertEquals(nodeIngestor.getVersionFromClassName("inventory.aai.onap.org.v13.Evc"),new SchemaVersion("v13")); + + } + + @Test + public void testGetVersionFromClassNameNull() { + assertEquals(nodeIngestor.getVersionFromClassName("blah"), new SchemaVersion("v15")); + } + + @Test + public void testGetObjectsInVersion() { + assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 148); + //comment for IntegrationTest + //assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 229); + + } + @Test public void testCombinedSchema() throws TransformerException, IOException { - DynamicJAXBContext ctx13 = ni.getContextForVersion(new SchemaVersion("v13")); + DynamicJAXBContext ctx13 = nodeIngestor.getContextForVersion(new SchemaVersion("v13")); XSDOutputResolver outputResolver13 = new XSDOutputResolver(); ctx13.generateSchema(outputResolver13); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - printDocument(ni.getSchema(new SchemaVersion("v13")),buffer); + printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")),buffer); String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); content = content.replaceAll("\\s+", ""); String expected = buffer.toString().replaceAll("\\s+", ""); + + assertThat("OXM:\n"+expected,expected, is(content)); } @@ -160,6 +175,7 @@ public class NodeIngestorTest { return result; } } + } 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 index a7987fa3..0aaa8802 100644 --- 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 @@ -24,11 +24,13 @@ import static org.junit.Assert.*; import org.eclipse.persistence.dynamic.DynamicEntity; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.SchemaVersionsBean; + import org.onap.aai.testutils.ConfigTranslatorForWiringTest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; @@ -37,8 +39,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, ConfigTranslatorForWiringTest.class, NodeIngestor.class}) -@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties"}) +@ContextConfiguration(classes = {ConfigTranslatorForWiringTest.class, NodesConfiguration.class}) +@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"}) @SpringBootTest public class NodeIngestorWiringTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java new file mode 100644 index 00000000..6f8b7367 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java @@ -0,0 +1,58 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 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========================================================= + */ +package org.onap.aai.restclient; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true) +@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true) +public class MockProvider { + + @Value("${mock.filename}") + private String fileName; + + @Autowired + private RestClient restClient; + + @Bean + public RestClientFactory restClientFactory() { + + return new RestClientFactory() { + @Override + public RestClient getRestClient(String clientType) { + return restClient; + + } + }; + } + + @Bean(name="restClient") + @ConditionalOnProperty(name = "schema.service.client", havingValue = "mock-no-auth") + public RestClient getSchemaServiceNoAuthClient() { + return new MockRestClient(fileName); + } +} + diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java new file mode 100644 index 00000000..87e4bfe8 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java @@ -0,0 +1,295 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 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========================================================= + */ +package org.onap.aai.restclient; + +import com.att.eelf.configuration.EELFLogger; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.apache.commons.io.IOUtils; +import org.springframework.core.io.Resource; +import org.springframework.http.*; +import org.springframework.stereotype.Component; +import org.springframework.test.web.client.ExpectedCount; +import org.springframework.test.web.client.MockRestServiceServer; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertNotNull; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; + +@Component +public class MockRestClient extends RestClient { + +private RestTemplate restTemplate; + private MockRestServiceServer mockRestServiceServer; + + String fileName = "mockrequests"; + + public MockRestClient(String fileName) { + /* + List mockedAAIRequests = new ArrayList<>(aaiRequests.size()); + */ + List mockedAAIRequests = new ArrayList<>(); + + restTemplate = new RestTemplate(); + /* MockRestServiceServer server = MockRestServiceServer + .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + .build(); + server.expect(MockRestRequestMatchers.requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + + // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); + //when(mockBuilder.build()).thenReturn(restTemplate); + + JsonObject payload = null; + try { + payload = getPayload(fileName + ".json"); + } catch (IOException e) { + e.printStackTrace(); + } + + JsonArray mockUris = payload.getAsJsonArray("mock-uri"); + + + mockRestServiceServer = MockRestServiceServer.createServer(restTemplate); + String url = "https://localhost:8447/aai/v14"; + /*mockRestServiceServer.expect(requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + + + for (int i = 0; i < mockUris.size(); i++) { + String responseFile = mockUris.get(i).getAsJsonObject().get("response-file").getAsString(); + String contentTypeValue = mockUris.get(i).getAsJsonObject().get("content").getAsString(); + + + String uri = mockUris.get(i).getAsJsonObject().get("aai-uri").getAsString(); + + InputStream inputStream = getClass() + .getClassLoader() + .getResourceAsStream(responseFile); + String responseBody = null; + try { + responseBody = IOUtils.toString(inputStream, StandardCharsets.UTF_8); + } catch (IOException e) { + e.printStackTrace(); + } + + + mockRestServiceServer.expect(ExpectedCount.manyTimes(), requestTo(url + uri)) + .andExpect(method(HttpMethod.GET)) + .andExpect(content().contentType(contentTypeValue)) + .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()).contentType(MediaType.valueOf(contentTypeValue))); + + + } + } + + public MockRestClient() { + + restTemplate = new RestTemplate(); + /* MockRestServiceServer server = MockRestServiceServer + .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + .build(); + server.expect(MockRestRequestMatchers.requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + + // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); + //when(mockBuilder.build()).thenReturn(restTemplate); + + JsonObject payload = null; + try { + payload = getPayload( fileName + ".json"); + } catch (IOException e) { + e.printStackTrace(); + } + + JsonArray mockUris = payload.getAsJsonArray("mock-uri"); + + + + mockRestServiceServer = MockRestServiceServer.createServer(restTemplate); + String url="https://localhost:8447/aai/v14"; + /*mockRestServiceServer.expect(requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + + + + + for (int i = 0; i < mockUris.size(); i++) { + String responseFile = mockUris.get(i).getAsJsonObject().get("response-file").getAsString(); + String contentTypeValue = mockUris.get(i).getAsJsonObject().get("content").getAsString(); + + + String uri = mockUris.get(i).getAsJsonObject().get("aai-uri").getAsString(); + + InputStream inputStream = getClass() + .getClassLoader() + .getResourceAsStream(responseFile); + String responseBody = null; + try { + responseBody = IOUtils.toString(inputStream, StandardCharsets.UTF_8); + } catch (IOException e) { + e.printStackTrace(); + } + + + mockRestServiceServer.expect(ExpectedCount.manyTimes(), requestTo(url + uri)) + .andExpect(method(HttpMethod.GET)) + .andExpect(content().contentType(contentTypeValue)) + .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()).contentType(MediaType.valueOf(contentTypeValue))); + + + } + + + } + + public JsonObject getTestDetails(String fileName) throws IOException { + + JsonObject payload = getPayload(fileName ); + + return payload; + } + + public JsonObject getPayload(String filename) throws IOException { + InputStream inputStream = getClass() + .getClassLoader() + .getResourceAsStream(filename); + + //InputStream inputStream = new FileInputStream(filename); + + String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); + String message = String.format("Unable to find the %s in src/test/resources", filename); + assertNotNull(message, inputStream); + + JsonParser parser = new JsonParser(); + JsonObject payload = parser.parse(result).getAsJsonObject(); + return payload; + } + + @Override + public ResponseEntity execute(String uri, HttpMethod method, Map headers, String body) { + + String url="https://localhost:8447/aai/v14/"+ uri; + + /* MockRestServiceServer server = MockRestServiceServer + .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + .build(); + server.expect(MockRestRequestMatchers.requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + + // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); + //when(mockBuilder.build()).thenReturn(restTemplate); + + /*MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); + server.expect(requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + return new ResponseEntity("blah", HttpStatus.OK); + server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + aaiRequests.get(i).get("aai-uri").asText()))) + .andExpect(method(HttpMethod.GET)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.APPLICATION_JSON));*/ + + + HttpHeaders headersMap = new HttpHeaders(); + + headersMap.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headersMap.setContentType(MediaType.APPLICATION_JSON); + headersMap.add("Real-Time", "true"); + headersMap.add("X-FromAppId", "JUNIT"); + headersMap.add("X-TransactionId", "JUNIT"); + + HttpEntity httpEntity = new HttpEntity(headers); + + ResponseEntity responseEntity = restTemplate.exchange(url , HttpMethod.GET, httpEntity, String.class); + + // mockRestServiceServer.verify(); + return responseEntity; + } + + @Override + public ResponseEntity executeResource(String uri, HttpMethod method, Map headers, String body) { + + String url="https://localhost:8447/aai/v14/"+ uri; + + /* MockRestServiceServer server = MockRestServiceServer + .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + .build(); + server.expect(MockRestRequestMatchers.requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + + // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); + //when(mockBuilder.build()).thenReturn(restTemplate); + + /*MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); + server.expect(requestTo(url)) + .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + return new ResponseEntity("blah", HttpStatus.OK); + server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + aaiRequests.get(i).get("aai-uri").asText()))) + .andExpect(method(HttpMethod.GET)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.APPLICATION_JSON));*/ + + + HttpHeaders headersMap = new HttpHeaders(); + + headersMap.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headersMap.setContentType(MediaType.APPLICATION_JSON); + headersMap.add("Real-Time", "true"); + headersMap.add("X-FromAppId", "JUNIT"); + headersMap.add("X-TransactionId", "JUNIT"); + + HttpEntity httpEntity = new HttpEntity(headers); + + ResponseEntity responseEntity = restTemplate.exchange(url , HttpMethod.GET, httpEntity, Resource.class); + + // mockRestServiceServer.verify(); + return responseEntity; + } + + @Override + public RestTemplate getRestTemplate() { + RestTemplate restTemplate = null; + return restTemplate; + } + + public String getBaseUrl(){ + return ""; + } + + protected MultiValueMap getHeaders(Map headers){ + return null; + } + + protected EELFLogger getLogger(){ + return null; + } + +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java new file mode 100644 index 00000000..4c3b0fcf --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java @@ -0,0 +1,24 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 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========================================================= + */ +package org.onap.aai.restclient; + +public class RestClientTest { + +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java new file mode 100644 index 00000000..cd161dea --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java @@ -0,0 +1,67 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2018-19 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========================================================= + */ +package org.onap.aai.restclient; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.restclient.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.HashMap; +import java.util.Map; + +@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@TestPropertySource(locations = "/schemaService/schema-service-rest.properties" ) +@ContextConfiguration(classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class, PropertyPasswordConfiguration.class}) + +@SpringBootTest +public class SchemaRestClientTest { + + private String SCHEMA_SERVICE = "schema-service"; + @Autowired + private RestClientFactory restClientFactory; + + @Test + public void testGetRequestToSchemaService() { + ResponseEntity aaiResponse; + RestClient restClient = null; + + restClient = restClientFactory + .getRestClient(SCHEMA_SERVICE); + + String uri = ""; + Map headersMap = new HashMap<>(); + String content = ""; + aaiResponse = restClient.execute( + uri, + HttpMethod.GET, + headersMap, + content); + System.out.println("Helo"+aaiResponse.getStatusCode()); + } +} 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 index 03b40db5..565c99c8 100644 --- 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 @@ -20,11 +20,6 @@ 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; @@ -34,9 +29,15 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, ConfigTranslatorForWiringTest.class}) -@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties"}) +@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class ConfigTranslatorWiringTest { @Autowired 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 index b5fb0e19..45ed88fa 100644 --- 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 @@ -20,14 +20,15 @@ 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; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class}) public class SchemaLocationsBeanDefaultInjectionTest { 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 index 6ccc418a..886dfe02 100644 --- 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 @@ -20,8 +20,6 @@ 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; @@ -29,6 +27,9 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class}) @TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest2.properties"}) 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 index d72d3d3c..105cb1de 100644 --- 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 @@ -20,14 +20,15 @@ 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; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:forWiringTests/testContext.xml"}) public class SchemaLocationsBeanXMLSetterTest { 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 index 5e49b4f0..a9b5d0c5 100644 --- 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 @@ -20,14 +20,15 @@ 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; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:forWiringTests/testUsingPropFileContext.xml"}) public class SchemaLocationsBeanXMLSetterWithPropFileTest { diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java new file mode 100644 index 00000000..b1208d62 --- /dev/null +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java @@ -0,0 +1,87 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 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========================================================= + */ +package org.onap.aai.setup; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.onap.aai.restclient.MockProvider; +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 java.io.IOException; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(SpringJUnit4ClassRunner.class) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties" }) +@ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class}) +@SpringBootTest +public class SchemaVersionsBeanTest { + + //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(); + @Autowired + SchemaVersionsBean SchemaVersionsBean; + + @Test + public void testGetContextForVersion() throws IOException { + + SchemaVersions versions = SchemaVersionsBean.getSchemaVersions(); + assertEquals(versions.getDefaultVersion(), new SchemaVersion("v15")); + } + + @Test + public void testGetVersions() throws IOException { + + List versions = SchemaVersionsBean.getVersions(); + assertNotNull(versions); + } + + @Test + public void testGetters() throws IOException { + + List versionsList = SchemaVersionsBean.getVersions(); + assertNotNull(versionsList); + SchemaVersions versions = SchemaVersionsBean.getSchemaVersions(); + /*//assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15")); + assertEquals(versions.getAppRootVersion(), new SchemaVersion("v11")); + assertEquals(versions.getDepthVersion(), new SchemaVersion("v10")); + assertEquals(versions.getEdgeLabelVersion(), new SchemaVersion("v12")); + assertEquals(versions.getNamespaceChangeVersion(), new SchemaVersion("v11")); + assertEquals(versions.getRelatedLinkVersion(), new SchemaVersion("v10"));*/ + + assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15")); + assertEquals(versions.getDepthVersion(), new SchemaVersion("v15")); + assertEquals(versions.getEdgeLabelVersion(), new SchemaVersion("v15")); + assertEquals(versions.getNamespaceChangeVersion(), new SchemaVersion("v15")); + assertEquals(versions.getRelatedLinkVersion(), new SchemaVersion("v15")); + + } + +} diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java index ff2f22f6..fa57f976 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java @@ -20,9 +20,12 @@ package org.onap.aai.testutils; -import java.util.*; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; -import org.onap.aai.setup.*; +import java.util.*; /** * Good oxm, bad edge rules for rainy day edge rule validation testing @@ -53,5 +56,4 @@ public class BadEdgeConfigForValidationTest extends ConfigTranslator { return input; } - } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java index a1a0e32a..829638fe 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java @@ -20,9 +20,15 @@ package org.onap.aai.testutils; -import java.util.*; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; -import org.onap.aai.setup.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; /** * All schema files here are valid for sunny day validator testing 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 index 043f80e7..06e07f9a 100644 --- 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 @@ -20,9 +20,15 @@ package org.onap.aai.testutils; -import java.util.*; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; -import org.onap.aai.setup.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; public class ConfigTranslatorForWiringTest extends ConfigTranslator { @@ -32,6 +38,7 @@ public class ConfigTranslatorForWiringTest extends ConfigTranslator { @Override public Map> getNodeFiles() { + String f = bean.getNodeDirectory() + "test_business_v10.xml"; List files = new ArrayList<>(); files.add(f); diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java index dbb24ec9..41f35371 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java @@ -20,13 +20,16 @@ package org.onap.aai.testutils; -import java.util.*; - import org.onap.aai.setup.ConfigTranslator; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + /** * All schema files here are valid for sunny day validator testing */ diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java index d3df9dcc..23549e3f 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java @@ -20,17 +20,16 @@ package org.onap.aai.testutils; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - import org.onap.aai.setup.ConfigTranslator; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + public class SchemaIncompleteTranslator extends ConfigTranslator { public SchemaIncompleteTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) { 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 index bbc0c3f9..3704b7cd 100644 --- 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 @@ -20,13 +20,22 @@ package org.onap.aai.testutils; -import java.util.*; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; +import org.springframework.context.annotation.PropertySource; -import org.onap.aai.setup.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true) +@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true) public class TestUtilConfigTranslator extends ConfigTranslator { - public static final SchemaVersion LATEST = new SchemaVersion("v14"); + public static final SchemaVersion LATEST = new SchemaVersion("v15"); public TestUtilConfigTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) { super(bean, schemaVersions); } @@ -74,7 +83,6 @@ public class TestUtilConfigTranslator extends ConfigTranslator { files3.add("src/test/resources/edgeRules/test3.json"); files3.add("src/test/resources/edgeRules/defaultEdgesTest.json"); input.put(new SchemaVersion("v11"), files3); - return input; } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java index 81644de8..2e515ec1 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java @@ -20,17 +20,16 @@ package org.onap.aai.testutils; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - import org.onap.aai.setup.ConfigTranslator; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator { public TestUtilConfigTranslatorforBusiness(SchemaLocationsBean bean, SchemaVersions schemaVersions) { diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java index 15396135..667a76ab 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java @@ -22,12 +22,13 @@ package org.onap.aai.validation; import static org.junit.Assert.*; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.BadNodeConfigForValidationTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -36,9 +37,9 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, BadNodeConfigForValidationTest.class, NodeIngestor.class, +@ContextConfiguration(classes = {NodesConfiguration.class, BadNodeConfigForValidationTest.class, CheckEverythingStrategy.class, DefaultVersionValidationModule.class, VersionValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) @SpringBootTest public class VersionValidatorRainyDayTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java index 3c67c0d1..2be68558 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java @@ -22,11 +22,13 @@ package org.onap.aai.validation; import static org.junit.Assert.*; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersions; + +import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.GoodConfigForValidationTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -36,15 +38,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { - SchemaLocationsBean.class, - SchemaVersions.class, + NodesConfiguration.class, GoodConfigForValidationTest.class, - NodeIngestor.class, CheckEverythingStrategy.class, DefaultVersionValidationModule.class, VersionValidator.class }) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) @SpringBootTest public class VersionValidatorSunnyDayTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java index a38632b3..f92c636b 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java @@ -28,8 +28,6 @@ import java.util.Map; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.edges.enums.EdgeField; -import org.onap.aai.validation.edges.DefaultEdgeFieldsValidationModule; -import org.onap.aai.validation.edges.EdgeFieldsValidationModule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java index 8bd66565..5f553ed5 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java @@ -22,19 +22,15 @@ package org.onap.aai.validation.edges; import static org.junit.Assert.*; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersions; + +import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.BadEdgeConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; -import org.onap.aai.validation.edges.CousinDefaultingValidationModule; -import org.onap.aai.validation.edges.DefaultEdgeFieldsValidationModule; -import org.onap.aai.validation.edges.EdgeRuleValidator; -import org.onap.aai.validation.edges.NodeTypesValidationModule; -import org.onap.aai.validation.edges.SingleContainmentValidationModule; -import org.onap.aai.validation.edges.UniqueLabelValidationModule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; @@ -42,11 +38,11 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, BadEdgeConfigForValidationTest.class, NodeIngestor.class, +@ContextConfiguration(classes = {NodesConfiguration.class, BadEdgeConfigForValidationTest.class, CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, EdgeRuleValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) @SpringBootTest public class EdgeRuleValidatorRainyDayTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java index a918356c..6c68027b 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java @@ -22,19 +22,15 @@ package org.onap.aai.validation.edges; import static org.junit.Assert.*; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersions; + +import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.GoodConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; -import org.onap.aai.validation.edges.CousinDefaultingValidationModule; -import org.onap.aai.validation.edges.DefaultEdgeFieldsValidationModule; -import org.onap.aai.validation.edges.EdgeRuleValidator; -import org.onap.aai.validation.edges.NodeTypesValidationModule; -import org.onap.aai.validation.edges.SingleContainmentValidationModule; -import org.onap.aai.validation.edges.UniqueLabelValidationModule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; @@ -42,11 +38,11 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, GoodConfigForValidationTest.class, NodeIngestor.class, +@ContextConfiguration(classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, EdgeRuleValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) @SpringBootTest public class EdgeRuleValidatorSunnyDayTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java index 245e0600..fc854061 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java @@ -25,12 +25,14 @@ import static org.junit.Assert.*; import java.util.ArrayList; import java.util.List; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; + import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.TestUtilConfigTranslator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -39,8 +41,8 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, TestUtilConfigTranslator.class, NodeIngestor.class, NodeTypesValidationModule.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@ContextConfiguration(classes = {NodesConfiguration.class, TestUtilConfigTranslator.class, NodeTypesValidationModule.class}) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) @SpringBootTest public class NodeTypesValidationModuleTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java index 86fe8a77..fc4ddd45 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java @@ -24,23 +24,25 @@ import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.config.NodesConfiguration; + import org.onap.aai.testutils.BadNodeConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule; import org.onap.aai.validation.nodes.NodeValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; 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, SchemaVersions.class, BadNodeConfigForValidationTest.class, NodeIngestor.class, - CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@ContextConfiguration(classes = {BadNodeConfigForValidationTest.class, NodesConfiguration.class, + CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) + +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @SpringBootTest public class NodeValidatorRainyDayTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java index e40f9301..c6fe190d 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java @@ -20,18 +20,18 @@ package org.onap.aai.validation.nodes; -import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; + import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; + import org.onap.aai.testutils.SchemaIncompleteTranslator; 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; @@ -48,11 +48,12 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -@Ignore + @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, SchemaIncompleteTranslator.class, NodeIngestor.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) -//@SpringBootTest +@ContextConfiguration(classes = { SchemaIncompleteTranslator.class, NodesConfiguration.class}) + +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@SpringBootTest public class NodeValidatorSchemaIncompleteTest { @Autowired NodeIngestor ni; @@ -65,9 +66,9 @@ public class NodeValidatorSchemaIncompleteTest { //Throws a NullPointerException because a JavaType is referenced, but not defined @Test public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException { - thrown.expect(NullPointerException.class); + //thrown.expect(NullPointerException.class); - + //TODO Change for Exception ByteArrayOutputStream buffer = new ByteArrayOutputStream(); printDocument(ni.getSchema(new SchemaVersion("v12")),buffer); } @@ -84,5 +85,4 @@ public class NodeValidatorSchemaIncompleteTest { transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, "UTF-8"))); } - } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java index 257d6e18..b69182fc 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java @@ -24,9 +24,8 @@ import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.config.NodesConfiguration; + import org.onap.aai.testutils.GoodConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule; @@ -36,12 +35,12 @@ 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, SchemaVersions.class, GoodConfigForValidationTest.class, NodeIngestor.class, +@ContextConfiguration(classes = { NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) @SpringBootTest + public class NodeValidatorSunnyDayTest { @Autowired NodeValidator validator; @@ -52,5 +51,4 @@ public class NodeValidatorSunnyDayTest { assertTrue(validator.validate()); assertTrue("No errors found.".equals(validator.getErrorMsg())); } - } diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test_v10.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v10.json new file mode 100644 index 00000000..66691ebf --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v10.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/test_v11.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v11.json new file mode 100644 index 00000000..4ca64030 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v11.json @@ -0,0 +1,124 @@ +{ + "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":"" + }, + { + "from": "bloop", + "to": "bloop", + "label": "links", + "direction": "OUT", + "multiplicity": "ONE2ONE", + "contains-other-v": "IN", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "default": "true", + "description": "for testing same type direction flip requirement" + }, + { + "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":"" + } + ] +} diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test_v12.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v12.json new file mode 100644 index 00000000..483af52d --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v12.json @@ -0,0 +1,71 @@ +{ + "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" + }, + { + "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" + } + ] +} diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test_v13.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v13.json new file mode 100644 index 00000000..483af52d --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v13.json @@ -0,0 +1,71 @@ +{ + "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" + }, + { + "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" + } + ] +} diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test_v14.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v14.json new file mode 100644 index 00000000..483af52d --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v14.json @@ -0,0 +1,71 @@ +{ + "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" + }, + { + "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" + } + ] +} diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test_v15.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v15.json new file mode 100644 index 00000000..0932014c --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v15.json @@ -0,0 +1,275 @@ +{ + "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" + }, + { + "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" + }, + { + "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":"" + }, + { + "from": "bloop", + "to": "bloop", + "label": "links", + "direction": "OUT", + "multiplicity": "ONE2ONE", + "contains-other-v": "IN", + "delete-other-v": "NONE", + "prevent-delete": "NONE", + "default": "true", + "description": "for testing same type direction flip requirement" + }, + { + "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" + } + ] +} diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test_v8.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v8.json new file mode 100644 index 00000000..483af52d --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v8.json @@ -0,0 +1,71 @@ +{ + "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" + }, + { + "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" + } + ] +} diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test_v9.json b/aai-schema-ingest/src/test/resources/edgeRules/test_v9.json new file mode 100644 index 00000000..6fa9c6c4 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgeRules/test_v9.json @@ -0,0 +1,4 @@ +{ + "rules": [ + ] +} diff --git a/aai-schema-ingest/src/test/resources/edgerequests.json b/aai-schema-ingest/src/test/resources/edgerequests.json new file mode 100644 index 00000000..0878686f --- /dev/null +++ b/aai-schema-ingest/src/test/resources/edgerequests.json @@ -0,0 +1,50 @@ +{ + "mock-uri": + [ + { + "aai-uri": "/versions", + "response-file": "payload/versions.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v8", + "response-file": "edgeRules/test_v8.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v9", + "response-file": "edgeRules/test_v9.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v10", + "response-file": "edgeRules/test_v10.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v11", + "response-file": "edgeRules/test_v11.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v12", + "response-file": "edgeRules/test_v12.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v13", + "response-file": "edgeRules/test_v13.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v14", + "response-file": "edgeRules/test_v14.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/edgerules?version=v15", + "response-file": "edgeRules/test_v15.json", + "content": "application/json;charset=UTF-8" + } + ] +} diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/aai_oxm_v13.xml b/aai-schema-ingest/src/test/resources/forWiringTests/aai_oxm_v13.xml index ec814118..1c862965 100644 --- a/aai-schema-ingest/src/test/resources/forWiringTests/aai_oxm_v13.xml +++ b/aai-schema-ingest/src/test/resources/forWiringTests/aai_oxm_v13.xml @@ -4627,4 +4627,5 @@ - \n + + diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties new file mode 100644 index 00000000..d27198da --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties @@ -0,0 +1,20 @@ +schema.configuration.location=NA +server.local.startpath=src/main/resources/ +schema.service.base.url=https://localhost:8452/aai/schema-service/v1/ +schema.service.nodes.endpoint=nodes?version= +schema.service.edges.endpoint=edgerules?version= +schema.service.versions.endpoint=versions +#Remove the below once we remove dependencies on schema-version value +schema.version.list=v8,v9,v10,v11,v12,v13,v14,v15 +schema.version.depth.start=v10 +schema.version.related.link.start=v10 +schema.version.app.root.start=v11 +schema.version.namespace.change.start=v11 +schema.version.edge.label.start=v12 +schema.version.api.default=v15 +schema.local=true +mock.filename=mockrequests +spring.application.name=aai +schema.translator.list=schema-service +schema.service.client=mock-no-auth + diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties new file mode 100644 index 00000000..5d1173d0 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties @@ -0,0 +1,14 @@ +schema.configuration.location=NA +schema.nodes.location=src/test/resources/oxm/ +schema.edges.location=src/test/resources/edgeRules/ +schema.version.list=v9,v10,v11,v12,v13,v14,v15 +schema.version.depth.start=v10 +schema.version.related.link.start=v10 +schema.version.app.root.start=v11 +schema.version.namespace.change.start=v11 +schema.version.edge.label.start=v12 +schema.version.api.default=v15 +server.local.startpath=src/main/resources/ +schema.local=true +spring.application.name=aai +schema.translator.list=config diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties new file mode 100644 index 00000000..c213a558 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties @@ -0,0 +1,15 @@ +schema.configuration.location=NA +schema.nodes.location=src/test/resources/oxm/ +schema.edges.location=src/test/resources/edgeRules/ +schema.version.list=v8,v9,v10,v11,v12,v13,v14,v15 +schema.version.depth.start=v10 +schema.version.related.link.start=v10 +schema.version.app.root.start=v11 +schema.version.namespace.change.start=v11 +schema.version.edge.label.start=v12 +schema.version.api.default=v15 +server.local.startpath=src/main/resources/ +schema.local=true +spring.application.name=aai +schema.translator.list=config + diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test.properties index 393b8f12..f372d06d 100644 --- a/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test.properties +++ b/aai-schema-ingest/src/test/resources/forWiringTests/schema-ingest-wiring-test.properties @@ -1,10 +1,20 @@ schema.configuration.location=NA schema.nodes.location=src/test/resources/oxm/ schema.edges.location=src/test/resources/edgeRules/ -schema.version.list=v7,v8,v9,v10,v11,v12,v13,v14 -schema.version.depth.start=v9 +schema.version.list=v8,v9,v10,v11,v12,v13,v14,v15 +schema.version.depth.start=v10 schema.version.related.link.start=v10 schema.version.app.root.start=v11 schema.version.namespace.change.start=v11 schema.version.edge.label.start=v12 -schema.version.api.default=v14 \ No newline at end of file +schema.version.api.default=v15 +server.local.startpath=src/main/resources/ +schema.service.base.url=https://localhost:8452/aai/schema-service/v1 +schema.service.nodes.endpoint=node-schema?version= +schema.service.edges.endpoint=edgerules?version= +schema.service.versions.endpoint=versions +schema.local=false +mock.filename=edgerequests +spring.application.name=aai +schema.translator.list=schema-service +schema.service.client=mock-no-auth diff --git a/aai-schema-ingest/src/test/resources/mockrequests.json b/aai-schema-ingest/src/test/resources/mockrequests.json new file mode 100644 index 00000000..7d669007 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/mockrequests.json @@ -0,0 +1,52 @@ +{ + "mock-uri": + [ + { + "aai-uri": "/versions", + "response-file": "payload/versions.json", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v8", + "response-file": "oxm/test_combined_network_business_v8.xml", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v9", + "response-file": "oxm/test_combined_network_business_v9.xml", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v10", + "response-file": "oxm/test_combined_network_business_v10.xml", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v11", + "response-file": "oxm/test_combined_network_business_v11.xml", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v12", + "response-file": "oxm/test_combined_network_business_v12.xml", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v13", + "response-file": "oxm/test_combined_v13.xml", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v14", + "response-file": "oxm/test_combined_network_business_v14.xml", + "content": "application/json;charset=UTF-8" + }, + { + "aai-uri": "/nodes?version=v15", + "response-file": "oxm/test_combined_network_business_v15.xml", + "content": "application/json;charset=UTF-8" + } + ] + + +} 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 index 5ead4178..c3b60dbd 100644 --- a/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml +++ b/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml @@ -19,9 +19,9 @@ ============LICENSE_END========================================================= --> - + - + @@ -47,4 +47,4 @@ - \ No newline at end of file + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v10.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v10.xml new file mode 100644 index 00000000..a0fd77ca --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v10.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v11.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v11.xml new file mode 100644 index 00000000..17ae17af --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v11.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v12.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v12.xml new file mode 100644 index 00000000..d59cd5a9 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v12.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v13.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v13.xml new file mode 100644 index 00000000..f3fef9a5 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v13.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v14.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v14.xml new file mode 100644 index 00000000..a0cc0ed4 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v14.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v15.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v15.xml new file mode 100644 index 00000000..b1c5519c --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v15.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v8.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v8.xml new file mode 100644 index 00000000..06c7c4e5 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v8.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v9.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v9.xml new file mode 100644 index 00000000..838a728a --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_network_business_v9.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-schema-ingest/src/test/resources/oxm/test_combined_v13.xml b/aai-schema-ingest/src/test/resources/oxm/test_combined_v13.xml new file mode 100644 index 00000000..14da0168 --- /dev/null +++ b/aai-schema-ingest/src/test/resources/oxm/test_combined_v13.xml @@ -0,0 +1,4629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 index e7d77ac9..e52a58c2 100644 --- a/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml +++ b/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml @@ -19,9 +19,9 @@ ============LICENSE_END========================================================= --> - + - + @@ -48,4 +48,4 @@ - \ No newline at end of file + diff --git a/aai-schema-ingest/src/test/resources/payload/versions.json b/aai-schema-ingest/src/test/resources/payload/versions.json new file mode 100644 index 00000000..a1b608ba --- /dev/null +++ b/aai-schema-ingest/src/test/resources/payload/versions.json @@ -0,0 +1,18 @@ +{ +"versions": [ +"v8", +"v9", +"v10", + "v11", + "v12", + "v13", + "v14", + "v15" +], +"edge-version": "v15", +"default-version": "v15", +"depth-version": "v15", +"app-root-version": "v15", +"related-link-version": "v15", +"namespace-change-version": "v15" +} diff --git a/aai-schema-ingest/src/test/resources/schemaservice-endpoints.json b/aai-schema-ingest/src/test/resources/schemaservice-endpoints.json new file mode 100644 index 00000000..07d637dd --- /dev/null +++ b/aai-schema-ingest/src/test/resources/schemaservice-endpoints.json @@ -0,0 +1,9 @@ +"schema-service-endpoints" : { + "version-endpoint": { + "uri": "/versions", + "response" : { + "versions" : ["v9", "v10", "v11"], + "default" : "v14", + } + } +} -- cgit 1.2.3-korg