summaryrefslogtreecommitdiffstats
path: root/aai-schema-ingest/src
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-ingest/src')
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java581
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java191
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java214
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java62
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java49
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java50
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java43
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java27
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java41
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java29
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java29
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java107
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java61
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java111
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java40
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java306
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java58
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java135
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java84
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java57
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java61
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java46
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java48
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java46
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java46
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java60
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java76
-rw-r--r--aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json52
-rw-r--r--aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json136
-rw-r--r--aai-schema-ingest/src/test/resources/edgeRules/test.json48
-rw-r--r--aai-schema-ingest/src/test/resources/edgeRules/test2.json27
-rw-r--r--aai-schema-ingest/src/test/resources/edgeRules/test3.json64
-rw-r--r--aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties3
-rw-r--r--aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties3
-rw-r--r--aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties3
-rw-r--r--aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml14
-rw-r--r--aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml19
-rw-r--r--aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml50
-rw-r--r--aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml45
-rw-r--r--aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml51
-rw-r--r--aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml76
-rw-r--r--aai-schema-ingest/src/test/resources/schemaIngest.properties3
42 files changed, 3252 insertions, 0 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
new file mode 100644
index 00000000..aa90a300
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
@@ -0,0 +1,581 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.onap.aai.edges.enums.AAIDirection;
+import org.onap.aai.edges.enums.DirectionNotation;
+import org.onap.aai.edges.enums.EdgeField;
+import org.onap.aai.edges.enums.EdgeType;
+import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.Version;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.jayway.jsonpath.Criteria;
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.Filter;
+import static com.jayway.jsonpath.Filter.filter;
+import com.jayway.jsonpath.JsonPath;
+import static com.jayway.jsonpath.Criteria.where;
+
+@Component
+/**
+ * EdgeIngestor - ingests A&AI edge rule schema files per given config, serves that edge rule
+ * information, including allowing various filters to extract particular rules.
+ */
+public class EdgeIngestor {
+ private Map<Version, List<DocumentContext>> versionJsonFilesMap = new EnumMap<>(Version.class);
+ private static final String READ_START = "$.rules.[?]";
+ private static final String READ_ALL_START = "$.rules.*";
+
+ //-----ingest-----//
+ @Autowired
+ /**
+ * Instantiates the EdgeIngestor bean.
+ *
+ * @param translator - ConfigTranslator autowired in by Spring framework which
+ * contains the configuration information needed to ingest the desired files.
+ */
+ public EdgeIngestor(ConfigTranslator translator) {
+ Map<Version, List<String>> filesToIngest = translator.getEdgeFiles();
+
+ for (Entry<Version, List<String>> verFile : filesToIngest.entrySet()) {
+ Version v = verFile.getKey();
+ List<String> files = verFile.getValue();
+
+ List<DocumentContext> docs = new ArrayList<>();
+
+ for (String rulesFilename : files) {
+ String fileContents = readInJsonFile(rulesFilename);
+ docs.add(JsonPath.parse(fileContents));
+ }
+ versionJsonFilesMap.put(v, docs);
+ }
+ }
+
+ /**
+ * Reads the json file at the given filename into an in-memory String.
+ *
+ * @param rulesFilename - json file to be read (must include path to the file)
+ * @return String json contents of the given file
+ */
+ private String readInJsonFile(String rulesFilename) {
+ StringBuilder sb = new StringBuilder();
+ try(BufferedReader br = new BufferedReader(new FileReader(rulesFilename))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ sb.append(line);
+ }
+ } catch (IOException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ return sb.toString();
+ }
+
+ //-----methods for getting rule info-----//
+
+ /**
+ * Gets list of all edge rules defined in the latest version's schema
+ *
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules associated with those types
+ * where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * @throws EdgeRuleNotFoundException if none found
+ */
+ public Multimap<String, EdgeRule> getAllCurrentRules() throws EdgeRuleNotFoundException {
+ return getAllRules(Version.getLatest());
+ }
+
+ /**
+ * Gets list of all edge rules defined in the given version's schema
+ *
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules associated with those types
+ * where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * @throws EdgeRuleNotFoundException if none found
+ */
+ public Multimap<String, EdgeRule> getAllRules(Version v) throws EdgeRuleNotFoundException {
+ Multimap<String, EdgeRule> found = extractRules(null, v);
+ if (found.isEmpty()) {
+ throw new EdgeRuleNotFoundException("No rules found for version " + v.toString() + ".");
+ } else {
+ return found;
+ }
+ }
+
+ /**
+ * Finds the rules (if any) matching the given query criteria. If none, the returned Multimap
+ * will be empty.
+ *
+ * @param q - EdgeRuleQuery with filter criteria set
+ *
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * @throws EdgeRuleNotFoundException if none found
+ */
+ public Multimap<String, EdgeRule> getRules(EdgeRuleQuery q) throws EdgeRuleNotFoundException {
+ Multimap<String, EdgeRule> found = extractRules(q.getFilter(), q.getVersion());
+ if (found.isEmpty()) {
+ throw new EdgeRuleNotFoundException("No rules found for " + q.toString());
+ } else {
+ return found;
+ }
+ }
+
+ /**
+ * Gets the rule satisfying the given filter criteria. If there are more than one
+ * that match, return the default rule. If there is no clear default to return, or
+ * no rules match at all, error.
+ *
+ * @param q - EdgeRuleQuery with filter criteria set
+ * @return EdgeRule satisfying given criteria
+ * @throws EdgeRuleNotFoundException if none found that match
+ * @throws AmbiguousRuleChoiceException if multiple match but no way to choice one from them
+ * Specifically, if multiple node type pairs come back (ie bar|foo and asdf|foo,
+ * no way to know which is appropriate over the others),
+ * or if there is a mix of Tree and Cousin edges because again there is no way to
+ * know which is "defaulter" than the other.
+ * The default property only clarifies among multiple cousin edges of the same node pair,
+ * ex: which l-interface|logical-link rule to default to.
+ */
+ public EdgeRule getRule(EdgeRuleQuery q) throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ Multimap<String, EdgeRule> found = extractRules(q.getFilter(), q.getVersion());
+
+ if (found.isEmpty()) {
+ throw new EdgeRuleNotFoundException("No rule found for " + q.toString() + ".");
+ }
+
+ EdgeRule rule = null;
+ if (found.keys().size() == 1) { //only one found, cool we're done
+ for (Entry<String, EdgeRule> e : found.entries()) {
+ rule = e.getValue();
+ }
+ } else {
+ rule = getDefaultRule(found);
+ }
+
+ if (rule == null) { //should never get here though
+ throw new EdgeRuleNotFoundException("No rule found for " + q.toString() + ".");
+ } else {
+ return rule;
+ }
+ }
+
+ private EdgeRule getDefaultRule(Multimap<String, EdgeRule> found) throws AmbiguousRuleChoiceException {
+ if (found.keySet().size() > 1) { //ie multiple node pairs (a|c and b|c not just all a|c) case
+ StringBuilder sb = new StringBuilder();
+ for (String k : found.keySet()) {
+ sb.append(k).append(" ");
+ }
+ throw new AmbiguousRuleChoiceException("No way to select single rule from these pairs: " + sb.toString() + ".");
+ }
+
+ int defaultCount = 0;
+ EdgeRule defRule = null;
+ for (Entry<String, EdgeRule> e : found.entries()) {
+ EdgeRule rule = e.getValue();
+ if (rule.isDefault()) {
+ defaultCount++;
+ defRule = rule;
+ }
+ }
+ if (defaultCount > 1) {
+ throw new AmbiguousRuleChoiceException("Multiple defaults found.");
+ } else if (defaultCount == 0) {
+ throw new AmbiguousRuleChoiceException("No default found.");
+ }
+
+ return defRule;
+ }
+
+ /**
+ * Checks if there exists any rule that satisfies the given filter criteria.
+ *
+ * @param q - EdgeRuleQuery with filter criteria set
+ * @return boolean
+ */
+ public boolean hasRule(EdgeRuleQuery q) {
+ return !extractRules(q.getFilter(), q.getVersion()).isEmpty();
+ }
+
+ /**
+ * Gets all cousin rules for the given node type in the latest schema version.
+ *
+ * @param nodeType
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ public Multimap<String, EdgeRule> getCousinRules(String nodeType) {
+ return getCousinRules(nodeType, Version.getLatest()); //default to latest
+ }
+
+ /**
+ * Gets all cousin rules for the given node type in the given schema version.
+ *
+ * @param nodeType
+ * @param v - the version of the edge rules to query
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ public Multimap<String, EdgeRule> getCousinRules(String nodeType, Version v) {
+ return extractRules(new EdgeRuleQuery.Builder(nodeType).edgeType(EdgeType.COUSIN).build().getFilter(), v);
+ }
+
+ /**
+ * Returns if the given node type has any cousin relationships in the current version.
+ * @param nodeType
+ * @return boolean
+ */
+ public boolean hasCousinRule(String nodeType) {
+ return hasCousinRule(nodeType, Version.getLatest());
+ }
+
+ /**
+ * Returns if the given node type has any cousin relationships in the given version.
+ * @param nodeType
+ * @return boolean
+ */
+ public boolean hasCousinRule(String nodeType, Version v) {
+ return !getCousinRules(nodeType, v).isEmpty();
+ }
+
+ /**
+ * Gets all rules where "{given nodeType} contains {otherType}" in the latest schema version.
+ *
+ * @param nodeType - node type that is the container in the returned relationships
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ public Multimap<String, EdgeRule> getChildRules(String nodeType) {
+ return getChildRules(nodeType, Version.getLatest());
+ }
+
+ /**
+ * Gets all rules where "{given nodeType} contains {otherType}" in the given schema version.
+ *
+ * @param nodeType - node type that is the container in the returned relationships
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ public Multimap<String, EdgeRule> getChildRules(String nodeType, Version v) {
+ Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getSameDirectionContainmentCriteria());
+ Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
+ Filter total = from.or(to);
+
+ return extractRules(total, v);
+ }
+
+ /**
+ * Returns if the given node type has any child relationships (ie it contains another node type) in the current version.
+ * @param nodeType
+ * @return boolean
+ */
+ public boolean hasChildRule(String nodeType) {
+ return hasChildRule(nodeType, Version.getLatest());
+ }
+
+ /**
+ * Returns if the given node type has any child relationships (ie it contains another node type) in the given version.
+ * @param nodeType
+ * @return boolean
+ */
+ public boolean hasChildRule(String nodeType, Version v) {
+ return !getChildRules(nodeType, v).isEmpty();
+ }
+
+ /**
+ * Gets all rules where "{given nodeType} is contained by {otherType}" in the latest schema version.
+ *
+ * @param nodeType - node type that is the containee in the returned relationships
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ public Multimap<String, EdgeRule> getParentRules(String nodeType) {
+ return getParentRules(nodeType, Version.getLatest());
+ }
+
+ /**
+ * Gets all rules where "{given nodeType} is contained by {otherType}" in the given schema version.
+ *
+ * @param nodeType - node type that is the containee in the returned relationships
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ public Multimap<String, EdgeRule> getParentRules(String nodeType, Version v) {
+ Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
+ Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getSameDirectionContainmentCriteria());
+ Filter total = from.or(to);
+
+ return extractRules(total, v);
+ }
+
+ /**
+ * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the current version.
+ * @param nodeType
+ * @return boolean
+ */
+ public boolean hasParentRule(String nodeType) {
+ return hasParentRule(nodeType, Version.getLatest());
+ }
+
+ /**
+ * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the given version.
+ * @param nodeType
+ * @return boolean
+ */
+ public boolean hasParentRule(String nodeType, Version v) {
+ return !getParentRules(nodeType, v).isEmpty();
+ }
+
+ /**
+ * Applies the given filter to the DocumentContext(s) for the given version to extract
+ * edge rules, and converts this extracted information into the Multimap form
+ *
+ * @param filter - JsonPath filter to read the DocumentContexts with. May be null
+ * to denote no filter, ie get all.
+ * @param v - The schema version to extract from
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ private Multimap<String, EdgeRule> extractRules(Filter filter, Version v) {
+ List<Map<String, String>> foundRules = new ArrayList<>();
+ List<DocumentContext> docs = versionJsonFilesMap.get(v);
+ if (docs != null) {
+ for (DocumentContext doc : docs) {
+ if (filter == null) {
+ foundRules.addAll(doc.read(READ_ALL_START));
+ } else {
+ foundRules.addAll(doc.read(READ_START, filter));
+ }
+ }
+ }
+
+ return convertToEdgeRules(foundRules);
+ }
+
+ //-----filter building helpers-----//
+ /**
+ * ANDs together the given start criteria with each criteria in the pieces list, and
+ * then ORs together these segments into one filter.
+ *
+ * JsonPath doesn't have an OR method on Criteria, only on Filters, so assembling
+ * a complete filter requires this sort of roundabout construction.
+ *
+ * @param start - Criteria of the form where(from/to).is(nodeType)
+ * (ie the start of any A&AI edge rule query)
+ * @param pieces - Other Criteria to be applied
+ * @return Filter constructed from the given Criteria
+ */
+ private Filter assembleFilterSegments(Criteria start, List<Criteria> pieces) {
+ List<Filter> segments = new ArrayList<>();
+ for (Criteria c : pieces) {
+ segments.add(filter(start).and(c));
+ }
+ Filter assembled = segments.remove(0);
+ for (Filter f : segments) {
+ assembled = assembled.or(f);
+ }
+ return assembled;
+ }
+
+ /**
+ * Builds the sub-Criteria for a containment edge rule query where the direction
+ * and containment fields must match.
+ *
+ * Used for getChildRules() where the container node type is in the "from" position and
+ * for getParentRules() where the containee type is in the "to" position.
+ *
+ * @return List<Criteria> covering property permutations defined with either notation or explicit direction
+ */
+ private List<Criteria> getSameDirectionContainmentCriteria() {
+ List<Criteria> crits = new ArrayList<>();
+
+ crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.DIRECTION.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString())
+ .and(EdgeField.CONTAINS.toString()).is(Direction.OUT.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString())
+ .and(EdgeField.CONTAINS.toString()).is(Direction.IN.toString()));
+
+ return crits;
+ }
+
+ /**
+ * Builds the sub-Criteria for a containment edge rule query where the direction
+ * and containment fields must not match.
+ *
+ * Used for getChildRules() where the container node type is in the "to" position and
+ * for getParentRules() where the containee type is in the "from" position.
+ *
+ * @return List<Criteria> covering property permutations defined with either notation or explicit direction
+ */
+ private List<Criteria> getOppositeDirectionContainmentCriteria() {
+ List<Criteria> crits = new ArrayList<>();
+
+ crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.OPPOSITE.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString())
+ .and(EdgeField.CONTAINS.toString()).is(Direction.IN.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString())
+ .and(EdgeField.CONTAINS.toString()).is(Direction.OUT.toString()));
+
+ return crits;
+ }
+
+ //-----rule packaging helpers-----//
+ /**
+ * Converts the raw output from reading the json file to the Multimap<String key, EdgeRule> format
+ *
+ * @param List<Map<String, String>> allFound - raw edge rule output read from json file(s)
+ * (could be empty if none found)
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Will be empty if input
+ * was empty.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ private Multimap<String, EdgeRule> convertToEdgeRules(List<Map<String, String>> allFound) {
+ Multimap<String, EdgeRule> rules = ArrayListMultimap.create();
+
+ if (!allFound.isEmpty()) {
+ for (Map<String, String> raw : allFound) {
+ EdgeRule converted = new EdgeRule(raw);
+ String alphabetizedKey = buildAlphabetizedKey(raw.get(EdgeField.FROM.toString()), raw.get(EdgeField.TO.toString()));
+ rules.put(alphabetizedKey, converted);
+ }
+ }
+
+ return rules;
+ }
+
+ /**
+ * Builds the multimap key for the rules, where nodetypes are alphabetically sorted
+ * (ignoring dashes).
+ *
+ * @param nodeA - first nodetype
+ * @param nodeB - second nodetype
+ * @return {alphabetically first nodetype}|{alphabetically second nodetype}
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ private String buildAlphabetizedKey(String nodeA, String nodeB) {
+ //normalize
+ String normalizedNodeA = nodeA.replace("-", "");
+ String normalizedNodeB = nodeB.replace("-", "");
+ int cmp = normalizedNodeA.compareTo(normalizedNodeB);
+
+ StringBuilder sb = new StringBuilder();
+ if (cmp <= 0) {
+ sb.append(nodeA);
+ sb.append("|");
+ sb.append(nodeB);
+ } else {
+ sb.append(nodeB);
+ sb.append("|");
+ sb.append(nodeA);
+ }
+ return sb.toString();
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
new file mode 100644
index 00000000..f859aae6
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
@@ -0,0 +1,191 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.edges;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.onap.aai.edges.enums.AAIDirection;
+import org.onap.aai.edges.enums.DirectionNotation;
+import org.onap.aai.edges.enums.EdgeField;
+import org.onap.aai.edges.enums.EdgeProperty;
+import org.onap.aai.edges.enums.MultiplicityRule;
+
+import java.util.EnumMap;
+import java.util.Map;
+
+/**
+ * Container for A&AI edge rule information
+ */
+public class EdgeRule {
+ private String from;
+ private String to;
+ private String label;
+ private Direction direction;
+ private MultiplicityRule multiplicityRule;
+ private Map<EdgeProperty, AAIDirection> edgeFields;
+ private boolean isDefaultEdge;
+ private String description;
+
+ /**
+ * Instantiates a new edge rule.
+ *
+ * @param fieldVals - Map<String, String> where first string is
+ * an EdgeField value and second string is the
+ * value of that field
+ */
+ public EdgeRule(Map<String, String> fieldVals) {
+ edgeFields = new EnumMap<>(EdgeProperty.class);
+
+ from = fieldVals.get(EdgeField.FROM.toString());
+ to = fieldVals.get(EdgeField.TO.toString());
+ label = fieldVals.get(EdgeField.LABEL.toString());
+ direction = Direction.valueOf(fieldVals.get(EdgeField.DIRECTION.toString()));
+ multiplicityRule = MultiplicityRule.getValue(fieldVals.get(EdgeField.MULTIPLICITY.toString()));
+
+ for (EdgeProperty prop : EdgeProperty.values()) {
+ String rawVal = fieldVals.get(prop.toString());
+ edgeFields.put(prop, convertNotation(direction, rawVal));
+ }
+
+ isDefaultEdge = Boolean.valueOf(fieldVals.get(EdgeField.DEFAULT.toString()));
+
+ description = fieldVals.get(EdgeField.DESCRIPTION.toString());
+ if (description == null) { //bc description is optional and not in v12 and earlier
+ description = "";
+ }
+ }
+
+ /**
+ * Converts whatever string was in the json for an edge property value into
+ * the appropriate AAIDirection
+ *
+ * @param Direction dir - the edge direction
+ * @param String rawVal - property value from the json, may be
+ * IN, OUT, BOTH, NONE, ${direction}, or !${direction}
+ * @return AAIDirection - IN/OUT/BOTH/NONE if that's the rawVal, or
+ * translates the direction notation into the correct IN/OUT
+ */
+ private AAIDirection convertNotation(Direction dir, String rawVal) {
+ if (AAIDirection.NONE.toString().equals(rawVal)) {
+ return AAIDirection.NONE;
+ } else if (AAIDirection.BOTH.toString().equals(rawVal)) {
+ return AAIDirection.BOTH;
+ } else if (AAIDirection.OUT.toString().equals(rawVal)) {
+ return AAIDirection.OUT;
+ } else if (AAIDirection.IN.toString().equals(rawVal)) {
+ return AAIDirection.IN;
+ }
+
+ DirectionNotation rawDN = DirectionNotation.getValue(rawVal);
+ if (DirectionNotation.DIRECTION.equals(rawDN)) {
+ return AAIDirection.getValue(dir);
+ } else {
+ return AAIDirection.getValue(dir.opposite());
+ }
+ }
+
+ /**
+ * Gets the name of the node type in the "from" field
+ * @return String nodetype
+ */
+ public String getFrom() {
+ return from;
+ }
+
+ /**
+ * Gets the name of the node type in the "to" field
+ * @return String nodetype
+ */
+ public String getTo() {
+ return to;
+ }
+
+ /**
+ * Gets the edge label
+ *
+ * @return String label
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * Gets the multiplicity rule.
+ *
+ * @return MultiplicityRule
+ */
+ public MultiplicityRule getMultiplicityRule() {
+ return multiplicityRule;
+ }
+
+ /**
+ * Gets the edge direction
+ *
+ * @return Direction
+ */
+ public Direction getDirection() {
+ return direction;
+ }
+
+ /**
+ * Gets the value of contains-other-v
+ *
+ * @return the value of contains-other-v
+ */
+ public String getContains() {
+ return edgeFields.get(EdgeProperty.CONTAINS).toString();
+ }
+
+ /**
+ * Gets the value of delete-other-v
+ *
+ * @return the value of delete-other-v
+ */
+ public String getDeleteOtherV() {
+ return edgeFields.get(EdgeProperty.DELETE_OTHER_V).toString();
+ }
+
+ /**
+ * Gets the value of the prevent-delete property
+ *
+ * @return String prevent-delete property value
+ */
+ public String getPreventDelete() {
+ return edgeFields.get(EdgeProperty.PREVENT_DELETE).toString();
+ }
+
+ /**
+ * Returns if this rule is a default or not
+ *
+ * @return boolean
+ */
+ public boolean isDefault() {
+ return isDefaultEdge;
+ }
+
+ /**
+ * Gets the description on the edge rule (if there is one)
+ * @return String description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
new file mode 100644
index 00000000..3029685f
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
@@ -0,0 +1,214 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges;
+
+import org.onap.aai.edges.enums.AAIDirection;
+import org.onap.aai.edges.enums.EdgeField;
+import org.onap.aai.edges.enums.EdgeProperty;
+import org.onap.aai.edges.enums.EdgeType;
+import org.onap.aai.setup.Version;
+
+import com.jayway.jsonpath.Filter;
+import com.jayway.jsonpath.Predicate;
+
+import static com.jayway.jsonpath.Filter.filter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.jayway.jsonpath.Criteria.where;
+
+/**
+ * For querying the edge rules schema (not the database)
+ *
+ */
+public class EdgeRuleQuery {
+ private Filter filter;
+ private Version v;
+ private String nodeA;
+ private String nodeB;
+ private String label;
+ private EdgeType type;
+
+ public static class Builder {
+ //required
+ private String nodeA;
+
+ //optional - null will translate to any value of the param
+ private String nodeB = null;
+ private String label = null;
+ private EdgeType type = null;
+ private Version version = Version.getLatest(); //default
+
+ public Builder(String nodeA) {
+ this.nodeA = nodeA;
+ }
+
+ public Builder(String nodeA, String nodeB) {
+ this.nodeA = nodeA;
+ this.nodeB = nodeB;
+ }
+
+ private String getFirstNodeType() {
+ return nodeA;
+ }
+
+ private String getSecondNodeType() {
+ return nodeB;
+ }
+
+ public Builder label(String label) {
+ this.label = label;
+ return this;
+ }
+
+ private String getLabel() {
+ return label;
+ }
+
+ public Builder edgeType(EdgeType type) {
+ this.type = type;
+ return this;
+ }
+
+ private EdgeType getEdgeType() {
+ return type;
+ }
+
+ public Builder version(Version version) {
+ this.version = version;
+ return this;
+ }
+ private Version getVersion() {
+ return version;
+ }
+
+ public EdgeRuleQuery build() {
+ return new EdgeRuleQuery(this);
+ }
+ }
+
+ private EdgeRuleQuery(Builder builder) {
+ this.v = builder.getVersion();
+ this.nodeA = builder.getFirstNodeType();
+ this.nodeB = builder.getSecondNodeType();
+ this.label = builder.getLabel();
+ this.type = builder.getEdgeType();
+
+ //will cover from A to B case
+ List<Predicate> criteriaFromTo = new ArrayList<>();
+ criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), builder.getSecondNodeType()));
+ //will cover from B to A case - must be separate bc jsonpath won't let me OR predicates >:C
+ List<Predicate> criteriaToFrom = new ArrayList<>();
+ criteriaToFrom.add(buildToFromPart(builder.getSecondNodeType(), builder.getFirstNodeType()));
+
+
+
+ if (builder.getLabel() != null) {
+ Predicate labelPred = addLabel(builder.getLabel());
+ criteriaFromTo.add(labelPred);
+ criteriaToFrom.add(labelPred);
+ }
+
+ if (builder.getEdgeType() != null) {
+ Predicate typePred = addType(builder.getEdgeType());
+ criteriaFromTo.add(typePred);
+ criteriaToFrom.add(typePred);
+ }
+
+
+
+ this.filter = filter(criteriaFromTo).or(filter(criteriaToFrom));
+ }
+
+ private Predicate buildToFromPart(String from, String to) {
+ if (from == null && to == null) { //shouldn't ever happen though
+ throw new IllegalStateException("must have at least one node defined");
+ }
+
+ Predicate p;
+
+ if (to == null) {
+ p = where(EdgeField.FROM.toString()).is(from);
+ } else if (from == null) {
+ p = where(EdgeField.TO.toString()).is(to);
+ } else {
+ p = where(EdgeField.FROM.toString()).is(from).and(EdgeField.TO.toString()).is(to);
+ }
+
+ return p;
+ }
+
+ private Predicate addLabel(String label) {
+ return where(EdgeField.LABEL.toString()).is(label);
+ }
+
+ private Predicate addType(EdgeType type) {
+ if (type == EdgeType.COUSIN) {
+ return where(EdgeProperty.CONTAINS.toString()).is(AAIDirection.NONE.toString());
+ } else { //equals TREE
+ return where(EdgeProperty.CONTAINS.toString()).ne(AAIDirection.NONE.toString());
+ }
+ }
+
+ /**
+ * Provides the JsonPath filter for actually querying the edge rule schema files
+ * @return Filter
+ */
+ public Filter getFilter() {
+ return this.filter;
+ }
+
+ /**
+ * So the Ingestor knows which version of the rules to search
+ * @return the Version
+ */
+ public Version getVersion() {
+ return this.v;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("EdgeRuleQuery with filter params node type: ").append(nodeA);
+
+ if (nodeB != null) {
+ sb.append(", node type: ").append(nodeB);
+ }
+
+ if (label != null) {
+ sb.append(", label: ").append(label);
+ }
+
+ sb.append(", type: ");
+ if (type != null) {
+ sb.append(type.toString());
+ } else {
+ sb.append("any");
+ }
+
+ sb.append(", for version: ").append(v.toString()).append(".");
+ return sb.toString();
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
new file mode 100644
index 00000000..3f748a50
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
@@ -0,0 +1,62 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.edges.enums;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+
+public enum AAIDirection {
+ IN, OUT, BOTH, NONE;
+
+ public AAIDirection opposite() {
+ if (this.equals(OUT)) {
+ return IN;
+ } else if (this.equals(IN)) {
+ return OUT;
+ } else {
+ return BOTH;
+ }
+ }
+
+ public static AAIDirection getValue(String aaidir) {
+ if (OUT.toString().equals(aaidir)) {
+ return OUT;
+ } else if (IN.toString().equals(aaidir)) {
+ return IN;
+ } else if (NONE.toString().equals(aaidir)) {
+ return NONE;
+ } else { //should be BOTH
+ return BOTH;
+ }
+ }
+
+ public static AAIDirection getValue(Direction dir) {
+ if (dir == Direction.OUT) {
+ return OUT;
+ } else if (dir == Direction.IN) {
+ return IN;
+ } else if (dir == Direction.BOTH) {
+ return BOTH;
+ } else {
+ return NONE;
+ }
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
new file mode 100644
index 00000000..203249a4
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
@@ -0,0 +1,49 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges.enums;
+
+public enum DirectionNotation {
+ DIRECTION("${direction}"),
+ OPPOSITE("!${direction}");
+
+ private final String val;
+
+ DirectionNotation(String dir) {
+ this.val = dir;
+ }
+
+ public static DirectionNotation getValue(String val) {
+ if (DIRECTION.toString().equals(val)) {
+ return DIRECTION;
+ } else if (OPPOSITE.toString().equals(val)) {
+ return OPPOSITE;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.val;
+ }
+} \ No newline at end of file
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
new file mode 100644
index 00000000..3e896f61
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
@@ -0,0 +1,50 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges.enums;
+
+/**
+ * Enumerates all edge rule fields
+ *
+ */
+public enum EdgeField {
+ FROM("from"),
+ TO("to"),
+ LABEL("label"),
+ DIRECTION("direction"),
+ MULTIPLICITY("multiplicity"),
+ CONTAINS("contains-other-v"),
+ DELETE_OTHER_V("delete-other-v"),
+ PREVENT_DELETE("prevent-delete"),
+ DEFAULT("default"),
+ DESCRIPTION("description");
+ private final String name;
+
+ private EdgeField(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
new file mode 100644
index 00000000..2f6afa47
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
@@ -0,0 +1,43 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges.enums;
+
+/**
+ * Enumerates edge rule fields which are edge properties
+ * (ie which have a directional value)
+ */
+public enum EdgeProperty {
+ CONTAINS("contains-other-v"),
+ DELETE_OTHER_V("delete-other-v"),
+ PREVENT_DELETE("prevent-delete");
+ private final String name;
+
+ private EdgeProperty(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
new file mode 100644
index 00000000..00dce0fd
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
@@ -0,0 +1,27 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.edges.enums;
+
+public enum EdgeType {
+ COUSIN,
+ TREE;
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
new file mode 100644
index 00000000..4fc8938d
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
@@ -0,0 +1,41 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.edges.enums;
+
+public enum MultiplicityRule {
+ MANY2ONE,
+ ONE2MANY,
+ ONE2ONE,
+ MANY2MANY;
+
+ public static MultiplicityRule getValue(String multiplicity) {
+ if ("Many2Many".equalsIgnoreCase(multiplicity)) {
+ return MANY2MANY;
+ } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
+ return ONE2MANY;
+ } else if ("One2One".equalsIgnoreCase(multiplicity)) {
+ return ONE2ONE;
+ } else { //should be "Many2One"
+ return MANY2ONE;
+ }
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
new file mode 100644
index 00000000..ebb9739b
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
@@ -0,0 +1,29 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges.exceptions;
+
+public class AmbiguousRuleChoiceException extends Exception {
+ public AmbiguousRuleChoiceException(String msg) {
+ super(msg);
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
new file mode 100644
index 00000000..e1a8fe6b
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
@@ -0,0 +1,29 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges.exceptions;
+
+public class EdgeRuleNotFoundException extends Exception {
+ public EdgeRuleNotFoundException(String msg) {
+ super(msg);
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
new file mode 100644
index 00000000..5a29806d
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
@@ -0,0 +1,107 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.nodes;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.xml.bind.JAXBException;
+
+import org.eclipse.persistence.jaxb.JAXBContextProperties;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.Version;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+/**
+ * NodeIngestor - ingests A&AI OXM files per given config, serves DynamicJAXBContext per version
+ */
+public class NodeIngestor {
+
+ private Map<Version, DynamicJAXBContext> versionContextMap = new EnumMap<>(Version.class);
+
+ @Autowired
+ /**
+ * Instantiates the NodeIngestor bean.
+ *
+ * @param translator - ConfigTranslator autowired in by Spring framework which
+ * contains the configuration information needed to ingest the desired files.
+ */
+ public NodeIngestor(ConfigTranslator translator) {
+ Map<Version, List<String>> filesToIngest = translator.getNodeFiles();
+
+ try {
+ for (Entry<Version, List<String>> verFiles : filesToIngest.entrySet()) {
+ Version v = verFiles.getKey();
+ List<String> files = verFiles.getValue();
+ final DynamicJAXBContext ctx = ingest(files);
+ versionContextMap.put(v, ctx);
+ }
+ } catch (FileNotFoundException | JAXBException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ /**
+ * Ingests the given OXM files into DynamicJAXBContext
+ *
+ * @param files - List<String> of full filenames (ie including the path) to be ingested
+ *
+ * @return DynamicJAXBContext including schema information from all given files
+ *
+ * @throws FileNotFoundException if an OXM file can't be found
+ * @throws JAXBException if there's an error creating the DynamicJAXBContext
+ */
+ private DynamicJAXBContext ingest(List<String> files) throws FileNotFoundException, JAXBException {
+ List<InputStream> streams = new ArrayList<>();
+
+ for (String name : files) {
+ streams.add(new FileInputStream(new File(name)));
+ }
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, streams);
+ return DynamicJAXBContextFactory.createContextFromOXM(this.getClass().getClassLoader(), properties);
+ }
+
+ /**
+ * Gets the DynamicJAXBContext for the given version
+ *
+ * @param Version v
+ * @return DynamicJAXBContext
+ */
+ public DynamicJAXBContext getContextForVersion(Version v) {
+ return versionContextMap.get(v);
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
new file mode 100644
index 00000000..b34622de
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
@@ -0,0 +1,61 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.setup;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Converts the contents of the schema config file
+ * (which lists which schema files to be loaded) to
+ * the format the Ingestors can work with.
+ *
+ */
+public abstract class ConfigTranslator {
+ protected SchemaLocationsBean bean;
+
+ @Autowired
+ public ConfigTranslator(SchemaLocationsBean bean) {
+ this.bean = bean;
+ }
+
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the NodeIngestor
+ *
+ * @return Map of Version to the list of (string) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<Version, List<String>> getNodeFiles();
+
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the EdgeIngestor
+ *
+ * @return Map of Version to the List of (String) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<Version, List<String>> getEdgeFiles();
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
new file mode 100644
index 00000000..96c63447
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.setup;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+@Configuration
+@PropertySource("classpath:schemaIngest.properties")
+@PropertySource(value = "file:${schemaIngestPropLoc}", ignoreResourceNotFound=true)
+public class SchemaLocationsBean {
+ /*
+ * Per Spring documentation, the last PropertySource that works will
+ * be applied. Here, schemaIngestPropLoc will be an environment variable
+ * set on install that tells Spring where to look for the schema
+ * ingest properties file (and the actual filename), but the former
+ * PropertySource gives the default of looking on the classpath for
+ * schemaIngest.properties in case that second one doesn't work.
+ *
+ * The schemaIngest.properties file (or its equivalent if you choose
+ * to name it otherwise) must contain the entries the below @Value
+ * annotations are looking for.
+ */
+
+ @Value("${schemaConfig}")
+ private String schemaConfigLoc;
+
+ @Value("${nodeDir}")
+ private String nodeDirectory;
+
+ @Value("${edgeDir}")
+ private String edgeDirectory;
+
+ /**
+ * @return the file name/location with the list of schema files to be ingested
+ */
+ public String getSchemaConfigLocation() {
+ return schemaConfigLoc;
+ }
+
+ /**
+ * Sets the name/location of the file with the list of schema files to ingest
+ *
+ * @param String schemaConfigLoc - the file name/location
+ */
+ public void setSchemaConfigLocation(String schemaConfigLoc) {
+ this.schemaConfigLoc = schemaConfigLoc;
+ }
+
+ /**
+ * @return the location of the OXM files
+ */
+ public String getNodeDirectory() {
+ return nodeDirectory;
+ }
+
+ /**
+ * Sets the location of the OXM files
+ *
+ * @param String nodeDirectory - the location of the OXM files
+ */
+ public void setNodeDirectory(String nodeDirectory) {
+ this.nodeDirectory = nodeDirectory;
+ }
+
+ /**
+ * @return the location of the edge rule json files
+ */
+ public String getEdgeDirectory() {
+ return edgeDirectory;
+ }
+
+ /**
+ * Sets the location of the edge rule json files
+ *
+ * @param String edgeDirectory - the location of the edge rule files
+ */
+ public void setEdgeDirectory(String edgeDirectory) {
+ this.edgeDirectory = edgeDirectory;
+ }
+
+ //this allows the code to actually read the value from the config file
+ //without this those strings get set to literally "${edgeDir}" etc
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java
new file mode 100644
index 00000000..8cc39426
--- /dev/null
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Version.java
@@ -0,0 +1,40 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.setup;
+
+public enum Version {
+ V8,
+ V9,
+ V10,
+ V11,
+ V12,
+ V13;
+
+ public static boolean isLatest(Version v) {
+ return getLatest().equals(v);
+ }
+
+ public static Version getLatest(){
+ Version[] vals = values(); //guaranteed to be in declaration order
+ return vals[vals.length-1]; //requires we always have the latest version listed last
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
new file mode 100644
index 00000000..9f6d67a1
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
@@ -0,0 +1,306 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges;
+
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.onap.aai.edges.enums.AAIDirection;
+import org.onap.aai.edges.enums.MultiplicityRule;
+import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.Version;
+import org.onap.aai.testutils.TestUtilConfigTranslator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Multimap;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SchemaLocationsBean.class, TestUtilConfigTranslator.class, EdgeIngestor.class})
+@SpringBootTest
+public class EdgeIngestorTest {
+ @Autowired
+ EdgeIngestor ei;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void getRulesTest1() throws EdgeRuleNotFoundException {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
+ Multimap<String, EdgeRule> results = ei.getRules(q);
+ assertTrue(results.size() == 5);
+ assertTrue(results.containsKey("bar|foo"));
+
+ assertTrue(2 == results.get("bar|foo").size());
+ boolean seenLabel1 = false;
+ boolean seenLabel2 = false;
+ for(EdgeRule r : results.get("bar|foo")) {
+ if ("eats".equals(r.getLabel())) {
+ seenLabel1 = true;
+ }
+ if ("eatz".equals(r.getLabel())) {
+ seenLabel2 = true;
+ }
+ }
+ assertTrue(seenLabel1 && seenLabel2);
+
+ assertTrue(results.containsKey("baz|foo"));
+ assertTrue(results.containsKey("foo|quux"));
+ assertTrue(results.containsKey("dog|foo"));
+ }
+
+ @Test
+ public void getRulesTest2() throws EdgeRuleNotFoundException {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("puppy", "dog").build();
+ Multimap<String, EdgeRule> results = ei.getRules(q);
+ assertTrue(results.size() == 1);
+ assertTrue(results.containsKey("dog|puppy"));
+ Collection<EdgeRule> cr = results.get("dog|puppy");
+ for (EdgeRule r : cr) {
+ assertTrue("dog".equals(r.getFrom()));
+ assertTrue("puppy".equals(r.getTo()));
+ assertTrue("caresFor".equals(r.getLabel()));
+ assertTrue(Direction.OUT.equals(r.getDirection()));
+ assertTrue("One2Many".equalsIgnoreCase(r.getMultiplicityRule().toString()));
+ assertTrue("NONE".equals(r.getContains()));
+ assertTrue("OUT".equals(r.getDeleteOtherV()));
+ assertTrue("NONE".equals(r.getPreventDelete()));
+ assertTrue(r.isDefault());
+ }
+ }
+
+ @Test
+ public void getRulesTest3() throws EdgeRuleNotFoundException {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").version(Version.V11).build();
+ Multimap<String, EdgeRule> results = ei.getRules(q);
+ assertTrue(results.size() == 4);
+ assertTrue(results.containsKey("lag-interface|l-interface"));
+ assertTrue(results.containsKey("l-interface|logical-link"));
+ assertTrue(results.get("l-interface|logical-link").size() == 3);
+ }
+
+ @Test
+ public void getRulesNoneFound() throws EdgeRuleNotFoundException {
+ thrown.expect(EdgeRuleNotFoundException.class);
+ thrown.expectMessage("No rules found for");
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").build();
+ ei.getRules(q);
+ }
+
+ @Test
+ public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("notation", "parent").build();
+ EdgeRule result = ei.getRule(q);
+ assertTrue("parent".equals(result.getFrom()));
+ assertTrue("notation".equals(result.getTo()));
+ assertTrue("has".equals(result.getLabel()));
+ assertTrue(Direction.OUT.equals(result.getDirection()));
+ assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule()));
+ assertTrue(AAIDirection.OUT.toString().equals(result.getContains()));
+ assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV()));
+ assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete()));
+ assertTrue("parent contains notation".equals(result.getDescription()));
+ }
+
+ @Test
+ public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(Version.V11).build();
+ EdgeRule res = ei.getRule(q);
+ assertTrue(res.isDefault());
+ assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel()));
+ }
+
+ @Test
+ public void getRuleWithNonDefault() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").label("org.onap.relationships.inventory.Source").version(Version.V11).build();
+ EdgeRule res = ei.getRule(q);
+ assertFalse(res.isDefault());
+ assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel()));
+ }
+
+ @Test
+ public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ thrown.expect(EdgeRuleNotFoundException.class);
+ thrown.expectMessage("No rule found for");
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","nonexistent").build();
+ ei.getRule(q);
+ }
+
+ @Test
+ public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ thrown.expect(AmbiguousRuleChoiceException.class);
+ thrown.expectMessage("No way to select single rule from these pairs:");
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
+ ei.getRule(q);
+ }
+
+ @Test
+ public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ thrown.expect(AmbiguousRuleChoiceException.class);
+ thrown.expectMessage("Multiple defaults found.");
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed","plant").version(Version.V11).build();
+ ei.getRule(q);
+ }
+
+ @Test
+ public void getRuleNoDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ thrown.expect(AmbiguousRuleChoiceException.class);
+ thrown.expectMessage("No default found.");
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(Version.V11).build();
+ ei.getRule(q);
+ }
+
+ @Test
+ public void hasRuleTest() {
+ assertTrue(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").version(Version.V11).build()));
+ assertFalse(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").build()));
+ }
+
+ @Test
+ public void getCousinRulesTest() {
+ Multimap<String, EdgeRule> results = ei.getCousinRules("dog");
+ assertTrue(results.size() == 2);
+ assertTrue(results.containsKey("dog|puppy"));
+ assertTrue(results.containsKey("dog|foo"));
+ }
+
+ @Test
+ public void getCousinRulesWithVersionTest() {
+ Multimap<String, EdgeRule> results = ei.getCousinRules("foo", Version.V10);
+ assertTrue(results.size() == 2);
+ assertTrue(results.containsKey("bar|foo"));
+ assertTrue(results.get("bar|foo").size() == 2);
+ }
+
+ @Test
+ public void getCousinsNoneInVersionTest() {
+ Multimap<String, EdgeRule> results = ei.getCousinRules("foo", Version.V11);
+ assertTrue(results.isEmpty());
+ }
+
+ @Test
+ public void hasCousinTest() {
+ assertTrue(ei.hasCousinRule("foo"));
+ assertTrue(ei.hasCousinRule("foo", Version.V10));
+ assertFalse(ei.hasCousinRule("parent"));
+ assertFalse(ei.hasCousinRule("foo", Version.V11));
+ }
+
+ @Test
+ public void getChildRulesTest() {
+ Multimap<String, EdgeRule> results = ei.getChildRules("parent");
+ assertTrue(results.size() == 6);
+ assertTrue(results.containsKey("notation|parent"));
+ assertTrue(results.containsKey("not-notation|parent"));
+ assertTrue(results.containsKey("out-out|parent"));
+ assertTrue(results.containsKey("in-in|parent"));
+ assertTrue(results.containsKey("in-out|parent"));
+ assertTrue(results.containsKey("out-in|parent"));
+ }
+
+ @Test
+ public void getChildRulesWithVersionTest() {
+ Multimap<String, EdgeRule> results = ei.getChildRules("foo", Version.V10);
+ assertTrue(results.size() == 2);
+ assertTrue(results.containsKey("baz|foo"));
+ assertTrue(results.containsKey("foo|quux"));
+ }
+
+ @Test
+ public void getChildRulesNoneInVersionTest() {
+ Multimap<String, EdgeRule> results = ei.getChildRules("foo", Version.V11);
+ assertTrue(results.isEmpty());
+ }
+
+ @Test
+ public void hasChildTest() {
+ assertTrue(ei.hasChildRule("foo"));
+ assertTrue(ei.hasChildRule("foo", Version.V10));
+ assertFalse(ei.hasChildRule("puppy"));
+ assertFalse(ei.hasChildRule("foo", Version.V11));
+ }
+
+ @Test
+ public void getParentRulesTest() {
+ Multimap<String, EdgeRule> results = ei.getParentRules("parent");
+ assertTrue(results.size() == 6);
+ assertTrue(results.containsKey("grandparent1|parent"));
+ assertTrue(results.containsKey("grandparent2|parent"));
+ assertTrue(results.containsKey("grandparent3|parent"));
+ assertTrue(results.containsKey("grandparent4|parent"));
+ assertTrue(results.containsKey("grandparent5|parent"));
+ assertTrue(results.containsKey("grandparent6|parent"));
+ }
+
+ @Test
+ public void getParentRulesWithVersionTest() {
+ Multimap<String, EdgeRule> results = ei.getParentRules("baz", Version.V10);
+ assertTrue(results.size() == 1);
+ assertTrue(results.containsKey("baz|foo"));
+ }
+
+ @Test
+ public void getParentRulesNoneInVersionTest() {
+ Multimap<String, EdgeRule> results = ei.getParentRules("baz", Version.V11);
+ assertTrue(results.isEmpty());
+ }
+
+ @Test
+ public void hasParentTest() {
+ assertTrue(ei.hasParentRule("parent"));
+ assertTrue(ei.hasParentRule("quux", Version.V10));
+ assertFalse(ei.hasParentRule("puppy"));
+ assertFalse(ei.hasParentRule("foo", Version.V11));
+ }
+
+ @Test
+ public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException {
+ Multimap<String, EdgeRule> res = ei.getAllCurrentRules();
+ assertTrue(res.size() == 18);
+ }
+
+ @Test
+ public void getAllRulesTest() throws EdgeRuleNotFoundException {
+ Multimap<String, EdgeRule> res = ei.getAllRules(Version.V10);
+ assertTrue(res.size() == 4);
+ assertTrue(res.containsKey("bar|foo"));
+ assertTrue(res.get("bar|foo").size() == 2);
+ assertTrue(res.containsKey("baz|foo"));
+ assertTrue(res.containsKey("foo|quux"));
+
+ thrown.expect(EdgeRuleNotFoundException.class);
+ thrown.expectMessage("No rules found for version V9.");
+ ei.getAllRules(Version.V9);
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
new file mode 100644
index 00000000..74aceb51
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
@@ -0,0 +1,58 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.Version;
+import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Multimap;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SchemaLocationsBean.class, ConfigTranslatorForWiringTest.class, EdgeIngestor.class})
+@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngestWiringTest.properties"})
+@SpringBootTest
+public class EdgeIngestorWiringTest {
+ @Autowired
+ EdgeIngestor ei;
+
+ @Test
+ public void test() throws EdgeRuleNotFoundException {
+ assertNotNull(ei);
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").label("dancesWith").version(Version.V10).build();
+ Multimap<String, EdgeRule> results = ei.getRules(q);
+ assertTrue(results.size() == 1);
+ assertTrue(results.containsKey("foo|quux"));
+ }
+
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java
new file mode 100644
index 00000000..f21246cb
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java
@@ -0,0 +1,135 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.edges;
+
+import static org.junit.Assert.*;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Scanner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.edges.enums.EdgeType;
+
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.JsonPath;
+
+public class EdgeRuleQueryTest {
+ private DocumentContext testRules;
+ private String readStart = "$.rules.[?]";
+
+ /* **** DATA SETUP **** */
+ @Before
+ public void setup() {
+ InputStream is = getClass().getResourceAsStream("/edgeRules/test.json");
+
+ Scanner scanner = new Scanner(is);
+ String json = scanner.useDelimiter("\\Z").next();
+ scanner.close();
+
+ this.testRules = JsonPath.parse(json);
+ }
+
+ /* **** TESTS **** */
+ @Test
+ public void testFromToSingle() {
+ //rule defined from quux to foo
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+
+ assertTrue(results.size() == 1);
+ }
+
+ @Test
+ public void testToFromSingle() {
+ //rule defined from quux to foo, this is flipped
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "quux").build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+
+ assertTrue(results.size() == 1);
+ }
+
+ @Test
+ public void testFromToMultiple() {
+ //rules have two from foo to bar
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "bar").build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+ assertTrue(results.size() == 2);
+ }
+
+ @Test
+ public void testToFromMultiple() {
+ //rules have two from foo to bar
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("bar", "foo").build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+
+ assertTrue(results.size() == 2);
+ assertTrue(!(results.get(0).toString().equals(results.get(1).toString())));
+ }
+
+ @Test
+ public void testJustFrom() {
+ //there are 4 foo rules (foo>bar, foo>bar, foo>baz, quux>foo)
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+ assertTrue(results.size() == 4);
+
+ //there are 2 bar rules
+ EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bar").build();
+ List<Object> results2 = testRules.read(readStart, q2.getFilter());
+ assertTrue(results2.size() == 2);
+ }
+
+ @Test
+ public void testWithLabel() {
+ //there are foo >eats> bar and foo >eatz> bar
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo","bar").label("eatz").build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+ assertTrue(results.size() == 1);
+ assertTrue(results.get(0).toString().contains("eatz"));
+ }
+
+ @Test
+ public void testCousin() {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.COUSIN).build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+ assertTrue(results.size() == 2);
+
+ EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("foo", "bar").edgeType(EdgeType.COUSIN).label("eats").build();
+ List<Object> results2 = testRules.read(readStart, q2.getFilter());
+ assertTrue(results2.size() == 1);
+ assertTrue(results2.get(0).toString().contains("eats"));
+
+ EdgeRuleQuery q3 = new EdgeRuleQuery.Builder("foo","quux").edgeType(EdgeType.COUSIN).build();
+ List<Object> results3 = testRules.read(readStart, q3.getFilter());
+ assertTrue(results3.isEmpty());
+ }
+
+ @Test
+ public void testTree() {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.TREE).build();
+ List<Object> results = testRules.read(readStart, q.getFilter());
+ assertTrue(results.size() == 2);
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
new file mode 100644
index 00000000..08507a34
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.nodes;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.persistence.dynamic.DynamicEntity;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.Version;
+import org.onap.aai.testutils.TestUtilConfigTranslator;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SchemaLocationsBean.class, TestUtilConfigTranslator.class, NodeIngestor.class})
+@SpringBootTest
+public class NodeIngestorTest {
+ @Autowired
+ NodeIngestor ni;
+
+ //set thrown.expect to whatever a specific test needs
+ //this establishes a default of expecting no exceptions to be thrown
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void test() {
+ DynamicJAXBContext ctx10 = ni.getContextForVersion(Version.V10);
+
+ //should work bc Foo is valid in test_network_v10 schema
+ DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
+ foo10.set("fooId","bar");
+ assertTrue("bar".equals(foo10.get("fooId")));
+
+ //should work bc Bar is valid in test_business_v10 schema
+ DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
+ bar10.set("barId","bar2");
+ assertTrue("bar2".equals(bar10.get("barId")));
+
+
+ DynamicJAXBContext ctx11 = ni.getContextForVersion(Version.V11);
+
+ //should work bc Foo.quantity is valid in test_network_v11 schema
+ DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
+ foo11.set("quantity","12");
+ assertTrue("12".equals(foo11.get("quantity")));
+
+ DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
+ quux11.set("qManagerName","some guy");
+ assertTrue("some guy".equals(quux11.get("qManagerName")));
+
+
+ thrown.expect(IllegalArgumentException.class);
+ //should fail bc Quux not in v10 test schema
+ ctx10.newDynamicEntity("Quux");
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
new file mode 100644
index 00000000..e62cc6ab
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
@@ -0,0 +1,57 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.nodes;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.persistence.dynamic.DynamicEntity;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.Version;
+import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SchemaLocationsBean.class, ConfigTranslatorForWiringTest.class, NodeIngestor.class})
+@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngestWiringTest.properties"})
+@SpringBootTest
+public class NodeIngestorWiringTest {
+ @Autowired
+ NodeIngestor ni;
+
+ @Test
+ public void test() {
+ DynamicJAXBContext ctx10 = ni.getContextForVersion(Version.V10);
+
+ //should work bc Bar is valid in test_business_v10 schema
+ DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
+ bar10.set("barId","bar2");
+ assertTrue("bar2".equals(bar10.get("barId")));
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java
new file mode 100644
index 00000000..9d66551b
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java
@@ -0,0 +1,61 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.setup;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SchemaLocationsBean.class, ConfigTranslatorForWiringTest.class})
+@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngestWiringTest.properties"})
+@SpringBootTest
+public class ConfigTranslatorWiringTest {
+ @Autowired
+ ConfigTranslator ct;
+
+ @Test
+ public void test() {
+ assertNotNull(ct);
+ Map<Version, List<String>> nodes = ct.getNodeFiles();
+ assertTrue(nodes.containsKey(Version.V10));
+ assertTrue(1 == nodes.get(Version.V10).size());
+ assertTrue("src/test/resources/oxm/test_business_v10.xml".equals(nodes.get(Version.V10).get(0)));
+
+ Map<Version, List<String>> edges = ct.getEdgeFiles();
+ assertTrue(edges.containsKey(Version.V10));
+ assertTrue(1 == edges.get(Version.V10).size());
+ assertTrue("src/test/resources/edgeRules/test.json".equals(edges.get(Version.V10).get(0)));
+ }
+
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java
new file mode 100644
index 00000000..5074f913
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java
@@ -0,0 +1,46 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.setup;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SchemaLocationsBean.class})
+public class SchemaLocationsBeanDefaultInjectionTest {
+ @Autowired
+ SchemaLocationsBean bean;
+
+ @Test
+ public void test() {
+ assertNotNull(bean);
+ assertTrue("foo".equals(bean.getSchemaConfigLocation()));
+ assertTrue("bar".equals(bean.getNodeDirectory()));
+ assertTrue("quux".equals(bean.getEdgeDirectory()));
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java
new file mode 100644
index 00000000..f9d6b620
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java
@@ -0,0 +1,48 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.setup;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SchemaLocationsBean.class})
+@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/forWiringTests/schemaIngest2.properties"})
+public class SchemaLocationsBeanEnvVarInjectionTest {
+ @Autowired
+ SchemaLocationsBean bean;
+
+ @Test
+ public void test() {
+ assertNotNull(bean);
+ assertTrue("testConfig.json".equals(bean.getSchemaConfigLocation()));
+ assertTrue("bloop/blap".equals(bean.getNodeDirectory()));
+ assertTrue("different".equals(bean.getEdgeDirectory()));
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java
new file mode 100644
index 00000000..0a22bbb0
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java
@@ -0,0 +1,46 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.setup;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:forWiringTests/testContext.xml"})
+public class SchemaLocationsBeanXMLSetterTest {
+ @Autowired
+ SchemaLocationsBean bean;
+
+ @Test
+ public void test() {
+ assertNotNull(bean);
+ assertTrue("fromXML".equals(bean.getSchemaConfigLocation()));
+ assertTrue("whatAnXML".equals(bean.getNodeDirectory()));
+ assertTrue("XMLwiringYAY".equals(bean.getEdgeDirectory()));
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java
new file mode 100644
index 00000000..4604b045
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java
@@ -0,0 +1,46 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.setup;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:forWiringTests/testUsingPropFileContext.xml"})
+public class SchemaLocationsBeanXMLSetterWithPropFileTest {
+ @Autowired
+ SchemaLocationsBean bean;
+
+ @Test
+ public void test() {
+ assertNotNull(bean);
+ assertTrue("imatest".equals(bean.getSchemaConfigLocation()));
+ assertTrue("andIMalittleteapot".equals(bean.getNodeDirectory()));
+ assertTrue("meh".equals(bean.getEdgeDirectory()));
+ }
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java
new file mode 100644
index 00000000..5e1b6c82
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java
@@ -0,0 +1,60 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.testutils;
+
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.Version;
+
+public class ConfigTranslatorForWiringTest extends ConfigTranslator {
+
+ public ConfigTranslatorForWiringTest(SchemaLocationsBean bean) {
+ super(bean);
+ }
+
+ @Override
+ public Map<Version, List<String>> getNodeFiles() {
+ String f = bean.getNodeDirectory() + "test_business_v10.xml";
+ List<String> files = new ArrayList<>();
+ files.add(f);
+ Map<Version, List<String>> mp = new EnumMap<>(Version.class);
+ mp.put(Version.V10, files);
+ return mp;
+ }
+
+ @Override
+ public Map<Version, List<String>> getEdgeFiles() {
+ String f = bean.getEdgeDirectory() + "test.json";
+ List<String> files = new ArrayList<>();
+ files.add(f);
+ Map<Version, List<String>> mp = new EnumMap<>(Version.class);
+ mp.put(Version.V10, files);
+ return mp;
+ }
+
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java
new file mode 100644
index 00000000..785b7403
--- /dev/null
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java
@@ -0,0 +1,76 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.testutils;
+
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.Version;
+
+public class TestUtilConfigTranslator extends ConfigTranslator {
+
+ public TestUtilConfigTranslator(SchemaLocationsBean bean) {
+ super(bean);
+ }
+
+ @Override
+ public Map<Version, List<String>> getNodeFiles() {
+ List<String> files10 = new ArrayList<>();
+ files10.add("src/test/resources/oxm/test_network_v10.xml");
+ files10.add("src/test/resources/oxm/test_business_v10.xml");
+
+ List<String> files11 = new ArrayList<>();
+ files11.add("src/test/resources/oxm/test_network_v11.xml");
+ files11.add("src/test/resources/oxm/test_business_v11.xml");
+
+ Map<Version, List<String>> input = new EnumMap<>(Version.class);
+ input.put(Version.V10, files10);
+ input.put(Version.V11, files11);
+ return input;
+ }
+
+ @Override
+ public Map<Version, List<String>> getEdgeFiles() {
+ List<String> files = new ArrayList<>();
+ files.add("src/test/resources/edgeRules/test.json");
+ files.add("src/test/resources/edgeRules/test2.json");
+ files.add("src/test/resources/edgeRules/otherTestRules.json");
+ Map<Version, List<String>> input = new EnumMap<>(Version.class);
+ input.put(Version.getLatest(), files);
+
+ List<String> files2 = new ArrayList<>();
+ files2.add("src/test/resources/edgeRules/test.json");
+ input.put(Version.V10, files2);
+
+ List<String> files3 = new ArrayList<>();
+ files3.add("src/test/resources/edgeRules/test3.json");
+ files3.add("src/test/resources/edgeRules/defaultEdgesTest.json");
+ input.put(Version.V11, files3);
+
+ return input;
+ }
+}
diff --git a/aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json b/aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json
new file mode 100644
index 00000000..2f4baed6
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/edgeRules/defaultEdgesTest.json
@@ -0,0 +1,52 @@
+{
+ "rules": [
+ {
+ "from": "apple",
+ "to": "orange",
+ "label": "sitsBy",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "default": "false",
+ "description":"for testing pairs with no default"
+ },
+ {
+ "from": "apple",
+ "to": "orange",
+ "label": "makesSaladWith",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "default": "false",
+ "description":"for testing pairs with no default"
+ },
+ {
+ "from": "seed",
+ "to": "plant",
+ "label": "grows",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "NONE",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "default": "true",
+ "description":""
+ },
+ {
+ "from": "seed",
+ "to": "plant",
+ "label": "becomes",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "OUT",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "default": "true",
+ "description":""
+ }
+ ]
+} \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json b/aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json
new file mode 100644
index 00000000..881239f6
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/edgeRules/otherTestRules.json
@@ -0,0 +1,136 @@
+{
+ "rules": [
+ {
+ "from": "parent",
+ "to": "notation",
+ "label": "has",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "${direction}",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contains notation"
+ },
+ {
+ "from": "not-notation",
+ "to": "parent",
+ "label": "contains",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contains not-notation"
+ },
+ {
+ "from": "parent",
+ "to": "out-out",
+ "label": "eats",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "OUT",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contains out-out"
+ },
+ {
+ "from": "parent",
+ "to": "in-in",
+ "label": "verbs",
+ "direction": "IN",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "IN",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contains in-in"
+ },
+ {
+ "from": "out-in",
+ "to": "parent",
+ "label": "alarms",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "IN",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contains out-in"
+ },
+ {
+ "from": "in-out",
+ "to": "parent",
+ "label": "befriends",
+ "direction": "IN",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "OUT",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contains in-out"
+ },
+ {
+ "from": "parent",
+ "to": "grandparent1",
+ "label": "has",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contained by grandparent1"
+ },
+ {
+ "from": "grandparent2",
+ "to": "parent",
+ "label": "contains",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "${direction}",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contained by grandparent2"
+ },
+ {
+ "from": "parent",
+ "to": "grandparent3",
+ "label": "eats",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "IN",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contained by grandparent3"
+ },
+ {
+ "from": "parent",
+ "to": "grandparent4",
+ "label": "verbs",
+ "direction": "IN",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "OUT",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contained by grandparent4"
+ },
+ {
+ "from": "grandparent5",
+ "to": "parent",
+ "label": "alarms",
+ "direction": "OUT",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "OUT",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contained by grandparent5"
+ },
+ {
+ "from": "grandparent6",
+ "to": "parent",
+ "label": "befriends",
+ "direction": "IN",
+ "multiplicity": "Many2Many",
+ "contains-other-v": "IN",
+ "delete-other-v": "NONE",
+ "prevent-delete": "NONE",
+ "description": "parent contained by grandparent6"
+ }
+ ]
+} \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test.json b/aai-schema-ingest/src/test/resources/edgeRules/test.json
new file mode 100644
index 00000000..66691ebf
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/edgeRules/test.json
@@ -0,0 +1,48 @@
+{
+ "rules": [
+ {
+ "from": "foo",
+ "to": "bar",
+ "label": "eats",
+ "direction": "OUT",
+ "multiplicity": "One2Many",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "Hard to describe"
+ },
+ {
+ "from": "foo",
+ "to": "bar",
+ "label": "eatz",
+ "direction": "IN",
+ "multiplicity": "One2Many",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "Hard to describe"
+ },
+ {
+ "from": "foo",
+ "to": "baz",
+ "label": "isVeryHappyAbout",
+ "direction": "OUT",
+ "multiplicity": "One2Many",
+ "contains-other-v": "${direction}",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "Hard to describe"
+ },
+ {
+ "from": "quux",
+ "to": "foo",
+ "label": "dancesWith",
+ "direction": "IN",
+ "multiplicity": "One2Many",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "Hard to describe"
+ }
+ ]
+} \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test2.json b/aai-schema-ingest/src/test/resources/edgeRules/test2.json
new file mode 100644
index 00000000..7d94e41c
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/edgeRules/test2.json
@@ -0,0 +1,27 @@
+{
+ "rules": [
+ {
+ "from": "foo",
+ "to": "dog",
+ "label": "pets",
+ "direction": "OUT",
+ "multiplicity": "One2Many",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "Hard to describe"
+ },
+ {
+ "from": "dog",
+ "to": "puppy",
+ "label": "caresFor",
+ "direction": "OUT",
+ "multiplicity": "One2Many",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "Hard to describe",
+ "default": "true"
+ }
+ ]
+} \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/edgeRules/test3.json b/aai-schema-ingest/src/test/resources/edgeRules/test3.json
new file mode 100644
index 00000000..916efdcc
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/edgeRules/test3.json
@@ -0,0 +1,64 @@
+{
+ "rules": [
+ {
+ "from": "l-interface",
+ "to": "logical-link",
+ "label": "tosca.relationships.network.LinksTo",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "default": "true",
+ "description":""
+ },
+ {
+ "from": "logical-link",
+ "to": "l-interface",
+ "label": "org.onap.relationships.inventory.Source",
+ "direction": "OUT",
+ "multiplicity": "ONE2MANY",
+ "contains-other-v": "NONE",
+ "delete-other-v": "!${direction}",
+ "prevent-delete": "NONE",
+ "default": "false",
+ "description":""
+ },
+ {
+ "from": "logical-link",
+ "to": "l-interface",
+ "label": "org.onap.relationships.inventory.Destination",
+ "direction": "OUT",
+ "multiplicity": "ONE2MANY",
+ "contains-other-v": "NONE",
+ "delete-other-v": "!${direction}",
+ "prevent-delete": "NONE",
+ "default": "false",
+ "description":""
+ },
+ {
+ "from": "l-interface",
+ "to": "lag-interface",
+ "label": "org.onap.relationships.inventory.BelongsTo",
+ "direction": "OUT",
+ "multiplicity": "MANY2ONE",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "!${direction}",
+ "prevent-delete": "NONE",
+ "default": "true",
+ "description":""
+ },
+ {
+ "from": "lag-interface",
+ "to": "logical-link",
+ "label": "org.onap.relationships.inventory.Uses",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "NONE",
+ "delete-other-v": "${direction}",
+ "prevent-delete": "NONE",
+ "default": "true",
+ "description":""
+ }
+ ]
+} \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties
new file mode 100644
index 00000000..fb20eba2
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngest2.properties
@@ -0,0 +1,3 @@
+schemaConfig=testConfig.json
+nodeDir=bloop/blap
+edgeDir=different \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties
new file mode 100644
index 00000000..11e5fb47
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestForXMLTest.properties
@@ -0,0 +1,3 @@
+schemaConfig=imatest
+nodeDir=andIMalittleteapot
+edgeDir=meh \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties
new file mode 100644
index 00000000..8bff7d4d
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/forWiringTests/schemaIngestWiringTest.properties
@@ -0,0 +1,3 @@
+schemaConfig=NA
+nodeDir=src/test/resources/oxm/
+edgeDir=src/test/resources/edgeRules/ \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml b/aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml
new file mode 100644
index 00000000..592c2661
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/forWiringTests/testContext.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+
+ <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean">
+ <property name="schemaConfigLocation" value="fromXML" />
+ <property name="nodeDirectory" value="whatAnXML" />
+ <property name="edgeDirectory" value="XMLwiringYAY" />
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml b/aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml
new file mode 100644
index 00000000..7c3302f0
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/forWiringTests/testUsingPropFileContext.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+
+ <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean">
+ <property name="schemaConfigLocation" value="${schemaConfig}" />
+ <property name="nodeDirectory" value="${nodeDir}" />
+ <property name="edgeDirectory" value="${edgeDir}" />
+ </bean>
+
+ <context:property-placeholder location="classpath:forWiringTests/schemaIngestForXMLTest.properties" ignore-unresolvable="true" />
+
+</beans> \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml b/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml
new file mode 100644
index 00000000..5ead4178
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/oxm/test_business_v10.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ ============LICENSE_START=======================================================
+ org.openecomp.aai
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true">
+ <xml-schema element-form-default="QUALIFIED">
+ <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" />
+ </xml-schema>
+ <java-types>
+
+ <java-type name="Bar">
+ <xml-root-element name="bar" />
+ <java-attributes>
+ <xml-element java-attribute="barId" name="bar-id" required="true" type="java.lang.String" xml-key="true">
+ <xml-properties>
+ <xml-property name="description" value="Unique id of Bar This is unique across the graph." />
+ </xml-properties>
+ </xml-element>
+ <xml-element java-attribute="quantity" name="quantity" required="false" type="java.lang.Integer">
+ <xml-properties>
+ <xml-property name="description" value="How many." />
+ </xml-properties>
+ </xml-element>
+
+ </java-attributes>
+ <xml-properties>
+ <xml-property name="description" value="General purpose metasyntactic variable" />
+ <xml-property name="uniqueProps" value="bar-id" />
+ </xml-properties>
+ </java-type>
+
+ </java-types>
+</xml-bindings> \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml b/aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml
new file mode 100644
index 00000000..39a3ca9b
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/oxm/test_business_v11.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ ============LICENSE_START=======================================================
+ org.openecomp.aai
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true">
+ <xml-schema element-form-default="QUALIFIED">
+ <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" />
+ </xml-schema>
+ <java-types>
+
+ <java-type name="Bar">
+ <xml-root-element name="bar" />
+ <java-attributes>
+ <xml-element java-attribute="barId" name="bar-id" required="true" type="java.lang.String" xml-key="true">
+ <xml-properties>
+ <xml-property name="description" value="Unique id of Bar This is unique across the graph." />
+ </xml-properties>
+ </xml-element>
+
+ </java-attributes>
+ <xml-properties>
+ <xml-property name="description" value="General purpose metasyntactic variable" />
+ <xml-property name="uniqueProps" value="bar-id" />
+ </xml-properties>
+ </java-type>
+
+ </java-types>
+</xml-bindings> \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml b/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml
new file mode 100644
index 00000000..e7d77ac9
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/oxm/test_network_v10.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ ============LICENSE_START=======================================================
+ org.openecomp.aai
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true">
+ <xml-schema element-form-default="QUALIFIED">
+ <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" />
+ </xml-schema>
+ <java-types>
+
+ <java-type name="Foo">
+ <xml-root-element name="foo" />
+ <java-attributes>
+ <xml-element java-attribute="fooId" name="foo-id" required="true" type="java.lang.String" xml-key="true">
+ <xml-properties>
+ <xml-property name="description" value="Unique id of Foo. This is unique across the graph." />
+ </xml-properties>
+ </xml-element>
+ <xml-element java-attribute="fooName" name="foo-name" required="true" type="java.lang.String">
+ <xml-properties>
+ <xml-property name="description" value="Name of Foo." />
+ </xml-properties>
+ </xml-element>
+
+ </java-attributes>
+ <xml-properties>
+ <xml-property name="description" value="General purpose metasyntactic variable" />
+ <xml-property name="nameProps" value="foo-name" />
+ <xml-property name="uniqueProps" value="foo-id" />
+ </xml-properties>
+ </java-type>
+
+ </java-types>
+</xml-bindings> \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml b/aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml
new file mode 100644
index 00000000..9ede62d4
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/oxm/test_network_v11.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ ============LICENSE_START=======================================================
+ org.openecomp.aai
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v12" xml-mapping-metadata-complete="true">
+ <xml-schema element-form-default="QUALIFIED">
+ <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" />
+ </xml-schema>
+ <java-types>
+
+ <java-type name="Foo">
+ <xml-root-element name="foo" />
+ <java-attributes>
+ <xml-element java-attribute="fooId" name="foo-id" required="true" type="java.lang.String" xml-key="true">
+ <xml-properties>
+ <xml-property name="description" value="Unique id of Foo. This is unique across the graph." />
+ </xml-properties>
+ </xml-element>
+ <xml-element java-attribute="fooName" name="foo-name" required="true" type="java.lang.String">
+ <xml-properties>
+ <xml-property name="description" value="Name of Foo." />
+ </xml-properties>
+ </xml-element>
+ <xml-element java-attribute="quantity" name="quantity" required="false" type="java.lang.String">
+ <xml-properties>
+ <xml-property name="description" value="How many." />
+ </xml-properties>
+ </xml-element>
+
+ </java-attributes>
+ <xml-properties>
+ <xml-property name="description" value="General purpose metasyntactic variable" />
+ <xml-property name="nameProps" value="foo-name" />
+ <xml-property name="uniqueProps" value="foo-id" />
+ </xml-properties>
+ </java-type>
+
+ <java-type name="Quux">
+ <xml-root-element name="quux" />
+ <java-attributes>
+ <xml-element java-attribute="qManagerName" name="q-manager-name" required="true" type="java.lang.String" xml-key="true">
+ <xml-properties>
+ <xml-property name="description" value="Unique id of Quux owner. This is unique across the graph." />
+ </xml-properties>
+ </xml-element>
+ <xml-element java-attribute="color" name="color" required="false" type="java.lang.String">
+ <xml-properties>
+ <xml-property name="description" value="color" />
+ </xml-properties>
+ </xml-element>
+
+ </java-attributes>
+ <xml-properties>
+ <xml-property name="description" value="General purpose metasyntactic variable" />
+ </xml-properties>
+ </java-type>
+
+ </java-types>
+</xml-bindings> \ No newline at end of file
diff --git a/aai-schema-ingest/src/test/resources/schemaIngest.properties b/aai-schema-ingest/src/test/resources/schemaIngest.properties
new file mode 100644
index 00000000..3112c994
--- /dev/null
+++ b/aai-schema-ingest/src/test/resources/schemaIngest.properties
@@ -0,0 +1,3 @@
+schemaConfig=foo
+nodeDir=bar
+edgeDir=quux \ No newline at end of file