diff options
author | Keong Lim <keong.lim@huawei.com> | 2018-08-21 17:37:03 +1000 |
---|---|---|
committer | Keong Lim <keong.lim@huawei.com> | 2018-09-11 02:32:35 +1000 |
commit | 1879a4dca6d2b390d83189af7409371719679c62 (patch) | |
tree | b8c3dde4986ede50205ea7e7c2b2371dd681abb8 /aai-schema-ingest/src/test | |
parent | ebefd8cecfc8ea7eb47e349d79aa086662771c60 (diff) |
AAI-1523 checkstyle warnings for aai-schema-ingest
Issue-ID: AAI-1523
re-indent code with spaces to clean up some checkstyle warnings
for aai-schema-ingest (part of 24k lines of output)
Change-Id: I1d3785fcbfa9cc53680129506daa2c392950de31
Signed-off-by: Keong Lim <keong.lim@huawei.com>
Diffstat (limited to 'aai-schema-ingest/src/test')
34 files changed, 1169 insertions, 1169 deletions
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java index e8c946d9..6292da71 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java @@ -50,316 +50,316 @@ import com.google.common.collect.Multimap; @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @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("dog", "puppy").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 getRulesFlippedTypesTest() throws EdgeRuleNotFoundException { - EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); - Multimap<String, EdgeRule> results = ei.getRules(q); - assertTrue(results.size() == 3); - for (EdgeRule r : results.get("l-interface|logical-link")) { - if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) || - "org.onap.relationships.inventory.Destination".equals(r.getLabel())) { - //these are defined with from=logical-link, to=l-interface, so they must be flipped - assertTrue(Direction.IN.equals(r.getDirection())); - } else if ("tosca.relationships.network.LinksTo".equals(r.getLabel())) { - //this is defined with from=l-interface, to=logical-link, so it shouldn't be flipped - assertTrue(Direction.OUT.equals(r.getDirection())); - } else { - fail("how did you get here"); - } - } - } - - @Test - public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { - //getRules, setting from and to - EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build(); - Multimap<String, EdgeRule> results = ei.getRules(q); - assertTrue(results.size() == 1); - for (EdgeRule r : results.get("bloop|bloop")) { - assertTrue(Direction.IN.equals(r.getDirection())); - } - - //getRule, setting just from - EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build(); - assertTrue(Direction.IN.equals(ei.getRule(q2).getDirection())); - - //getChildRules - Multimap<String, EdgeRule> child = ei.getChildRules("bloop", new SchemaVersion("v11")); - assertTrue(child.size() == 1); - for (EdgeRule r : child.get("bloop|bloop")) { - assertTrue(Direction.IN.equals(r.getDirection())); - } - } - - @Test - public void getRulesTest3() throws EdgeRuleNotFoundException { - EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build(); - Multimap<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("parent", "notation").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 getRuleFlippedTypesTest() 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())); - //direction flipped to match input order per old EdgeRules.java API - assertTrue(Direction.IN.equals(result.getDirection())); - assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule())); - assertTrue(AAIDirection.OUT.toString().equals(result.getContains())); - assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV())); - assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete())); - assertTrue("parent contains notation".equals(result.getDescription())); - } - - @Test - public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + @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("dog", "puppy").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 getRulesFlippedTypesTest() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); + Multimap<String, EdgeRule> results = ei.getRules(q); + assertTrue(results.size() == 3); + for (EdgeRule r : results.get("l-interface|logical-link")) { + if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) || + "org.onap.relationships.inventory.Destination".equals(r.getLabel())) { + //these are defined with from=logical-link, to=l-interface, so they must be flipped + assertTrue(Direction.IN.equals(r.getDirection())); + } else if ("tosca.relationships.network.LinksTo".equals(r.getLabel())) { + //this is defined with from=l-interface, to=logical-link, so it shouldn't be flipped + assertTrue(Direction.OUT.equals(r.getDirection())); + } else { + fail("how did you get here"); + } + } + } + + @Test + public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + //getRules, setting from and to + EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build(); + Multimap<String, EdgeRule> results = ei.getRules(q); + assertTrue(results.size() == 1); + for (EdgeRule r : results.get("bloop|bloop")) { + assertTrue(Direction.IN.equals(r.getDirection())); + } + + //getRule, setting just from + EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build(); + assertTrue(Direction.IN.equals(ei.getRule(q2).getDirection())); + + //getChildRules + Multimap<String, EdgeRule> child = ei.getChildRules("bloop", new SchemaVersion("v11")); + assertTrue(child.size() == 1); + for (EdgeRule r : child.get("bloop|bloop")) { + assertTrue(Direction.IN.equals(r.getDirection())); + } + } + + @Test + public void getRulesTest3() throws EdgeRuleNotFoundException { + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build(); + Multimap<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("parent", "notation").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 getRuleFlippedTypesTest() 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())); + //direction flipped to match input order per old EdgeRules.java API + assertTrue(Direction.IN.equals(result.getDirection())); + assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule())); + assertTrue(AAIDirection.OUT.toString().equals(result.getContains())); + assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV())); + assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete())); + assertTrue("parent contains notation".equals(result.getDescription())); + } + + @Test + public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { - EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new SchemaVersion("v11")).build(); - EdgeRule res = 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(new SchemaVersion("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(new SchemaVersion("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(new SchemaVersion("v11")).build(); - ei.getRule(q); - } - - @Test - public void hasRuleTest() { - assertTrue(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); - assertFalse(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); - } - - @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", new SchemaVersion("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", new SchemaVersion("v11")); - assertTrue(results.isEmpty()); - } - - @Test - public void hasCousinTest() { - assertTrue(ei.hasCousinRule("foo")); - assertTrue(ei.hasCousinRule("foo", new SchemaVersion("v10"))); - assertFalse(ei.hasCousinRule("parent")); - assertFalse(ei.hasCousinRule("foo", new SchemaVersion("v11"))); - } + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new SchemaVersion("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(new SchemaVersion("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(new SchemaVersion("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(new SchemaVersion("v11")).build(); + ei.getRule(q); + } + + @Test + public void hasRuleTest() { + assertTrue(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); + assertFalse(ei.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); + } + + @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", new SchemaVersion("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", new SchemaVersion("v11")); + assertTrue(results.isEmpty()); + } + + @Test + public void hasCousinTest() { + assertTrue(ei.hasCousinRule("foo")); + assertTrue(ei.hasCousinRule("foo", new SchemaVersion("v10"))); + assertFalse(ei.hasCousinRule("parent")); + assertFalse(ei.hasCousinRule("foo", new SchemaVersion("v11"))); + } - @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", new SchemaVersion("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", new SchemaVersion("v11")); - assertTrue(results.isEmpty()); - } - - @Test - public void hasChildTest() { - assertTrue(ei.hasChildRule("foo")); - assertTrue(ei.hasChildRule("foo", new SchemaVersion("v10"))); - assertFalse(ei.hasChildRule("puppy")); - assertFalse(ei.hasChildRule("foo", new SchemaVersion("v11"))); - } - - @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", new SchemaVersion("v10")); - assertTrue(results.size() == 1); - assertTrue(results.containsKey("baz|foo")); - } - - @Test - public void getParentRulesNoneInVersionTest() { - Multimap<String, EdgeRule> results = ei.getParentRules("baz", new SchemaVersion("v11")); - assertTrue(results.isEmpty()); - } - - @Test - public void hasParentTest() { - assertTrue(ei.hasParentRule("parent")); - assertTrue(ei.hasParentRule("quux", new SchemaVersion("v10"))); - assertFalse(ei.hasParentRule("puppy")); - assertFalse(ei.hasParentRule("foo", new SchemaVersion("v11"))); - } - - @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(new SchemaVersion("v10")); - assertTrue(res.size() == 4); - assertTrue(res.containsKey("bar|foo")); - assertTrue(res.get("bar|foo").size() == 2); - assertTrue(res.containsKey("baz|foo")); - assertTrue(res.containsKey("foo|quux")); - - thrown.expect(EdgeRuleNotFoundException.class); - thrown.expectMessage("No rules found for version v9."); - ei.getAllRules(new SchemaVersion("v9")); - } + @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", new SchemaVersion("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", new SchemaVersion("v11")); + assertTrue(results.isEmpty()); + } + + @Test + public void hasChildTest() { + assertTrue(ei.hasChildRule("foo")); + assertTrue(ei.hasChildRule("foo", new SchemaVersion("v10"))); + assertFalse(ei.hasChildRule("puppy")); + assertFalse(ei.hasChildRule("foo", new SchemaVersion("v11"))); + } + + @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", new SchemaVersion("v10")); + assertTrue(results.size() == 1); + assertTrue(results.containsKey("baz|foo")); + } + + @Test + public void getParentRulesNoneInVersionTest() { + Multimap<String, EdgeRule> results = ei.getParentRules("baz", new SchemaVersion("v11")); + assertTrue(results.isEmpty()); + } + + @Test + public void hasParentTest() { + assertTrue(ei.hasParentRule("parent")); + assertTrue(ei.hasParentRule("quux", new SchemaVersion("v10"))); + assertFalse(ei.hasParentRule("puppy")); + assertFalse(ei.hasParentRule("foo", new SchemaVersion("v11"))); + } + + @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(new SchemaVersion("v10")); + assertTrue(res.size() == 4); + assertTrue(res.containsKey("bar|foo")); + assertTrue(res.get("bar|foo").size() == 2); + assertTrue(res.containsKey("baz|foo")); + assertTrue(res.containsKey("foo|quux")); + + thrown.expect(EdgeRuleNotFoundException.class); + thrown.expectMessage("No rules found for version v9."); + ei.getAllRules(new SchemaVersion("v9")); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java index cf23a702..cae3bf78 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java @@ -42,16 +42,16 @@ import com.google.common.collect.Multimap; @TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.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(new SchemaVersion("v10")).build(); - Multimap<String, EdgeRule> results = ei.getRules(q); - assertTrue(results.size() == 1); - assertTrue(results.containsKey("foo|quux")); - } + @Autowired + EdgeIngestor ei; + + @Test + public void test() throws EdgeRuleNotFoundException { + assertNotNull(ei); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").label("dancesWith").version(new SchemaVersion("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 index da875ffe..856ebb70 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java @@ -34,100 +34,100 @@ 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"); + 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); - } + 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); - } + /* **** 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); - } + @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/edges/EdgeRuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java index 4be987e7..5abae6b7 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java @@ -29,31 +29,31 @@ import org.junit.Test; public class EdgeRuleTest { - @Test - public void testFlipDirection() { - Map<String, String> rule = new HashMap<>(); - rule.put("from", "foo"); - rule.put("to", "bar"); - rule.put("label", "links"); - rule.put("contains-other-v", "NONE"); - rule.put("delete-other-v", "NONE"); - rule.put("prevent-delete", "NONE"); - rule.put("multiplicity", "ONE2ONE"); - rule.put("direction", "OUT"); - rule.put("default", "true"); - rule.put("private", "true"); + @Test + public void testFlipDirection() { + Map<String, String> rule = new HashMap<>(); + rule.put("from", "foo"); + rule.put("to", "bar"); + rule.put("label", "links"); + rule.put("contains-other-v", "NONE"); + rule.put("delete-other-v", "NONE"); + rule.put("prevent-delete", "NONE"); + rule.put("multiplicity", "ONE2ONE"); + rule.put("direction", "OUT"); + rule.put("default", "true"); + rule.put("private", "true"); - EdgeRule r = new EdgeRule(rule); - - r.flipDirection(); - assertTrue(Direction.IN.equals(r.getDirection())); - r.flipDirection(); - assertTrue(Direction.OUT.equals(r.getDirection())); - - rule.put("direction", "BOTH"); - EdgeRule r2 = new EdgeRule(rule); - r2.flipDirection(); - assertTrue(Direction.BOTH.equals(r2.getDirection())); - } + EdgeRule r = new EdgeRule(rule); + + r.flipDirection(); + assertTrue(Direction.IN.equals(r.getDirection())); + r.flipDirection(); + assertTrue(Direction.OUT.equals(r.getDirection())); + + rule.put("direction", "BOTH"); + EdgeRule r2 = new EdgeRule(rule); + r2.flipDirection(); + assertTrue(Direction.BOTH.equals(r2.getDirection())); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java index 188848b7..b718c0fd 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java @@ -34,41 +34,41 @@ import static com.jayway.jsonpath.Filter.filter; public class JsonIngestorTest { - private SchemaVersion LATEST = new SchemaVersion("v14"); - private SchemaVersion V10 = new SchemaVersion("v10"); - private SchemaVersion V11 = new SchemaVersion("v11"); + private SchemaVersion LATEST = new SchemaVersion("v14"); + private SchemaVersion V10 = new SchemaVersion("v10"); + private SchemaVersion V11 = new SchemaVersion("v11"); - @Test - public void test() { - //setup - 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<SchemaVersion, List<String>> input = new TreeMap<>(); - input.put(LATEST, files); - - List<String> files2 = new ArrayList<>(); - files2.add("src/test/resources/edgeRules/test.json"); - input.put(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(V11, files3); - - //test - JsonIngestor ji = new JsonIngestor(); - Map<SchemaVersion, List<DocumentContext>> results = ji.ingest(input); - - assertTrue(results.entrySet().size() == 3); - assertTrue(results.get(LATEST).size() == 3); - assertTrue(results.get(V11).size() == 2); - assertTrue(results.get(V10).size() == 1); - - Filter f = filter(where("from").is("foo").and("contains-other-v").is("NONE")); - List<Map<String, String>> filterRes = results.get(V10).get(0).read("$.rules.[?]",f); - assertTrue(filterRes.size() == 2); - } + @Test + public void test() { + //setup + 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<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(LATEST, files); + + List<String> files2 = new ArrayList<>(); + files2.add("src/test/resources/edgeRules/test.json"); + input.put(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(V11, files3); + + //test + JsonIngestor ji = new JsonIngestor(); + Map<SchemaVersion, List<DocumentContext>> results = ji.ingest(input); + + assertTrue(results.entrySet().size() == 3); + assertTrue(results.get(LATEST).size() == 3); + assertTrue(results.get(V11).size() == 2); + assertTrue(results.get(V10).size() == 1); + + Filter f = filter(where("from").is("foo").and("contains-other-v").is("NONE")); + List<Map<String, String>> filterRes = results.get(V10).get(0).read("$.rules.[?]",f); + assertTrue(filterRes.size() == 2); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java index dd5da519..4e3d61dd 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java @@ -26,15 +26,15 @@ import org.junit.Test; public class TypeAlphabetizerTest { - @Test - public void test() { - TypeAlphabetizer alpher = new TypeAlphabetizer(); - assertTrue("aaa|bbb".equals(alpher.buildAlphabetizedKey("aaa", "bbb"))); - assertTrue("l-interface|logical-link".equals(alpher.buildAlphabetizedKey("l-interface", "logical-link"))); - assertTrue("l-interface|logical-link".equals(alpher.buildAlphabetizedKey("logical-link", "l-interface"))); - assertTrue("|foo".equals(alpher.buildAlphabetizedKey(null, "foo"))); - assertTrue("|foo".equals(alpher.buildAlphabetizedKey("foo", null))); - assertTrue("|".equals(alpher.buildAlphabetizedKey(null, null))); - } + @Test + public void test() { + TypeAlphabetizer alpher = new TypeAlphabetizer(); + assertTrue("aaa|bbb".equals(alpher.buildAlphabetizedKey("aaa", "bbb"))); + assertTrue("l-interface|logical-link".equals(alpher.buildAlphabetizedKey("l-interface", "logical-link"))); + assertTrue("l-interface|logical-link".equals(alpher.buildAlphabetizedKey("logical-link", "l-interface"))); + assertTrue("|foo".equals(alpher.buildAlphabetizedKey(null, "foo"))); + assertTrue("|foo".equals(alpher.buildAlphabetizedKey("foo", null))); + assertTrue("|".equals(alpher.buildAlphabetizedKey(null, null))); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java index 5421aa2a..2de5847e 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java @@ -65,101 +65,101 @@ import org.springframework.boot.test.context.SpringBootTest; @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @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 testGetContextForVersion() { - DynamicJAXBContext ctx10 = ni.getContextForVersion(new SchemaVersion("v10")); - - //should work bc Foo is valid in test_network_v10 schema - DynamicEntity foo10 = ctx10.newDynamicEntity("Foo"); + @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 testGetContextForVersion() { + DynamicJAXBContext ctx10 = ni.getContextForVersion(new SchemaVersion("v10")); + + //should work bc Foo is valid in test_network_v10 schema + DynamicEntity foo10 = ctx10.newDynamicEntity("Foo"); - foo10.set("fooId","bar"); - assertTrue("bar".equals(foo10.get("fooId"))); - - //should work bc Bar is valid in test_business_v10 schema - DynamicEntity bar10 = ctx10.newDynamicEntity("Bar"); - bar10.set("barId","bar2"); - assertTrue("bar2".equals(bar10.get("barId"))); - XSDOutputResolver outputResolver10 = new XSDOutputResolver(); - ctx10.generateSchema(outputResolver10); - - DynamicJAXBContext ctx11 = ni.getContextForVersion(new SchemaVersion("v11")); - - //should work bc Foo.quantity is valid in test_network_v11 schema - DynamicEntity foo11 = ctx11.newDynamicEntity("Foo"); - foo11.set("quantity","12"); - assertTrue("12".equals(foo11.get("quantity"))); - - DynamicEntity quux11 = ctx11.newDynamicEntity("Quux"); - quux11.set("qManagerName","some guy"); - assertTrue("some guy".equals(quux11.get("qManagerName"))); - XSDOutputResolver outputResolver11 = new XSDOutputResolver(); - ctx11.generateSchema(outputResolver11); + foo10.set("fooId","bar"); + assertTrue("bar".equals(foo10.get("fooId"))); + + //should work bc Bar is valid in test_business_v10 schema + DynamicEntity bar10 = ctx10.newDynamicEntity("Bar"); + bar10.set("barId","bar2"); + assertTrue("bar2".equals(bar10.get("barId"))); + XSDOutputResolver outputResolver10 = new XSDOutputResolver(); + ctx10.generateSchema(outputResolver10); + + DynamicJAXBContext ctx11 = ni.getContextForVersion(new SchemaVersion("v11")); + + //should work bc Foo.quantity is valid in test_network_v11 schema + DynamicEntity foo11 = ctx11.newDynamicEntity("Foo"); + foo11.set("quantity","12"); + assertTrue("12".equals(foo11.get("quantity"))); + + DynamicEntity quux11 = ctx11.newDynamicEntity("Quux"); + quux11.set("qManagerName","some guy"); + assertTrue("some guy".equals(quux11.get("qManagerName"))); + XSDOutputResolver outputResolver11 = new XSDOutputResolver(); + ctx11.generateSchema(outputResolver11); - - thrown.expect(IllegalArgumentException.class); - //should fail bc Quux not in v10 test schema - ctx10.newDynamicEntity("Quux"); - } - - @Test - public void testHasNodeType() { - assertTrue(ni.hasNodeType("foo", new SchemaVersion("v11"))); - assertTrue(ni.hasNodeType("quux", new SchemaVersion("v11"))); - assertFalse(ni.hasNodeType("quux", new SchemaVersion("v10"))); - } - @Test - public void testCombinedSchema() throws TransformerException, IOException { - DynamicJAXBContext ctx13 = ni.getContextForVersion(new SchemaVersion("v13")); - XSDOutputResolver outputResolver13 = new XSDOutputResolver(); - ctx13.generateSchema(outputResolver13); - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - printDocument(ni.getSchema(new SchemaVersion("v13")),buffer); - String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); - content = content.replaceAll("\\s+", ""); - String expected = buffer.toString().replaceAll("\\s+", ""); - assertThat("OXM:\n"+expected,expected, is(content)); - } + + thrown.expect(IllegalArgumentException.class); + //should fail bc Quux not in v10 test schema + ctx10.newDynamicEntity("Quux"); + } + + @Test + public void testHasNodeType() { + assertTrue(ni.hasNodeType("foo", new SchemaVersion("v11"))); + assertTrue(ni.hasNodeType("quux", new SchemaVersion("v11"))); + assertFalse(ni.hasNodeType("quux", new SchemaVersion("v10"))); + } + @Test + public void testCombinedSchema() throws TransformerException, IOException { + DynamicJAXBContext ctx13 = ni.getContextForVersion(new SchemaVersion("v13")); + XSDOutputResolver outputResolver13 = new XSDOutputResolver(); + ctx13.generateSchema(outputResolver13); + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + printDocument(ni.getSchema(new SchemaVersion("v13")),buffer); + String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); + content = content.replaceAll("\\s+", ""); + String expected = buffer.toString().replaceAll("\\s+", ""); + assertThat("OXM:\n"+expected,expected, is(content)); + } - public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); + public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - transformer.transform(new DOMSource(doc), - new StreamResult(new OutputStreamWriter(out, "UTF-8"))); - } - - private class XSDOutputResolver extends SchemaOutputResolver { + transformer.transform(new DOMSource(doc), + new StreamResult(new OutputStreamWriter(out, "UTF-8"))); + } + + private class XSDOutputResolver extends SchemaOutputResolver { - @Override - public Result createOutput(String namespaceUri, String suggestedFileName) - throws IOException { - - // create new file - // create stream result - File temp = File.createTempFile("schema", ".xsd"); - StreamResult result = new StreamResult(temp); - System.out.println("Schema file: "+temp.getAbsolutePath()); - - // set system id - result.setSystemId(temp.toURI().toURL().toString()); - - // return result - return result; - } - } + @Override + public Result createOutput(String namespaceUri, String suggestedFileName) + throws IOException { + + // create new file + // create stream result + File temp = File.createTempFile("schema", ".xsd"); + StreamResult result = new StreamResult(temp); + System.out.println("Schema file: "+temp.getAbsolutePath()); + + // set system id + result.setSystemId(temp.toURI().toURL().toString()); + + // return result + return result; + } + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java index 2749cdb7..a7987fa3 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java @@ -41,16 +41,16 @@ import org.springframework.boot.test.context.SpringBootTest; @TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties"}) @SpringBootTest public class NodeIngestorWiringTest { - @Autowired - NodeIngestor ni; - - @Test - public void test() { - DynamicJAXBContext ctx10 = ni.getContextForVersion(new SchemaVersion("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"))); - } + @Autowired + NodeIngestor ni; + + @Test + public void test() { + DynamicJAXBContext ctx10 = ni.getContextForVersion(new SchemaVersion("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 index 543284cb..03b40db5 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java @@ -39,21 +39,21 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties"}) @SpringBootTest public class ConfigTranslatorWiringTest { - @Autowired - ConfigTranslator ct; - - @Test - public void test() { - assertNotNull(ct); - Map<SchemaVersion, List<String>> nodes = ct.getNodeFiles(); - assertTrue(nodes.containsKey(new SchemaVersion("v10"))); - assertTrue(1 == nodes.get(new SchemaVersion("v10")).size()); - assertTrue("src/test/resources/oxm/test_business_v10.xml".equals(nodes.get(new SchemaVersion("v10")).get(0))); - - Map<SchemaVersion, List<String>> edges = ct.getEdgeFiles(); - assertTrue(edges.containsKey(new SchemaVersion("v10"))); - assertTrue(1 == edges.get(new SchemaVersion("v10")).size()); - assertTrue("src/test/resources/edgeRules/test.json".equals(edges.get(new SchemaVersion("v10")).get(0))); - } + @Autowired + ConfigTranslator ct; + + @Test + public void test() { + assertNotNull(ct); + Map<SchemaVersion, List<String>> nodes = ct.getNodeFiles(); + assertTrue(nodes.containsKey(new SchemaVersion("v10"))); + assertTrue(1 == nodes.get(new SchemaVersion("v10")).size()); + assertTrue("src/test/resources/oxm/test_business_v10.xml".equals(nodes.get(new SchemaVersion("v10")).get(0))); + + Map<SchemaVersion, List<String>> edges = ct.getEdgeFiles(); + assertTrue(edges.containsKey(new SchemaVersion("v10"))); + assertTrue(1 == edges.get(new SchemaVersion("v10")).size()); + assertTrue("src/test/resources/edgeRules/test.json".equals(edges.get(new SchemaVersion("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 index 2103ac21..b5fb0e19 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java @@ -31,14 +31,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class}) public class SchemaLocationsBeanDefaultInjectionTest { - @Autowired - SchemaLocationsBean bean; + @Autowired + SchemaLocationsBean bean; - @Test - public void test() { - assertNotNull(bean); - assertTrue("foo".equals(bean.getSchemaConfigLocation())); - assertTrue("bar".equals(bean.getNodeDirectory())); - assertTrue("quux".equals(bean.getEdgeDirectory())); - } + @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 index aed9c633..6ccc418a 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java @@ -33,14 +33,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(classes = {SchemaLocationsBean.class}) @TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest2.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())); - } + @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 index 99f2104a..d72d3d3c 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java @@ -31,14 +31,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:forWiringTests/testContext.xml"}) public class SchemaLocationsBeanXMLSetterTest { - @Autowired - SchemaLocationsBean bean; + @Autowired + SchemaLocationsBean bean; - @Test - public void test() { - assertNotNull(bean); - assertTrue("fromXML".equals(bean.getSchemaConfigLocation())); - assertTrue("whatAnXML".equals(bean.getNodeDirectory())); - assertTrue("XMLwiringYAY".equals(bean.getEdgeDirectory())); - } + @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 index 150313b3..5e49b4f0 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java @@ -31,14 +31,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:forWiringTests/testUsingPropFileContext.xml"}) public class SchemaLocationsBeanXMLSetterWithPropFileTest { - @Autowired - SchemaLocationsBean bean; + @Autowired + SchemaLocationsBean bean; - @Test - public void test() { - assertNotNull(bean); - assertTrue("imatest".equals(bean.getSchemaConfigLocation())); - assertTrue("andIMalittleteapot".equals(bean.getNodeDirectory())); - assertTrue("meh".equals(bean.getEdgeDirectory())); - } + @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/BadEdgeConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java index b2400aab..ff2f22f6 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java @@ -29,29 +29,29 @@ import org.onap.aai.setup.*; */ public class BadEdgeConfigForValidationTest extends ConfigTranslator { - public static final SchemaVersion LATEST = new SchemaVersion("v14"); - - public BadEdgeConfigForValidationTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - } - - @Override - public Map<SchemaVersion, List<String>> getNodeFiles() { - List<String> files = new ArrayList<>(); - files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml"); - Map<SchemaVersion, List<String>> input = new HashMap<>(); - input.put(LATEST, files); - return input; - } - - @Override - public Map<SchemaVersion, List<String>> getEdgeFiles() { - Map<SchemaVersion, List<String>> input = new TreeMap<>(); - List<String> files = new ArrayList<>(); - files.add("src/test/resources/edgeRules/test3-butbad.json"); - input.put(LATEST, files); - return input; - } - - + public static final SchemaVersion LATEST = new SchemaVersion("v14"); + + public BadEdgeConfigForValidationTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } + + @Override + public Map<SchemaVersion, List<String>> getNodeFiles() { + List<String> files = new ArrayList<>(); + files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml"); + Map<SchemaVersion, List<String>> input = new HashMap<>(); + input.put(LATEST, files); + return input; + } + + @Override + public Map<SchemaVersion, List<String>> getEdgeFiles() { + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + List<String> files = new ArrayList<>(); + files.add("src/test/resources/edgeRules/test3-butbad.json"); + input.put(LATEST, files); + return input; + } + + } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java index 9de21f31..a1a0e32a 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java @@ -29,30 +29,30 @@ import org.onap.aai.setup.*; */ public class BadNodeConfigForValidationTest extends ConfigTranslator { - public static final SchemaVersion LATEST = new SchemaVersion("v14"); - - public BadNodeConfigForValidationTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - } - - @Override - public Map<SchemaVersion, List<String>> getNodeFiles() { - List<String> files = new ArrayList<>(); - files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml"); - files.add("src/test/resources/oxm/badConfigForValidationTest_oxm.xml"); - Map<SchemaVersion, List<String>> input = new TreeMap<>(); - input.put(LATEST, files); - return input; - } - - @Override - public Map<SchemaVersion, List<String>> getEdgeFiles() { - Map<SchemaVersion, List<String>> input = new TreeMap<>(); - List<String> files = new ArrayList<>(); - files.add("src/test/resources/edgeRules/test3.json"); - input.put(LATEST, files); - return input; - } - - + public static final SchemaVersion LATEST = new SchemaVersion("v14"); + + public BadNodeConfigForValidationTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } + + @Override + public Map<SchemaVersion, List<String>> getNodeFiles() { + List<String> files = new ArrayList<>(); + files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml"); + files.add("src/test/resources/oxm/badConfigForValidationTest_oxm.xml"); + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(LATEST, files); + return input; + } + + @Override + public Map<SchemaVersion, List<String>> getEdgeFiles() { + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + List<String> files = new ArrayList<>(); + files.add("src/test/resources/edgeRules/test3.json"); + input.put(LATEST, files); + return input; + } + + } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java index fc0a3984..043f80e7 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java @@ -26,28 +26,28 @@ import org.onap.aai.setup.*; public class ConfigTranslatorForWiringTest extends ConfigTranslator { - public ConfigTranslatorForWiringTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - } - - @Override - public Map<SchemaVersion, List<String>> getNodeFiles() { - String f = bean.getNodeDirectory() + "test_business_v10.xml"; - List<String> files = new ArrayList<>(); - files.add(f); - Map<SchemaVersion, List<String>> mp = new TreeMap<>(); - mp.put(new SchemaVersion("v10"), files); - return mp; - } - - @Override - public Map<SchemaVersion, List<String>> getEdgeFiles() { - String f = bean.getEdgeDirectory() + "test.json"; - List<String> files = new ArrayList<>(); - files.add(f); - Map<SchemaVersion, List<String>> mp = new TreeMap<>(); - mp.put(new SchemaVersion("v10"), files); - return mp; - } + public ConfigTranslatorForWiringTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } + + @Override + public Map<SchemaVersion, List<String>> getNodeFiles() { + String f = bean.getNodeDirectory() + "test_business_v10.xml"; + List<String> files = new ArrayList<>(); + files.add(f); + Map<SchemaVersion, List<String>> mp = new TreeMap<>(); + mp.put(new SchemaVersion("v10"), files); + return mp; + } + + @Override + public Map<SchemaVersion, List<String>> getEdgeFiles() { + String f = bean.getEdgeDirectory() + "test.json"; + List<String> files = new ArrayList<>(); + files.add(f); + Map<SchemaVersion, List<String>> mp = new TreeMap<>(); + mp.put(new SchemaVersion("v10"), files); + return mp; + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java index dd8d5977..dbb24ec9 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java @@ -32,36 +32,36 @@ import org.onap.aai.setup.SchemaVersions; */ public class GoodConfigForValidationTest extends ConfigTranslator { - private SchemaVersions schemaVersions; + private SchemaVersions schemaVersions; - public GoodConfigForValidationTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - this.schemaVersions = schemaVersions; - } + public GoodConfigForValidationTest(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + this.schemaVersions = schemaVersions; + } - @Override - public Map<SchemaVersion, List<String>> getNodeFiles() { - List<String> files = new ArrayList<>(); - files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml"); - Map<SchemaVersion, List<String>> input = new TreeMap<>(); - //input.put(SchemaVersion.getLatest(), files); - for (SchemaVersion v : schemaVersions.getVersions()) { - input.put(v, files); - } - return input; - } + @Override + public Map<SchemaVersion, List<String>> getNodeFiles() { + List<String> files = new ArrayList<>(); + files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml"); + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + //input.put(SchemaVersion.getLatest(), files); + for (SchemaVersion v : schemaVersions.getVersions()) { + input.put(v, files); + } + return input; + } - @Override - public Map<SchemaVersion, List<String>> getEdgeFiles() { - Map<SchemaVersion, List<String>> input = new TreeMap<>(); - List<String> files = new ArrayList<>(); - files.add("src/test/resources/edgeRules/test3.json"); - //input.put(SchemaVersion.getLatest(), files); - for (SchemaVersion v : schemaVersions.getVersions()) { - input.put(v, files); - } - return input; - } + @Override + public Map<SchemaVersion, List<String>> getEdgeFiles() { + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + List<String> files = new ArrayList<>(); + files.add("src/test/resources/edgeRules/test3.json"); + //input.put(SchemaVersion.getLatest(), files); + for (SchemaVersion v : schemaVersions.getVersions()) { + input.put(v, files); + } + return input; + } - + } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java index 66f2bea2..d3df9dcc 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java @@ -32,51 +32,51 @@ import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; public class SchemaIncompleteTranslator extends ConfigTranslator { - - public SchemaIncompleteTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - } + + public SchemaIncompleteTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } - @Override - public Map<SchemaVersion, 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"); + @Override + public Map<SchemaVersion, 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"); - List<String> files12 = new ArrayList<>(); - files12.add("src/test/resources/oxm/business_oxm_v12.xml"); - - Map<SchemaVersion, List<String>> input = new TreeMap<>(); - - - input.put(new SchemaVersion("v10"), files10); - input.put(new SchemaVersion("v11"), files11); - input.put(new SchemaVersion("v12"), files12); - return input; - } + List<String> files12 = new ArrayList<>(); + files12.add("src/test/resources/oxm/business_oxm_v12.xml"); + + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + + + input.put(new SchemaVersion("v10"), files10); + input.put(new SchemaVersion("v11"), files11); + input.put(new SchemaVersion("v12"), files12); + return input; + } - @Override - public Map<SchemaVersion, 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<SchemaVersion, List<String>> input = new TreeMap<>(); - input.put(schemaVersions.getDefaultVersion(), files); - - List<String> files2 = new ArrayList<>(); - files2.add("src/test/resources/edgeRules/test.json"); - input.put(new SchemaVersion("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(new SchemaVersion("v11"), files3); - - return input; - } + @Override + public Map<SchemaVersion, 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<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(schemaVersions.getDefaultVersion(), files); + + List<String> files2 = new ArrayList<>(); + files2.add("src/test/resources/edgeRules/test.json"); + input.put(new SchemaVersion("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(new SchemaVersion("v11"), files3); + + return input; + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java index b4756d64..bbc0c3f9 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java @@ -26,57 +26,57 @@ import org.onap.aai.setup.*; public class TestUtilConfigTranslator extends ConfigTranslator { - public static final SchemaVersion LATEST = new SchemaVersion("v14"); - public TestUtilConfigTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - } + public static final SchemaVersion LATEST = new SchemaVersion("v14"); + public TestUtilConfigTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } - @Override - public Map<SchemaVersion, 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<SchemaVersion, List<String>> input = new TreeMap<>(); - input.put(new SchemaVersion("v10"), files10); - input.put(new SchemaVersion("v11"), files11); + @Override + public Map<SchemaVersion, 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<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(new SchemaVersion("v10"), files10); + input.put(new SchemaVersion("v11"), files11); - List<String> files13 = new ArrayList<>(); - files13.add("src/test/resources/oxm/business_oxm_v13.xml"); - files13.add("src/test/resources/oxm/common_oxm_v13.xml"); - files13.add("src/test/resources/oxm/serviceDesign_oxm_v13.xml"); - files13.add("src/test/resources/oxm/network_oxm_v13.xml"); - - input.put(new SchemaVersion("v10"), files10); - input.put(new SchemaVersion("v11"), files11); - input.put(new SchemaVersion("v13"), files13); - return input; - } + List<String> files13 = new ArrayList<>(); + files13.add("src/test/resources/oxm/business_oxm_v13.xml"); + files13.add("src/test/resources/oxm/common_oxm_v13.xml"); + files13.add("src/test/resources/oxm/serviceDesign_oxm_v13.xml"); + files13.add("src/test/resources/oxm/network_oxm_v13.xml"); + + input.put(new SchemaVersion("v10"), files10); + input.put(new SchemaVersion("v11"), files11); + input.put(new SchemaVersion("v13"), files13); + return input; + } - @Override - public Map<SchemaVersion, 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<SchemaVersion, List<String>> input = new TreeMap<>(); - input.put(LATEST, files); - - List<String> files2 = new ArrayList<>(); - files2.add("src/test/resources/edgeRules/test.json"); - input.put(new SchemaVersion("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(new SchemaVersion("v11"), files3); - - return input; - } + @Override + public Map<SchemaVersion, 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<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(LATEST, files); + + List<String> files2 = new ArrayList<>(); + files2.add("src/test/resources/edgeRules/test.json"); + input.put(new SchemaVersion("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(new SchemaVersion("v11"), files3); + + return input; + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java index 2d753efb..81644de8 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java @@ -32,49 +32,49 @@ import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator { - - public TestUtilConfigTranslatorforBusiness(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - } + + public TestUtilConfigTranslatorforBusiness(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } - @Override - public Map<SchemaVersion, 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/business_v11.xml"); - - List<String> files13 = new ArrayList<>(); - files13.add("src/test/resources/oxm/business_oxm_v13.xml"); - files13.add("src/test/resources/oxm/common_oxm_v13.xml"); - files13.add("src/test/resources/oxm/serviceDesign_oxm_v13.xml"); - files13.add("src/test/resources/oxm/network_oxm_v13.xml"); - - Map<SchemaVersion, List<String>> input = new TreeMap<>(); -// input.put(Version.V10, files10); - input.put(new SchemaVersion("v11"), files11); - input.put(schemaVersions.getDefaultVersion(), files13); - return input; - } + @Override + public Map<SchemaVersion, 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/business_v11.xml"); + + List<String> files13 = new ArrayList<>(); + files13.add("src/test/resources/oxm/business_oxm_v13.xml"); + files13.add("src/test/resources/oxm/common_oxm_v13.xml"); + files13.add("src/test/resources/oxm/serviceDesign_oxm_v13.xml"); + files13.add("src/test/resources/oxm/network_oxm_v13.xml"); + + Map<SchemaVersion, List<String>> input = new TreeMap<>(); +// input.put(Version.V10, files10); + input.put(new SchemaVersion("v11"), files11); + input.put(schemaVersions.getDefaultVersion(), files13); + return input; + } - @Override - public Map<SchemaVersion, List<String>> getEdgeFiles() { - List<String> files = new ArrayList<>(); - files.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json"); - Map<SchemaVersion, List<String>> input = new TreeMap<>(); - input.put(schemaVersions.getDefaultVersion(), files); - - List<String> files2 = new ArrayList<>(); - files2.add("src/test/resources/dbedgerules/test.json"); -// input.put(Version.V10, files2); - - List<String> files3 = new ArrayList<>(); - files3.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json"); - input.put(new SchemaVersion("v11"), files3); - - return input; - } + @Override + public Map<SchemaVersion, List<String>> getEdgeFiles() { + List<String> files = new ArrayList<>(); + files.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json"); + Map<SchemaVersion, List<String>> input = new TreeMap<>(); + input.put(schemaVersions.getDefaultVersion(), files); + + List<String> files2 = new ArrayList<>(); + files2.add("src/test/resources/dbedgerules/test.json"); +// input.put(Version.V10, files2); + + List<String> files3 = new ArrayList<>(); + files3.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json"); + input.put(new SchemaVersion("v11"), files3); + + return input; + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java index 49bb5986..f43ea7dc 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java @@ -27,29 +27,29 @@ import org.onap.aai.validation.CheckEverythingStrategy; public class CheckEverythingStrategyTest { - @Test - public void test() { - CheckEverythingStrategy strat = new CheckEverythingStrategy(); - //no issues so nothing notified, should be fine - assertTrue(strat.isOK()); - assertTrue("No errors found.".equals(strat.getErrorMsg())); - - //simulate post one error - String testError1 = "oh noes a problem with the gooble-gobble edge rule!"; - strat.notifyOnError(testError1); - assertFalse(strat.isOK()); - assertTrue(testError1.equals(strat.getErrorMsg())); - - //simulate multiple found - String testError2 = "error 2"; - String testError3 = "duplicate labels not everything is a fork"; - strat.notifyOnError(testError2); - strat.notifyOnError(testError3); - assertFalse(strat.isOK()); - System.out.println(strat.getErrorMsg()); - assertTrue(strat.getErrorMsg().contains(testError1)); - assertTrue(strat.getErrorMsg().contains(testError2)); - assertTrue(strat.getErrorMsg().contains(testError3)); - } + @Test + public void test() { + CheckEverythingStrategy strat = new CheckEverythingStrategy(); + //no issues so nothing notified, should be fine + assertTrue(strat.isOK()); + assertTrue("No errors found.".equals(strat.getErrorMsg())); + + //simulate post one error + String testError1 = "oh noes a problem with the gooble-gobble edge rule!"; + strat.notifyOnError(testError1); + assertFalse(strat.isOK()); + assertTrue(testError1.equals(strat.getErrorMsg())); + + //simulate multiple found + String testError2 = "error 2"; + String testError3 = "duplicate labels not everything is a fork"; + strat.notifyOnError(testError2); + strat.notifyOnError(testError3); + assertFalse(strat.isOK()); + System.out.println(strat.getErrorMsg()); + assertTrue(strat.getErrorMsg().contains(testError1)); + assertTrue(strat.getErrorMsg().contains(testError2)); + assertTrue(strat.getErrorMsg().contains(testError3)); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java index b70d13d6..0d9ded01 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java @@ -29,22 +29,22 @@ import org.onap.aai.validation.AAISchemaValidationException; import org.onap.aai.validation.FailFastStrategy; public class FailFastStrategyTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void test() { - FailFastStrategy strat = new FailFastStrategy(); - - //simulate no issues found - assertTrue(strat.isOK()); - assertTrue("No errors found.".equals(strat.getErrorMsg())); - - //simulate an issue found - String testError = "hi i'm a problem"; - thrown.expect(AAISchemaValidationException.class); - thrown.expectMessage(testError); - strat.notifyOnError(testError); - } + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void test() { + FailFastStrategy strat = new FailFastStrategy(); + + //simulate no issues found + assertTrue(strat.isOK()); + assertTrue("No errors found.".equals(strat.getErrorMsg())); + + //simulate an issue found + String testError = "hi i'm a problem"; + thrown.expect(AAISchemaValidationException.class); + thrown.expectMessage(testError); + strat.notifyOnError(testError); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java index 8c0ac82c..15396135 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java @@ -37,18 +37,18 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, BadNodeConfigForValidationTest.class, NodeIngestor.class, - CheckEverythingStrategy.class, DefaultVersionValidationModule.class, VersionValidator.class}) + CheckEverythingStrategy.class, DefaultVersionValidationModule.class, VersionValidator.class}) @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @SpringBootTest public class VersionValidatorRainyDayTest { - @Autowired - VersionValidator validator; + @Autowired + VersionValidator validator; - @Test - public void test() { - assertFalse(validator.validate()); - assertTrue(validator.getErrorMsg().contains(new SchemaVersion("v12").toString())); - assertTrue(validator.getErrorMsg().contains(new SchemaVersion("v11").toString())); - } + @Test + public void test() { + assertFalse(validator.validate()); + assertTrue(validator.getErrorMsg().contains(new SchemaVersion("v12").toString())); + assertTrue(validator.getErrorMsg().contains(new SchemaVersion("v11").toString())); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java index ff944aad..3c67c0d1 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java @@ -36,23 +36,23 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { - SchemaLocationsBean.class, - SchemaVersions.class, - GoodConfigForValidationTest.class, - NodeIngestor.class, - CheckEverythingStrategy.class, - DefaultVersionValidationModule.class, - VersionValidator.class + SchemaLocationsBean.class, + SchemaVersions.class, + GoodConfigForValidationTest.class, + NodeIngestor.class, + CheckEverythingStrategy.class, + DefaultVersionValidationModule.class, + VersionValidator.class }) @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @SpringBootTest public class VersionValidatorSunnyDayTest { - @Autowired - VersionValidator validator; + @Autowired + VersionValidator validator; - @Test - public void test() { - assertTrue(validator.validate()); - } + @Test + public void test() { + assertTrue(validator.validate()); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java index a4613813..75ab0d52 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java @@ -35,45 +35,45 @@ import org.onap.aai.setup.SchemaVersion; import com.jayway.jsonpath.DocumentContext; public class CousinDefaultingValidationModuleTest { - private static List<DocumentContext> ctxs; - private static CousinDefaultingValidationModule validator; + private static List<DocumentContext> ctxs; + private static CousinDefaultingValidationModule validator; - @BeforeClass - public static void setUpBeforeClass() { - Map<SchemaVersion, List<String>> testRules = new HashMap<>(); - List<String> testFiles = new ArrayList<>(); - testFiles.add("src/test/resources/edgeRules/cousinDefaultValidationTest.json"); + @BeforeClass + public static void setUpBeforeClass() { + Map<SchemaVersion, List<String>> testRules = new HashMap<>(); + List<String> testFiles = new ArrayList<>(); + testFiles.add("src/test/resources/edgeRules/cousinDefaultValidationTest.json"); - SchemaVersion LATEST_VERSION = new SchemaVersion("v14"); - testRules.put(LATEST_VERSION, testFiles); - - JsonIngestor ji = new JsonIngestor(); - ctxs = ji.ingest(testRules).get(LATEST_VERSION); - validator = new CousinDefaultingValidationModule(); - } - - @Test - public void testValidCousins() { - assertTrue("".equals(validator.validate("boop|beep", ctxs))); - } + SchemaVersion LATEST_VERSION = new SchemaVersion("v14"); + testRules.put(LATEST_VERSION, testFiles); + + JsonIngestor ji = new JsonIngestor(); + ctxs = ji.ingest(testRules).get(LATEST_VERSION); + validator = new CousinDefaultingValidationModule(); + } + + @Test + public void testValidCousins() { + assertTrue("".equals(validator.validate("boop|beep", ctxs))); + } - @Test - public void testValidBoth() { - assertTrue("".equals(validator.validate("monster|human", ctxs))); - } + @Test + public void testValidBoth() { + assertTrue("".equals(validator.validate("monster|human", ctxs))); + } - @Test - public void testValidSingleContains() { - assertTrue("".equals(validator.validate("family|baby", ctxs))); - } - - @Test - public void testInvalidTooManyDefaults() { - assertTrue(validator.validate("sheep|wool", ctxs).contains("Multiple set")); - } - - @Test - public void testInvalidNoDefaults() { - assertTrue(validator.validate("cloth|thread", ctxs).contains("None set")); - } + @Test + public void testValidSingleContains() { + assertTrue("".equals(validator.validate("family|baby", ctxs))); + } + + @Test + public void testInvalidTooManyDefaults() { + assertTrue(validator.validate("sheep|wool", ctxs).contains("Multiple set")); + } + + @Test + public void testInvalidNoDefaults() { + assertTrue(validator.validate("cloth|thread", ctxs).contains("None set")); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java index a1b5fa43..a38632b3 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java @@ -39,25 +39,25 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(classes = {DefaultEdgeFieldsValidationModule.class}) @SpringBootTest public class DefaultEdgeFieldsValidationModuleTest { - @Autowired - EdgeFieldsValidationModule validator; - - @Test - public void test() { - Map<String, String> test = new HashMap<>(); - for (EdgeField f : EdgeField.values()) { - test.put(f.toString(), "test"); - } - assertTrue("".equals(validator.verifyFields(test))); - - test.remove(EdgeField.DESCRIPTION.toString()); - assertTrue("".equals(validator.verifyFields(test))); //bc description is optional - - test.remove(EdgeField.CONTAINS.toString()); - assertTrue(validator.verifyFields(test).contains("missing required fields: contains-other-v")); - - test.remove(EdgeField.FROM.toString()); - assertTrue(validator.verifyFields(test).contains("missing required fields: from contains-other-v")); - } + @Autowired + EdgeFieldsValidationModule validator; + + @Test + public void test() { + Map<String, String> test = new HashMap<>(); + for (EdgeField f : EdgeField.values()) { + test.put(f.toString(), "test"); + } + assertTrue("".equals(validator.verifyFields(test))); + + test.remove(EdgeField.DESCRIPTION.toString()); + assertTrue("".equals(validator.verifyFields(test))); //bc description is optional + + test.remove(EdgeField.CONTAINS.toString()); + assertTrue(validator.verifyFields(test).contains("missing required fields: contains-other-v")); + + test.remove(EdgeField.FROM.toString()); + assertTrue(validator.verifyFields(test).contains("missing required fields: from contains-other-v")); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java index 2a49e45a..8bd66565 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java @@ -43,22 +43,22 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, BadEdgeConfigForValidationTest.class, NodeIngestor.class, - CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, - SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, - EdgeRuleValidator.class}) + CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, + SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, + EdgeRuleValidator.class}) @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @SpringBootTest public class EdgeRuleValidatorRainyDayTest { - @Autowired - EdgeRuleValidator validator; + @Autowired + EdgeRuleValidator validator; - @Test - public void test() { - assertNotNull(validator); //verify spring wiring OK - assertFalse(validator.validate()); - String errors = validator.getErrorMsg(); - assertTrue(errors.contains("missing required fields: delete-other-v")); - assertTrue(errors.contains("has multiple rules using the same label: org.onap.relationships.inventory.Source")); - assertTrue(errors.contains("Invalid node type(s) found: gooble")); - } + @Test + public void test() { + assertNotNull(validator); //verify spring wiring OK + assertFalse(validator.validate()); + String errors = validator.getErrorMsg(); + assertTrue(errors.contains("missing required fields: delete-other-v")); + assertTrue(errors.contains("has multiple rules using the same label: org.onap.relationships.inventory.Source")); + assertTrue(errors.contains("Invalid node type(s) found: gooble")); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java index af782ccf..a918356c 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java @@ -43,19 +43,19 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, GoodConfigForValidationTest.class, NodeIngestor.class, - CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, - SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, - EdgeRuleValidator.class}) + CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, + SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, + EdgeRuleValidator.class}) @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @SpringBootTest public class EdgeRuleValidatorSunnyDayTest { - @Autowired - EdgeRuleValidator validator; + @Autowired + EdgeRuleValidator validator; - @Test - public void test() { - assertNotNull(validator); //verify spring wiring OK - assertTrue(validator.validate()); - assertTrue("No errors found.".equals(validator.getErrorMsg())); - } + @Test + public void test() { + assertNotNull(validator); //verify spring wiring OK + assertTrue(validator.validate()); + assertTrue("No errors found.".equals(validator.getErrorMsg())); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java index e3efc23c..245e0600 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java @@ -43,25 +43,25 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @SpringBootTest public class NodeTypesValidationModuleTest { - @Autowired - NodeTypesValidationModule validator; + @Autowired + NodeTypesValidationModule validator; - @Test - public void test() { - List<String> testPairs = new ArrayList<>(); - testPairs.add("bar|foo"); - testPairs.add("foo|foo"); - testPairs.add("foo|quux"); - assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11")))); - assertTrue(validator.validate(testPairs, new SchemaVersion("v10")).contains("Invalid node type(s) found: quux")); //bc no quux in v10 - } + @Test + public void test() { + List<String> testPairs = new ArrayList<>(); + testPairs.add("bar|foo"); + testPairs.add("foo|foo"); + testPairs.add("foo|quux"); + assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11")))); + assertTrue(validator.validate(testPairs, new SchemaVersion("v10")).contains("Invalid node type(s) found: quux")); //bc no quux in v10 + } - @Test - public void testWeirdCases() { - List<String> testPairs = new ArrayList<>(); - testPairs.add("bar|"); - testPairs.add("|foo"); - testPairs.add("|"); - assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11")))); //bc empty just ignored - } + @Test + public void testWeirdCases() { + List<String> testPairs = new ArrayList<>(); + testPairs.add("bar|"); + testPairs.add("|foo"); + testPairs.add("|"); + assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11")))); //bc empty just ignored + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java index ae7c23d7..7acb558a 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java @@ -32,34 +32,34 @@ import org.onap.aai.setup.SchemaVersion; import com.jayway.jsonpath.DocumentContext; public class SingleContainmentValidationModuleTest { - private static List<DocumentContext> ctxs; - private static SingleContainmentValidationModule validator; - public static final SchemaVersion LATEST = new SchemaVersion("v14"); + private static List<DocumentContext> ctxs; + private static SingleContainmentValidationModule validator; + public static final SchemaVersion LATEST = new SchemaVersion("v14"); - @BeforeClass - public static void setUpBeforeClass() { - Map<SchemaVersion, List<String>> testRules = new TreeMap<>(); - List<String> testFiles = new ArrayList<>(); - testFiles.add("src/test/resources/edgeRules/containsValidationTest.json"); - testRules.put(LATEST, testFiles); - - JsonIngestor ji = new JsonIngestor(); - ctxs = ji.ingest(testRules).get(LATEST); - validator = new SingleContainmentValidationModule(); - } + @BeforeClass + public static void setUpBeforeClass() { + Map<SchemaVersion, List<String>> testRules = new TreeMap<>(); + List<String> testFiles = new ArrayList<>(); + testFiles.add("src/test/resources/edgeRules/containsValidationTest.json"); + testRules.put(LATEST, testFiles); + + JsonIngestor ji = new JsonIngestor(); + ctxs = ji.ingest(testRules).get(LATEST); + validator = new SingleContainmentValidationModule(); + } - @Test - public void testValid() { - assertTrue("".equals(validator.validate("human|monster", ctxs))); - } + @Test + public void testValid() { + assertTrue("".equals(validator.validate("human|monster", ctxs))); + } - @Test - public void testValidWithNone() { - assertTrue("".equals(validator.validate("bread|cheese", ctxs))); - } - - @Test - public void testInvalid() { - assertTrue(validator.validate("box|cat", ctxs).contains("has multiple containment rules")); - } + @Test + public void testValidWithNone() { + assertTrue("".equals(validator.validate("bread|cheese", ctxs))); + } + + @Test + public void testInvalid() { + assertTrue(validator.validate("box|cat", ctxs).contains("has multiple containment rules")); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java index 3b0ab034..233f8b4b 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java @@ -32,61 +32,61 @@ import org.onap.aai.setup.SchemaVersion; import com.jayway.jsonpath.DocumentContext; public class UniqueLabelValidationModuleTest { - private static List<DocumentContext> ctxs; - private static UniqueLabelValidationModule validator; - public static final SchemaVersion LATEST = new SchemaVersion("v14"); + private static List<DocumentContext> ctxs; + private static UniqueLabelValidationModule validator; + public static final SchemaVersion LATEST = new SchemaVersion("v14"); - @BeforeClass - public static void setup() { - Map<SchemaVersion, List<String>> testRules = new TreeMap<>(); - List<String> testFiles = new ArrayList<>(); - testFiles.add("src/test/resources/edgeRules/labelValidationTest1.json"); - testFiles.add("src/test/resources/edgeRules/labelValidationTest2.json"); - testRules.put(LATEST, testFiles); - - JsonIngestor ji = new JsonIngestor(); - ctxs = ji.ingest(testRules).get(LATEST); - validator = new UniqueLabelValidationModule(); - } + @BeforeClass + public static void setup() { + Map<SchemaVersion, List<String>> testRules = new TreeMap<>(); + List<String> testFiles = new ArrayList<>(); + testFiles.add("src/test/resources/edgeRules/labelValidationTest1.json"); + testFiles.add("src/test/resources/edgeRules/labelValidationTest2.json"); + testRules.put(LATEST, testFiles); + + JsonIngestor ji = new JsonIngestor(); + ctxs = ji.ingest(testRules).get(LATEST); + validator = new UniqueLabelValidationModule(); + } - @Test - public void testValidSetOneFile() { - assertTrue("".equals(validator.validate("human|monster", ctxs))); - assertTrue("".equals(validator.validate("monster|human", ctxs))); - } - - @Test - public void testValidDupLabelButDiffPairs() { - assertTrue("".equals(validator.validate("human|strange-and-interesting-plant", ctxs))); - assertTrue("".equals(validator.validate("strange-and-interesting-plant|human", ctxs))); - } - - @Test - public void testValidAcrossFiles() { - assertTrue("".equals(validator.validate("human|toaster", ctxs))); - assertTrue("".equals(validator.validate("toaster|human", ctxs))); - } + @Test + public void testValidSetOneFile() { + assertTrue("".equals(validator.validate("human|monster", ctxs))); + assertTrue("".equals(validator.validate("monster|human", ctxs))); + } + + @Test + public void testValidDupLabelButDiffPairs() { + assertTrue("".equals(validator.validate("human|strange-and-interesting-plant", ctxs))); + assertTrue("".equals(validator.validate("strange-and-interesting-plant|human", ctxs))); + } + + @Test + public void testValidAcrossFiles() { + assertTrue("".equals(validator.validate("human|toaster", ctxs))); + assertTrue("".equals(validator.validate("toaster|human", ctxs))); + } - @Test - public void testInvalidSetOneFileBothTypes() { - assertTrue(validator.validate("sphinx|monster", ctxs).contains("has multiple rules using the same label")); - assertTrue(validator.validate("monster|sphinx", ctxs).contains("has multiple rules using the same label")); - } - - @Test - public void testInvalidSetOneFileJustCousins() { - assertTrue(validator.validate("griffin|hippogriff", ctxs).contains("has multiple rules using the same label")); - assertTrue(validator.validate("hippogriff|griffin", ctxs).contains("has multiple rules using the same label")); - } - - @Test - public void testInvalidSetMultipleFiles() { - assertTrue(validator.validate("lava|floor", ctxs).contains("has multiple rules using the same label")); - assertTrue(validator.validate("floor|lava", ctxs).contains("has multiple rules using the same label")); - } - - @Test - public void testInvalidCopyInOtherFile() { - assertTrue(validator.validate("badger|mushroom", ctxs).contains("has multiple rules using the same label")); - } + @Test + public void testInvalidSetOneFileBothTypes() { + assertTrue(validator.validate("sphinx|monster", ctxs).contains("has multiple rules using the same label")); + assertTrue(validator.validate("monster|sphinx", ctxs).contains("has multiple rules using the same label")); + } + + @Test + public void testInvalidSetOneFileJustCousins() { + assertTrue(validator.validate("griffin|hippogriff", ctxs).contains("has multiple rules using the same label")); + assertTrue(validator.validate("hippogriff|griffin", ctxs).contains("has multiple rules using the same label")); + } + + @Test + public void testInvalidSetMultipleFiles() { + assertTrue(validator.validate("lava|floor", ctxs).contains("has multiple rules using the same label")); + assertTrue(validator.validate("floor|lava", ctxs).contains("has multiple rules using the same label")); + } + + @Test + public void testInvalidCopyInOtherFile() { + assertTrue(validator.validate("badger|mushroom", ctxs).contains("has multiple rules using the same label")); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java index a026504f..86fe8a77 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java @@ -39,21 +39,21 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, BadNodeConfigForValidationTest.class, NodeIngestor.class, - CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) + CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @SpringBootTest public class NodeValidatorRainyDayTest { - @Autowired - NodeValidator validator; + @Autowired + NodeValidator validator; - @Test - public void test() { - assertNotNull(validator); //check spring wiring ok - assertFalse(validator.validate()); - String result = validator.getErrorMsg(); - assertTrue(result.contains("LogicalLink")); - assertTrue(result.contains("LagInterface")); - assertFalse(result.contains("LInterface")); - } + @Test + public void test() { + assertNotNull(validator); //check spring wiring ok + assertFalse(validator.validate()); + String result = validator.getErrorMsg(); + assertTrue(result.contains("LogicalLink")); + assertTrue(result.contains("LagInterface")); + assertFalse(result.contains("LInterface")); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java index 83bf3748..e40f9301 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java @@ -54,35 +54,35 @@ import javax.xml.transform.stream.StreamResult; @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) //@SpringBootTest public class NodeValidatorSchemaIncompleteTest { - @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(); + @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(); - //Throws a NullPointerException because a JavaType is referenced, but not defined - @Test - public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException { - thrown.expect(NullPointerException.class); + //Throws a NullPointerException because a JavaType is referenced, but not defined + @Test + public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException { + thrown.expect(NullPointerException.class); - - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - printDocument(ni.getSchema(new SchemaVersion("v12")),buffer); - } - - public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); + + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + printDocument(ni.getSchema(new SchemaVersion("v12")),buffer); + } + + public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - transformer.transform(new DOMSource(doc), - new StreamResult(new OutputStreamWriter(out, "UTF-8"))); - } + transformer.transform(new DOMSource(doc), + new StreamResult(new OutputStreamWriter(out, "UTF-8"))); + } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java index 6d0a6a50..257d6e18 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java @@ -39,18 +39,18 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaVersions.class, GoodConfigForValidationTest.class, NodeIngestor.class, - CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) + CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) @TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) @SpringBootTest public class NodeValidatorSunnyDayTest { - @Autowired - NodeValidator validator; + @Autowired + NodeValidator validator; - @Test - public void test() { - assertNotNull(validator); //check spring wiring ok - assertTrue(validator.validate()); - assertTrue("No errors found.".equals(validator.getErrorMsg())); - } + @Test + public void test() { + assertNotNull(validator); //check spring wiring ok + assertTrue(validator.validate()); + assertTrue("No errors found.".equals(validator.getErrorMsg())); + } } |