From a93b19450f6fb966afa1c30a6795e8e670d2aee7 Mon Sep 17 00:00:00 2001 From: Venkata Harish K Kajur Date: Wed, 24 May 2017 13:46:23 -0400 Subject: Update the aai-common with the latest code Change-Id: Ia4758a3d7e462e5120fa1db7ebe97adaeac3ebc2 Signed-off-by: Venkata Harish K Kajur --- .../openecomp/aai/exceptions/AAIExceptionTest.java | 15 +-- .../aai/exceptions/AAIExceptionWithInfoTest.java | 9 +- .../aai/introspection/IntrospectorTestSpec.java | 9 +- .../aai/introspection/MoxyEngineTest.java | 12 +- .../aai/introspection/PojoInjestorTest.java | 9 +- .../aai/introspection/PojoLoaderTest.java | 6 +- .../aai/introspection/PojoStrategyTest.java | 5 +- .../aai/introspection/PropertyPredicatesTest.java | 11 +- .../aai/introspection/ReflectionEngineTest.java | 16 ++- .../aai/introspection/sideeffect/DataCopyTest.java | 4 +- .../aai/introspection/sideeffect/DataLinkTest.java | 4 +- .../validation/IntrospectorValidationTest.java | 99 ++++++++++++++ .../openecomp/aai/logging/LoggingContextTest.java | 114 ++++++++++++++++ .../aai/parsers/query/GraphTraversalTest.java | 145 ++++++++++++++++++++- .../aai/parsers/query/LegacyQueryTest.java | 67 ++++++++-- .../query/RelationshipGremlinQueryTest.java | 4 +- .../aai/parsers/query/RelationshipQueryTest.java | 6 +- .../parsers/query/UniqueRelationshipQueryTest.java | 30 +++-- .../relationship/RelationshipToURITest.java | 4 +- .../openecomp/aai/parsers/uri/URIParserTest.java | 4 +- .../parsers/uri/URIToExtensionInformationTest.java | 4 +- .../openecomp/aai/parsers/uri/URIToObjectTest.java | 4 +- .../parsers/uri/URIToRelationshipObjectTest.java | 7 +- .../aai/query/builder/TraversalQueryTest.java | 19 ++- .../aai/serialization/db/DbAliasTest.java | 6 +- .../aai/workarounds/RemoveDME2QueryParamsTest.java | 91 +++++++++++++ 26 files changed, 599 insertions(+), 105 deletions(-) create mode 100644 aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java create mode 100644 aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java create mode 100644 aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java (limited to 'aai-core/src/test/java') 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 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 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 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> contexts = new LinkedList> (); + + 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 expected = __.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 expectedParent = expected; assertEquals( @@ -534,8 +535,7 @@ public class GraphTraversalTest { GraphTraversal expected = __.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 expectedParent = __.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 expected = __.start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex") + .in("locatedIn").has("aai-node-type", "pserver"); + GraphTraversal expectedParent = __.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 expected = __.start() + .has("physical-location-id", "key1") + .has("aai-node-type", "complex") + .in("locatedIn").has("aai-node-type", "pserver") + .has("hostname", "key2"); + GraphTraversal expectedParent = __.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 expected = __.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 expectedParent = __.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,10 +107,14 @@ 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, @@ -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 tQ = new TraversalQuery<>(loader, g); + TraversalQuery tQ2 = new TraversalQuery<>(loader, g); + TraversalQuery 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 tQ = new TraversalQuery<>(loader, g); + QueryBuilder builder = tQ.createQueryFromURI(new URI("network/test-objects/test-object/key1")).getQueryBuilder(); GraphTraversal expected = __.start().has("vnf-id", "key1").has("aai-node-type", "test-object"); GraphTraversal containerExpected = __.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 tQ = new TraversalQuery<>(loader, g); + QueryBuilder builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder(); GraphTraversal expected = __.start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf").out("hasLInterface").has(AAIProperties.NODE_TYPE, "l-interface").has("interface-name", "key2"); GraphTraversal containerExpected = __.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 hasParams; + private MultivaluedMap 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")); + } +} -- cgit 1.2.3-korg