From dd41187b272341b8250ad4e09a03462107bc8847 Mon Sep 17 00:00:00 2001 From: Keong Lim Date: Thu, 21 Mar 2019 15:32:25 +1100 Subject: AAI-1523 Batch reformat aai-schema-ingest Use maven plugins from AAI-2198 to do batch reformat of aai-schema-ingest to consistent code style. Change-Id: I9ad7aa66edcada25fbeba7658ff8f258dab9ca93 Issue-ID: AAI-1523 Signed-off-by: Keong Lim --- .../org/onap/aai/edges/EdgeIngestorLocalTest.java | 160 ++++++++------- .../java/org/onap/aai/edges/EdgeIngestorTest.java | 89 ++++---- .../org/onap/aai/edges/EdgeIngestorWiringTest.java | 14 +- .../java/org/onap/aai/edges/EdgeRuleQueryTest.java | 53 +++-- .../test/java/org/onap/aai/edges/EdgeRuleTest.java | 5 +- .../java/org/onap/aai/edges/JsonIngestorTest.java | 27 +-- .../org/onap/aai/edges/TypeAlphabetizerTest.java | 1 + .../org/onap/aai/nodes/NodeIngestorLocalTest.java | 48 ++--- .../java/org/onap/aai/nodes/NodeIngestorTest.java | 117 ++++++----- .../org/onap/aai/nodes/NodeIngestorWiringTest.java | 17 +- .../java/org/onap/aai/restclient/MockProvider.java | 8 +- .../org/onap/aai/restclient/MockRestClient.java | 224 ++++++++++----------- .../org/onap/aai/restclient/RestClientTest.java | 1 + .../onap/aai/restclient/SchemaRestClientTest.java | 26 ++- .../onap/aai/setup/ConfigTranslatorWiringTest.java | 23 ++- .../SchemaLocationsBeanDefaultInjectionTest.java | 6 +- .../SchemaLocationsBeanEnvVarInjectionTest.java | 8 +- .../setup/SchemaLocationsBeanXMLSetterTest.java | 8 +- ...hemaLocationsBeanXMLSetterWithPropFileTest.java | 8 +- .../aai/setup/SchemaVersionsBeanOverrideTest.java | 21 +- .../org/onap/aai/setup/SchemaVersionsBeanTest.java | 34 ++-- .../testutils/BadEdgeConfigForValidationTest.java | 5 +- .../testutils/BadNodeConfigForValidationTest.java | 10 +- .../testutils/ConfigTranslatorForWiringTest.java | 9 +- .../aai/testutils/GoodConfigForValidationTest.java | 16 +- .../aai/testutils/SchemaIncompleteTranslator.java | 24 +-- .../aai/testutils/TestUtilConfigTranslator.java | 27 +-- .../TestUtilConfigTranslatorforBusiness.java | 33 +-- .../validation/CheckEverythingStrategyTest.java | 10 +- .../onap/aai/validation/FailFastStrategyTest.java | 10 +- .../validation/VersionValidatorRainyDayTest.java | 9 +- .../validation/VersionValidatorSunnyDayTest.java | 15 +- .../CousinDefaultingValidationModuleTest.java | 12 +- .../DefaultEdgeFieldsValidationModuleTest.java | 10 +- .../edges/EdgeRuleValidatorRainyDayTest.java | 16 +- .../edges/EdgeRuleValidatorSunnyDayTest.java | 16 +- .../edges/NodeTypesValidationModuleTest.java | 17 +- .../SingleContainmentValidationModuleTest.java | 8 +- .../edges/UniqueLabelValidationModuleTest.java | 16 +- .../nodes/NodeValidatorRainyDayTest.java | 12 +- .../nodes/NodeValidatorSchemaIncompleteTest.java | 51 +++-- .../nodes/NodeValidatorSunnyDayTest.java | 13 +- 42 files changed, 639 insertions(+), 598 deletions(-) (limited to 'aai-schema-ingest/src/test') diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java index 3ed7bb79..e3826576 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java @@ -20,18 +20,23 @@ package org.onap.aai.edges; +import static org.junit.Assert.*; + import com.google.common.collect.Multimap; + +import java.util.Collection; + import org.apache.tinkerpop.gremlin.structure.Direction; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.onap.aai.restclient.MockProvider; import org.onap.aai.config.EdgesConfiguration; import org.onap.aai.edges.enums.AAIDirection; import org.onap.aai.edges.enums.MultiplicityRule; import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; +import org.onap.aai.restclient.MockProvider; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.testutils.TestUtilConfigTranslator; @@ -42,16 +47,14 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.Collection; - -import static org.junit.Assert.*; - @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { EdgesConfiguration.class, TestUtilConfigTranslator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@ContextConfiguration(classes = {EdgesConfiguration.class, TestUtilConfigTranslator.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -//@TestPropertySource(locations = "/schema-service-rest.properties" ) +// @TestPropertySource(locations = "/schema-service-rest.properties" ) @SpringBootTest public class EdgeIngestorLocalTest { @Autowired @@ -70,7 +73,7 @@ public class EdgeIngestorLocalTest { assertTrue(2 == results.get("bar|foo").size()); boolean seenLabel1 = false; boolean seenLabel2 = false; - for(EdgeRule r : results.get("bar|foo")) { + for (EdgeRule r : results.get("bar|foo")) { if ("eats".equals(r.getLabel())) { seenLabel1 = true; } @@ -107,16 +110,17 @@ public class EdgeIngestorLocalTest { @Test public void getRulesFlippedTypesTest() throws EdgeRuleNotFoundException { - EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); + EdgeRuleQuery q = + new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); Multimap results = edgeIngestor.getRules(q); assertTrue(results.size() == 3); for (EdgeRule r : results.get("l-interface|logical-link")) { - if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) || - "org.onap.relationships.inventory.Destination".equals(r.getLabel())) { - //these are defined with from=logical-link, to=l-interface, so they must be flipped + 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 + // 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"); @@ -126,19 +130,19 @@ public class EdgeIngestorLocalTest { @Test public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { - //getRules, setting from and to - EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build(); + // getRules, setting from and to + EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop", "bloop").version(new SchemaVersion("v11")).build(); Multimap results = edgeIngestor.getRules(q); assertTrue(results.size() == 1); for (EdgeRule r : results.get("bloop|bloop")) { assertTrue(Direction.IN.equals(r.getDirection())); } - //getRule, setting just from + // getRule, setting just from EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build(); assertTrue(Direction.IN.equals(edgeIngestor.getRule(q2).getDirection())); - //getChildRules + // getChildRules Multimap child = edgeIngestor.getChildRules("bloop", new SchemaVersion("v11")); assertTrue(child.size() == 1); for (EdgeRule r : child.get("bloop|bloop")) { @@ -186,7 +190,7 @@ public class EdgeIngestorLocalTest { 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 + // 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())); @@ -195,44 +199,47 @@ public class EdgeIngestorLocalTest { assertTrue("parent contains notation".equals(result.getDescription())); } -// @Test -// public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { -// -// EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new SchemaVersion("v11")).build(); -// EdgeRule res = edgeIngestor.getRule(q); -// assertTrue(res.isDefault()); -// assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel())); -// } -// -// @Test -// public void getRuleWithNonDefault() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { -// EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").label("org.onap.relationships.inventory.Source").version(new SchemaVersion("v11")).build(); -// EdgeRule res = edgeIngestor.getRule(q); -// assertFalse(res.isDefault()); -// assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel())); -// } + // @Test + // public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + // + // EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new + // SchemaVersion("v11")).build(); + // EdgeRule res = edgeIngestor.getRule(q); + // assertTrue(res.isDefault()); + // assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel())); + // } + // + // @Test + // public void getRuleWithNonDefault() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + // EdgeRuleQuery q = new + // EdgeRuleQuery.Builder("l-interface","logical-link").label("org.onap.relationships.inventory.Source").version(new + // SchemaVersion("v11")).build(); + // EdgeRule res = edgeIngestor.getRule(q); + // assertFalse(res.isDefault()); + // assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel())); + // } @Test public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { thrown.expect(EdgeRuleNotFoundException.class); thrown.expectMessage("No rule found for"); - EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","nonexistent").build(); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build(); edgeIngestor.getRule(q); } -// @Test -// public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { -// thrown.expect(AmbiguousRuleChoiceException.class); -// thrown.expectMessage("No way to select single rule from these pairs:"); -// EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); -// edgeIngestor.getRule(q); -// } + // @Test + // public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + // thrown.expect(AmbiguousRuleChoiceException.class); + // thrown.expectMessage("No way to select single rule from these pairs:"); + // EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); + // edgeIngestor.getRule(q); + // } @Test public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { thrown.expect(AmbiguousRuleChoiceException.class); thrown.expectMessage("Multiple defaults found."); - EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed","plant").version(new SchemaVersion("v11")).build(); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build(); edgeIngestor.getRule(q); } @@ -244,19 +251,20 @@ public class EdgeIngestorLocalTest { edgeIngestor.getRule(q); } -// @Test -// public void hasRuleTest() { -// assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); -// assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); -// } -// -// @Test -// public void getCousinRulesTest() { -// Multimap results = edgeIngestor.getCousinRules("dog"); -// assertTrue(results.size() == 2); -// assertTrue(results.containsKey("dog|puppy")); -// assertTrue(results.containsKey("dog|foo")); -// } + // @Test + // public void hasRuleTest() { + // assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new + // SchemaVersion("v11")).build())); + // assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); + // } + // + // @Test + // public void getCousinRulesTest() { + // Multimap results = edgeIngestor.getCousinRules("dog"); + // assertTrue(results.size() == 2); + // assertTrue(results.containsKey("dog|puppy")); + // assertTrue(results.containsKey("dog|foo")); + // } @Test public void getCousinRulesWithVersionTest() { @@ -272,13 +280,13 @@ public class EdgeIngestorLocalTest { assertTrue(results.isEmpty()); } -// @Test -// public void hasCousinTest() { -// assertTrue(edgeIngestor.hasCousinRule("foo")); -// assertTrue(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v10"))); -// assertFalse(edgeIngestor.hasCousinRule("parent")); -// assertFalse(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v11"))); -// } + // @Test + // public void hasCousinTest() { + // assertTrue(edgeIngestor.hasCousinRule("foo")); + // assertTrue(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v10"))); + // assertFalse(edgeIngestor.hasCousinRule("parent")); + // assertFalse(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v11"))); + // } @Test public void getChildRulesTest() { @@ -306,13 +314,13 @@ public class EdgeIngestorLocalTest { assertTrue(results.isEmpty()); } -// @Test -// public void hasChildTest() { -// assertTrue(edgeIngestor.hasChildRule("foo")); -// assertTrue(edgeIngestor.hasChildRule("foo", new SchemaVersion("v10"))); -// assertFalse(edgeIngestor.hasChildRule("puppy")); -// assertFalse(edgeIngestor.hasChildRule("foo", new SchemaVersion("v11"))); -// } + // @Test + // public void hasChildTest() { + // assertTrue(edgeIngestor.hasChildRule("foo")); + // assertTrue(edgeIngestor.hasChildRule("foo", new SchemaVersion("v10"))); + // assertFalse(edgeIngestor.hasChildRule("puppy")); + // assertFalse(edgeIngestor.hasChildRule("foo", new SchemaVersion("v11"))); + // } @Test public void getParentRulesTest() { @@ -347,11 +355,11 @@ public class EdgeIngestorLocalTest { assertFalse(edgeIngestor.hasParentRule("foo", new SchemaVersion("v11"))); } -// @Test -// public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException { -// Multimap res = edgeIngestor.getAllCurrentRules(); -// assertTrue(res.size() == 18); -// } + // @Test + // public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException { + // Multimap res = edgeIngestor.getAllCurrentRules(); + // assertTrue(res.size() == 18); + // } @Test public void getAllRulesTest() throws EdgeRuleNotFoundException { 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 ab83e196..8fdce62b 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 @@ -22,6 +22,8 @@ package org.onap.aai.edges; import static org.junit.Assert.*; +import com.google.common.collect.Multimap; + import java.util.Collection; import org.apache.tinkerpop.gremlin.structure.Direction; @@ -30,13 +32,13 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.onap.aai.restclient.MockProvider; -import org.onap.aai.restclient.MockRestClient; import org.onap.aai.config.EdgesConfiguration; import org.onap.aai.edges.enums.AAIDirection; import org.onap.aai.edges.enums.MultiplicityRule; import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; +import org.onap.aai.restclient.MockProvider; +import org.onap.aai.restclient.MockRestClient; import org.onap.aai.setup.SchemaVersion; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -45,11 +47,10 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.google.common.collect.Multimap; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {MockProvider.class, EdgesConfiguration.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" }) +@TestPropertySource( + properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @SpringBootTest @@ -74,7 +75,7 @@ public class EdgeIngestorTest { assertTrue(2 == results.get("bar|foo").size()); boolean seenLabel1 = false; boolean seenLabel2 = false; - for(EdgeRule r : results.get("bar|foo")) { + for (EdgeRule r : results.get("bar|foo")) { if ("eats".equals(r.getLabel())) { seenLabel1 = true; } @@ -111,16 +112,17 @@ public class EdgeIngestorTest { @Test public void getRulesFlippedTypesTest() throws EdgeRuleNotFoundException { - EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); + EdgeRuleQuery q = + new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); Multimap results = edgeIngestor.getRules(q); assertTrue(results.size() == 3); for (EdgeRule r : results.get("l-interface|logical-link")) { - if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) || - "org.onap.relationships.inventory.Destination".equals(r.getLabel())) { - //these are defined with from=logical-link, to=l-interface, so they must be flipped + 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 + // 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"); @@ -130,19 +132,19 @@ public class EdgeIngestorTest { @Test public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { - //getRules, setting from and to - EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build(); + // getRules, setting from and to + EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop", "bloop").version(new SchemaVersion("v11")).build(); Multimap results = edgeIngestor.getRules(q); assertTrue(results.size() == 1); for (EdgeRule r : results.get("bloop|bloop")) { assertTrue(Direction.IN.equals(r.getDirection())); } - //getRule, setting just from + // getRule, setting just from EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build(); assertTrue(Direction.IN.equals(edgeIngestor.getRule(q2).getDirection())); - //getChildRules + // getChildRules Multimap child = edgeIngestor.getChildRules("bloop", new SchemaVersion("v11")); assertTrue(child.size() == 1); for (EdgeRule r : child.get("bloop|bloop")) { @@ -182,25 +184,24 @@ public class EdgeIngestorTest { assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete())); assertTrue("parent contains notation".equals(result.getDescription())); } -// @Test -// public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { -// EdgeRuleQuery q = new EdgeRuleQuery.Builder("parent", "notation").build(); -// Multimap results = edgeIngestor.getRules(q); -// assertTrue(results.size() == 1); -// // EdgeRule result = edgeIngestor.getRule(q); -// for (EdgeRule result : results.get("parent|notation")) { -// assertTrue("parent".equals(result.getFrom())); -// assertTrue("notation".equals(result.getTo())); -// assertTrue("has".equals(result.getLabel())); -// assertTrue(Direction.OUT.equals(result.getDirection())); -// assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule())); -// assertTrue(AAIDirection.OUT.toString().equals(result.getContains())); -// assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV())); -// assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete())); -// assertTrue("parent contains notation".equals(result.getDescription())); -// } -// } - + // @Test + // public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { + // EdgeRuleQuery q = new EdgeRuleQuery.Builder("parent", "notation").build(); + // Multimap results = edgeIngestor.getRules(q); + // assertTrue(results.size() == 1); + // // EdgeRule result = edgeIngestor.getRule(q); + // for (EdgeRule result : results.get("parent|notation")) { + // assertTrue("parent".equals(result.getFrom())); + // assertTrue("notation".equals(result.getTo())); + // assertTrue("has".equals(result.getLabel())); + // assertTrue(Direction.OUT.equals(result.getDirection())); + // assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule())); + // assertTrue(AAIDirection.OUT.toString().equals(result.getContains())); + // assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV())); + // assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete())); + // assertTrue("parent contains notation".equals(result.getDescription())); + // } + // } @Test public void getRuleFlippedTypesTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { @@ -209,7 +210,7 @@ public class EdgeIngestorTest { 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 + // 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())); @@ -221,7 +222,8 @@ public class EdgeIngestorTest { @Test public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException { - EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new SchemaVersion("v11")).build(); + EdgeRuleQuery q = + new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build(); EdgeRule res = edgeIngestor.getRule(q); assertTrue(res.isDefault()); assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel())); @@ -229,7 +231,8 @@ public class EdgeIngestorTest { @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(); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link") + .label("org.onap.relationships.inventory.Source").version(new SchemaVersion("v11")).build(); EdgeRule res = edgeIngestor.getRule(q); assertFalse(res.isDefault()); assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel())); @@ -239,7 +242,7 @@ public class EdgeIngestorTest { 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(); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build(); edgeIngestor.getRule(q); } @@ -255,7 +258,7 @@ public class EdgeIngestorTest { 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(); + EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build(); edgeIngestor.getRule(q); } @@ -269,10 +272,12 @@ public class EdgeIngestorTest { @Test public void hasRuleTest() { - assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); - assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v10")).build())); + assertTrue(edgeIngestor + .hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build())); + assertFalse(edgeIngestor + .hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v10")).build())); assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); -// assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); + // assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build())); } @Test 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 395c9cc7..0a6a3f07 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java @@ -22,6 +22,8 @@ package org.onap.aai.edges; import static org.junit.Assert.*; +import com.google.common.collect.Multimap; + import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -29,7 +31,6 @@ import org.onap.aai.config.EdgesConfiguration; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersionsBean; - import org.onap.aai.testutils.ConfigTranslatorForWiringTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -37,20 +38,21 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.google.common.collect.Multimap; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {EdgesConfiguration.class, ConfigTranslatorForWiringTest.class}) -@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.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(); + EdgeRuleQuery q = + new EdgeRuleQuery.Builder("quux", "foo").label("dancesWith").version(new SchemaVersion("v10")).build(); Multimap results = ei.getRules(q); assertTrue(results.size() == 1); assertTrue(results.containsKey("foo|quux")); diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java index 27c8d6e1..c1894f00 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 @@ -22,6 +22,9 @@ package org.onap.aai.edges; import static org.junit.Assert.*; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; + import java.io.InputStream; import java.util.List; import java.util.Scanner; @@ -30,14 +33,10 @@ import org.junit.Before; import org.junit.Test; import org.onap.aai.edges.enums.EdgeType; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.JsonPath; - - public class EdgeRuleQueryTest { private DocumentContext testRules; private String readStart = "$.rules.[?]"; - + /* **** DATA SETUP **** */ @Before public void setup() { @@ -46,85 +45,85 @@ public class EdgeRuleQueryTest { 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 + // rule defined from quux to foo EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").build(); List results = testRules.read(readStart, q.getFilter()); - + assertTrue(results.size() == 1); } @Test public void testToFromSingle() { - //rule defined from quux to foo, this is flipped + // rule defined from quux to foo, this is flipped EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "quux").build(); List results = testRules.read(readStart, q.getFilter()); - + assertTrue(results.size() == 1); } - + @Test public void testFromToMultiple() { - //rules have two from foo to bar + // rules have two from foo to bar EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "bar").build(); List results = testRules.read(readStart, q.getFilter()); assertTrue(results.size() == 2); } - + @Test public void testToFromMultiple() { - //rules have two from foo to bar + // rules have two from foo to bar EdgeRuleQuery q = new EdgeRuleQuery.Builder("bar", "foo").build(); List results = testRules.read(readStart, q.getFilter()); - + assertTrue(results.size() == 2); assertTrue(!(results.get(0).toString().equals(results.get(1).toString()))); } - + @Test public void testJustFrom() { - //there are 4 foo rules (foo>bar, foo>bar, foo>baz, quux>foo) + // there are 4 foo rules (foo>bar, foo>bar, foo>baz, quux>foo) EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build(); List results = testRules.read(readStart, q.getFilter()); assertTrue(results.size() == 4); - - //there are 2 bar rules + + // there are 2 bar rules EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bar").build(); List results2 = testRules.read(readStart, q2.getFilter()); assertTrue(results2.size() == 2); } - + @Test public void testWithLabel() { - //there are foo >eats> bar and foo >eatz> bar - EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo","bar").label("eatz").build(); + // there are foo >eats> bar and foo >eatz> bar + EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "bar").label("eatz").build(); List results = testRules.read(readStart, q.getFilter()); assertTrue(results.size() == 1); assertTrue(results.get(0).toString().contains("eatz")); } - + @Test public void testCousin() { EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.COUSIN).build(); List results = testRules.read(readStart, q.getFilter()); assertTrue(results.size() == 2); - + EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("foo", "bar").edgeType(EdgeType.COUSIN).label("eats").build(); List results2 = testRules.read(readStart, q2.getFilter()); assertTrue(results2.size() == 1); assertTrue(results2.get(0).toString().contains("eats")); - - EdgeRuleQuery q3 = new EdgeRuleQuery.Builder("foo","quux").edgeType(EdgeType.COUSIN).build(); + + EdgeRuleQuery q3 = new EdgeRuleQuery.Builder("foo", "quux").edgeType(EdgeType.COUSIN).build(); List results3 = testRules.read(readStart, q3.getFilter()); assertTrue(results3.isEmpty()); } - + @Test public void testTree() { EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.TREE).build(); 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 5abae6b7..3fdabfd1 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 @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.edges; import static org.junit.Assert.*; @@ -44,12 +45,12 @@ public class EdgeRuleTest { 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(); 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 4475b3f2..c67be641 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 @@ -20,17 +20,18 @@ package org.onap.aai.edges; +import static com.jayway.jsonpath.Criteria.where; +import static com.jayway.jsonpath.Filter.filter; import static org.junit.Assert.*; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.Filter; + import java.util.*; + import org.junit.Test; import org.onap.aai.setup.SchemaVersion; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.Filter; -import static com.jayway.jsonpath.Criteria.where; -import static com.jayway.jsonpath.Filter.filter; - public class JsonIngestorTest { private SchemaVersion LATEST = new SchemaVersion("v14"); @@ -39,34 +40,34 @@ public class JsonIngestorTest { @Test public void test() { - //setup + // setup List files = new ArrayList<>(); files.add("src/test/resources/edgeRules/test.json"); files.add("src/test/resources/edgeRules/test2.json"); files.add("src/test/resources/edgeRules/otherTestRules.json"); Map> input = new TreeMap<>(); input.put(LATEST, files); - + List files2 = new ArrayList<>(); files2.add("src/test/resources/edgeRules/test.json"); input.put(V10, files2); - + List files3 = new ArrayList<>(); files3.add("src/test/resources/edgeRules/test3.json"); files3.add("src/test/resources/edgeRules/defaultEdgesTest.json"); input.put(V11, files3); - - //test + + // test JsonIngestor ji = new JsonIngestor(); Map> 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> filterRes = results.get(V10).get(0).read("$.rules.[?]",f); + List> 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 3f49428f..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 @@ -21,6 +21,7 @@ package org.onap.aai.edges; import static org.junit.Assert.*; + import org.junit.Test; public class TypeAlphabetizerTest { diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java index cec3f9d8..dca21f2d 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java @@ -20,14 +20,26 @@ package org.onap.aai.nodes; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.xml.bind.SchemaOutputResolver; +import javax.xml.transform.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + import org.eclipse.persistence.dynamic.DynamicEntity; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.onap.aai.restclient.MockProvider; import org.onap.aai.config.NodesConfiguration; +import org.onap.aai.restclient.MockProvider; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.testutils.TestUtilConfigTranslator; import org.springframework.beans.factory.annotation.Autowired; @@ -39,19 +51,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringRunner; import org.w3c.dom.Document; -import javax.xml.bind.SchemaOutputResolver; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Paths; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - @RunWith(SpringRunner.class) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties" }) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"}) @ContextConfiguration(classes = {TestUtilConfigTranslator.class, NodesConfiguration.class}) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @@ -59,8 +62,8 @@ import static org.junit.Assert.*; @SpringBootTest public class NodeIngestorLocalTest { - //set thrown.expect to whatever a specific test needs - //this establishes a default of expecting no exceptions to be thrown + // 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 @@ -75,21 +78,20 @@ public class NodeIngestorLocalTest { 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"))); } @Test public void testGetContextForVersion11() { DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10")); - //should work bc Foo is valid in test_network_v10 schema + // 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 + // 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"))); @@ -98,7 +100,7 @@ public class NodeIngestorLocalTest { DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11")); - //should work bc Foo.quantity is valid in test_network_v11 schema + // 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"))); @@ -109,9 +111,8 @@ public class NodeIngestorLocalTest { XSDOutputResolver outputResolver11 = new XSDOutputResolver(); ctx11.generateSchema(outputResolver11); - thrown.expect(IllegalArgumentException.class); - //should fail bc Quux not in v10 test schema + // should fail bc Quux not in v10 test schema ctx10.newDynamicEntity("Quux"); } @@ -157,8 +158,7 @@ public class NodeIngestorLocalTest { private class XSDOutputResolver extends SchemaOutputResolver { @Override - public Result createOutput(String namespaceUri, String suggestedFileName) - throws IOException { + public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { // create new file // create stream result diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java index ec529f9d..7035affd 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java @@ -20,14 +20,26 @@ package org.onap.aai.nodes; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.xml.bind.SchemaOutputResolver; +import javax.xml.transform.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + import org.eclipse.persistence.dynamic.DynamicEntity; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.onap.aai.restclient.MockProvider; import org.onap.aai.config.NodesConfiguration; +import org.onap.aai.restclient.MockProvider; import org.onap.aai.setup.SchemaVersion; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -37,72 +49,60 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.w3c.dom.Document; -import javax.xml.bind.SchemaOutputResolver; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Paths; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - - @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties" }) +@TestPropertySource( + properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties"}) -@ContextConfiguration(classes = { MockProvider.class, NodesConfiguration.class}) +@ContextConfiguration(classes = {MockProvider.class, NodesConfiguration.class}) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @SpringBootTest public class NodeIngestorTest { @Autowired NodeIngestor nodeIngestor; - //set thrown.expect to whatever a specific test needs - //this establishes a default of expecting no exceptions to be thrown + // 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 = nodeIngestor.getContextForVersion(new SchemaVersion("v10")); - - //should work bc Foo is valid in test_network_v10 schema + + // should work bc Foo is valid in test_network_v10 schema DynamicEntity foo10 = ctx10.newDynamicEntity("Foo"); - foo10.set("fooId","bar"); + foo10.set("fooId", "bar"); assertTrue("bar".equals(foo10.get("fooId"))); - - //should work bc Bar is valid in test_business_v10 schema + + // should work bc Bar is valid in test_business_v10 schema DynamicEntity bar10 = ctx10.newDynamicEntity("Bar"); - bar10.set("barId","bar2"); + bar10.set("barId", "bar2"); assertTrue("bar2".equals(bar10.get("barId"))); XSDOutputResolver outputResolver10 = new XSDOutputResolver(); ctx10.generateSchema(outputResolver10); - + DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11")); - - //should work bc Foo.quantity is valid in test_network_v11 schema + + // should work bc Foo.quantity is valid in test_network_v11 schema DynamicEntity foo11 = ctx11.newDynamicEntity("Foo"); - foo11.set("quantity","12"); + foo11.set("quantity", "12"); assertTrue("12".equals(foo11.get("quantity"))); - + DynamicEntity quux11 = ctx11.newDynamicEntity("Quux"); - quux11.set("qManagerName","some guy"); + 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 + // should fail bc Quux not in v10 test schema ctx10.newDynamicEntity("Quux"); } @Test public void testHasNodeType() { - //TODO remove for integration tests + // TODO remove for integration tests assertTrue(nodeIngestor.hasNodeType("foo", new SchemaVersion("v11"))); assertTrue(nodeIngestor.hasNodeType("quux", new SchemaVersion("v11"))); assertFalse(nodeIngestor.hasNodeType("quux", new SchemaVersion("v10"))); @@ -110,7 +110,7 @@ public class NodeIngestorTest { @Test public void testGetVersionFromClassName() { - assertEquals(nodeIngestor.getVersionFromClassName("inventory.aai.onap.org.v13.Evc"),new SchemaVersion("v13")); + assertEquals(nodeIngestor.getVersionFromClassName("inventory.aai.onap.org.v13.Evc"), new SchemaVersion("v13")); } @@ -123,24 +123,23 @@ public class NodeIngestorTest { @Test public void testGetObjectsInVersion() { assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 148); - //comment for IntegrationTest - //assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 229); + // comment for IntegrationTest + // assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 229); } - + @Test public void testCombinedSchema() throws TransformerException, IOException { DynamicJAXBContext ctx13 = nodeIngestor.getContextForVersion(new SchemaVersion("v13")); XSDOutputResolver outputResolver13 = new XSDOutputResolver(); ctx13.generateSchema(outputResolver13); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")),buffer); + printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")), buffer); String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); content = content.replaceAll("\\s+", ""); String expected = buffer.toString().replaceAll("\\s+", ""); - - assertThat("OXM:\n"+expected,expected, is(content)); + assertThat("OXM:\n" + expected, expected, is(content)); } public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { @@ -152,30 +151,26 @@ public class NodeIngestorTest { 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"))); } - + 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 0aaa8802..d2412c08 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 @@ -30,29 +30,30 @@ import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersionsBean; - import org.onap.aai.testutils.ConfigTranslatorForWiringTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {ConfigTranslatorForWiringTest.class, NodesConfiguration.class}) -@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.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 + + // should work bc Bar is valid in test_business_v10 schema DynamicEntity bar10 = ctx10.newDynamicEntity("Bar"); - bar10.set("barId","bar2"); + bar10.set("barId", "bar2"); assertTrue("bar2".equals(bar10.get("barId"))); } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java index 6f8b7367..f0fed324 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.restclient; import org.springframework.beans.factory.annotation.Autowired; @@ -27,8 +28,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; @Configuration -@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true) -@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true) +@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true) +@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true) public class MockProvider { @Value("${mock.filename}") @@ -49,10 +50,9 @@ public class MockProvider { }; } - @Bean(name="restClient") + @Bean(name = "restClient") @ConditionalOnProperty(name = "schema.service.client", havingValue = "mock-no-auth") public RestClient getSchemaServiceNoAuthClient() { return new MockRestClient(fileName); } } - diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java index 87e4bfe8..52e6364b 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java @@ -17,20 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.restclient; +import static org.junit.Assert.assertNotNull; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; + import com.att.eelf.configuration.EELFLogger; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import org.apache.commons.io.IOUtils; -import org.springframework.core.io.Resource; -import org.springframework.http.*; -import org.springframework.stereotype.Component; -import org.springframework.test.web.client.ExpectedCount; -import org.springframework.test.web.client.MockRestServiceServer; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; import java.io.IOException; import java.io.InputStream; @@ -40,33 +37,40 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertNotNull; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; +import org.apache.commons.io.IOUtils; +import org.springframework.core.io.Resource; +import org.springframework.http.*; +import org.springframework.stereotype.Component; +import org.springframework.test.web.client.ExpectedCount; +import org.springframework.test.web.client.MockRestServiceServer; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; @Component public class MockRestClient extends RestClient { -private RestTemplate restTemplate; - private MockRestServiceServer mockRestServiceServer; + private RestTemplate restTemplate; + private MockRestServiceServer mockRestServiceServer; String fileName = "mockrequests"; public MockRestClient(String fileName) { /* - List mockedAAIRequests = new ArrayList<>(aaiRequests.size()); + * List mockedAAIRequests = new ArrayList<>(aaiRequests.size()); */ List mockedAAIRequests = new ArrayList<>(); restTemplate = new RestTemplate(); - /* MockRestServiceServer server = MockRestServiceServer - .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) - .build(); - server.expect(MockRestRequestMatchers.requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + /* + * MockRestServiceServer server = MockRestServiceServer + * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + * .build(); + * server.expect(MockRestRequestMatchers.requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + */ // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); - //when(mockBuilder.build()).thenReturn(restTemplate); + // when(mockBuilder.build()).thenReturn(restTemplate); JsonObject payload = null; try { @@ -77,23 +81,20 @@ private RestTemplate restTemplate; JsonArray mockUris = payload.getAsJsonArray("mock-uri"); - mockRestServiceServer = MockRestServiceServer.createServer(restTemplate); String url = "https://localhost:8447/aai/v14"; - /*mockRestServiceServer.expect(requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ - + /* + * mockRestServiceServer.expect(requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + */ for (int i = 0; i < mockUris.size(); i++) { String responseFile = mockUris.get(i).getAsJsonObject().get("response-file").getAsString(); String contentTypeValue = mockUris.get(i).getAsJsonObject().get("content").getAsString(); - String uri = mockUris.get(i).getAsJsonObject().get("aai-uri").getAsString(); - InputStream inputStream = getClass() - .getClassLoader() - .getResourceAsStream(responseFile); + InputStream inputStream = getClass().getClassLoader().getResourceAsStream(responseFile); String responseBody = null; try { responseBody = IOUtils.toString(inputStream, StandardCharsets.UTF_8); @@ -101,57 +102,51 @@ private RestTemplate restTemplate; e.printStackTrace(); } - mockRestServiceServer.expect(ExpectedCount.manyTimes(), requestTo(url + uri)) - .andExpect(method(HttpMethod.GET)) - .andExpect(content().contentType(contentTypeValue)) - .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()).contentType(MediaType.valueOf(contentTypeValue))); - + .andExpect(method(HttpMethod.GET)).andExpect(content().contentType(contentTypeValue)) + .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()) + .contentType(MediaType.valueOf(contentTypeValue))); } } - public MockRestClient() { + public MockRestClient() { - restTemplate = new RestTemplate(); - /* MockRestServiceServer server = MockRestServiceServer - .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) - .build(); - server.expect(MockRestRequestMatchers.requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + restTemplate = new RestTemplate(); + /* + * MockRestServiceServer server = MockRestServiceServer + * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + * .build(); + * server.expect(MockRestRequestMatchers.requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + */ // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); - //when(mockBuilder.build()).thenReturn(restTemplate); + // when(mockBuilder.build()).thenReturn(restTemplate); JsonObject payload = null; try { - payload = getPayload( fileName + ".json"); + payload = getPayload(fileName + ".json"); } catch (IOException e) { e.printStackTrace(); } JsonArray mockUris = payload.getAsJsonArray("mock-uri"); - - - mockRestServiceServer = MockRestServiceServer.createServer(restTemplate); - String url="https://localhost:8447/aai/v14"; - /*mockRestServiceServer.expect(requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ - - - + mockRestServiceServer = MockRestServiceServer.createServer(restTemplate); + String url = "https://localhost:8447/aai/v14"; + /* + * mockRestServiceServer.expect(requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + */ for (int i = 0; i < mockUris.size(); i++) { String responseFile = mockUris.get(i).getAsJsonObject().get("response-file").getAsString(); String contentTypeValue = mockUris.get(i).getAsJsonObject().get("content").getAsString(); - String uri = mockUris.get(i).getAsJsonObject().get("aai-uri").getAsString(); - InputStream inputStream = getClass() - .getClassLoader() - .getResourceAsStream(responseFile); + InputStream inputStream = getClass().getClassLoader().getResourceAsStream(responseFile); String responseBody = null; try { responseBody = IOUtils.toString(inputStream, StandardCharsets.UTF_8); @@ -159,31 +154,26 @@ private RestTemplate restTemplate; e.printStackTrace(); } - mockRestServiceServer.expect(ExpectedCount.manyTimes(), requestTo(url + uri)) - .andExpect(method(HttpMethod.GET)) - .andExpect(content().contentType(contentTypeValue)) - .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()).contentType(MediaType.valueOf(contentTypeValue))); - + .andExpect(method(HttpMethod.GET)).andExpect(content().contentType(contentTypeValue)) + .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()) + .contentType(MediaType.valueOf(contentTypeValue))); } - } - public JsonObject getTestDetails(String fileName) throws IOException { + public JsonObject getTestDetails(String fileName) throws IOException { - JsonObject payload = getPayload(fileName ); + JsonObject payload = getPayload(fileName); return payload; } public JsonObject getPayload(String filename) throws IOException { - InputStream inputStream = getClass() - .getClassLoader() - .getResourceAsStream(filename); + InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename); - //InputStream inputStream = new FileInputStream(filename); + // InputStream inputStream = new FileInputStream(filename); String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); String message = String.format("Unable to find the %s in src/test/resources", filename); @@ -195,28 +185,33 @@ private RestTemplate restTemplate; } @Override - public ResponseEntity execute(String uri, HttpMethod method, Map headers, String body) { + public ResponseEntity execute(String uri, HttpMethod method, Map headers, String body) { - String url="https://localhost:8447/aai/v14/"+ uri; + String url = "https://localhost:8447/aai/v14/" + uri; - /* MockRestServiceServer server = MockRestServiceServer - .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) - .build(); - server.expect(MockRestRequestMatchers.requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ - - // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); - //when(mockBuilder.build()).thenReturn(restTemplate); + /* + * MockRestServiceServer server = MockRestServiceServer + * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + * .build(); + * server.expect(MockRestRequestMatchers.requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + */ - /*MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); - server.expect(requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); - return new ResponseEntity("blah", HttpStatus.OK); - server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + aaiRequests.get(i).get("aai-uri").asText()))) - .andExpect(method(HttpMethod.GET)) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.APPLICATION_JSON));*/ + // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); + // when(mockBuilder.build()).thenReturn(restTemplate); + /* + * MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); + * server.expect(requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + * return new ResponseEntity("blah", HttpStatus.OK); + * server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + + * aaiRequests.get(i).get("aai-uri").asText()))) + * .andExpect(method(HttpMethod.GET)) + * .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + * .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType. + * APPLICATION_JSON)); + */ HttpHeaders headersMap = new HttpHeaders(); @@ -228,35 +223,40 @@ private RestTemplate restTemplate; HttpEntity httpEntity = new HttpEntity(headers); - ResponseEntity responseEntity = restTemplate.exchange(url , HttpMethod.GET, httpEntity, String.class); + ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); - // mockRestServiceServer.verify(); - return responseEntity; + // mockRestServiceServer.verify(); + return responseEntity; } @Override - public ResponseEntity executeResource(String uri, HttpMethod method, Map headers, String body) { + public ResponseEntity executeResource(String uri, HttpMethod method, Map headers, String body) { - String url="https://localhost:8447/aai/v14/"+ uri; + String url = "https://localhost:8447/aai/v14/" + uri; - /* MockRestServiceServer server = MockRestServiceServer - .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) - .build(); - server.expect(MockRestRequestMatchers.requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/ + /* + * MockRestServiceServer server = MockRestServiceServer + * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate()) + * .build(); + * server.expect(MockRestRequestMatchers.requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + */ // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class); - //when(mockBuilder.build()).thenReturn(restTemplate); - - /*MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); - server.expect(requestTo(url)) - .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); - return new ResponseEntity("blah", HttpStatus.OK); - server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + aaiRequests.get(i).get("aai-uri").asText()))) - .andExpect(method(HttpMethod.GET)) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.APPLICATION_JSON));*/ + // when(mockBuilder.build()).thenReturn(restTemplate); + /* + * MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); + * server.expect(requestTo(url)) + * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON)); + * return new ResponseEntity("blah", HttpStatus.OK); + * server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + + * aaiRequests.get(i).get("aai-uri").asText()))) + * .andExpect(method(HttpMethod.GET)) + * .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + * .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType. + * APPLICATION_JSON)); + */ HttpHeaders headersMap = new HttpHeaders(); @@ -268,7 +268,7 @@ private RestTemplate restTemplate; HttpEntity httpEntity = new HttpEntity(headers); - ResponseEntity responseEntity = restTemplate.exchange(url , HttpMethod.GET, httpEntity, Resource.class); + ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, Resource.class); // mockRestServiceServer.verify(); return responseEntity; @@ -280,16 +280,16 @@ private RestTemplate restTemplate; return restTemplate; } - public String getBaseUrl(){ - return ""; + public String getBaseUrl() { + return ""; } - protected MultiValueMap getHeaders(Map headers){ - return null; + protected MultiValueMap getHeaders(Map headers) { + return null; } - protected EELFLogger getLogger(){ - return null; + protected EELFLogger getLogger() { + return null; } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java index 4c3b0fcf..36b8fb3e 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.restclient; public class RestClientTest { diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java index cd161dea..53134075 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java @@ -17,8 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.restclient; +import java.util.HashMap; +import java.util.Map; + import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,13 +35,12 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.HashMap; -import java.util.Map; - @Ignore @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = "/schemaService/schema-service-rest.properties" ) -@ContextConfiguration(classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class, PropertyPasswordConfiguration.class}) +@TestPropertySource(locations = "/schemaService/schema-service-rest.properties") +@ContextConfiguration( + classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class, + PropertyPasswordConfiguration.class}) @SpringBootTest public class SchemaRestClientTest { @@ -47,21 +50,16 @@ public class SchemaRestClientTest { private RestClientFactory restClientFactory; @Test - public void testGetRequestToSchemaService() { + public void testGetRequestToSchemaService() { ResponseEntity aaiResponse; RestClient restClient = null; - restClient = restClientFactory - .getRestClient(SCHEMA_SERVICE); + restClient = restClientFactory.getRestClient(SCHEMA_SERVICE); String uri = ""; Map headersMap = new HashMap<>(); String content = ""; - aaiResponse = restClient.execute( - uri, - HttpMethod.GET, - headersMap, - content); - System.out.println("Helo"+aaiResponse.getStatusCode()); + aaiResponse = restClient.execute(uri, HttpMethod.GET, headersMap, content); + System.out.println("Helo" + aaiResponse.getStatusCode()); } } diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java index aca50416..8136ac0b 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java @@ -20,6 +20,12 @@ package org.onap.aai.setup; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; +import java.util.Map; + import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.testutils.ConfigTranslatorForWiringTest; @@ -29,20 +35,17 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaConfigVersions.class, ConfigTranslatorForWiringTest.class}) -@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) +@ContextConfiguration( + classes = {SchemaLocationsBean.class, SchemaConfigVersions.class, ConfigTranslatorForWiringTest.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class ConfigTranslatorWiringTest { @Autowired ConfigTranslator ct; - + @Test public void test() { assertNotNull(ct); @@ -50,7 +53,7 @@ public class ConfigTranslatorWiringTest { 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> edges = ct.getEdgeFiles(); assertTrue(edges.containsKey(new SchemaVersion("v10"))); assertTrue(1 == edges.get(new SchemaVersion("v10")).size()); 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 45ed88fa..4d7bf692 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java @@ -20,15 +20,15 @@ package org.onap.aai.setup; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class}) public class SchemaLocationsBeanDefaultInjectionTest { diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java index 886dfe02..bfaa917e 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java @@ -20,6 +20,9 @@ package org.onap.aai.setup; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -27,16 +30,13 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {SchemaLocationsBean.class}) @TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest2.properties"}) public class SchemaLocationsBeanEnvVarInjectionTest { @Autowired SchemaLocationsBean bean; - + @Test public void test() { assertNotNull(bean); 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 105cb1de..78df3891 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java @@ -20,17 +20,17 @@ package org.onap.aai.setup; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:forWiringTests/testContext.xml"}) +@ContextConfiguration(locations = {"classpath:forWiringTests/testContext.xml"}) public class SchemaLocationsBeanXMLSetterTest { @Autowired SchemaLocationsBean bean; 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 a9b5d0c5..af94765f 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java @@ -20,17 +20,17 @@ package org.onap.aai.setup; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:forWiringTests/testUsingPropFileContext.xml"}) +@ContextConfiguration(locations = {"classpath:forWiringTests/testUsingPropFileContext.xml"}) public class SchemaLocationsBeanXMLSetterWithPropFileTest { @Autowired SchemaLocationsBean bean; diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java index 72409bc7..ecc188f7 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java @@ -17,8 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.setup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.util.List; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -30,20 +37,16 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.io.IOException; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-override-test.properties" }) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-override-test.properties"}) @ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class, SchemaConfigVersions.class}) @SpringBootTest public class SchemaVersionsBeanOverrideTest { - //set thrown.expect to whatever a specific test needs - //this establishes a default of expecting no exceptions to be thrown + // 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 diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java index b1208d62..981be806 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java @@ -17,8 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.setup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.util.List; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -30,20 +37,15 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import java.io.IOException; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties" }) +@TestPropertySource( + properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties"}) @ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class}) @SpringBootTest public class SchemaVersionsBeanTest { - //set thrown.expect to whatever a specific test needs - //this establishes a default of expecting no exceptions to be thrown + // 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 @@ -69,12 +71,14 @@ public class SchemaVersionsBeanTest { List versionsList = SchemaVersionsBean.getVersions(); assertNotNull(versionsList); SchemaVersions versions = SchemaVersionsBean.getSchemaVersions(); - /*//assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15")); - assertEquals(versions.getAppRootVersion(), new SchemaVersion("v11")); - assertEquals(versions.getDepthVersion(), new SchemaVersion("v10")); - assertEquals(versions.getEdgeLabelVersion(), new SchemaVersion("v12")); - assertEquals(versions.getNamespaceChangeVersion(), new SchemaVersion("v11")); - assertEquals(versions.getRelatedLinkVersion(), new SchemaVersion("v10"));*/ + /* + * //assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15")); + * assertEquals(versions.getAppRootVersion(), new SchemaVersion("v11")); + * assertEquals(versions.getDepthVersion(), new SchemaVersion("v10")); + * assertEquals(versions.getEdgeLabelVersion(), new SchemaVersion("v12")); + * assertEquals(versions.getNamespaceChangeVersion(), new SchemaVersion("v11")); + * assertEquals(versions.getRelatedLinkVersion(), new SchemaVersion("v10")); + */ assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15")); assertEquals(versions.getDepthVersion(), new SchemaVersion("v15")); 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 dd1c0b7c..2f5f15e8 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java @@ -20,11 +20,12 @@ package org.onap.aai.testutils; +import java.util.*; + import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaConfigVersions; -import java.util.*; /** * Good oxm, bad edge rules for rainy day edge rule validation testing 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 90afdcce..b91007be 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java @@ -20,15 +20,16 @@ package org.onap.aai.testutils; -import org.onap.aai.setup.ConfigTranslator; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaConfigVersions; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; + /** * All schema files here are valid for sunny day validator testing */ @@ -59,5 +60,4 @@ public class BadNodeConfigForValidationTest extends ConfigTranslator { 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 e8d10e8c..1d8e4bcb 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java @@ -20,15 +20,16 @@ package org.onap.aai.testutils; -import org.onap.aai.setup.ConfigTranslator; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaConfigVersions; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; + public class ConfigTranslatorForWiringTest extends ConfigTranslator { public ConfigTranslatorForWiringTest(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) { 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 631ce91f..8f1f1761 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java @@ -20,16 +20,17 @@ package org.onap.aai.testutils; -import org.onap.aai.setup.ConfigTranslator; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaConfigVersions; -import org.onap.aai.setup.SchemaVersions; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; + /** * All schema files here are valid for sunny day validator testing */ @@ -47,7 +48,7 @@ public class GoodConfigForValidationTest extends ConfigTranslator { List files = new ArrayList<>(); files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml"); Map> input = new TreeMap<>(); - //input.put(SchemaVersion.getLatest(), files); + // input.put(SchemaVersion.getLatest(), files); for (SchemaVersion v : schemaVersions.getVersions()) { input.put(v, files); } @@ -59,12 +60,11 @@ public class GoodConfigForValidationTest extends ConfigTranslator { Map> input = new TreeMap<>(); List files = new ArrayList<>(); files.add("src/test/resources/edgeRules/test3.json"); - //input.put(SchemaVersion.getLatest(), files); + // 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 ba3e4ac0..28dfd60c 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java @@ -20,17 +20,18 @@ package org.onap.aai.testutils; -import org.onap.aai.setup.ConfigTranslator; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaConfigVersions; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; + public class SchemaIncompleteTranslator extends ConfigTranslator { - + public SchemaIncompleteTranslator(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) { super(bean, schemaVersions); } @@ -40,17 +41,16 @@ public class SchemaIncompleteTranslator extends ConfigTranslator { List files10 = new ArrayList<>(); files10.add("src/test/resources/oxm/test_network_v10.xml"); files10.add("src/test/resources/oxm/test_business_v10.xml"); - + List files11 = new ArrayList<>(); files11.add("src/test/resources/oxm/test_network_v11.xml"); files11.add("src/test/resources/oxm/test_business_v11.xml"); List files12 = new ArrayList<>(); files12.add("src/test/resources/oxm/business_oxm_v12.xml"); - + Map> input = new TreeMap<>(); - - + input.put(new SchemaVersion("v10"), files10); input.put(new SchemaVersion("v11"), files11); input.put(new SchemaVersion("v12"), files12); @@ -65,16 +65,16 @@ public class SchemaIncompleteTranslator extends ConfigTranslator { files.add("src/test/resources/edgeRules/otherTestRules.json"); Map> input = new TreeMap<>(); input.put(schemaVersions.getDefaultVersion(), files); - + List files2 = new ArrayList<>(); files2.add("src/test/resources/edgeRules/test.json"); input.put(new SchemaVersion("v10"), files2); - + List 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 8988a1ca..74ea5135 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java @@ -20,21 +20,24 @@ package org.onap.aai.testutils; -import org.onap.aai.setup.ConfigTranslator; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaConfigVersions; -import org.springframework.context.annotation.PropertySource; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; + +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; +import org.springframework.context.annotation.PropertySource; + @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true) @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true) public class TestUtilConfigTranslator extends ConfigTranslator { public static final SchemaVersion LATEST = new SchemaVersion("v15"); + public TestUtilConfigTranslator(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) { super(bean, schemaVersions); } @@ -44,11 +47,11 @@ public class TestUtilConfigTranslator extends ConfigTranslator { List files10 = new ArrayList<>(); files10.add("src/test/resources/oxm/test_network_v10.xml"); files10.add("src/test/resources/oxm/test_business_v10.xml"); - + List files11 = new ArrayList<>(); files11.add("src/test/resources/oxm/test_network_v11.xml"); files11.add("src/test/resources/oxm/test_business_v11.xml"); - + Map> input = new TreeMap<>(); input.put(new SchemaVersion("v10"), files10); input.put(new SchemaVersion("v11"), files11); @@ -58,8 +61,8 @@ public class TestUtilConfigTranslator extends ConfigTranslator { 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("v10"), files10); input.put(new SchemaVersion("v11"), files11); input.put(new SchemaVersion("v13"), files13); return input; @@ -73,11 +76,11 @@ public class TestUtilConfigTranslator extends ConfigTranslator { files.add("src/test/resources/edgeRules/otherTestRules.json"); Map> input = new TreeMap<>(); input.put(LATEST, files); - + List files2 = new ArrayList<>(); files2.add("src/test/resources/edgeRules/test.json"); input.put(new SchemaVersion("v10"), files2); - + List files3 = new ArrayList<>(); files3.add("src/test/resources/edgeRules/test3.json"); files3.add("src/test/resources/edgeRules/defaultEdgesTest.json"); @@ -85,5 +88,3 @@ public class TestUtilConfigTranslator extends ConfigTranslator { 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 28b0e2da..1c572ac8 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java @@ -20,17 +20,18 @@ package org.onap.aai.testutils; -import org.onap.aai.setup.ConfigTranslator; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaConfigVersions; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersion; + public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator { - + public TestUtilConfigTranslatorforBusiness(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) { super(bean, schemaVersions); } @@ -38,21 +39,21 @@ public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator { @Override public Map> getNodeFiles() { List files10 = new ArrayList<>(); -// files10.add("src/test/resources/oxm/test_network_v10.xml"); -// files10.add("src/test/resources/oxm/test_business_v10.xml"); - + // files10.add("src/test/resources/oxm/test_network_v10.xml"); + // files10.add("src/test/resources/oxm/test_business_v10.xml"); + List files11 = new ArrayList<>(); -// files11.add("src/test/resources/oxm/test_network_v11.xml"); + // files11.add("src/test/resources/oxm/test_network_v11.xml"); files11.add("src/test/resources/oxm/business_v11.xml"); - + List 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> input = new TreeMap<>(); -// input.put(Version.V10, files10); + // input.put(Version.V10, files10); input.put(new SchemaVersion("v11"), files11); input.put(schemaVersions.getDefaultVersion(), files13); return input; @@ -64,15 +65,15 @@ public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator { files.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json"); Map> input = new TreeMap<>(); input.put(schemaVersions.getDefaultVersion(), files); - + List files2 = new ArrayList<>(); files2.add("src/test/resources/dbedgerules/test.json"); -// input.put(Version.V10, files2); - + // input.put(Version.V10, files2); + List 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 f43ea7dc..d2852925 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 @@ -30,17 +30,17 @@ public class CheckEverythingStrategyTest { @Test public void test() { CheckEverythingStrategy strat = new CheckEverythingStrategy(); - //no issues so nothing notified, should be fine + // no issues so nothing notified, should be fine assertTrue(strat.isOK()); assertTrue("No errors found.".equals(strat.getErrorMsg())); - - //simulate post one error + + // 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 + + // simulate multiple found String testError2 = "error 2"; String testError3 = "duplicate labels not everything is a fork"; strat.notifyOnError(testError2); 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 0d9ded01..ceced416 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 @@ -31,16 +31,16 @@ 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 + + // simulate no issues found assertTrue(strat.isOK()); assertTrue("No errors found.".equals(strat.getErrorMsg())); - - //simulate an issue found + + // simulate an issue found String testError = "hi i'm a problem"; thrown.expect(AAISchemaValidationException.class); thrown.expectMessage(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 667a76ab..4bab99a1 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,9 +37,12 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {NodesConfiguration.class, BadNodeConfigForValidationTest.class, - CheckEverythingStrategy.class, DefaultVersionValidationModule.class, VersionValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@ContextConfiguration( + classes = {NodesConfiguration.class, BadNodeConfigForValidationTest.class, CheckEverythingStrategy.class, + DefaultVersionValidationModule.class, VersionValidator.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class VersionValidatorRainyDayTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java index 2be68558..2598928e 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 @@ -27,7 +27,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; - import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.GoodConfigForValidationTest; import org.springframework.beans.factory.annotation.Autowired; @@ -37,14 +36,12 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { - NodesConfiguration.class, - GoodConfigForValidationTest.class, - CheckEverythingStrategy.class, - DefaultVersionValidationModule.class, - VersionValidator.class -}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@ContextConfiguration( + classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class, + DefaultVersionValidationModule.class, VersionValidator.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class VersionValidatorSunnyDayTest { @Autowired diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java index 75ab0d52..58940af5 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 @@ -22,6 +22,8 @@ package org.onap.aai.validation.edges; import static org.junit.Assert.*; +import com.jayway.jsonpath.DocumentContext; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -32,8 +34,6 @@ import org.junit.Test; import org.onap.aai.edges.JsonIngestor; import org.onap.aai.setup.SchemaVersion; -import com.jayway.jsonpath.DocumentContext; - public class CousinDefaultingValidationModuleTest { private static List ctxs; private static CousinDefaultingValidationModule validator; @@ -46,12 +46,12 @@ public class CousinDefaultingValidationModuleTest { 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))); @@ -66,12 +66,12 @@ public class CousinDefaultingValidationModuleTest { 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 f92c636b..a4c70b81 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,7 +39,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; public class DefaultEdgeFieldsValidationModuleTest { @Autowired EdgeFieldsValidationModule validator; - + @Test public void test() { Map test = new HashMap<>(); @@ -47,13 +47,13 @@ public class DefaultEdgeFieldsValidationModuleTest { test.put(f.toString(), "test"); } assertTrue("".equals(validator.verifyFields(test))); - + test.remove(EdgeField.DESCRIPTION.toString()); - assertTrue("".equals(validator.verifyFields(test))); //bc description is optional - + 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 5f553ed5..75b27716 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 @@ -27,7 +27,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; - import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.BadEdgeConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; @@ -38,11 +37,14 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {NodesConfiguration.class, BadEdgeConfigForValidationTest.class, - CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, - SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, - EdgeRuleValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@ContextConfiguration( + classes = {NodesConfiguration.class, BadEdgeConfigForValidationTest.class, CheckEverythingStrategy.class, + DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, + SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, + NodeTypesValidationModule.class, EdgeRuleValidator.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class EdgeRuleValidatorRainyDayTest { @Autowired @@ -50,7 +52,7 @@ public class EdgeRuleValidatorRainyDayTest { @Test public void test() { - assertNotNull(validator); //verify spring wiring OK + assertNotNull(validator); // verify spring wiring OK assertFalse(validator.validate()); String errors = validator.getErrorMsg(); assertTrue(errors.contains("missing required fields: delete-other-v")); 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 6c68027b..ca6b3171 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 @@ -27,7 +27,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; - import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.GoodConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; @@ -38,11 +37,14 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, - CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, - SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class, - EdgeRuleValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@ContextConfiguration( + classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class, + DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class, + SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, + NodeTypesValidationModule.class, EdgeRuleValidator.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class EdgeRuleValidatorSunnyDayTest { @Autowired @@ -50,7 +52,7 @@ public class EdgeRuleValidatorSunnyDayTest { @Test public void test() { - assertNotNull(validator); //verify spring wiring OK + 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 fc854061..cc38915c 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 @@ -30,7 +30,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; - import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersionsBean; import org.onap.aai.testutils.TestUtilConfigTranslator; @@ -41,8 +40,11 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {NodesConfiguration.class, TestUtilConfigTranslator.class, NodeTypesValidationModule.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@ContextConfiguration( + classes = {NodesConfiguration.class, TestUtilConfigTranslator.class, NodeTypesValidationModule.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class NodeTypesValidationModuleTest { @Autowired @@ -55,7 +57,12 @@ public class NodeTypesValidationModuleTest { 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 + assertTrue( + validator.validate(testPairs, new SchemaVersion("v10")).contains("Invalid node type(s) found: quux")); // bc + // no + // quux + // in + // v10 } @Test @@ -64,6 +71,6 @@ public class NodeTypesValidationModuleTest { testPairs.add("bar|"); testPairs.add("|foo"); testPairs.add("|"); - assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11")))); //bc empty just ignored + 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 7acb558a..a704d80b 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 @@ -22,6 +22,8 @@ package org.onap.aai.validation.edges; import static org.junit.Assert.*; +import com.jayway.jsonpath.DocumentContext; + import java.util.*; import org.junit.BeforeClass; @@ -29,8 +31,6 @@ import org.junit.Test; import org.onap.aai.edges.JsonIngestor; import org.onap.aai.setup.SchemaVersion; -import com.jayway.jsonpath.DocumentContext; - public class SingleContainmentValidationModuleTest { private static List ctxs; private static SingleContainmentValidationModule validator; @@ -42,7 +42,7 @@ public class SingleContainmentValidationModuleTest { List 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(); @@ -57,7 +57,7 @@ public class SingleContainmentValidationModuleTest { 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 233f8b4b..76e52036 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 @@ -22,6 +22,8 @@ package org.onap.aai.validation.edges; import static org.junit.Assert.*; +import com.jayway.jsonpath.DocumentContext; + import java.util.*; import org.junit.BeforeClass; @@ -29,8 +31,6 @@ import org.junit.Test; import org.onap.aai.edges.JsonIngestor; import org.onap.aai.setup.SchemaVersion; -import com.jayway.jsonpath.DocumentContext; - public class UniqueLabelValidationModuleTest { private static List ctxs; private static UniqueLabelValidationModule validator; @@ -43,7 +43,7 @@ public class UniqueLabelValidationModuleTest { 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(); @@ -54,13 +54,13 @@ public class UniqueLabelValidationModuleTest { 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))); @@ -72,19 +72,19 @@ public class UniqueLabelValidationModuleTest { 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 fc4ddd45..e164df04 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 @@ -25,7 +25,6 @@ import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; - import org.onap.aai.testutils.BadNodeConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule; @@ -38,10 +37,13 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {BadNodeConfigForValidationTest.class, NodesConfiguration.class, - CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) +@ContextConfiguration( + classes = {BadNodeConfigForValidationTest.class, NodesConfiguration.class, CheckEverythingStrategy.class, + DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @SpringBootTest public class NodeValidatorRainyDayTest { @@ -50,7 +52,7 @@ public class NodeValidatorRainyDayTest { @Test public void test() { - assertNotNull(validator); //check spring wiring ok + assertNotNull(validator); // check spring wiring ok assertFalse(validator.validate()); String result = validator.getErrorMsg(); assertTrue(result.contains("LogicalLink")); 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 6ab84d40..288913b1 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java @@ -20,6 +20,18 @@ package org.onap.aai.validation.nodes; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; + +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -27,9 +39,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; import org.onap.aai.nodes.NodeIngestor; - import org.onap.aai.setup.SchemaVersion; - import org.onap.aai.testutils.SchemaIncompleteTranslator; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Autowired; @@ -40,43 +50,33 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.w3c.dom.Document; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { SchemaIncompleteTranslator.class, NodesConfiguration.class}) +@ContextConfiguration(classes = {SchemaIncompleteTranslator.class, NodesConfiguration.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest @Ignore 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 + + // 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(); + public ExpectedException thrown = ExpectedException.none(); - //Throws a NullPointerException because a JavaType is referenced, but not defined + // Throws a NullPointerException because a JavaType is referenced, but not defined @Test public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException { thrown.expect(NullPointerException.class); - //TODO Change for Exception + // TODO Change for Exception ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - printDocument(ni.getSchema(new SchemaVersion("v12")),buffer); + 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(); @@ -86,7 +86,6 @@ public class NodeValidatorSchemaIncompleteTest { 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 b69182fc..81b69e6e 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 @@ -25,7 +25,6 @@ import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.config.NodesConfiguration; - import org.onap.aai.testutils.GoodConfigForValidationTest; import org.onap.aai.validation.CheckEverythingStrategy; import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule; @@ -35,10 +34,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { NodesConfiguration.class, GoodConfigForValidationTest.class, - CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) -@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" }) +@ContextConfiguration( + classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class, + DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class}) +@TestPropertySource( + properties = { + "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"}) @SpringBootTest public class NodeValidatorSunnyDayTest { @@ -47,7 +50,7 @@ public class NodeValidatorSunnyDayTest { @Test public void test() { - assertNotNull(validator); //check spring wiring ok + assertNotNull(validator); // check spring wiring ok assertTrue(validator.validate()); assertTrue("No errors found.".equals(validator.getErrorMsg())); } -- cgit 1.2.3-korg