diff options
Diffstat (limited to 'aai-core/src/test')
32 files changed, 907 insertions, 111 deletions
diff --git a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java index 25b777d0..862f6911 100644 --- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java @@ -20,14 +20,12 @@ package org.openecomp.aai.exceptions; - import static org.junit.Assert.assertEquals; import org.junit.BeforeClass; - import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper; +import org.openecomp.aai.util.AAIConstants; public class AAIExceptionTest { private static final String code = "4004"; @@ -36,11 +34,12 @@ public class AAIExceptionTest { private static final Throwable noMessage = new RuntimeException(); @BeforeClass - public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + public static void configure() throws NoSuchFieldException, SecurityException, Exception { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); + QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); } - + /** * Test constructor with 0 params. * diff --git a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java index 65381d64..b6357e43 100644 --- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java @@ -22,6 +22,8 @@ package org.openecomp.aai.exceptions; import org.junit.BeforeClass; import org.junit.Test; +import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper; +import org.openecomp.aai.util.AAIConstants; import java.util.HashMap; @@ -44,9 +46,10 @@ public class AAIExceptionWithInfoTest { private static final Throwable cause = new RuntimeException("This is a runtime exception."); @BeforeClass - public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + public static void configure() throws NoSuchFieldException, SecurityException, Exception { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); + QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); } /** diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java b/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java index 73d8101f..47fef7ee 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java @@ -20,12 +20,13 @@ package org.openecomp.aai.introspection; -import com.google.common.collect.Sets; -import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; +import static org.junit.Assert.assertEquals; +import java.util.Arrays; import java.util.Set; -import static org.junit.Assert.assertEquals; +import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; +import com.google.common.collect.Sets; public class IntrospectorTestSpec { @@ -35,7 +36,7 @@ public class IntrospectorTestSpec { * Container test set. * * @param wrappedPortGroups the wrapped port groups - * @throws AAIUnknownObjectException + * @throws AAIUnknownObjectException */ protected void containerTestSet(Introspector wrappedPortGroups) throws AAIUnknownObjectException { diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java index 7b8f338e..9504c46b 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java @@ -20,19 +20,21 @@ package org.openecomp.aai.introspection; +import java.io.StringReader; + +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + import org.eclipse.persistence.dynamic.DynamicEntity; import org.eclipse.persistence.jaxb.UnmarshallerProperties; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.junit.BeforeClass; import org.junit.Test; + import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper; import org.openecomp.aai.util.AAIConstants; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import java.io.StringReader; - public class MoxyEngineTest extends IntrospectorTestSpec { /** @@ -50,7 +52,7 @@ public class MoxyEngineTest extends IntrospectorTestSpec { /** * Container object. - * @throws AAIUnknownObjectException + * @throws AAIUnknownObjectException */ @Test public void containerObject() throws AAIUnknownObjectException { diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java index 333bc9e3..34a6279b 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java @@ -20,15 +20,16 @@ package org.openecomp.aai.introspection; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openecomp.aai.db.props.AAIProperties; +import static org.junit.Assert.*; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; -import static org.junit.Assert.*; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.openecomp.aai.db.props.AAIProperties; public class PojoInjestorTest { diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java index d1e35a22..0eeb966b 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java @@ -20,15 +20,15 @@ package org.openecomp.aai.introspection; +import static org.junit.Assert.*; + import org.junit.BeforeClass; import org.junit.Test; + import org.openecomp.aai.domain.yang.v9.VnfImage; import org.openecomp.aai.introspection.exceptions.AAIUnmarshallingException; import org.openecomp.aai.restcore.MediaType; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - public class PojoLoaderTest { diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java index 0bd61178..4843b10d 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java @@ -20,13 +20,14 @@ package org.openecomp.aai.introspection; +import static org.junit.Assert.*; + import org.junit.Test; + import org.openecomp.aai.domain.yang.CloudRegion; import org.openecomp.aai.domain.yang.VolumeGroup; import org.openecomp.aai.schema.enums.ObjectMetadata; -import static org.junit.Assert.assertEquals; - public class PojoStrategyTest { @Test diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java index a7cde118..1f997333 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java @@ -20,18 +20,17 @@ package org.openecomp.aai.introspection; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; +import java.util.Set; + import org.junit.BeforeClass; import org.junit.Test; + import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper; import org.openecomp.aai.util.AAIConstants; -import java.util.Set; - -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; - public class PropertyPredicatesTest { diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java index 52ed0d87..8781d59c 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java @@ -20,17 +20,19 @@ package org.openecomp.aai.introspection; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; -import org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider; - -import javax.xml.bind.JAXBException; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import javax.xml.bind.JAXBException; + +import org.junit.BeforeClass; +import org.junit.Test; + +import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; +import org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider; + public class ReflectionEngineTest extends IntrospectorTestSpec { /** @@ -48,7 +50,7 @@ public class ReflectionEngineTest extends IntrospectorTestSpec { * @throws InstantiationException the instantiation exception * @throws IllegalAccessException the illegal access exception * @throws ClassNotFoundException the class not found exception - * @throws AAIUnknownObjectException + * @throws AAIUnknownObjectException */ @Test public void containerObject() throws InstantiationException, IllegalAccessException, ClassNotFoundException, AAIUnknownObjectException { diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java index 70d6b123..4d18835e 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java @@ -83,8 +83,8 @@ public class DataCopyTest { @BeforeClass public static void setup() throws NoSuchFieldException, SecurityException, Exception { graph = TitanFactory.build().set("storage.backend","inmemory").open(); - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); dbEngine = new TitanDBEngine( diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java index a9e707a2..595cb868 100644 --- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java @@ -80,8 +80,8 @@ public class DataLinkTest { @BeforeClass public static void setup() throws NoSuchFieldException, SecurityException, Exception { graph = TitanFactory.build().set("storage.backend","inmemory").open(); - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); dbEngine = new TitanDBEngine( diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java new file mode 100644 index 00000000..459746bc --- /dev/null +++ b/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.introspection.validation; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.LoaderFactory; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.introspection.tools.IntrospectorValidator; +import org.openecomp.aai.introspection.tools.Issue; +import org.openecomp.aai.introspection.tools.IssueType; +import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper; +import org.openecomp.aai.util.AAIConstants; + +public class IntrospectorValidationTest { + + + private final static Version version = Version.v10; + private final static ModelType introspectorFactoryType = ModelType.MOXY; + private static Loader loader; + private IntrospectorValidator validator; + @BeforeClass + public static void setUp() throws NoSuchFieldException, SecurityException, Exception { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); + + loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); + + } + @Before + public void createValidator() { + validator = new IntrospectorValidator.Builder() + .validateRequired(false) + .restrictDepth(10000) + .build(); + } + @Test + public void verifySuccessWhenEmpty() throws AAIException { + Introspector obj = loader.introspectorFromName("test-object"); + obj.setValue("vnf-id", "key1"); + validator.validate(obj); + List<Issue> issues = validator.getIssues(); + assertEquals("no issues found", true, issues.isEmpty()); + } + + @Ignore + @Test + public void verifyRequiresSingleFieldFailure() throws AAIException { + Introspector obj = loader.introspectorFromName("test-object"); + obj.setValue("vnf-id", "key1"); + obj.setValue("model-invariant-id", "id1"); + validator.validate(obj); + List<Issue> issues = validator.getIssues(); + assertEquals("issues found", true, issues.size() == 1); + Issue issue = issues.get(0); + assertEquals("found expected issue", IssueType.DEPENDENT_PROP_NOT_FOUND, issue.getType()); + } + + @Test + public void verifyRequiresSuccess() throws AAIException { + Introspector obj = loader.introspectorFromName("test-object"); + obj.setValue("vnf-id", "key1"); + obj.setValue("model-invariant-id", "id1"); + obj.setValue("model-version-id", "version-id1"); + validator.validate(obj); + List<Issue> issues = validator.getIssues(); + assertEquals("no issues found", true, issues.isEmpty()); + } +} diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java new file mode 100644 index 00000000..3fe2098c --- /dev/null +++ b/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.logging; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.Deque; +import java.util.LinkedList; +import java.util.Map; +import java.util.UUID; + +import org.junit.Test; + +public class LoggingContextTest { + + private static final int MAX_STORED_CONTEXTS = 100; + + @Test + public void testStopWatch() { + try { + LoggingContext.stopWatchStop(); + throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() called without a prior LoggingContext.stopWatchStart()"); + } catch (StopWatchNotStartedException e) { + //Expected + } + + LoggingContext.stopWatchStart(); + + assertTrue(LoggingContext.stopWatchStop() >= 0); + + try { + LoggingContext.stopWatchStop(); + throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() twice in succession"); + } catch (StopWatchNotStartedException e) { + //Expected + } + } + + @Test + public void testRequestId() { //AKA Transaction ID + final String sUuid = "57d51eaa-edc6-4f50-a69d-f2d4d2445120"; + + LoggingContext.requestId(sUuid); + + assertEquals(LoggingContext.requestId(), UUID.fromString(sUuid)); + + final UUID uuid = UUID.randomUUID(); + + LoggingContext.requestId(uuid); + + assertEquals(LoggingContext.requestId(), uuid); + + LoggingContext.requestId("foo"); //Illegal - this will result in a new, randomly + //generated UUID as per the logging spec + + assertNotNull(LoggingContext.requestId()); //Make sure ANY UUID was assigned + assertNotEquals(LoggingContext.requestId(), uuid); //Make sure it actually changed from the last + //known valid UUID + } + + @Test + public void testClear() { + LoggingContext.init(); + LoggingContext.clear(); + + assertEquals(Collections.emptyMap(), LoggingContext.getCopy()); + } + + @Test + public void testSaveRestore() { + + final Deque<Map<String, String>> contexts = new LinkedList<Map<String, String>> (); + + LoggingContext.init(); + + for (int i = 0; i < MAX_STORED_CONTEXTS; i++) { + LoggingContext.customField1(String.valueOf(i)); + + assertEquals(LoggingContext.customField1(), String.valueOf(i)); + + LoggingContext.save(); + + contexts.push(LoggingContext.getCopy()); + } + + while (contexts.peek() != null) { + LoggingContext.restore(); + + assertEquals(LoggingContext.getCopy(), contexts.pop()); + } + } +} diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java index 79f75ab9..099ea37e 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java @@ -39,6 +39,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -48,6 +49,7 @@ import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.LoaderFactory; import org.openecomp.aai.introspection.ModelType; import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.rest.RestTokens; import org.openecomp.aai.serialization.engines.QueryStyle; import org.openecomp.aai.serialization.engines.TitanDBEngine; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; @@ -72,8 +74,8 @@ public class GraphTraversalTest { */ @BeforeClass public static void configure() throws NoSuchFieldException, SecurityException, Exception { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); dbEngine = new TitanDBEngine(QueryStyle.TRAVERSAL, @@ -486,8 +488,7 @@ public class GraphTraversalTest { QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() - .has("vnf-id", "key1").has( - AAIProperties.NODE_TYPE, P.within("vce" , "vpe" , "generic-vnf")); + .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "vpe", "generic-vnf")); GraphTraversal<Vertex, Vertex> expectedParent = expected; assertEquals( @@ -534,8 +535,7 @@ public class GraphTraversalTest { GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "vpe", "generic-vnf")) - .union(__.out("has").has("aai-node-type", "vf-module")) - .has("vf-module-id", "key2"); + .union(__.out("has").has(AAIProperties.NODE_TYPE, "vf-module")).has("vf-module-id", "key2"); GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "vpe", "generic-vnf")); @@ -691,7 +691,138 @@ public class GraphTraversalTest { "", query.getParentResultType()); assertEquals("dependent",true, query.isDependent()); - + } + + @Ignore + @Test + public void pluralCousin() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers").build(); + + QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex") + .in("locatedIn").has("aai-node-type", "pserver"); + GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex"); + + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().getQuery().toString()); + + assertEquals( + "result type should be", + "pserver", + query.getResultType()); + assertEquals( + "result type should be", + "complex", + query.getParentResultType()); + //this is controversial but we're not allowing writes on this currently + assertEquals("dependent",true, query.isDependent()); + } + + @Ignore + @Test + public void specificCousin() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2").build(); + + QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex") + .in("locatedIn").has("aai-node-type", "pserver") + .has("hostname", "key2"); + GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex"); + + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().getQuery().toString()); + + assertEquals( + "result type should be", + "pserver", + query.getResultType()); + assertEquals( + "result type should be", + "complex", + query.getParentResultType()); + //this is controversial but we're not allowing writes on this currently + assertEquals("dependent",true, query.isDependent()); + } + + @Ignore + @Test + public void doubleSpecificCousin() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2/related-to/vservers/vserver/key3").build(); + + QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex") + .in("locatedIn").has("aai-node-type", "pserver") + .has("hostname", "key2") + .in("runsOnPserver").has("aai-node-type", "vserver") + .has("vserver-id", "key3"); + GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex") + .in("locatedIn").has("aai-node-type", "pserver") + .has("hostname", "key2"); + + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().getQuery().toString()); + + assertEquals( + "result type should be", + "vserver", + query.getResultType()); + assertEquals( + "result type should be", + "pserver", + query.getParentResultType()); + //this is controversial but we're not allowing writes on this currently + assertEquals("dependent",true, query.isDependent()); + } + + @Ignore + @Test + public void traversalEndsInRelatedTo() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to").build(); + + thrown.expect(AAIException.class); + thrown.expectMessage(containsString(RestTokens.COUSIN.toString())); + QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); + + } + + @Ignore + @Test + public void pluralCousinToPluralCousin() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/related-to/pservers").build(); + + thrown.expect(AAIException.class); + thrown.expectMessage(containsString("chain plurals")); + QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri); } } diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java index bab74ed0..af61fcb0 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java @@ -20,9 +20,19 @@ package org.openecomp.aai.parsers.query; +import static org.junit.Assert.assertEquals; + +import java.io.UnsupportedEncodingException; +import java.net.URI; + +import javax.ws.rs.core.UriBuilder; +import javax.xml.bind.JAXBException; + import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; + import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.LoaderFactory; import org.openecomp.aai.introspection.ModelInjestor; @@ -32,13 +42,6 @@ import org.openecomp.aai.serialization.engines.QueryStyle; import org.openecomp.aai.serialization.engines.TitanDBEngine; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; -import javax.ws.rs.core.UriBuilder; -import javax.xml.bind.JAXBException; -import java.io.UnsupportedEncodingException; -import java.net.URI; - -import static org.junit.Assert.assertEquals; - public class LegacyQueryTest { private ModelInjestor injestor = ModelInjestor.getInstance(); @@ -55,8 +58,8 @@ public class LegacyQueryTest { */ @BeforeClass public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); } /** @@ -104,11 +107,15 @@ public class LegacyQueryTest { String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')" - + ".in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')" + + ".out('hasLAGInterface').has('aai-node-type', 'lag-interface')" + ".has('interface-name', 'key2')"; String parentExpected = ".has('hostname', 'key1').has('aai-node-type', 'pserver')"; assertEquals( + "gremlin query should be for node", + expected, + query.getQueryBuilder().getQuery()); + assertEquals( "parent gremlin query should be for parent", parentExpected, query.getQueryBuilder().getParentQuery().getQuery()); @@ -117,5 +124,43 @@ public class LegacyQueryTest { "lag-interface", query.getResultType()); } - + + /** + * Naming exceptions. + * + * @throws JAXBException the JAXB exception + * @throws UnsupportedEncodingException the unsupported encoding exception + * @throws AAIException the AAI exception + */ + @Ignore + @Test + public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build(); + + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + String expected = + ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + + ".has('interface-id', 'key2')" + + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')" + + ".has('cvlan-tag', 655)"; + String expectedParent = + ".has('vnf-id', 'key1').has('aai-node-type', 'vce')" + + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')" + + ".has('interface-id', 'key2')"; + assertEquals( + "gremlin query should be " + expected, + expected, + query.getQueryBuilder().getQuery()); + assertEquals( + "parent gremlin query should be equal the query for port group", + expectedParent, + query.getQueryBuilder().getParentQuery().getQuery()); + assertEquals( + "result type should be cvlan-tag", + "cvlan-tag", + query.getResultType()); + + } + } diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java index 12a689f4..b3385e32 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java @@ -69,8 +69,8 @@ public class RelationshipGremlinQueryTest { */ @BeforeClass public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); } diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java index 82378577..807c750f 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java @@ -62,8 +62,8 @@ public class RelationshipQueryTest { */ @BeforeClass public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); } @@ -171,8 +171,8 @@ public class RelationshipQueryTest { * @throws UnsupportedEncodingException the unsupported encoding exception * @throws AAIException the AAI exception */ - @Test @Ignore + @Test public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException { String content = "{" diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java index b8dbc2a9..50bbbd0e 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java @@ -20,6 +20,15 @@ package org.openecomp.aai.parsers.query; +import static org.junit.Assert.assertEquals; + +import java.io.StringReader; +import java.io.UnsupportedEncodingException; + +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; + import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -30,25 +39,22 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; + import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.introspection.*; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.IntrospectorFactory; +import org.openecomp.aai.introspection.LoaderFactory; +import org.openecomp.aai.introspection.ModelInjestor; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; import org.openecomp.aai.serialization.engines.QueryStyle; import org.openecomp.aai.serialization.engines.TitanDBEngine; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.stream.StreamSource; -import java.io.StringReader; -import java.io.UnsupportedEncodingException; - -import static org.junit.Assert.assertEquals; - @Ignore public class UniqueRelationshipQueryTest { private ModelInjestor injestor = ModelInjestor.getInstance(); - private TransactionalGraphEngine dbEngine = - new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE, + private TransactionalGraphEngine dbEngine = + new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE, LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8), false); private final Version version = Version.v8; diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java index a676b9bd..185814b8 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java @@ -59,8 +59,8 @@ public class RelationshipToURITest { @BeforeClass public static void setup() throws NoSuchFieldException, SecurityException, Exception { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); } diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java index c2312b2b..899119ee 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java @@ -53,8 +53,8 @@ public class URIParserTest { */ @BeforeClass public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); } /** diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java index 52c44c12..bc586b86 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java @@ -48,8 +48,8 @@ public class URIToExtensionInformationTest { */ @BeforeClass public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); } /** diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java index 3750e473..7cdcfc56 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java @@ -61,8 +61,8 @@ public class URIToObjectTest { */ @BeforeClass public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); } diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java index 1c945ee7..ed278243 100644 --- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java @@ -33,6 +33,7 @@ import javax.ws.rs.core.UriBuilder; import javax.xml.bind.JAXBException; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -45,7 +46,7 @@ import org.openecomp.aai.introspection.LoaderFactory; import org.openecomp.aai.introspection.ModelType; import org.openecomp.aai.introspection.Version; - +@Ignore public class URIToRelationshipObjectTest { private Version latest = AAIProperties.LATEST; @@ -59,8 +60,8 @@ public class URIToRelationshipObjectTest { */ @BeforeClass public static void configure() { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); } /** diff --git a/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java index a9d2c001..eae1c970 100644 --- a/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java @@ -50,17 +50,17 @@ public class TraversalQueryTest { @BeforeClass public static void configure() throws NoSuchFieldException, SecurityException, Exception { - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); } @Test public void unionQuery() { - TraversalQuery tQ = new TraversalQuery(loader, g); - TraversalQuery tQ2 = new TraversalQuery(loader, g); - TraversalQuery tQ3 = new TraversalQuery(loader, g); + TraversalQuery<Vertex> tQ = new TraversalQuery<>(loader, g); + TraversalQuery<Vertex> tQ2 = new TraversalQuery<>(loader, g); + TraversalQuery<Vertex> tQ3 = new TraversalQuery<>(loader, g); tQ.union( tQ2.getVerticesByProperty("test1", "value1"), tQ3.getVerticesByIndexedProperty("test2", "value2")); @@ -74,9 +74,8 @@ public class TraversalQueryTest { @Test public void traversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException { - TraversalQuery tQ = new TraversalQuery(loader, g); - Introspector test = loader.introspectorFromName("test-object"); - QueryBuilder builder = tQ.createQueryFromURI(new URI("network/test-objects/test-object/key1")).getQueryBuilder(); + TraversalQuery<Vertex> tQ = new TraversalQuery<>(loader, g); + QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/test-objects/test-object/key1")).getQueryBuilder(); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "test-object"); GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start().has("aai-node-type", "test-object"); @@ -88,8 +87,8 @@ public class TraversalQueryTest { @Test public void nestedTraversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException { - TraversalQuery tQ = new TraversalQuery(loader, g); - QueryBuilder builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder(); + TraversalQuery<Vertex> tQ = new TraversalQuery<>(loader, g); + QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder(); GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf").out("hasLInterface").has(AAIProperties.NODE_TYPE, "l-interface").has("interface-name", "key2"); GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf").out("hasLInterface").has(AAIProperties.NODE_TYPE, "l-interface"); diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java index 10586fb4..78e91109 100644 --- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java +++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java @@ -56,7 +56,7 @@ import com.thinkaurelius.titan.core.TitanTransaction; import java.util.Collections; -@Ignore("Causing problems when only parallel tests are run") +@Ignore public class DbAliasTest { @@ -71,8 +71,8 @@ public class DbAliasTest { @Before public void setup() throws NoSuchFieldException, SecurityException, Exception { graph = TitanFactory.build().set("storage.backend","inmemory").open(); - System.setProperty("AJSC_HOME", "./src/test/resources/"); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); dbEngine = new TitanDBEngine( queryStyle, diff --git a/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java b/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java new file mode 100644 index 00000000..61ba275d --- /dev/null +++ b/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.workarounds; + +import static org.junit.Assert.*; + +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Before; +import org.junit.Test; + +public class RemoveDME2QueryParamsTest { + + private MultivaluedMap<String, String> hasParams; + private MultivaluedMap<String, String> doesNotHaveParams; + private RemoveDME2QueryParams removeParams = new RemoveDME2QueryParams(); + + /** + * Setup. + */ + @Before + public void setup() { + hasParams = new MultivaluedHashMap<>(); + doesNotHaveParams = new MultivaluedHashMap<>(); + + hasParams.add("version", "1"); + hasParams.add("envContext", "DEV"); + hasParams.add("routeOffer", "INT1"); + hasParams.add("test1", "peppermints"); + hasParams.add("test2", "amber"); + + doesNotHaveParams.add("version", "1"); + doesNotHaveParams.add("envContext", "DEV"); + doesNotHaveParams.add("test1", "peppermints"); + doesNotHaveParams.add("test2", "amber"); + + } + + /** + * Test removal. + */ + @Test + public void testRemoval() { + + if (removeParams.shouldRemoveQueryParams(hasParams)) { + removeParams.removeQueryParams(hasParams); + } + + assertEquals("no version", false, hasParams.containsKey("version")); + assertEquals("no envContext", false, hasParams.containsKey("envContext")); + assertEquals("no routeOffer", false, hasParams.containsKey("routeOffer")); + assertEquals("has test1", true, hasParams.containsKey("test1")); + assertEquals("has test2", true, hasParams.containsKey("test2")); + + } + + /** + * Should not remove. + */ + @Test + public void shouldNotRemove() { + + if (removeParams.shouldRemoveQueryParams(doesNotHaveParams)) { + removeParams.removeQueryParams(doesNotHaveParams); + } + + assertEquals("no version", true, doesNotHaveParams.containsKey("version")); + assertEquals("no envContext", true, doesNotHaveParams.containsKey("envContext")); + assertEquals("has test1", true, doesNotHaveParams.containsKey("test1")); + assertEquals("has test2", true, doesNotHaveParams.containsKey("test2")); + } +} diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties index 4e98d62c..11416ca4 100644 --- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties +++ b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties @@ -110,6 +110,7 @@ AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship +AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead #--- aaicsvp: 7101-7199 AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml index 9c3c5e87..af05d3d9 100644 --- a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml +++ b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml @@ -5048,7 +5048,7 @@ </xml-element> <xml-element java-attribute="ikev1Encryption" name="ikev1-encryption" type="java.lang.String"> <xml-properties> - <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" /> + <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc,? aes-192-cbc, aes-265-cbc" /> <xml-property name="sourceOfTruthType" value="aai" /> </xml-properties> </xml-element> @@ -5084,7 +5084,7 @@ </xml-element> <xml-element java-attribute="ipsecEncryption" name="ipsec-encryption" type="java.lang.String"> <xml-properties> - <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" /> + <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc,? aes-192-cbc, aes-265-cbc" /> <xml-property name="sourceOfTruthType" value="aai" /> </xml-properties> </xml-element> @@ -6405,7 +6405,7 @@ </xml-element> <xml-element java-attribute="designType" name="design-type" required="true" type="java.lang.String"> <xml-properties> - <xml-property name="description" value="Design of zone [Medium/Large…]" /> + <xml-property name="description" value="Design of zone [Medium/Large?]" /> <xml-property name="sourceOfTruthType" value="aai" /> </xml-properties> </xml-element> diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml index ea77e8e5..dab82440 100644 --- a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml +++ b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml @@ -4342,7 +4342,7 @@ </xml-element> <xml-element java-attribute="ikev1Encryption" name="ikev1-encryption" type="java.lang.String"> <xml-properties> - <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" /> + <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc,?aes-192-cbc, aes-265-cbc" /> </xml-properties> </xml-element> <xml-element java-attribute="ikev1DhGroup" name="ikev1-dh-group" type="java.lang.String"> @@ -4372,7 +4372,7 @@ </xml-element> <xml-element java-attribute="ipsecEncryption" name="ipsec-encryption" type="java.lang.String"> <xml-properties> - <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" /> + <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc,?aes-192-cbc, aes-265-cbc" /> </xml-properties> </xml-element> <xml-element java-attribute="ipsecSaLifetime" name="ipsec-sa-lifetime" type="java.lang.String"> @@ -5417,7 +5417,7 @@ </xml-element> <xml-element java-attribute="designType" name="design-type" required="true" type="java.lang.String"> <xml-properties> - <xml-property name="description" value="Design of zone [Medium/Large…]" /> + <xml-property name="description" value="Design of zone [Medium/Large?]" /> </xml-properties> </xml-element> <xml-element java-attribute="zoneContext" name="zone-context" required="true" type="java.lang.String"> diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt b/aai-core/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt new file mode 100644 index 00000000..a5be7911 --- /dev/null +++ b/aai-core/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt @@ -0,0 +1,6 @@ +vnf-id,service-instance-id,global-customer-id +vnf-id1,sample-service-instance-id,customer-id1 +vnf-id2,sample-service-instance-id-1,customer-id1 +vnf-id3,sample-service-instance-id-2,customer-id2 +vnf-id5,sample-service-instance-id-3,customer-id3 +vnf-id6,sample-service-instance-id-4,customer-id4 diff --git a/aai-core/src/test/resources/log4j.properties b/aai-core/src/test/resources/log4j.properties new file mode 100644 index 00000000..2e68f61a --- /dev/null +++ b/aai-core/src/test/resources/log4j.properties @@ -0,0 +1,3 @@ +log4j.logger.org.apache.zookeeper=WARN +log4j.logger.org.apache.hadoop.hbase.zookeeper=WARN +log4j.logger.org.apache.hadoop.hbase.client=WARN
\ No newline at end of file diff --git a/aai-core/src/test/resources/logback.xml b/aai-core/src/test/resources/logback.xml new file mode 100644 index 00000000..d9627b22 --- /dev/null +++ b/aai-core/src/test/resources/logback.xml @@ -0,0 +1,292 @@ +<!-- + ============LICENSE_START======================================================= + org.openecomp.aai + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<configuration scan="true" scanPeriod="60 seconds" debug="false"> + <contextName>${module.ajsc.namespace.name}</contextName> + <jmxConfigurator /> + <property name="logDirectory" value="${AJSC_HOME}/logs" /> + + <!-- Example evaluator filter applied against console appender --> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> --> + <level>ERROR</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + </pattern> + </encoder> + </appender> + + <appender name="METRIC" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>INFO</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + <file>${logDirectory}/rest/metric.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern> + </rollingPolicy> + <!-- <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> --> + <encoder> + <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> + </encoder> + </appender> + + <appender name="DEBUG" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>DEBUG</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + <file>${logDirectory}/rest/debug.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}</fileNamePattern> + </rollingPolicy> + <!-- <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy>--> + <encoder> + <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> + </encoder> + </appender> + + <appender name="ERROR" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>WARN</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + <file>${logDirectory}/rest/error.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}</fileNamePattern> + </rollingPolicy> + <!-- <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy>--> + <encoder> + <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n"</pattern> --> + <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> + </encoder> + </appender> + + <appender name="AUDIT" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator> + <matcher> + <Name>audit</Name> + <!-- filter out odd numbered statements --> + <regex>co\=aairest</regex> + </matcher> + <expression>level == INFO && audit.matches(formattedMessage)</expression> + </evaluator> + <OnMatch>ACCEPT</OnMatch> + <OnMismatch>DENY</OnMismatch> + </filter> + <file>${logDirectory}/rest/audit.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern> + </rollingPolicy> + <encoder> + <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> + </encoder> + </appender> + + <appender name="auditLogs" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + </filter> + <file>${logDirectory}/rest/audit.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/rest/audit-${Pid}.%d{yyyy-MM-dd}.log.zip + </fileNamePattern> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern> + </encoder> + </appender> + + <appender name="perfLogs" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + </filter> + <file>${logDirectory}/rest/perform.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/rest/perform-${Pid}.%d{yyyy-MM-dd}.log.zip + </fileNamePattern> + </rollingPolicy> + <!-- <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> --> + <encoder> + <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern> + </encoder> + </appender> + + <!-- Spring related loggers --> + <logger name="org.springframework" level="WARN" /> + <logger name="org.springframework.beans" level="WARN" /> + <logger name="org.springframework.web" level="WARN" /> + <logger name="com.blog.spring.jms" level="WARN" /> + + <!-- AJSC Services (bootstrap services) --> + <logger name="ajsc" level="WARN" /> + <logger name="ajsc.RouteMgmtService" level="WARN" /> + <logger name="ajsc.ComputeService" level="WARN" /> + <logger name="ajsc.VandelayService" level="WARN" /> + <logger name="ajsc.FilePersistenceService" level="WARN" /> + <logger name="ajsc.UserDefinedJarService" level="WARN" /> + <logger name="ajsc.UserDefinedBeansDefService" level="WARN" /> + <logger name="ajsc.LoggingConfigurationService" level="WARN" /> + + <!-- AJSC related loggers (DME2 Registration, csi logging, restlet, servlet + logging) --> + <logger name="ajsc.utils" level="WARN" /> + <logger name="ajsc.utils.DME2Helper" level="WARN" /> + <logger name="ajsc.filters" level="WARN" /> + <logger name="ajsc.beans.interceptors" level="WARN" /> + <logger name="ajsc.restlet" level="WARN" /> + <logger name="ajsc.servlet" level="WARN" /> + <logger name="com.att.ajsc" level="WARN" /> + <logger name="com.att.ajsc.csi.logging" level="WARN" /> + <logger name="com.att.ajsc.filemonitor" level="WARN" /> + + <!-- Other Loggers that may help troubleshoot --> + <logger name="net.sf" level="WARN" /> + <logger name="org.apache.commons.httpclient" level="WARN" /> + <logger name="org.apache.commons" level="WARN" /> + <logger name="org.apache.coyote" level="WARN" /> + <logger name="org.apache.jasper" level="WARN" /> + + <!-- Camel Related Loggers (including restlet/servlet/jaxrs/cxf logging. + May aid in troubleshooting) --> + <logger name="org.apache.camel" level="WARN" /> + <logger name="org.apache.cxf" level="WARN" /> + <logger name="org.apache.camel.processor.interceptor" level="WARN" /> + <logger name="org.apache.cxf.jaxrs.interceptor" level="WARN" /> + <logger name="org.apache.cxf.service" level="WARN" /> + <logger name="org.restlet" level="WARN" /> + <logger name="org.apache.camel.component.restlet" level="WARN" /> + + <!-- logback internals logging --> + <logger name="ch.qos.logback.classic" level="INFO" /> + <logger name="ch.qos.logback.core" level="INFO" /> + + <!-- logback jms appenders & loggers definition starts here --> + + <if condition='property("JMS_BROKER").contains("WMQ")'> + <then> + <appender name="Audit-Record-Queue" class="ajsc.JMSQueueAppender"> + <param name="InitialContextFactoryName" value="${JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME}" /> + <param name="ProviderURL" value="${JMS_WMQ_PROVIDER_URL}" /> + <param name="DestinationName" value="${JMS_WMQ_AUDIT_DESTINATION_NAME}" /> + <param name="ConnectionFactoryName" value="${JMS_WMQ_CONNECTION_FACTORY_NAME}" /> + </appender> + <appender name="Performance-Tracker-Queue" class="ajsc.JMSQueueAppender"> + <param name="InitialContextFactoryName" value="${JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME}" /> + <param name="ProviderURL" value="${JMS_WMQ_PROVIDER_URL}" /> + <param name="DestinationName" value="${JMS_WMQ_PERF_DESTINATION_NAME}" /> + <param name="ConnectionFactoryName" value="${JMS_WMQ_CONNECTION_FACTORY_NAME}" /> + </appender> + </then> + <else> <!-- logback jms appenders definition starts here --> + <appender name="Audit-Record-Queue" class="ajsc.JMSQueueAppender"> + <param name="InitialContextFactoryName" + value="com.tibco.tibjms.naming.TibjmsInitialContextFactory" /> + <param name="ProviderURL" value="${JMS_TIBCO_PROVIDER_URL}" /> + <param name="userName" value="${JMS_LOGGER_USER_NAME}" /> + <param name="password" value="${JMS_LOGGER_PASSWORD}" /> + <QueueBindingName>${JMS_LOGGER_AUDIT_QUEUE_BINDING} + </QueueBindingName> + </appender> + <appender name="Performance-Tracker-Queue" class="ajsc.JMSQueueAppender"> + <param name="InitialContextFactoryName" + value="com.tibco.tibjms.naming.TibjmsInitialContextFactory" /> + <param name="ProviderURL" value="${JMS_TIBCO_PROVIDER_URL}" /> + <param name="userName" value="${JMS_LOGGER_USER_NAME}" /> + <param name="password" value="${JMS_LOGGER_PASSWORD}" /> + <QueueBindingName>${JMS_LOGGER_PERF_QUEUE_BINDING} + </QueueBindingName> + </appender> + </else> + </if> + + <appender name="ASYNC-audit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>1000</queueSize> + <discardingThreshold>0</discardingThreshold> + <appender-ref ref="Audit-Record-Queue" /> + </appender> + + <appender name="ASYNC-perf" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>1000</queueSize> + <discardingThreshold>0</discardingThreshold> + <appender-ref ref="Performance-Tracker-Queue" /> + </appender> + + <!-- + <logger name="AuditRecord" level="INFO" additivity="FALSE"> + <appender-ref ref="ASYNC-audit" /> + <appender-ref ref="auditLogs" /> + </logger> + <logger name="AuditRecord_DirectCall" level="INFO" additivity="FALSE"> + <appender-ref ref="ASYNC-audit" /> + <appender-ref ref="auditLogs" /> + </logger> + <logger name="PerfTrackerRecord" level="INFO" additivity="FALSE"> + <appender-ref ref="ASYNC-perf" /> + <appender-ref ref="perfLogs" /> + </logger> + --> + + <logger name="org.openecomp.aai" level="INFO" /> + + <!-- + <logger name="org.openecomp.aai.util" level="WARN" /> + <logger name="org.openecomp.aai.rest" level="WARN" /> + <logger name="org.openecomp.aai.rest.Business" level="WARN" /> + --> + + <logger name="org.apache" level="WARN" /> + <logger name="org.zookeeper" level="WARN" /> + <logger name="com.thinkaurelius" level="WARN" /> + + <root level="WARN"> + <appender-ref ref="DEBUG" /> + <appender-ref ref="ERROR" /> + <appender-ref ref="METRIC" /> + <appender-ref ref="AUDIT" /> + </root> + +</configuration> |