summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test/java/org/openecomp
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-09-28 12:43:08 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-09-28 13:29:27 -0400
commit1767960099ea2983eef5218b8ce44b167ae0774c (patch)
tree4efe13601c1f9ebebc6026b32ec749778cd96caf /aai-core/src/test/java/org/openecomp
parenta8a05641920545aa094dffdb016b7b5febe9a879 (diff)
Change openecomp to onap and update license
Issue-ID: AAI-61 AAI-82 Change-Id: Iae98d4bf4c693c0a3203158bff98c3c5e739f453 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-core/src/test/java/org/openecomp')
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/AAISetup.java34
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java113
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java147
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java58
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java45
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java59
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java52
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java43
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java74
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java46
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java267
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java258
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java95
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/CNNameTest.java137
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/CustomLogPatternLayoutTest.java51
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/DME2RestFlagTest.java82
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java70
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/ErrorObjectTest.java162
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java107
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java814
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java157
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java662
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java271
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java296
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java194
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java224
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java101
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java185
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java94
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java248
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java150
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java123
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java101
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java112
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java132
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java440
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java43
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java237
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java75
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java163
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java59
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java100
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java152
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java54
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java91
45 files changed, 0 insertions, 7178 deletions
diff --git a/aai-core/src/test/java/org/openecomp/aai/AAISetup.java b/aai-core/src/test/java/org/openecomp/aai/AAISetup.java
deleted file mode 100644
index b0fce58d..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/AAISetup.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * ============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;
-
-import org.junit.BeforeClass;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-
-public abstract class AAISetup {
-
- @BeforeClass
- public static void setupBundleconfig() throws 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/bundleconfig-local/etc/oxm/");
- }
-}
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
deleted file mode 100644
index 554b6418..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============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.exceptions;
-
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-
-import static org.junit.Assert.assertEquals;
-
-public class AAIExceptionTest extends AAISetup {
-
- private static final String code = "4004";
- private static final String details = "This is a detailed description of the exception.";
- private static final Throwable cause = new RuntimeException("This is a runtime exception.");
- private static final Throwable noMessage = new RuntimeException();
-
- /**
- * Test constructor with 0 params.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith0Params() throws Exception {
- AAIException exception = new AAIException();
- assertEquals(exception, exception);
- }
-
- /**
- * Test constructor with 1 params.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith1Params() throws Exception {
- AAIException exception = new AAIException(code);
- assertEquals(exception, exception);
- }
-
- /**
- * Test constructor with 2 params details.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith2ParamsDetails() throws Exception {
- AAIException exception = new AAIException(code, details);
- assertEquals(details, exception.getMessage());
- }
-
- /**
- * Test constructor with 2 params cause.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith2ParamsCause() throws Exception {
- AAIException exception = new AAIException(code, cause);
- assertEquals("java.lang.RuntimeException: This is a runtime exception.", exception.getMessage());
- }
-
- /**
- * Test constructor with 2 params null message.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith2ParamsNullMessage() throws Exception {
- AAIException exception = new AAIException(code, noMessage);
- assertEquals(noMessage.toString(), exception.getMessage());
- }
-
- /**
- * Test constructor with 3 params.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith3Params() throws Exception {
- AAIException exception = new AAIException(code, cause, details);
- String details = "This is a detailed description of the exception.";
- assertEquals(details, exception.getMessage());
- }
-
- /**
- * Test constructor with 3 params null message.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith3ParamsNullMessage() throws Exception {
- AAIException exception = new AAIException(code, noMessage, details);
- String detailString = new String(details);
- assertEquals(detailString, exception.getMessage());
- }
-}
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
deleted file mode 100644
index 41841ac7..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-
- * ============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.exceptions;
-
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-
-import java.util.HashMap;
-
-import static org.junit.Assert.assertEquals;
-
-public class AAIExceptionWithInfoTest extends AAISetup {
-
-
- private static final HashMap<String, Object> map = new HashMap<String, Object>();
-
- {
- map.put("itemInteger", 1);
- map.put("itemString", "Two");
- map.put("itemThree", Boolean.TRUE);
- }
-
- private static final String info = "An error has occurred.";
- private static final String code = "AAI_4004";
- private static final String details = "This is a detailed description of the exception.";
- private static final Throwable cause = new RuntimeException("This is a runtime exception.");
-
- /**
- * Test constructor with 2 params.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith2Params() throws Exception {
- AAIExceptionWithInfo exception = new AAIExceptionWithInfo(map, info);
-
- assertEquals(map, exception.getInfoHash());
- assertEquals(info, exception.getInfo());
- }
-
- /**
- * Test constructor with 3 params.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith3Params() throws Exception {
- AAIExceptionWithInfo exception = new AAIExceptionWithInfo(code, map, info);
-
- assertEquals("4004", exception.getErrorObject().getErrorCode());
- assertEquals(map, exception.getInfoHash());
- assertEquals(info, exception.getInfo());
- }
-
- /**
- * Test constructor with 4 params I.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith4ParamsI() throws Exception {
- AAIExceptionWithInfo exception = new AAIExceptionWithInfo(code, details, map, info);
-
- assertEquals("4004", exception.getErrorObject().getErrorCode());
- assertEquals(details, exception.getMessage());
- assertEquals(map, exception.getInfoHash());
- assertEquals(info, exception.getInfo());
- }
-
- /**
- * Test constructor with 4 params II.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith4ParamsII() throws Exception {
- AAIExceptionWithInfo exception = new AAIExceptionWithInfo(code, cause, map, info);
-
- assertEquals("4004", exception.getErrorObject().getErrorCode());
- assertEquals(cause.toString(), exception.getMessage());
- assertEquals(map, exception.getInfoHash());
- assertEquals(info, exception.getInfo());
- }
-
- /**
- * Test constructor with 5 params.
- *
- * @throws Exception the exception
- */
- @Test
- public void testConstructorWith5Params() throws Exception {
- AAIExceptionWithInfo exception = new AAIExceptionWithInfo(code, cause, details, map, info);
-
- assertEquals("4004", exception.getErrorObject().getErrorCode());
- assertEquals(details, exception.getMessage());
- assertEquals(map, exception.getInfoHash());
- assertEquals(info, exception.getInfo());
- }
-
- /**
- * Test set info hash.
- */
- @Test
- public void testSetInfoHash() {
- AAIExceptionWithInfo exception = new AAIExceptionWithInfo(map, info);
-
- HashMap<String, Object> newMap = new HashMap<String, Object>();
- newMap.put("itemInteger", 2);
- exception.setInfoHash(newMap);
-
- assertEquals(newMap, exception.getInfoHash());
- assertEquals(info, exception.getInfo());
- }
-
- /**
- * Test set info.
- */
- @Test
- public void testSetInfo() {
- AAIExceptionWithInfo exception = new AAIExceptionWithInfo(map, info);
-
- String newInfo = "This is updated info.";
- exception.setInfo(newInfo);
-
- assertEquals(map, exception.getInfoHash());
- assertEquals(newInfo, exception.getInfo());
- }
-
-}
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
deleted file mode 100644
index 1ecc6923..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============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;
-
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-
-import static org.junit.Assert.assertEquals;
-
-public class IntrospectorTestSpec extends AAISetup {
-
-
-
- /**
- * Container test set.
- *
- * @param wrappedPortGroups the wrapped port groups
- * @throws AAIUnknownObjectException
- */
- protected void containerTestSet(Introspector wrappedPortGroups) throws AAIUnknownObjectException {
-
- assertEquals(
- "isContainer",
- true,
- wrappedPortGroups.isContainer());
-
- assertEquals(
- "newInstanceOfNestedProperty",
- "PortGroup",
- wrappedPortGroups.newInstanceOfNestedProperty("port-group").getClass().getSimpleName());
-
- assertEquals(
- "isComplexGenericType",
- true,
- wrappedPortGroups.isComplexGenericType("port-group"));
-
-
- }
-
-}
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
deleted file mode 100644
index 0f67ddfc..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============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;
-
-import org.junit.Test;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-
-public class MoxyEngineTest extends IntrospectorTestSpec {
-
- /**
- * Container object.
- * @throws AAIUnknownObjectException
- */
- @Test
- public void containerObject() throws AAIUnknownObjectException {
-
- Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9);
-
- Introspector obj = loader.introspectorFromName("port-groups");
-
- this.containerTestSet(obj);
-
- }
-
-
-
-}
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
deleted file mode 100644
index b820cfef..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============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;
-
-import org.junit.Test;
-import org.openecomp.aai.db.props.AAIProperties;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
-import static org.junit.Assert.*;
-
-public class PojoInjestorTest {
-
- @Test
- public void getVersionTest() {
- String latestVersion = "org.openecomp.aai.yang.VnfImage";
- PojoInjestor testPI = new PojoInjestor();
- assertEquals("", AAIProperties.LATEST, testPI.getVersion(latestVersion));
-
- String oldVersion = "org.openecomp.aai.yang.v8.VnfImage";
- assertEquals("", Version.v8, testPI.getVersion(oldVersion));
- }
-
- @Test
- public void getContextForVersionTest() {
- PojoInjestor testPI = new PojoInjestor();
- JAXBContext context = testPI.getContextForVersion(Version.v9);
- try {
- Marshaller marshaller = context.createMarshaller();
- //this will fail if the context wasn't initialized successfully (I think)
- marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.MEDIA_TYPE, "application/json");
- } catch (JAXBException e) {
- e.printStackTrace();
- fail("failed on setting marshaller property");
- }
- //if we get to here that means everything went ok
- assertTrue(true);
- }
-}
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
deleted file mode 100644
index e4e58b60..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============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;
-
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-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 extends AAISetup {
-
-
- @Test
- public void test() {
- Loader pojoLoader = LoaderFactory.createLoaderForVersion(ModelType.POJO, Version.v9);
- String payload = "{\"vnf-image-uuid\":\"myuuid\",\"application\":\"testApp\",\"application-vendor\":\"testVendor\",\"application-version\":\"versionTest\"}";
- try {
- Introspector intro = pojoLoader.unmarshal("vnf-image", payload, MediaType.APPLICATION_JSON_TYPE);
- VnfImage myVnfImage = (VnfImage) intro.getUnderlyingObject();
- assertTrue("myuuid".equals(myVnfImage.getVnfImageUuid()));
- assertTrue("testApp".equals(myVnfImage.getApplication()));
- assertTrue("testVendor".equals(myVnfImage.getApplicationVendor()));
- assertTrue("versionTest".equals(myVnfImage.getApplicationVersion()));
- } catch (AAIUnmarshallingException e) {
- e.printStackTrace();
- fail("AAIUnmarshallingException thrown");
- }
- }
-
-}
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
deleted file mode 100644
index 0bd61178..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============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;
-
-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
- public void getMetadataTest() {
- Introspector cloudregion = IntrospectorFactory.newInstance(ModelType.POJO, new CloudRegion());
- assertEquals("cloud-infrastructure", cloudregion.getMetadata(ObjectMetadata.NAMESPACE));
- assertEquals("cloud-regions", cloudregion.getMetadata(ObjectMetadata.CONTAINER));
-
- Introspector volumegroup = IntrospectorFactory.newInstance(ModelType.POJO, new VolumeGroup());
- assertEquals("cloud-region", volumegroup.getMetadata(ObjectMetadata.DEPENDENT_ON));
- assertEquals("", volumegroup.getMetadata(ObjectMetadata.NAMESPACE));
- }
-
-}
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
deleted file mode 100644
index 50aea8fe..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============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;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-
-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 extends AAISetup {
-
- private final Version version = Version.getLatest();
-
- private Loader loader;
- private ModelType introspectorFactoryType = ModelType.MOXY;
- private Introspector obj;
-
- @Before
- public void setup() throws Exception {
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- obj = loader.introspectorFromName("test-object");
- }
-
- @Test
- public void includeInTestGeneration() throws AAIUnknownObjectException {
-
- Set<String> props = obj.getProperties(PropertyPredicates.includeInTestGeneration());
-
- assertThat("props not found", props,
- not(hasItems("persona-model-ver", "not-visible-test-element", "model-invariant-id", "model-version-id")));
- }
-
- @Test
- public void isVisible() throws AAIUnknownObjectException {
-
- Set<String> props = obj.getProperties(PropertyPredicates.isVisible());
-
- assertThat("props not found", props, not(hasItems("persona-model-ver")));
- }
-
- @Test
- public void all() throws AAIUnknownObjectException {
-
- Set<String> props = obj.getProperties();
-
- assertThat("all found", props, hasItems("persona-model-ver", "not-visible-test-element"));
- }
-
-
-}
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
deleted file mode 100644
index d7cd7b18..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============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;
-
-import org.junit.Test;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-
-public class ReflectionEngineTest extends IntrospectorTestSpec {
-
- /**
- * Container object.
- *
- * @throws InstantiationException the instantiation exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ClassNotFoundException the class not found exception
- * @throws AAIUnknownObjectException
- */
- @Test
- public void containerObject() throws InstantiationException, IllegalAccessException, ClassNotFoundException, AAIUnknownObjectException {
- Object javaObj = null;
- String className = "org.openecomp.aai.domain.yang.PortGroups";
- javaObj = Class.forName(className).newInstance();
-
- Introspector obj = IntrospectorFactory.newInstance(ModelType.POJO, javaObj);
-
-// this.containerTestSet(obj);
- }
-}
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
deleted file mode 100644
index 8e37fe05..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*-
- * ============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.sideeffect;
-
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.apache.commons.io.IOUtils;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.junit.*;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.dbmap.DBConnectionType;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-import org.openecomp.aai.introspection.sideeffect.exceptions.AAIMissingRequiredPropertyException;
-import org.openecomp.aai.parsers.query.QueryParser;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.db.EdgeProperty;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-public class DataCopyTest {
-
- private static TitanGraph graph;
- private final static Version version = Version.getLatest();
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
- private static Loader loader;
- private static TransactionalGraphEngine dbEngine;
- @Mock private Vertex self;
- @Mock private VertexProperty<String> prop;
- @Mock private QueryParser uriQuery;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
-
- @BeforeClass
- public static void setup() throws NoSuchFieldException, SecurityException, Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
- queryStyle,
- type,
- loader);
-
- graph.traversal().addV("aai-node-type", "model", "model-invariant-id", "key1").as("v1")
- .addV("aai-node-type", "model-ver", "model-ver", "myValue", "model-version-id", "key2", "model-version", "testValue").addInE("has", "v1", EdgeProperty.CONTAINS.toString(), true)
- .addV("aai-node-type", "model", "model-invariant-id", "key3").as("v2")
- .addV("aai-node-type", "model-ver", "model-ver", "myValue", "model-version-id", "key4").addInE("has", "v2", EdgeProperty.CONTAINS.toString(), true)
- .next();
- graph.tx().commit();
- }
-
- @AfterClass
- public static void tearDown() {
- graph.tx().rollback();
- graph.close();
- }
-
- @Before
- public void initMock() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void runPopulatePersonaModelVer() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
- final Introspector obj = loader.introspectorFromName("test-object");
- obj.setValue("vnf-id", "myId");
- obj.setValue("model-invariant-id", "key1");
- obj.setValue("model-version-id", "key2");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("value populated", "testValue", obj.getValue("persona-model-ver"));
-
- g.tx().rollback();
-
-
- }
-
- @Test
- public void runPopulateModelVersionId() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9);
- final Introspector obj = loader.introspectorFromName("test-object");
- obj.setValue("vnf-id", "myId");
- obj.setValue("persona-model-id", "key1");
- obj.setValue("persona-model-version", "testValue");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("value populated", "key2", obj.getValue("model-version-id"));
-
- g.tx().rollback();
- }
-
- @Test
- public void verifyNestedSideEffect() throws URISyntaxException, AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, IOException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
- final Introspector obj = loader.unmarshal("customer", this.getJsonString("nested-case.json"));
- System.out.println(obj.marshal(true));
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.tx()).thenReturn(g);
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- when(uriQuery.isDependent()).thenReturn(false);
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- Vertex v= serializer.createNewVertex(obj);
- serializer.serializeToDb(obj, v, uriQuery, obj.getURI(), "test");
-
- assertEquals("nested value populated", "testValue", g.traversal().V().has("service-instance-id", "nested-instance-key").next().property("persona-model-version").orElse(""));
-
- g.tx().rollback();
-
- }
-
- @Test
- public void expectedMissingPropertyExceptionInURI() throws AAIException, UnsupportedEncodingException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
- final Introspector obj = loader.introspectorFromName("test-object");
- obj.setValue("vnf-id", "myId");
- obj.setValue("model-invariant-id", "key1");
-
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- thrown.expect(AAIMissingRequiredPropertyException.class);
- runner.execute(obj, self);
- }
-
- @Test
- public void expectedMissingPropertyExceptionForResultingObject() throws AAIException, UnsupportedEncodingException {
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
- final Introspector obj = loader.introspectorFromName("test-object");
- obj.setValue("vnf-id", "myId");
- obj.setValue("model-invariant-id", "key3");
- obj.setValue("model-version-id", "key4");
-
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- thrown.expect(AAIMissingRequiredPropertyException.class);
- runner.execute(obj, self);
- }
-
- @Test
- public void expectNoProcessingWithNoProperties() throws AAIException, UnsupportedEncodingException {
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
- final Introspector obj = loader.introspectorFromName("test-object");
- obj.setValue("vnf-id", "myId");
-
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("no model-version-id", true, obj.getValue("model-version-id") == null);
- assertEquals("no model-invariant-id", true, obj.getValue("model-invariant-id") == null);
-
- }
-
- private String getJsonString(String filename) throws IOException {
-
-
- FileInputStream is = new FileInputStream("src/test/resources/bundleconfig-local/etc/oxm/sideeffect/" + filename);
- String s = IOUtils.toString(is, "UTF-8");
- IOUtils.closeQuietly(is);
-
- return s;
- }
-}
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
deleted file mode 100644
index 8220b86c..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*-
- * ============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.sideeffect;
-
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.junit.*;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.dbmap.DBConnectionType;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-import org.openecomp.aai.parsers.query.QueryParser;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.db.EdgeProperty;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-public class DataLinkTest {
-
- private static TitanGraph graph;
- private final static Version version = Version.getLatest();
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
- private static Loader loader;
- private static TransactionalGraphEngine dbEngine;
- @Mock private QueryParser parser;
- @Mock private Vertex self;
- @Mock private VertexProperty<String> prop;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
-
- @BeforeClass
- public static void setup() throws NoSuchFieldException, SecurityException, Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
- queryStyle,
- type,
- loader);
-
- graph.traversal().addV("aai-node-type", "vpn-binding", "vpn-id", "addKey").as("v1")
- .addV("aai-node-type", "vpn-binding", "vpn-id", "modifyKey").as("v2")
- .addV("aai-node-type", "route-target", "global-route-target", "modifyTargetKey", "route-target-role", "modifyRoleKey", "linked", true).addInE("has", "v2", EdgeProperty.CONTAINS.toString(), true)
- .addV("aai-node-type", "vpn-binding", "vpn-id", "deleteKey").as("v3")
- .addV("aai-node-type", "route-target", "global-route-target", "deleteTargetKey", "route-target-role", "deleteRoleKey", "linked", true).addInE("has", "v3", EdgeProperty.CONTAINS.toString(), true)
- .addV("aai-node-type", "vpn-binding", "vpn-id", "getKey").as("v4")
- .addV("aai-node-type", "route-target", "global-route-target", "getTargetKey", "route-target-role", "getRoleKey", "linked", true).addInE("has", "v4", EdgeProperty.CONTAINS.toString(), true)
- .addV("aai-node-type", "vpn-binding", "vpn-id", "getKeyNoLink").as("v5")
- .addV("aai-node-type", "route-target", "global-route-target", "getTargetKeyNoLink", "route-target-role", "getRoleKeyNoLink").addInE("has", "v5", EdgeProperty.CONTAINS.toString(), true)
- .next();
- graph.tx().commit();
- }
-
- @AfterClass
- public static void tearDown() {
- graph.tx().rollback();
- graph.close();
- }
-
- @Before
- public void initMock() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void verifyCreationOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9);
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "addKey");
- obj.setValue("global-route-target", "key1");
- obj.setValue("route-target-role", "key2");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("route-target vertex found", true, traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "key1").has("route-target-role", "key2").has("linked", true).hasNext());
-
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyModificationOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9);
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "modifyKey");
- obj.setValue("global-route-target", "modifyTargetKey2");
- obj.setValue("route-target-role", "modifyRoleKey2");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("route-target vertex found", true, traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").has("linked", true).hasNext());
- assertEquals("previous link removed", true, traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").hasNot("linked").hasNext());
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyDeleteOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9);
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "deleteKey");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(adminSpy.getReadOnlyTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("route-target vertex not found", false, traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "deleteTargetKey").has("route-target-role", "deleteRoleKey").has("linked", true).hasNext());
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyPropertyPopulation() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9);
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "getKey");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkReader.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("both properties have been populated in target object", true, obj.getValue("global-route-target").equals("getTargetKey") && obj.getValue("route-target-role").equals("getRoleKey"));
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyPropertyPopulationWithV10OnlyPut() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "getKeyNoLink");
- final Introspector routeTargets = loader.introspectorFromName("route-targets");
- obj.setValue("route-targets", routeTargets.getUnderlyingObject());
- List<Object> targets = routeTargets.getValue("route-target");
- final Introspector routeTargetOne = loader.introspectorFromName("route-target");
- routeTargetOne.setValue("global-route-target", "getTargetKeyNoLink");
- routeTargetOne.setValue("route-target-role", "getRoleKeyNoLink");
- targets.add(routeTargetOne.getUnderlyingObject());
- final Introspector routeTargetTwo = loader.introspectorFromName("route-target");
- routeTargetTwo.setValue("global-route-target", "getTargetKeyNoLink2");
- routeTargetTwo.setValue("route-target-role", "getRoleKeyNoLink2");
- targets.add(routeTargetTwo.getUnderlyingObject());
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.tx()).thenReturn(g);
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(parser.isDependent()).thenReturn(false);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- Vertex v = serializer.createNewVertex(obj);
- serializer.serializeToDb(obj, v, parser, obj.getURI(), "testing");
- Vertex routeTargetOneV = traversal.V().has("global-route-target", "getTargetKeyNoLink").next();
- Vertex routeTargetTwoV = traversal.V().has("global-route-target", "getTargetKeyNoLink2").next();
-
- assertEquals("first route target put has linked", true, routeTargetOneV.property(AAIProperties.LINKED).orElse(false));
- assertEquals("second route target put does not have linked", false, routeTargetTwoV.property(AAIProperties.LINKED).orElse(false));
-
- g.tx().rollback();
-
- }
-}
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
deleted file mode 100644
index 8b76967a..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * ============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 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.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;
-
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-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();
- }
- @Ignore
- @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());
- }
- @Ignore
- @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/CNNameTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/CNNameTest.java
deleted file mode 100644
index b4705030..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/logging/CNNameTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*-
- * ============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 ch.qos.logback.access.spi.IAccessEvent;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.aai.logging.CNName;
-import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.openecomp.aai.util.AAIConstants;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.agent.PowerMockAgent;
-
-import javax.security.auth.x500.X500Principal;
-import javax.servlet.http.HttpServletRequest;
-import java.security.cert.X509Certificate;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-@PowerMockIgnore("javax.security.auth.x500.X500Principal")
-@PrepareForTest({IAccessEvent.class, HttpServletRequest.class, X509Certificate.class})
-public class CNNameTest {
-
- static {
- PowerMockAgent.initializeIfNeeded();
- }
-
-
- IAccessEvent mockAccEvent;
- HttpServletRequest mockHttpServletRequest;
- CNName cnname;
- X509Certificate cert;
-
- /**
- * Initialize.
- */
- @Before
- public void initialize() throws 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/bundleconfig-local/etc/oxm/");
- mockAccEvent = Mockito.mock(IAccessEvent.class);
- mockHttpServletRequest = Mockito.mock(HttpServletRequest.class);
- cert = Mockito.mock(X509Certificate.class);
- }
-
-
- /**
- * Test 'convert' when there is no AccessConverter.
- */
- @Test
- public void testConvert_withoutAccessConverter(){
- cnname = getTestObj(false);
- assertTrue("Conversion failed with no AccessConverter", "INACTIVE_HEADER_CONV".equals(cnname.convert(mockAccEvent)));
- }
-
- /**
- * Test 'convert' with no CipherSuite.
- */
- @Test
- public void testConvert_withNullCipherSuite(){
- setupForCipherSuite(null);
- assertTrue("Conversion failed for a null CipherSuite", "-".equals(cnname.convert(mockAccEvent)));
- }
-
-
- /**
- * Test 'convert' with a non-null CipherSuite.
- */
- @Test
- public void testConvert_withNotNullCipherSuite(){
-
- setupForCipherSuite("StrRepOfAValidSuite");
-
- final X500Principal principal = new X500Principal("CN=AAI, OU=DOX, O=BWS, C=CA");
-
- Mockito.when(cert.getSubjectX500Principal()).thenReturn(principal);
-
- final X509Certificate[] certChain = {cert};
-
- when(mockHttpServletRequest.getAttribute("javax.servlet.request.X509Certificate")).thenReturn(certChain);
-
- assertTrue("Conversion failed for a valid CipherSuite", principal.toString().equals(cnname.convert(mockAccEvent)));
- }
-
-
- /**
- * Helper method to mock IAccessEvent and HttpServletRequest.
- *
- * @param suite CipherSuite to be used in current test
- */
- private void setupForCipherSuite(String suite){
- cnname = getTestObj(true);
- when(mockAccEvent.getRequest()).thenReturn(mockHttpServletRequest);
- when(mockHttpServletRequest.getAttribute("javax.servlet.request.cipher_suite")).thenReturn(suite);
- }
-
-
- /**
- * Helper method to create a CNName object with overridden 'start status' .
- *
- * @param instanceStarted Start status to be used
- * @return CNName object to test
- */
- private CNName getTestObj(final boolean instanceStarted){
- return new CNName(){
- @Override
- public boolean isStarted(){
- return instanceStarted;
- }
- };
- }
-}
-
-
-
diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/CustomLogPatternLayoutTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/CustomLogPatternLayoutTest.java
deleted file mode 100644
index 3e79646b..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/logging/CustomLogPatternLayoutTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * ============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 org.junit.Test;
-import org.openecomp.aai.logging.CNName;
-import org.openecomp.aai.logging.CustomLogPatternLayout;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class CustomLogPatternLayoutTest {
-
- /**
- * Test null when defaultConverterMap doesn't have corresponding entry.
- */
- @Test
- public void testNull(){
- String s = CustomLogPatternLayout.defaultConverterMap.get("z");
- assertFalse("Entry not found for key 'z'", CNName.class.getName().equals(s));
- }
-
- /**
- * Test defaultConverterMap when valid entry exists.
- */
- @Test
- public void testEntryFor_Z(){
- CustomLogPatternLayout layout = new CustomLogPatternLayout();
- String s = CustomLogPatternLayout.defaultConverterMap.get("z");
- assertTrue("Entry not found for key 'z'", CNName.class.getName().equals(s));
- }
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/DME2RestFlagTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/DME2RestFlagTest.java
deleted file mode 100644
index 1ac17dad..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/logging/DME2RestFlagTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============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.*;
-import static org.mockito.Mockito.*;
-import ch.qos.logback.access.spi.IAccessEvent;
-import org.junit.*;
-
-
-public class DME2RestFlagTest {
-
- IAccessEvent mockAccEvent;
- DME2RestFlag _DME2RestFlag;
-
- String[] temp = new String[4];
-
-
- @Before
- public void setUp() throws Exception {
-
- mockAccEvent = mock(IAccessEvent.class);
- _DME2RestFlag= spy(DME2RestFlag.class);
-
- }
- private DME2RestFlag getTestObj(final boolean instanceStarted){
- return new DME2RestFlag(){
- @Override
- public
- boolean isStarted(){
- return instanceStarted;
- }
- };
- }
-
- @Test
- public void convertTestAllValid(){
- temp[0]= "temp1";
- temp[1] = "-";
- when(mockAccEvent.getRequestParameter("envContext")).thenReturn(temp);
- when(mockAccEvent.getRequestParameter("routeOffer")).thenReturn(temp);
- when(mockAccEvent.getRequestParameter("version")).thenReturn(temp);
- _DME2RestFlag = getTestObj(true);
- assertEquals(_DME2RestFlag.convert(mockAccEvent),"DME2");
- }
-
- @Test
- public void convertMissingRouteTest(){
- temp[0]= "";
- temp[1] = "-";
- when(mockAccEvent.getRequestParameter("envContext")).thenReturn(temp);
- when(mockAccEvent.getRequestParameter("routeOffer")).thenReturn(temp);
- when(mockAccEvent.getRequestParameter("version")).thenReturn(temp);
- _DME2RestFlag = getTestObj(true);
- assertEquals(_DME2RestFlag.convert(mockAccEvent),"REST");
- }
-
- @Test
- public void convertIsStartedFalseTest(){
- _DME2RestFlag = getTestObj(false);
- assertEquals(_DME2RestFlag.convert(mockAccEvent),"INACTIVE_HEADER_CONV");
- }
-
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java
deleted file mode 100644
index 63ac5683..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/logging/EelfClassOfCallerTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============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.*;
-import static org.mockito.Mockito.*;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import org.junit.*;
-
-public class EelfClassOfCallerTest {
-
- EelfClassOfCaller _eelfClassOfCaller;
- ILoggingEvent mockEvent;
- StackTraceElement[] cdafive = new StackTraceElement[5];
- StackTraceElement[] cdaone = new StackTraceElement[1];
- StackTraceElement[] cdazero = new StackTraceElement[0];
-
-
- @Before
- public void setUp() throws Exception {
-
- mockEvent = mock(ILoggingEvent.class);
- _eelfClassOfCaller= spy(EelfClassOfCaller.class);
-
- }
-
-
- @Test
- public void getFullyQualifiedNameCDALENFiveTest(){
- StackTraceElement temp = new StackTraceElement("classname_five","methodname","filename", 4);
- cdafive[2]=temp;
- when(mockEvent.getCallerData()).thenReturn(cdafive);
- assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"classname_five");
-
- }
- @Test
- public void getFullyQualifiedNameCDALenOneTest(){
- StackTraceElement temp = new StackTraceElement("classname_one","methodname","filename", 4);
- cdaone[0]=temp;
- when(mockEvent.getCallerData()).thenReturn(cdaone);
- assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"classname_one");
-
- }
-
- @Test
- public void getFullyQualifiedNameCDALenZeroTest(){
- when(mockEvent.getCallerData()).thenReturn(cdazero);
- assertEquals(_eelfClassOfCaller.getFullyQualifiedName(mockEvent),"?");
-
- }
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/ErrorObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/ErrorObjectTest.java
deleted file mode 100644
index 6a5bb843..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/logging/ErrorObjectTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-
- * ============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 javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-public class ErrorObjectTest {
-
- ErrorObject newErrorObject = new ErrorObject("disposition","category","severity", 200, "restErrorCode","errorCode","errorText");
-
- //Constructor Tests
- @Test
- public void createObjectTest1(){
- //No HTTP Status argument
- ErrorObject errorObject = new ErrorObject("severity","errorcode","errortext","disposition","category");
- assertNotNull(errorObject);
- }
- @Test
- public void createObjectTest2(){
- //HTTP Status code as integer
- ErrorObject errorObject = new ErrorObject("severity",200,"errorcode","errortext","disposition","category");
- assertNotNull(errorObject);
- }
- @Test
- public void createObjectTest3(){
- //HTTP Status code as Status
- ErrorObject errorObject = new ErrorObject("severity",Status.OK,"errorcode","errortext","disposition","category");
- assertNotNull(errorObject);
- }
- //Disposition Tests
- @Test
- public void getDispositionTest() {
- assertEquals(newErrorObject.getDisposition(), "disposition");
- }
- @Test
- public void setDispositionTest() {
- newErrorObject.setDisposition("newDisposition");
- assertEquals(newErrorObject.getDisposition(), "newDisposition");
- }
-
- //Category Tests
- @Test
- public void getCategoryTest(){
- assertEquals(newErrorObject.getCategory(), "category");
- }
- @Test
- public void setCategoryTest(){
- newErrorObject.setCategory("newCategory");
- assertEquals(newErrorObject.getCategory(), "newCategory");
- }
-
- //Severity Tests
- @Test
- public void getSeverityTest(){
- assertEquals(newErrorObject.getSeverity(), "severity");
- }
- @Test
- public void setSeverityTest(){
- newErrorObject.setSeverity("newSeverity");
- assertEquals(newErrorObject.getSeverity(), "newSeverity");
- }
-
- //Error Code Tests
- @Test
- public void getErrorCodeTest(){
- assertEquals(newErrorObject.getErrorCode(), "errorCode");
- }
- @Test
- public void SetErrorCodeTest(){
- newErrorObject.setErrorCode("newErrorCode");
- assertEquals(newErrorObject.getErrorCode(), "newErrorCode");
- }
-
- //HTTP Response Code Tests
- @Test
- public void getHTTPCodeTest(){
- assertEquals(newErrorObject.getHTTPResponseCode(), Status.OK);
- }
- @Test
- public void setHTTPCodeTest(){
- newErrorObject.setHTTPResponseCode(201);
- assertEquals(newErrorObject.getHTTPResponseCode(), Status.CREATED);
- }
- @Test(expected=IllegalArgumentException.class)
- public void invalidHttpCodeTest(){
- newErrorObject.setHTTPResponseCode(6281723);
- }
- @Test(expected=IllegalArgumentException.class)
- public void invalidHttpCodeTest2(){
- newErrorObject.setHTTPResponseCode("82901");
- }
-
- //Rest Error Code Tests
- @Test
- public void getRestErrorCodeTest(){
- assertEquals(newErrorObject.getRESTErrorCode(), "restErrorCode");
- }
- @Test
- public void setRestErrorCodeTest(){
- newErrorObject.setRESTErrorCode("newRestErrorCode");
- assertEquals(newErrorObject.getRESTErrorCode(), "newRestErrorCode");
- }
-
- //Error Text Tests
- @Test
- public void getErrorTextTest(){
- assertEquals(newErrorObject.getErrorText(), "errorText");
- }
- @Test
- public void setErrorTextTest(){
- newErrorObject.setErrorText("newErrorText");
- assertEquals(newErrorObject.getErrorText(), "newErrorText");
- }
- @Test
- public void getErrorCodeStringTest(){
- assertEquals(newErrorObject.getErrorCodeString(), "disposition.category.errorCode");
- }
- @Test
- public void getErrorCodeStringDisposition5Test(){
- //get Error Code String while Disposition = 5
- newErrorObject.setDisposition("5");
- assertEquals(newErrorObject.getErrorCodeString(), "ERR.5.category.errorCode");
- }
- @Test
- public void getSeverityCodeTest(){
- newErrorObject.setSeverity("WARN");
- assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "1");
-
- newErrorObject.setSeverity("ERROR");
- assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "2");
-
- newErrorObject.setSeverity("FATAL");
- assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "3");
- }
- //To String Test
- @Test
- public void toStringTest(){
- assertEquals(newErrorObject.toString(), "ErrorObject [errorCode=errorCode, errorText=errorText, restErrorCode=restErrorCode, httpResponseCode=OK, severity=severity, disposition=disposition, category=category]");
- }
-}
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
deleted file mode 100644
index 9cc522eb..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============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 org.junit.Test;
-
-import java.util.*;
-
-import static org.junit.Assert.*;
-
-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
deleted file mode 100644
index a4070b02..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java
+++ /dev/null
@@ -1,814 +0,0 @@
-/*-
- * ============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.parsers.query;
-
-import org.apache.tinkerpop.gremlin.process.traversal.P;
-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.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.db.props.AAIProperties;
-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;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-public class GraphTraversalTest extends AAISetup {
-
- private TransactionalGraphEngine dbEngine;
- private TransactionalGraphEngine dbEnginev9;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Configure.
- * @throws Exception
- * @throws SecurityException
- * @throws NoSuchFieldException
- */
- @Before
- public void configure() throws Exception {
- dbEngine =
- new TitanDBEngine(QueryStyle.TRAVERSAL,
- LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST),
- false);
-
- dbEnginev9 =
- new TitanDBEngine(QueryStyle.TRAVERSAL,
- LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9),
- false);
- }
-
- /**
- * Parent query.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void parentQuery() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1").build();
-
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
-
- GraphTraversal<Vertex, Vertex> expected = __.<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 gremlin query should be equal to normal query",
- expected.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be complex",
- "complex",
- query.getResultType());
- assertEquals(
- "result type should be empty",
- "",
- query.getParentResultType());
- assertEquals("dependent",false, query.isDependent());
-
-
- }
-
- /**
- * Child query.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void childQuery() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3").build();
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("physical-location-id", "key1").has("aai-node-type", "complex")
- .out("hasCtagPool")
- .has("aai-node-type", "ctag-pool")
- .has("target-pe", "key2").has("availability-zone-name", "key3");
- 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 gremlin query should be equal the query for complex",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be complex",
- "complex",
- query.getParentResultType());
- assertEquals(
- "result type should be ctag-pool",
- "ctag-pool",
- query.getResultType());
- assertEquals("dependent",true, query.isDependent());
-
-
- }
-
- /**
- * Naming exceptions.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void namingExceptions() throws 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);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("vnf-id", "key1").has("aai-node-type", "vce")
- .out("hasPortGroup")
- .has("aai-node-type", "port-group")
- .has("interface-id", "key2").out("hasCTag")
- .has("aai-node-type", "cvlan-tag")
- .has("cvlan-tag", 655);
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("vnf-id", "key1").has("aai-node-type", "vce")
- .out("hasPortGroup")
- .has("aai-node-type", "port-group")
- .has("interface-id", "key2");
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for port group",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be cvlan-tag",
- "cvlan-tag",
- query.getResultType());
- assertEquals(
- "result type should be port-group",
- "port-group",
- query.getParentResultType());
- assertEquals(
- "contaner type should be empty",
- "",
- query.getContainerType());
- assertEquals("dependent",true, query.isDependent());
-
-
- }
-
- /**
- * Gets the all.
- *
- * @return the all
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void getAll() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags").build();
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("vnf-id", "key1").has("aai-node-type", "vce")
- .out("hasPortGroup")
- .has("aai-node-type", "port-group")
- .has("interface-id", "key2").out("hasCTag")
- .has("aai-node-type", "cvlan-tag");
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("vnf-id", "key1").has("aai-node-type", "vce")
- .out("hasPortGroup")
- .has("aai-node-type", "port-group")
- .has("interface-id", "key2");
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for port group",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be port-group",
- "port-group",
- query.getParentResultType());
- assertEquals(
- "result type should be cvlan-tag",
- "cvlan-tag",
- query.getResultType());
- assertEquals(
- "container type should be cvlan-tags",
- "cvlan-tags",
- query.getContainerType());
- assertEquals("dependent",true, query.isDependent());
-
-
- }
-
- @Test
- public void getAllParent() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers").build();
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("aai-node-type", "pserver");
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("aai-node-type", "pserver");
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for pserver",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "parent result type should be empty",
- "",
- query.getParentResultType());
- assertEquals(
- "result type should be pserver",
- "pserver",
- query.getResultType());
- assertEquals(
- "container type should be pservers",
- "pservers",
- query.getContainerType());
- assertEquals("dependent",false, query.isDependent());
-
-
- }
-
-
- /**
- * Gets the via query param.
- *
- * @return the via query param
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void getViaQueryParam() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("tenant-name", "Tenant1");
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("cloud-owner", "mycloudowner").has("cloud-region-id", "mycloudregionid")
- .has("aai-node-type", "cloud-region")
- .out("has")
- .has("aai-node-type", "tenant")
- .has("tenant-name", "Tenant1");
-
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("cloud-owner", "mycloudowner").has("cloud-region-id", "mycloudregionid")
- .has("aai-node-type", "cloud-region");
-
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for cloud-region",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be cloud-region",
- "cloud-region",
- query.getParentResultType());
- assertEquals(
- "result type should be tenant",
- "tenant",
- query.getResultType());
- assertEquals(
- "container type should be empty",
- "",
- query.getContainerType());
- assertEquals("dependent",true, query.isDependent());
-
- }
-
- @Test
- public void getViaDuplicateQueryParam() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- List<String> values = new ArrayList<>();
- values.add("Tenant1");
- values.add("Tenant2");
- map.put("tenant-name", values);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("cloud-owner", "mycloudowner").has("cloud-region-id", "mycloudregionid")
- .has("aai-node-type", "cloud-region")
- .out("has")
- .has("aai-node-type", "tenant")
- .has("tenant-name", P.within(values));
-
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("cloud-owner", "mycloudowner").has("cloud-region-id", "mycloudregionid")
- .has("aai-node-type", "cloud-region");
-
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for cloud-region",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be cloud-region",
- "cloud-region",
- query.getParentResultType());
- assertEquals(
- "result type should be tenant",
- "tenant",
- query.getResultType());
- assertEquals(
- "container type should be empty",
- "",
- query.getContainerType());
- assertEquals("dependent",true, query.isDependent());
-
- }
-
- /**
- * Gets the plural via query param.
- *
- * @return the plural via query param
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void getPluralViaQueryParam() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("network/vnfcs").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("prov-status", "up");
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("aai-node-type", "vnfc")
- .has("prov-status", "up");
-
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("aai-node-type", "vnfc");
-
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "parent result type should be empty",
- "",
- query.getParentResultType());
- assertEquals(
- "result type should be vnfc",
- "vnfc",
- query.getResultType());
- assertEquals(
- "container type should be empty",
- "vnfcs",
- query.getContainerType());
- assertEquals("dependent",true, query.isDependent());
-
- }
-
- /**
- * Gets the all query param naming exception.
- *
- * @return the all query param naming exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void getAllQueryParamNamingException() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("cvlan-tag", "333");
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map);
-
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("vnf-id", "key1").has("aai-node-type", "vce")
- .out("hasPortGroup")
- .has("aai-node-type", "port-group")
- .has("interface-id", "key2").out("hasCTag")
- .has("aai-node-type", "cvlan-tag")
- .has("cvlan-tag", 333);
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("vnf-id", "key1").has("aai-node-type", "vce")
- .out("hasPortGroup")
- .has("aai-node-type", "port-group")
- .has("interface-id", "key2");
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for port group",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be port-group",
- "port-group",
- query.getParentResultType());
- assertEquals(
- "result type should be cvlan-tag",
- "cvlan-tag",
- query.getResultType());
- assertEquals(
- "container type should be cvlan-tags",
- "cvlan-tags",
- query.getContainerType());
- assertEquals("dependent",true, query.isDependent());
-
-
- }
-
- /**
- * Abstract type.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void abstractType() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("vnf/key1").build();
-
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
-
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "generic-vnf"));
-
- GraphTraversal<Vertex, Vertex> expectedParent = expected;
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for port group",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be empty",
- "",
- query.getParentResultType());
- assertEquals(
- "result type should be vnf",
- "vnf",
- query.getResultType());
-
- assertEquals("dependent",false, query.isDependent());
-
-
- }
-
- /**
- * Non parent abstract type.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void nonParentAbstractType() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers/pserver/key2/vnf/key1").build();
- thrown.expect(AAIException.class);
- thrown.expectMessage(containsString("not a valid path"));
- dbEngine.getQueryBuilder().createQueryFromURI(uri);
- }
-
- @Test
- public void parentAbstractTypeWithNesting() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("vnf/key1/vf-modules/vf-module/key2").build();
-
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
-
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "generic-vnf"))
- .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", "generic-vnf"));
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent gremlin query should be equal the query for ",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "result type should be vnf",
- "vnf",
- query.getParentResultType());
- assertEquals(
- "result type should be vf-module",
- "vf-module",
- query.getResultType());
-
- assertEquals("dependent",true, query.isDependent());
-
- }
-
- @Test
- public void getViaBadQueryParam() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/cloud-regions/cloud-region/a/b/tenants/tenant").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("tenant-n231ame", "Tenant1");
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map);
-
- }
-
- @Test
- public void getPluralViaBadQueryParam() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/cloud-regions/cloud-region/a/b/tenants").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("tenant-n231ame", "Tenant1");
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map);
-
- }
-
- @Test
- public void getPluralViaDuplicateQueryParam() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("network/vnfcs").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- List<String> values = new ArrayList<>();
- values.add("up");
- values.add("down");
- values.add("left");
- values.add("right");
- values.add("start");
- map.put("prov-status", values);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("aai-node-type", "vnfc")
- .has("prov-status", P.within(values));
-
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("aai-node-type", "vnfc");
-
- assertEquals(
- "gremlin query should be " + expected.toString(),
- expected.toString(),
- query.getQueryBuilder().getQuery().toString());
- assertEquals(
- "parent",
- expectedParent.toString(),
- query.getQueryBuilder().getParentQuery().getQuery().toString());
- assertEquals(
- "parent result type should be empty",
- "",
- query.getParentResultType());
- assertEquals(
- "result type should be vnfc",
- "vnfc",
- query.getResultType());
- assertEquals(
- "container type should be empty",
- "vnfcs",
- query.getContainerType());
- assertEquals("dependent",true, query.isDependent());
-
- }
-
- @Test
- public void dbAliasedSearch() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("network/test-objects").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("persona-model-customization-id", "key2");
- QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri, map);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("aai-node-type", "test-object")
- .has("model-customization-id", "key2");
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("aai-node-type", "test-object");
-
- 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",
- "test-object",
- query.getResultType());
- assertEquals(
- "result type should be empty",
- "",
- query.getParentResultType());
- assertEquals("dependent",true, query.isDependent());
-
-
- }
-
- @Test
- public void dataLinkedSearch() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("network/vpn-bindings").build();
- MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
- map.putSingle("global-route-target", "key2");
- QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri, map);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("aai-node-type", "vpn-binding")
- .where(__.out("has").has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "key2"));
- GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
- .has("aai-node-type", "vpn-binding");
-
- 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",
- "vpn-binding",
- query.getResultType());
- assertEquals(
- "result type should be empty",
- "",
- query.getParentResultType());
- assertEquals("dependent",true, query.isDependent());
- }
-
- @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());
- }
-
- @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());
- }
-
- @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());
- }
-
- @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);
-
- }
-
- @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
deleted file mode 100644
index baaad6c9..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-
- * ============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.parsers.query;
-
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-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.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.junit.Assert.assertEquals;
-
-
-@Ignore
-public class LegacyQueryTest extends AAISetup {
-
- private ModelInjestor injestor = ModelInjestor.getInstance();
-
- private TransactionalGraphEngine dbEngine =
- new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
- LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
- false);
- private final Version version = Version.v8;
- private DynamicJAXBContext context = injestor.getContextForVersion(version);
-
-
- /**
- * Parent query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
-
- URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers/pserver/key1").build();
-
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
-
- String expected =
- ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
- assertEquals(
- "gremlin query should be " + expected,
- expected,
- query.getQueryBuilder().getQuery());
- assertEquals(
- "parent gremlin query should be equal to normal query",
- expected,
- query.getQueryBuilder().getParentQuery().getQuery());
- assertEquals(
- "result type should be pserver",
- "pserver",
- query.getResultType());
-
- }
-
- /**
- * Child query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers/pserver/key1/lag-interfaces/lag-interface/key2").build();
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
-
- String expected =
- ".has('hostname', 'key1').has('aai-node-type', 'pserver')"
- + ".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());
- assertEquals(
- "result type should be lag-interface",
- "lag-interface",
- query.getResultType());
- }
-
- /**
- * Naming exceptions.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @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
deleted file mode 100644
index 0aad09c4..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java
+++ /dev/null
@@ -1,662 +0,0 @@
-/*-
- * ============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.parsers.query;
-
-import org.eclipse.persistence.dynamic.DynamicEntity;
-import org.eclipse.persistence.jaxb.UnmarshallerProperties;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-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.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-
-@Ignore
-public class RelationshipGremlinQueryTest extends AAISetup {
-
- private ModelInjestor injestor = ModelInjestor.getInstance();
- private TransactionalGraphEngine dbEngine =
- new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
- LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
- false);
- private final Version version = Version.v8;
- private DynamicJAXBContext context = injestor.getContextForVersion(version);
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Parent query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
-
- String content =
- "{"
- + "\"related-to\" : \"pserver\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"pserver.hostname\","
- + "\"relationship-value\" : \"key1\""
- + "}]"
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String expected =
- ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
- assertEquals(
- "gremlin query should be " + expected,
- expected,
- query.getQueryBuilder().getQuery());
- assertEquals(
- "parent gremlin query should be equal to normal query",
- expected,
- query.getQueryBuilder().getParentQuery().getQuery());
- assertEquals(
- "result type should be pserver",
- "pserver",
- query.getResultType());
-
- }
-
- /**
- * Child query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"lag-interface\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"pserver.hostname\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"lag-interface.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "}]"
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String expected = ".has('hostname', 'key1').has('aai-node-type', 'pserver').in('tosca.relationships.BindsTo').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());
- assertEquals(
- "result type should be lag-interface",
- "lag-interface",
- query.getResultType());
- }
-
- /**
- * Naming exceptions.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"cvlan-tag\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"vce.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"port-group.interface-id\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
- + "\"relationship-value\" : \"655\""
- + "}]"
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- 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());
-
- }
-
- /**
- * Scrambled relationship.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void scrambledRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"l3-interface-ipv4-address-list\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
- + "\"relationship-value\" : \"key5\""
- + "},{"
- + "\"relationship-key\" : \"lag-interface.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"l-interface.interface-name\","
- + "\"relationship-value\" : \"key3\""
- + "},{"
- + "\"relationship-key\" : \"vlan.vlan-interface\","
- + "\"relationship-value\" : \"key4\""
- + "},{"
- + "\"relationship-key\" : \"generic-vnf.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "}]"
- + "}";
- scrambledRelationshipSpec(content);
- }
-
- /**
- * Reversed relationship.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void reversedRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"l3-interface-ipv4-address-list\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
- + "\"relationship-value\" : \"key5\""
- + "},{"
- + "\"relationship-key\" : \"vlan.vlan-interface\","
- + "\"relationship-value\" : \"key4\""
- + "},{"
- + "\"relationship-key\" : \"l-interface.interface-name\","
- + "\"relationship-value\" : \"key3\""
- + "},{"
- + "\"relationship-key\" : \"lag-interface.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"generic-vnf.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "}]"
- + "}";
- scrambledRelationshipSpec(content);
- }
-
- /**
- * Ordered ambiguous relationship.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void orderedAmbiguousRelationship() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"l3-interface-ipv4-address-list\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"generic-vnf.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "},{"
- + "\"relationship-key\" : \"lag-interface.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"l-interface.interface-name\","
- + "\"relationship-value\" : \"key3\""
- + "},{"
- + "\"relationship-key\" : \"vlan.vlan-interface\","
- + "\"relationship-value\" : \"key4\""
- + "},{"
- + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
- + "\"relationship-value\" : \"key5\""
- + "}]"
- + "}";
- scrambledRelationshipSpec(content);
- }
-
- /**
- * Scrambled relationship spec.
- *
- * @param content the content
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- public void scrambledRelationshipSpec(String content) throws JAXBException, UnsupportedEncodingException, AAIException {
-
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String expected =
- ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
- + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
- + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
- + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
- + ".has('vlan-interface', 'key4').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l3-interface-ipv4-address-list')"
- + ".has('l3-interface-ipv4-address', 'key5')";
- String expectedParent =
- ".has('vnf-id', 'key1').has('aai-node-type', 'generic-vnf')"
- + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'lag-interface')"
- + ".has('interface-name', 'key2').in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'l-interface')"
- + ".has('interface-name', 'key3').out('tosca.relationships.LinksTo').has('aai-node-type', 'vlan')"
- + ".has('vlan-interface', 'key4')";
- assertEquals(
- "gremlin query should be " + expected,
- expected,
- query.getQueryBuilder().getQuery());
- assertEquals(
- "parent gremlin query should be equal the query for vlan",
- expectedParent,
- query.getQueryBuilder().getParentQuery().getQuery());
- assertEquals(
- "result type should be l3-interface-ipv4-address-list",
- "l3-interface-ipv4-address-list",
- query.getResultType());
-
- }
-
- /**
- * Short circuit.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"cvlan-tag\","
- + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"vce.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"port-group.interface-id\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
- + "\"relationship-value\" : \"655\""
- + "}]"
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- 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());
-
- }
-
- @Test
- public void shorterCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"cvlan-tag\","
- + "\"related-link\" : \"file:///network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\""
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- 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());
-
- }
-
- /**
- * Double key.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"ctag-pool\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"complex.physical-location-id\","
- + "\"relationship-value\" : \"key1\""
- + " }, { "
- + "\"relationship-key\" : \"ctag-pool.target-pe\","
- + " \"relationship-value\" : \"key2\""
- + " },{"
- + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
- + "\"relationship-value\" : \"key3\""
- + "}]"
- + "}";
-
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String expected =
- ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
- + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
- + ".has('target-pe', 'key2')"
- + ".has('availability-zone-name', 'key3')";
- String expectedParent =
- ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
-
- 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 ctag-pool",
- "ctag-pool",
- query.getResultType());
-
- }
-
- /**
- * Abstract type.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void abstractType() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"vnf\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"vnf.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + " }]"
- + "}";
-
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String expected =
- ".has('vnf-id', 'key1')"
- + ".has('aai-node-type', P.within('vce','generic-vnf'))";
-
- String expectedParent =
- ".has('vnf-id', 'key1')"
- + ".has('aai-node-type', P.within('vce','generic-vnf'))";
-
- 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 vnf",
- "vnf",
- query.getResultType());
-
- }
-
- /**
- * Invalid node name.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void invalidNodeName() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"l3-interface-ipv4-address-list\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"generic-vnf.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "},{"
- + "\"relationship-key\" : \"lag-interface.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"l-infeaterface.interface-name\","
- + "\"relationship-value\" : \"key3\""
- + "},{"
- + "\"relationship-key\" : \"vlan.vlan-interface\","
- + "\"relationship-value\" : \"key4\""
- + "},{"
- + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
- + "\"relationship-value\" : \"key5\""
- + "}]"
- + "}";
- thrown.expect(AAIException.class);
- thrown.expectMessage(containsString("invalid object name"));
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- }
-
- /**
- * Invalid property name.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void invalidPropertyName() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"l3-interface-ipv4-address-list\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"generic-vnf.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "},{"
- + "\"relationship-key\" : \"lag-interface.intfdaferface-name\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"l-interface.interface-name\","
- + "\"relationship-value\" : \"key3\""
- + "},{"
- + "\"relationship-key\" : \"vlan.vlan-interface\","
- + "\"relationship-value\" : \"key4\""
- + "},{"
- + "\"relationship-key\" : \"l3-interface-ipv4-address-list.l3-interface-ipv4-address\","
- + "\"relationship-value\" : \"key5\""
- + "}]"
- + "}";
- thrown.expect(AAIException.class);
- thrown.expectMessage(containsString("invalid property name"));
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- }
-}
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
deleted file mode 100644
index 94fe0c59..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*-
- * ============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.parsers.query;
-
-import org.eclipse.persistence.dynamic.DynamicEntity;
-import org.eclipse.persistence.jaxb.UnmarshallerProperties;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-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 RelationshipQueryTest extends AAISetup {
-
- private ModelInjestor injestor = ModelInjestor.getInstance();
-
- private TransactionalGraphEngine dbEngine =
- new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL,
- LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
- false);
- private final Version version = Version.v8;
- private DynamicJAXBContext context = injestor.getContextForVersion(version);
-
- /**
- * Parent query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
-
- String content =
- "{"
- + "\"related-to\" : \"pserver\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"pserver.hostname\","
- + "\"relationship-value\" : \"key1\""
- + "}]"
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String expected =
- ".has('hostname', 'key1').has('aai-node-type', 'pserver')";
- assertEquals(
- "gremlin query should be " + expected,
- expected,
- query.getQueryBuilder().getQuery());
- assertEquals(
- "parent gremlin query should be equal to normal query",
- expected,
- query.getQueryBuilder().getParentQuery().getQuery());
- assertEquals(
- "result type should be pserver",
- "pserver",
- query.getResultType());
-
- }
-
- /**
- * Child query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Ignore
- @Test
- public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"lag-interface\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"pserver.hostname\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"lag-interface.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "}]"
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String expected =
- ".has('hostname', 'key1').has('aai-node-type', 'pserver').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());
- assertEquals(
- "result type should be lag-interface",
- "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 {
- String content =
- "{"
- + "\"related-to\" : \"cvlan-tag\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"vce.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"port-group.interface-id\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
- + "\"relationship-value\" : \"655\""
- + "}]"
- + "}";
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- 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());
-
- }
-
- /**
- * Double key.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Ignore
- @Test
- public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"ctag-pool\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"complex.physical-location-id\","
- + "\"relationship-value\" : \"key1\""
- + " }, { "
- + "\"relationship-key\" : \"ctag-pool.target-pe\","
- + " \"relationship-value\" : \"key2\""
- + " },{"
- + "\"relationship-key\" : \"ctag-pool.availability-zone-name\","
- + "\"relationship-value\" : \"key3\""
- + "}]"
- + "}";
-
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String expected =
- ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')"
- + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'ctag-pool')"
- + ".has('target-pe', 'key2')"
- + ".has('availability-zone-name', 'key3')";
- String expectedParent =
- ".has('physical-location-id', 'key1').has('aai-node-type', 'complex')";
-
- 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 ctag-pool",
- "ctag-pool",
- query.getResultType());
-
- }
-
-}
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
deleted file mode 100644
index 870bbd36..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*-
- * ============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.parsers.query;
-
-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.eclipse.persistence.dynamic.DynamicEntity;
-import org.eclipse.persistence.jaxb.UnmarshallerProperties;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-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 extends AAISetup {
-
- private ModelInjestor injestor = ModelInjestor.getInstance();
- private TransactionalGraphEngine dbEngine =
- new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE,
- LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
- false);
- private final Version version = Version.v8;
- private DynamicJAXBContext context = injestor.getContextForVersion(version);
- private Unmarshaller unmarshaller = null;
-
- /**
- * Setup.
- *
- * @throws JAXBException the JAXB exception
- */
- @Before
- public void setup() throws JAXBException {
- unmarshaller = context.createUnmarshaller();
- unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json");
- unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false);
- unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
- }
-
- /**
- * Parent query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void parentQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
-
- String content =
- "{"
- + "\"related-to\" : \"pserver\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"pserver.hostname\","
- + "\"relationship-value\" : \"key1\""
- + "}]"
- + "}";
-
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String key = "pserver/key1";
- GraphTraversal<Vertex, Vertex> expected =
- __.<Vertex>start().has("aai-unique-key", key);
- String resultType = "pserver";
- String containerType = "";
-
- testSet(query, expected, expected, resultType, containerType);
-
- }
-
- /**
- * Child query.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void childQuery() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"lag-interface\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"pserver.hostname\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"lag-interface.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "}]"
- + "}";
-
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String key = "pserver/key1/lag-interface/key2";
- GraphTraversal<Vertex, Vertex> expected =
- __.<Vertex>start().has("aai-unique-key", key);
- GraphTraversal<Vertex, Vertex> parentExpected =
- __.<Vertex>start().has("aai-unique-key", "pserver/key1");
- String resultType = "lag-interface";
- String containerType = "";
-
- testSet(query, expected, parentExpected, resultType, containerType);
- }
-
- /**
- * Naming exceptions.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"cvlan-tag\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"vce.vnf-id\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"port-group.interface-id\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"cvlan-tag.cvlan-tag\","
- + "\"relationship-value\" : \"655\""
- + "}]"
- + "}";
-
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String key = "vce/key1/port-group/key2/cvlan-tag/655";
- GraphTraversal<Vertex, Vertex> expected =
- __.<Vertex>start().has("aai-unique-key", key);
- GraphTraversal<Vertex, Vertex> parentExpected =
- __.<Vertex>start().has("aai-unique-key", "vce/key1/port-group/key2");
- String resultType = "cvlan-tag";
- String containerType = "";
-
- testSet(query, expected, parentExpected, resultType, containerType);
-
- }
-
- /**
- * Double key.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void doubleKey() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"service-capability\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"service-capability.service-type\","
- + "\"relationship-value\" : \"key1\""
- + " }, { "
- + "\"relationship-key\" : \"service-capability.vnf-type\","
- + " \"relationship-value\" : \"key2\""
- + " }]"
- + "}";
-
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
-
- String key = "service-capability/key1/key2";
- GraphTraversal<Vertex, Vertex> expected =
- __.<Vertex>start().has("aai-unique-key", key);
- GraphTraversal<Vertex, Vertex> parentExpected =
- __.<Vertex>start().has("aai-unique-key", "service-capability/key1/key2");
- String resultType = "service-capability";
- String containerType = "";
-
- testSet(query, expected, parentExpected, resultType, containerType);
-
- }
-
- /**
- * Short circuit.
- *
- * @throws JAXBException the JAXB exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void shortCircuit() throws JAXBException, UnsupportedEncodingException, AAIException {
- String content =
- "{"
- + "\"related-to\" : \"cvlan-tag\","
- + "\"related-link\" : \"http://mock-system-name.com:8443/aai/v6/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655\","
- + "\"relationship-data\" : [{"
- + "\"relationship-key\" : \"vce.hostname\","
- + "\"relationship-value\" : \"key1\""
- + "}, {"
- + "\"relationship-key\" : \"port-group.interface-name\","
- + "\"relationship-value\" : \"key2\""
- + "},{"
- + "\"relationship-key\" : \"cvlan-tag.-name\","
- + "\"relationship-value\" : \"655\""
- + "}]"
- + "}";
-
- Object obj = context.newDynamicEntity("Relationship");
-
- DynamicEntity entity = (DynamicEntity)unmarshaller.unmarshal(new StreamSource(new StringReader(content)), obj.getClass()).getValue();
-
- Introspector wrappedObj = IntrospectorFactory.newInstance(ModelType.MOXY, entity);
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromRelationship(wrappedObj);
- String key = "vce/key1/port-group/key2/cvlan-tag/655";
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key);
- GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", "vce/key1/port-group/key2");
- String resultType = "cvlan-tag";
- String containerType = "";
-
- testSet(query, expected, parentExpected, resultType, containerType);
-
- }
-
- /**
- * Test set.
- *
- * @param query the query
- * @param expected the expected
- * @param parentExpected the parent expected
- * @param resultType the result type
- * @param containerType the container type
- */
- public void testSet(QueryParser query, GraphTraversal<Vertex, Vertex> expected, GraphTraversal<Vertex, Vertex> parentExpected, String resultType, String containerType) {
- assertEquals(
- "gremlin query should be " + expected,
- expected,
- query.getQueryBuilder().getQuery());
- assertEquals(
- "parent gremlin query should be " + parentExpected,
- parentExpected,
- query.getParentQueryBuilder().getParentQuery());
- assertEquals(
- "result type should be " + resultType,
- resultType,
- query.getResultType());
- assertEquals(
- "container type should be " + containerType,
- containerType,
- query.getContainerType());
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java
deleted file mode 100644
index e1be7f25..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueURIQueryTest.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*-
- * ============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.parsers.query;
-
-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.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-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.ws.rs.core.UriBuilder;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.junit.Assert.assertEquals;
-
-@Ignore
-public class UniqueURIQueryTest extends AAISetup {
-
- private ModelInjestor injestor = ModelInjestor.getInstance();
- private TransactionalGraphEngine dbEngine =
- new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE,
- LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
- false);
- private final Version version = Version.v8;
- private DynamicJAXBContext context = injestor.getContextForVersion(version);
-
- /**
- * Parent query.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void parentQuery() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1").build();
- String key = "complex/key1";
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key);
- String parentResultType = "";
- String resultType = "complex";
- String containerType = "";
-
- testSet(query, expected, expected, parentResultType, resultType, containerType);
-
- }
-
- /**
- * Parent plural query.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void parentPluralQuery() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes").build();
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-node-type", "complex");
- String parentResultType = "";
- String resultType = "complex";
- String containerType = "complexes";
-
- testSet(query, expected, expected, parentResultType, resultType, containerType);
-
- }
-
- /**
- * Child query.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void childQuery() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3").build();
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- String parentKey = "complex/key1";
- String key = parentKey + "/ctag-pool/key2/key3";
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key);
- GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", parentKey);
- String parentResultType = "complex";
- String resultType = "ctag-pool";
- String containerType = "";
-
- testSet(query, expected, parentExpected, parentResultType, resultType, containerType);
-
- }
-
- /**
- * Naming exceptions.
- *
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void namingExceptions() throws 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 parentKey = "vce/key1/port-group/key2";
- String key = parentKey + "/cvlan-tag/655";
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key);
- GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", parentKey);
- String parentResultType = "port-group";
- String resultType = "cvlan-tag";
- String containerType = "";
-
- testSet(query, expected, parentExpected, parentResultType, resultType, containerType);
-
- }
-
- /**
- * Gets the all.
- *
- * @return the all
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- public void getAll() throws UnsupportedEncodingException, AAIException {
- String parentURI = "network/vces/vce/key1/port-groups/port-group/key2";
- String parentKey = "vce/key1/port-group/key2";
- URI uri = UriBuilder.fromPath(parentURI + "/cvlan-tags").build();
- QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", parentKey).out("hasCTag").has("aai-node-type", "cvlan-tag");
- GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key",parentKey);
- String parentResultType = "port-group";
- String resultType = "cvlan-tag";
- String containerType = "cvlan-tags";
-
- testSet(query, expected, parentExpected, parentResultType, resultType, containerType);
-
- }
-
- /**
- * Test set.
- *
- * @param query the query
- * @param expected the expected
- * @param parentExpected the parent expected
- * @param parentResultType the parent result type
- * @param resultType the result type
- * @param containerType the container type
- */
- public void testSet(QueryParser query, GraphTraversal<Vertex, Vertex> expected, GraphTraversal<Vertex, Vertex> parentExpected, String parentResultType, String resultType, String containerType) {
- assertEquals(
- "gremlin query should be " + expected,
- expected,
- query.getQueryBuilder().getQuery());
- assertEquals(
- "parent gremlin query should be " + parentExpected,
- parentExpected,
- query.getQueryBuilder().getParentQuery().getQuery());
- assertEquals(
- "parent result type should be " + parentResultType,
- parentResultType,
- query.getParentResultType());
- assertEquals(
- "result type should be " + resultType,
- resultType,
- query.getResultType());
- assertEquals(
- "container type should be " + containerType,
- containerType,
- query.getContainerType());
- }
-}
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
deleted file mode 100644
index 092d5c66..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*-
- * ============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.parsers.relationship;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-import org.openecomp.aai.parsers.exceptions.AAIIdentityMapParseException;
-import org.openecomp.aai.parsers.exceptions.AmbiguousMapAAIException;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-public class RelationshipToURITest extends AAISetup {
-
- private final ModelType modelType = ModelType.MOXY;
- private final Version version10 = Version.v10;
- private final Version version9 = Version.v9;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void onlyLink() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("only-related-link.json"));
- URI expected = new URI("/aai/v10/network/test-objects/test-object/key1");
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected.getPath(), uri.getPath());
- }
-
- @Test
- public void onlyData() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("only-relationship-data.json"));
- URI expected = new URI("/network/test-objects/test-object/key1");
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected, uri);
- }
-
- @Test
- public void failV10() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-failv10-successv9.json"));
- URI expected = new URI("/aai/v10/network/test-objects/test-object/key1");
-
- thrown.expect(AAIIdentityMapParseException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
- URI uri = parse.getUri();
-
- }
-
- @Test
- public void successV9() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version9);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-failv10-successv9.json"));
- URI expected = new URI("/network/test-objects/test-object/key2");
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected, uri);
-
-
- }
-
- @Test
- public void failV9() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version9);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-successv10-failv9.json"));
- URI expected = new URI("/network/test-objects/test-object/key1");
-
- thrown.expect(AAIIdentityMapParseException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
-
- URI uri = parse.getUri();
-
- }
-
- @Test
- public void failNothingToParse() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("nothing-to-parse.json"));
- URI expected = new URI("/aai/v10/network/test-objects/test-object/key1");
-
- thrown.expect(AAIIdentityMapParseException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
- URI uri = parse.getUri();
-
- }
-
- @Test
- public void successV10() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-successv10-failv9.json"));
- URI expected = new URI("/aai/v10/network/test-objects/test-object/key1");
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
-
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected, uri);
-
-
- }
-
- @Test
- public void ambiguousRelationship() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("ambiguous-relationship.json"));
- URI expected = new URI("/aai/v10/network/test-objects/test-object/key1");
-
- thrown.expect(AmbiguousMapAAIException.class);
- thrown.expect(hasProperty("code", is("AAI_6146")));
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected, uri);
-
-
- }
-
- @Ignore
- @Test
- public void moreItemsThanRequired() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("too-many-items-relationship.json"));
- URI expected = new URI("/network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2");
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected.toString(), uri.toString());
-
- }
-
- @Test
- public void twoTopLevelNodes() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("two-top-level-relationship.json"));
- URI expected = new URI("/network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2");
-
- thrown.expect(AmbiguousMapAAIException.class);
- thrown.expect(hasProperty("code", is("AAI_6146")));
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected, uri);
-
- }
-
- @Test
- public void topLevelWithTwoKeys() throws AAIException, URISyntaxException, IOException {
- Loader loader = LoaderFactory.createLoaderForVersion(modelType, version10);
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("top-level-two-keys-relationship.json"));
- URI expected = new URI("/cloud-infrastructure/cloud-regions/cloud-region/key1/key2/availability-zones/availability-zone/key3");
-
- RelationshipToURI parse = new RelationshipToURI(loader, obj);
-
- URI uri = parse.getUri();
-
- assertEquals("related-link is equal", expected.toString(), uri.toString());
-
- }
-
-
- private String getJsonString(String filename) throws IOException {
-
-
- FileInputStream is = new FileInputStream("src/test/resources/bundleconfig-local/etc/relationship/" + filename);
- String s = IOUtils.toString(is, "UTF-8");
- IOUtils.closeQuietly(is);
-
- return s;
- }
-}
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
deleted file mode 100644
index da863c1e..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * ============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.parsers.uri;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-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 javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-
-public class URIParserTest extends AAISetup {
-
- private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8);
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Invalid path.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void invalidPath() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/network/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
-
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- new URIToDBKey(loader, uri);
- }
-
- /**
- * Invalid path no name space.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void invalidPathNoNameSpace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
-
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- new URIToDBKey(loader, uri);
- }
-
- /**
- * Invalid path partial.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void invalidPathPartial() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("vservers/vserver/key2/l-interfaces/l-interface/key3").build();
-
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- new URIToDBKey(loader, uri);
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java
deleted file mode 100644
index 626e97ab..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToDBKeyTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-
- * ============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.parsers.uri;
-
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.parsers.exceptions.DoesNotStartWithValidNamespaceException;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.introspection.*;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-
-
-@PrepareForTest(ModelInjestor.class)
-public class URIToDBKeyTest extends AAISetup {
-
- private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Uri.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
- URIToDBKey parse = new URIToDBKey(loader, uri);
- Object result = parse.getResult();
-
- String expected = "cloud-region/tenant/vserver/l-interface";
-
- assertEquals("blah", expected, result);
-
- }
-
- /**
- * Uri no version.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void uriNoVersion() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
- URIToDBKey parse = new URIToDBKey(loader, uri);
- Object result = parse.getResult();
-
- String expected = "cloud-region/tenant/vserver/l-interface";
-
- assertEquals("blah", expected, result);
-
- }
-
-
- /**
- * Bad URI.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void badURI() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3").build();
-
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3001")));
-
- new URIToDBKey(loader, uri);
- }
-
- /**
- * NotValid namespace.
- *
- * @throws JAXBException the JAXB exception
- * @throws DoesNotStartWithValidNamespaceException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void notValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/cloud-region/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
- thrown.expect(DoesNotStartWithValidNamespaceException.class);
- URIToDBKey parse = new URIToDBKey(loader, uri);
- }
-
-
- /**
- * No valid tokens.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void noValidTokens() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud/blah/blah").build();
-
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- new URIToDBKey(loader, uri);
- }
-
- /**
- * Starts with valid namespace.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void startsWithValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
-
- URIToDBKey parse = new URIToDBKey(loader, uri);
- Object result = parse.getResult();
-
- String expected = "cloud-region/tenant/vserver/l-interface";
-
- assertEquals("blah", expected, result);
- }
-
- /**
- * Naming exceptions.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws AAIException the AAI exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void namingExceptions() throws IllegalArgumentException, AAIException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build();
- URIToDBKey parse = new URIToDBKey(loader, uri);
- Object result = parse.getResult();
-
- String expected = "vce/port-group/cvlan-tag";
-
- assertEquals("blah", expected, result);
-
- }
-
-}
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
deleted file mode 100644
index 38377f73..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============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.parsers.uri;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-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.restcore.HttpMethod;
-
-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 URIToExtensionInformationTest extends AAISetup {
-
- private Loader v8Loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
-
- /**
- * Vservers V 7.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void vserversV8() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + v8Loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/key1/vservers/vserver/key2").build();
- URIToExtensionInformation parse = new URIToExtensionInformation(v8Loader, uri);
-
- String namespace = "cloudInfrastructure";
- String preMethodName = "DynamicAddCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverPreProc";
- String postMethodName = "DynamicAddCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverPostProc";
- String topLevel = "CloudRegion";
- testSpec(parse, HttpMethod.PUT, namespace, preMethodName, postMethodName, topLevel);
-
- }
-
- /**
- * Test spec.
- *
- * @param info the info
- * @param httpMethod the http method
- * @param namespace the namespace
- * @param preMethodName the pre method name
- * @param postMethodName the post method name
- * @param topLevel the top level
- */
- private void testSpec(URIToExtensionInformation info, HttpMethod httpMethod, String namespace, String preMethodName, String postMethodName, String topLevel) {
-
-
- String namespaceResult = info.getNamespace();
- String methodNameResult = info.getMethodName(httpMethod, true);
-
- assertEquals("namespace", namespace, namespaceResult);
- assertEquals("preprocess method name", preMethodName, methodNameResult);
- methodNameResult = info.getMethodName(httpMethod, false);
-
- assertEquals("postprocess method name", postMethodName, methodNameResult);
-
- String topLevelResult = info.getTopObject();
-
- assertEquals("topLevel", topLevel, topLevelResult);
- }
-
-
-}
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
deleted file mode 100644
index 9eb013f6..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*-
- * ============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.parsers.uri;
-
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.HashMap;
-
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
-
-
-public class URIToObjectTest extends AAISetup {
-
- private Version version = Version.v10;
- private Version currentVersion = AAIProperties.LATEST;
- private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, version);
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Uri.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
- URIToObject parse = new URIToObject(loader, uri);
- Introspector result = parse.getTopEntity();
- String expected = "{\"cloud-owner\":\"mycloudowner\",\"cloud-region-id\":\"mycloudregionid\",\"tenants\":{\"tenant\":[{\"tenant-id\":\"key1\",\"vservers\":{\"vserver\":[{\"vserver-id\":\"key2\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"key3\"}]}}]}}]}}";
- String topEntity = "cloud-region";
- String entity = "l-interface";
-
- testSet(result.marshal(false), parse, expected, topEntity, entity, version);
-
- }
-
- /**
- * Uri no version.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIUnknownObjectException
- */
- @Test
- public void uriNoVersion() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, AAIUnknownObjectException {
- URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
- HashMap<String, Introspector> relatedObjects = new HashMap<>();
- Introspector tenantObj = this.loader.introspectorFromName("tenant");
- tenantObj.setValue("tenant-id", "key1");
- tenantObj.setValue("tenant-name", "name1");
- relatedObjects.put(tenantObj.getObjectId(), tenantObj);
- Introspector vserverObj = this.loader.introspectorFromName("vserver");
- vserverObj.setValue("vserver-id", "key2");
- vserverObj.setValue("vserver-name", "name2");
- relatedObjects.put(vserverObj.getObjectId(), vserverObj);
-
- URIToObject parse = new URIToObject(loader, uri, relatedObjects);
- Introspector result = parse.getTopEntity();
- String expected = "{\"cloud-owner\":\"mycloudowner\",\"cloud-region-id\":\"mycloudregionid\",\"tenants\":{\"tenant\":[{\"tenant-id\":\"key1\",\"tenant-name\":\"name1\",\"vservers\":{\"vserver\":[{\"vserver-id\":\"key2\",\"vserver-name\":\"name2\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"key3\"}]}}]}}]}}";
- String topEntity = "cloud-region";
- String entity = "l-interface";
-
- testSet(result.marshal(false), parse, expected, topEntity, entity, version);
-
-
- }
-
-
- /**
- * Bad URI.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void badURI() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3").build();
-
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- new URIToObject(loader, uri);
- }
-
- /**
- * Starts with valid namespace.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void startsWithValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/mycloudowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
- URIToObject parse = new URIToObject(loader, uri);
- Introspector result = parse.getTopEntity();
- String expected = "{\"cloud-owner\":\"mycloudowner\",\"cloud-region-id\":\"mycloudregionid\",\"tenants\":{\"tenant\":[{\"tenant-id\":\"key1\",\"vservers\":{\"vserver\":[{\"vserver-id\":\"key2\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"key3\"}]}}]}}]}}";
- String topEntity = "cloud-region";
- String entity = "l-interface";
-
- testSet(result.marshal(false), parse, expected, topEntity, entity, version);
- }
-
- /**
- * Single top level.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void singleTopLevel() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/network/generic-vnfs/generic-vnf/key1").build();
- URIToObject parse = new URIToObject(loader, uri);
- Introspector result = parse.getTopEntity();
- String expected = "{\"vnf-id\":\"key1\"}";
-
- String topEntity = "generic-vnf";
- String entity = "generic-vnf";
-
- testSet(result.marshal(false), parse, expected, topEntity, entity, version);
-
- }
-
- /**
- * Naming exceptions.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- @Ignore
- public void namingExceptions() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build();
- URIToObject parse = new URIToObject(loader, uri);
- Introspector result = parse.getTopEntity();
- String expected = "{\"vnf-id\":\"key1\",\"port-groups\":{\"port-group\":[{\"interface-id\":\"key2\",\"cvlan-tags\":{\"cvlan-tag-entry\":[{\"cvlan-tag\":655}]}}]}}";
- String topEntity = "vce";
- String entity = "cvlan-tag";
-
- testSet(result.marshal(false), parse, expected, topEntity, entity, version);
-
- }
-
- /**
- * No list object.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIException the AAI exception
- */
- @Test
- @Ignore
- public void noListObject() throws IllegalArgumentException, UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("/aai/v6/network/vpls-pes/vpls-pe/0e6189fd-9257-49b9-a3be-d7ba980ccfc9/lag-interfaces/lag-interface/8ae5aa76-d597-4382-b219-04f266fe5e37/l-interfaces/l-interface/9e141d03-467b-437f-b4eb-b3133ec1e205/l3-interface-ipv4-address-list/8f19f0ea-a81f-488e-8d5c-9b7b53696c11").build();
- URIToObject parse = new URIToObject(loader, uri);
- Introspector result = parse.getTopEntity();
- String topEntity = "vpls-pe";
- String entity = "l3-interface-ipv4-address-list";
- String expected = "{\"equipment-name\":\"0e6189fd-9257-49b9-a3be-d7ba980ccfc9\",\"lag-interfaces\":{\"lag-interface\":[{\"interface-name\":\"8ae5aa76-d597-4382-b219-04f266fe5e37\",\"l-interfaces\":{\"l-interface\":[{\"interface-name\":\"9e141d03-467b-437f-b4eb-b3133ec1e205\",\"l3-interface-ipv4-address-list\":[{\"l3-interface-ipv4-address\":\"8f19f0ea-a81f-488e-8d5c-9b7b53696c11\"}]}]}}]}}";
- testSet(result.marshal(false), parse, expected, topEntity, entity, version);
-
- }
-
- @Test
- public void relativePath() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("./l-interfaces/l-interface/key1").build();
- URIToObject parse = new URIToObject(loader, uri);
- Introspector result = parse.getEntity();
- String expected = "{\"interface-name\":\"key1\"}";
-
- String topEntity = "l-interface";
- String entity = "l-interface";
-
- testSet(result.marshal(false), parse, expected, topEntity, entity, version);
-
- }
-
- /**
- * Test set.
- *
- * @param json the json
- * @param parse the parse
- * @param expected the expected
- * @param topEntity the top entity
- * @param entity the entity
- * @param version the version
- */
- public void testSet(String json, URIToObject parse, String expected, String topEntity, String entity, Version version) {
- assertEquals("blah", expected, json);
-
- assertEquals("top entity", topEntity, parse.getTopEntityName());
-
- assertEquals("entity", entity, parse.getEntityName());
-
- assertEquals("entity object", entity, parse.getEntity().getDbName());
-
- assertEquals("parent list object", 1, parse.getParentList().size());
-
- assertEquals("object version", version, parse.getObjectVersion());
- }
-}
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
deleted file mode 100644
index ee7b8651..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*-
- * ============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.parsers.uri;
-
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertTrue;
-
-
-public class URIToRelationshipObjectTest extends AAISetup {
-
- private Version latest = Version.v10;
- private Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, latest);
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Uri.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws URISyntaxException
- * @throws MalformedURLException the malformed URL exception
- */
- @Test
- public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, URISyntaxException {
-
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
- URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
- Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
- assertTrue("blah", result.marshal(false).matches(expected));
-
- }
-
- /**
- * Uri no version.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws URISyntaxException
- * @throws MalformedURLException the malformed URL exception
- */
- @Test
- public void uriNoVersion() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, URISyntaxException {
- URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build();
- URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
- Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"l-interface\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"cloud-region.cloud-owner\",\"relationship-value\":\"mycloudregionowner\"\\},\\{\"relationship-key\":\"cloud-region.cloud-region-id\",\"relationship-value\":\"mycloudregionid\"\\},\\{\"relationship-key\":\"tenant.tenant-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"vserver.vserver-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"l-interface.interface-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
- assertTrue("blah", result.marshal(false).matches(expected));
-
-
- }
-
- /**
- * Double key relationship.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws URISyntaxException
- * @throws MalformedURLException the malformed URL exception
- */
- @Test
- public void doubleKeyRelationship() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, URISyntaxException {
- URI uri = UriBuilder.fromPath("/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3/").build();
- URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
- Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"ctag-pool\",\"related-link\":\"/aai/" + latest + "/cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3\",\"relationship-data\":\\[\\{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"ctag-pool.target-pe\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"ctag-pool.availability-zone-name\",\"relationship-value\":\"key3\"\\}\\]\\}";
- assertTrue("blah", result.marshal(false).matches(expected));
-
- }
-
- /**
- * Uri with non string key.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws URISyntaxException
- * @throws MalformedURLException the malformed URL exception
- */
- @Test
- public void uriWithNonStringKey() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException, URISyntaxException {
- URI uri = UriBuilder.fromPath("/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144").build();
- URIToRelationshipObject parse = new URIToRelationshipObject(loader, uri);
- Introspector result = parse.getResult();
- String expected = "\\{\"related-to\":\"cvlan-tag\",\"related-link\":\"/aai/" + latest + "/network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/144\",\"relationship-data\":\\[\\{\"relationship-key\":\"vce.vnf-id\",\"relationship-value\":\"key1\"\\},\\{\"relationship-key\":\"port-group.interface-id\",\"relationship-value\":\"key2\"\\},\\{\"relationship-key\":\"cvlan-tag.cvlan-tag\",\"relationship-value\":\"144\"\\}\\]\\}";
- assertTrue("blah", result.marshal(false).matches(expected));
- }
- /**
- * Bad URI.
- *
- * @throws JAXBException the JAXB exception
- * @throws AAIException the AAI exception
- * @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- @Test
- public void badURI() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
- URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/mycloudregionowner/mycloudregionid/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3").build();
-
- thrown.expect(AAIException.class);
- thrown.expect(hasProperty("code", is("AAI_3000")));
-
- URIToObject parse = new URIToObject(loader, uri);
-
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java b/aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java
deleted file mode 100644
index e57fb0e5..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/query/builder/SimplePathTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * ============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.query.builder;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.exceptions.AAIException;
-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.serialization.db.EdgeRules;
-import org.openecomp.aai.serialization.db.EdgeType;
-
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-public class SimplePathTest extends AAISetup {
-
- public Loader loader;
-
- @Before
- public void setup() throws Exception {
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
- }
-
- private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException {
- return qb.createEdgeTraversal(EdgeType.TREE, "generic-vnf", "l-interface")
- .until(qb.newInstance().getVerticesByProperty("aai-node-type", "generic-vnf"))
- .repeat(qb.newInstance().union(
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "generic-vnf", "l-interface"),
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "l-interface", "generic-vnf"),
- qb.newInstance().createEdgeTraversal(EdgeType.COUSIN, "l-interface", "logical-link"),
- qb.newInstance().createEdgeTraversal(EdgeType.COUSIN, "logical-link", "l-interface")
- ).simplePath())
- .store("x").cap("x").unfold().dedup();
- }
-
- private GraphTraversalSource setupGraph() throws AAIException{
- Graph graph = TinkerGraph.open();
- GraphTraversalSource g = graph.traversal();
- EdgeRules rules = EdgeRules.getInstance();
-
- Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf",
- "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
-
- Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
- "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
-
- Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
- "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
-
- Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
- "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
-
- Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link",
- "link-name", "loglink2", "in-maint", "false", "link-type", "sausage");
-
- Vertex lint3 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface",
- "interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
-
- Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf",
- "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
-
- rules.addTreeEdge(g, gvnf1, lint1);
- rules.addEdge(g, lint1, loglink1);
- rules.addEdge(g, loglink1, lint2);
- rules.addEdge(g, lint2, loglink2);
- rules.addEdge(g, loglink2, lint3);
- rules.addTreeEdge(g, gvnf2, lint3);
-
- return g;
- }
-
- @Test
- public void gremlinQueryTest() throws AAIException {
- GraphTraversalSource g = setupGraph();
- List<Vertex> expected = g.V("01").toList();
- Vertex start = g.V("00").toList().get(0);
-
- GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, start);
- QueryBuilder<Vertex> q = buildTestQuery(qb);
- List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
-
- @Test
- public void traversalQueryTest() throws AAIException {
- GraphTraversalSource g = setupGraph();
- List<Vertex> expected = g.V("01").toList();
- Vertex start = g.V("00").toList().get(0);
-
- TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, start);
- QueryBuilder<Vertex> q = buildTestQuery(qb);
- List<Vertex> results = q.toList();
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
-}
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
deleted file mode 100644
index f8418bd1..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * ============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.query.builder;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static org.junit.Assert.assertEquals;
-
-public class TraversalQueryTest extends AAISetup {
-
- private Loader loader;
-
- @Mock
- private GraphTraversalSource g;
-
- @Before
- public void configure() throws Exception {
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
- }
-
- @Test
- public void unionQuery() {
- 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"));
-
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .union(__.has("test1", "value1"),__.has("test2", "value2"));
-
- assertEquals("they are equal", expected, tQ.getQuery());
-
- }
-
- @Ignore
- @Test
- public void traversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
- 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");
-
- assertEquals("query object", expected.toString(), builder.getQuery().toString());
- assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString());
-
- }
-
- @Ignore
- @Test
- public void nestedTraversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
-
- 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");
-
- assertEquals("query object", expected.toString(), builder.getQuery().toString());
- assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString());
-
- }
-
-
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java b/aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java
deleted file mode 100644
index b6c6025a..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/query/builder/UntilTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * ============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.query.builder;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.LoaderFactory;
-import org.openecomp.aai.introspection.ModelType;
-import org.openecomp.aai.serialization.db.EdgeRules;
-import org.openecomp.aai.serialization.db.EdgeType;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-public class UntilTest extends AAISetup {
-
- private Loader loader;
-
- @Before
- public void setup() throws Exception {
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
- }
-
- private QueryBuilder<Vertex> buildTestQuery(QueryBuilder<Vertex> qb) throws AAIException{
- return qb.until(qb.newInstance().getVerticesByProperty("aai-node-type", "l-interface")).repeat(
- qb.newInstance().union(
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "cloud-region", "tenant"),
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "tenant", "vserver"),
- qb.newInstance().createEdgeTraversal(EdgeType.TREE, "vserver", "l-interface")
- )).store("x").cap("x").unfold().dedup();
- }
-
- @Test
- public void gremlinQueryUntilTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- EdgeRules rules = EdgeRules.getInstance();
- GraphTraversalSource g = graph.traversal();
-
- Vertex v1 = graph.addVertex(T.id, 1, "aai-node-type", "cloud-region");
- Vertex v2 = graph.addVertex(T.id, 2, "aai-node-type", "tenant");
- Vertex v3 = graph.addVertex(T.id, 3, "aai-node-type", "vserver");
- Vertex v4 = graph.addVertex(T.id, 4, "aai-node-type", "l-interface");
- rules.addTreeEdge(g, v1, v2);
- rules.addTreeEdge(g, v2, v3);
- rules.addTreeEdge(g, v3, v4);
- List<Vertex> expected = new ArrayList<>();
- expected.add(v4);
-
- GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, v1);
- QueryBuilder q = buildTestQuery(qb);
-
- List<Vertex> results = q.toList();
-
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
-
- @Test
- public void traversalQueryUntilTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- EdgeRules rules = EdgeRules.getInstance();
- GraphTraversalSource g = graph.traversal();
-
- Vertex v1 = graph.addVertex(T.id, 1, "aai-node-type", "cloud-region");
- Vertex v2 = graph.addVertex(T.id, 2, "aai-node-type", "tenant");
- Vertex v3 = graph.addVertex(T.id, 3, "aai-node-type", "vserver");
- Vertex v4 = graph.addVertex(T.id, 4, "aai-node-type", "l-interface");
- rules.addTreeEdge(g, v1, v2);
- rules.addTreeEdge(g, v2, v3);
- rules.addTreeEdge(g, v3, v4);
- List<Vertex> expected = new ArrayList<>();
- expected.add(v4);
-
- TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, v1);
- QueryBuilder<Vertex> q = buildTestQuery(qb);
-
- List<Vertex> results = q.toList();
-
- assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
- }
-
-
-
-}
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
deleted file mode 100644
index d4793939..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============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.serialization.db;
-
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.dbmap.DBConnectionType;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
-import org.openecomp.aai.parsers.query.QueryParser;
-import org.openecomp.aai.schema.enums.PropertyMetadata;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-public class DbAliasTest extends AAISetup {
-
- private TitanGraph graph;
-
- private final Version version = Version.v9;
- private final ModelType introspectorFactoryType = ModelType.MOXY;
- private final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final DBConnectionType type = DBConnectionType.REALTIME;
- private Loader loader;
- private TransactionalGraphEngine dbEngine;
-
- @Before
- public void setup() throws Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
- queryStyle,
- type,
- loader);
- }
-
- @After
- public void tearDown() {
- graph.tx().rollback();
- graph.close();
- }
-
- @Test
- public void checkOnWrite() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException, NoSuchMethodException, InterruptedException {
- final String property = "persona-model-customization-id";
- String dbPropertyName = property;
- TransactionalGraphEngine spy = spy(this.dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- QueryParser uriQuery = spy.getQueryBuilder().createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1"));
- Introspector obj = loader.introspectorFromName("generic-vnf");
- Vertex v = g.addVertex();
- Object id = v.id();
- obj.setValue("vnf-id", "key1");
- obj.setValue(property, "hello");
- serializer.serializeToDb(obj, v, uriQuery, "", "");
- g.tx().commit();
- v = graph.traversal().V(id).next();
- Map<PropertyMetadata, String> map = obj.getPropertyMetadata(property);
- if (map.containsKey(PropertyMetadata.DB_ALIAS)) {
- dbPropertyName = map.get(PropertyMetadata.DB_ALIAS);
- }
-
- assertEquals("dbAlias is ", "model-customization-id", dbPropertyName);
- assertEquals("dbAlias property exists", "hello", v.property(dbPropertyName).orElse(""));
- assertEquals("model property does not", "missing", v.property(property).orElse("missing"));
-
- }
-
- @Test
- public void checkOnRead() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException, NoSuchMethodException, InterruptedException, MalformedURLException {
- final String property = "persona-model-customization-id";
-
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Vertex v = graph.traversal().addV("vnf-id", "key1", "model-customization-id", "hello").next();
- graph.tx().commit();
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- Introspector obj = loader.introspectorFromName("generic-vnf");
- serializer.dbToObject(Collections.singletonList(v), obj, 0, true, "false");
-
- assertEquals("dbAlias property exists", "hello", obj.getValue(property));
-
- }
-
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java
deleted file mode 100644
index b30c9367..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbSerializerTest.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*-
- * ============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.serialization.db;
-
-import com.thinkaurelius.titan.core.TitanFactory;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.dbmap.DBConnectionType;
-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.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class DbSerializerTest extends AAISetup {
-
- //to use, set thrown.expect to whatever your test needs
- //this line establishes default of expecting no exception to be thrown
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- protected Graph graph;
- protected final EdgeRules rules = EdgeRules.getInstance();
-
- private final Version version = Version.getLatest();
- private final ModelType introspectorFactoryType = ModelType.MOXY;
- private final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final DBConnectionType type = DBConnectionType.REALTIME;
- private Loader loader;
- private TransactionalGraphEngine dbEngine;
- private TransactionalGraphEngine engine; //for tests that aren't mocking the engine
- private DBSerializer dbser;
- TransactionalGraphEngine spy;
- TransactionalGraphEngine.Admin adminSpy;
-
- @Before
- public void setup() throws Exception {
- graph = TitanFactory.build().set("storage.backend", "inmemory").open();
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(queryStyle, type, loader);
- spy = spy(dbEngine);
- adminSpy = spy(dbEngine.asAdmin());
-
- createGraph();
-
- engine = new TitanDBEngine(queryStyle, type, loader);
- dbser = new DBSerializer(Version.getLatest(), engine, introspectorFactoryType, "AAI-TEST");
- }
-
- public void createGraph() throws AAIException {
- /*
- * This setus up the test graph, For future junits , add more vertices
- * and edges
- */
-
- Vertex l3interipv4addresslist_1 = graph.traversal().addV("aai-node-type", "l3-interface-ipv4-address-list",
- "l3-interface-ipv4-address", "l3-interface-ipv4-address-1").next();
- Vertex subnet_2 = graph.traversal().addV("aai-node-type", "subnet", "subnet-id", "subnet-id-2").next();
- Vertex l3interipv6addresslist_3 = graph.traversal().addV("aai-node-type", "l3-interface-ipv6-address-list",
- "l3-interface-ipv6-address", "l3-interface-ipv6-address-3").next();
- Vertex subnet_4 = graph.traversal().addV("aai-node-type", "subnet", "subnet-id", "subnet-id-4").next();
- Vertex subnet_5 = graph.traversal().addV("aai-node-type", "subnet", "subnet-id", "subnet-id-5").next();
- Vertex l3network_6 = graph.traversal()
- .addV("aai-node-type", "l3-network", "network-id", "network-id-6", "network-name", "network-name-6")
- .next();
-
- GraphTraversalSource g = graph.traversal();
- rules.addEdge(g, l3interipv4addresslist_1, subnet_2);
- rules.addEdge(g, l3interipv6addresslist_3, subnet_4);
- rules.addTreeEdge(g, subnet_5, l3network_6);
-
- }
-
- @After
- public void tearDown() throws Exception {
- graph.close();
- }
-
- @Test
- public void subnetDelwithInEdgesIpv4Test() throws AAIException {
- String expected_message = "Object is being reference by additional objects preventing it from being deleted. Please clean up references from the following types [l3-interface-ipv4-address-list]";
-
- /*
- * This subnet has in-edges with l3-ipv4 and NOT ok to delete
- */
- Vertex subnet = graph.traversal().V().has("aai-node-type", "subnet").has("subnet-id", "subnet-id-2").next();
-
- String exceptionMessage = testDelete(subnet);
- assertEquals(expected_message, exceptionMessage);
-
- }
-
- @Test
- public void subnetDelwithInEdgesIpv6Test() throws AAIException {
- String expected_message = "Object is being reference by additional objects preventing it from being deleted. Please clean up references from the following types [l3-interface-ipv6-address-list]";
-
- /*
- * This subnet has in-edges with l3-ipv6 and NOT ok to delete
- */
- Vertex subnet = graph.traversal().V().has("aai-node-type", "subnet").has("subnet-id", "subnet-id-4").next();
- String exceptionMessage = testDelete(subnet);
- assertEquals(expected_message, exceptionMessage);
-
- }
-
- @Test
- public void subnetDelwithInEdgesL3network() throws AAIException {
- String expected_message = "";
-
- /*
- * This subnet has in-edges with l3-network and ok to delete
- */
- Vertex subnet = graph.traversal().V().has("aai-node-type", "subnet").has("subnet-id", "subnet-id-5").next();
-
- String exceptionMessage = testDelete(subnet);
- assertEquals(expected_message, exceptionMessage);
-
- }
-
- public String testDelete(Vertex v) throws AAIException {
-
- // Graph g_tx = graph.newTransaction();
- GraphTraversalSource traversal = graph.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(adminSpy.getReadOnlyTraversalSource()).thenReturn(traversal);
-
- String exceptionMessage = "";
- DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST");
- try {
- serializer.delete(v, "resourceVersion", false);
- } catch (AAIException exception) {
- exceptionMessage = exception.getMessage();
-
- }
- return exceptionMessage;
-
- }
-
- @Test
- public void createNewVertexTest() throws AAIException {
- engine.startTransaction();
-
- Introspector testObj = loader.introspectorFromName("generic-vnf");
-
- Vertex testVertex = dbser.createNewVertex(testObj);
- Vertex fromGraph = engine.tx().traversal().V().has("aai-node-type","generic-vnf").toList().get(0);
- assertEquals(testVertex.id(), fromGraph.id());
- assertEquals("AAI-TEST", fromGraph.property(AAIProperties.SOURCE_OF_TRUTH.toString()).value());
- engine.rollback();
- }
-
- @Test
- public void touchStandardVertexPropertiesTest() throws AAIException, InterruptedException {
- engine.startTransaction();
- DBSerializer dbser2 = new DBSerializer(Version.getLatest(), engine, introspectorFactoryType, "AAI-TEST-2");
-
- Graph graph = TinkerGraph.open();
- Vertex vert = graph.addVertex("aai-node-type", "generic-vnf");
-
- dbser.touchStandardVertexProperties(vert, true);
- String resverStart = (String)vert.property(AAIProperties.RESOURCE_VERSION.toString()).value();
- String lastModTimeStart = (String)vert.property(AAIProperties.LAST_MOD_TS.toString()).value();
-
- Thread.sleep(10); //bc the resource version is set based on current time in milliseconds,
- //if this test runs through too fast the value may not change
- //causing the test to fail. sleeping ensures a different value
-
- dbser2.touchStandardVertexProperties(vert, false);
- assertFalse(resverStart.equals((String)vert.property(AAIProperties.RESOURCE_VERSION.toString()).value()));
- assertFalse(lastModTimeStart.equals((String)vert.property(AAIProperties.LAST_MOD_TS.toString()).value()));
- assertEquals("AAI-TEST-2", (String)vert.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH.toString()).value());
- engine.rollback();
- }
-
- @Test
- public void verifyResourceVersion_SunnyDayTest() throws AAIException {
- engine.startTransaction();
-
- assertTrue(dbser.verifyResourceVersion("delete", "vnfc", "abc", "abc", "vnfcs/vnfc/vnfcId"));
- engine.rollback();
- }
-
- @Test
- public void verifyResourceVersion_CreateWithRVTest() throws AAIException {
- engine.startTransaction();
-
- thrown.expect(AAIException.class);
- thrown.expectMessage("resource-version passed for create of generic-vnfs/generic-vnf/myid");
- try {
- dbser.verifyResourceVersion("create", "generic-vnf", null, "old-res-ver", "generic-vnfs/generic-vnf/myid");
- } finally {
- engine.rollback();
- }
- }
-
- @Test
- public void verifyResourceVersion_MissingRVTest() throws AAIException {
- engine.startTransaction();
-
- thrown.expect(AAIException.class);
- thrown.expectMessage("resource-version not passed for update of generic-vnfs/generic-vnf/myid");
- try {
- dbser.verifyResourceVersion("update", "generic-vnf", "current-res-ver", null, "generic-vnfs/generic-vnf/myid");
- } finally {
- engine.rollback();
- }
- }
-
- @Test
- public void verifyResourceVersion_MismatchRVTest() throws AAIException {
- engine.startTransaction();
-
- thrown.expect(AAIException.class);
- thrown.expectMessage("resource-version MISMATCH for update of generic-vnfs/generic-vnf/myid");
- try {
- dbser.verifyResourceVersion("update", "generic-vnf", "current-res-ver", "old-res-ver", "generic-vnfs/generic-vnf/myid");
- } finally {
- engine.rollback();
- }
- }
-
- @Test
- public void trimClassNameTest() throws AAIException {
- assertEquals("GenericVnf", dbser.trimClassName("GenericVnf"));
- assertEquals("GenericVnf", dbser.trimClassName("org.onap.aai.GenericVnf"));
- }
-
- @Test
- public void getURIForVertexTest() throws AAIException, URISyntaxException, UnsupportedEncodingException {
- engine.startTransaction();
-
- Vertex cr = engine.tx().addVertex("aai-node-type", "cloud-region", "cloud-owner", "me", "cloud-region-id", "123");
- Vertex ten = engine.tx().addVertex("aai-node-type", "tenant", "tenant-id", "453");
- EdgeRules rules = EdgeRules.getInstance();
- rules.addTreeEdge(engine.tx().traversal(), cr, ten);
-
- URI compare = new URI("/cloud-infrastructure/cloud-regions/cloud-region/me/123/tenants/tenant/453");
- assertEquals(compare, dbser.getURIForVertex(ten));
-
- cr.property("aai-node-type").remove();
- URI compareFailure = new URI("/unknown-uri");
- assertEquals(compareFailure, dbser.getURIForVertex(ten));
- engine.rollback();
- }
-
- @Test
- public void getVertexPropertiesTest() throws AAIException, UnsupportedEncodingException {
- engine.startTransaction();
-
- Vertex cr = engine.tx().addVertex("aai-node-type", "cloud-region", "cloud-owner", "me", "cloud-region-id", "123");
-
- Introspector crIntro = dbser.getVertexProperties(cr);
- assertEquals("cloud-region", crIntro.getDbName());
- assertEquals("me", crIntro.getValue("cloud-owner"));
- assertEquals("123", crIntro.getValue("cloud-region-id"));
- engine.rollback();
- }
-
- @Test
- public void setCachedURIsTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
- engine.startTransaction();
-
- Vertex cr = engine.tx().addVertex("aai-node-type", "cloud-region", "cloud-owner", "me", "cloud-region-id", "123");
- Vertex ten = engine.tx().addVertex("aai-node-type", "tenant", "tenant-id", "453");
- Vertex vs = engine.tx().addVertex("aai-node-type", "vserver", "vserver-id", "vs1",
- AAIProperties.AAI_URI.toString(),
- "/cloud-infrastructure/cloud-regions/cloud-region/me/123/tenants/tenant/453/vservers/vserver/vs1");
- EdgeRules rules = EdgeRules.getInstance();
- rules.addTreeEdge(engine.tx().traversal(), cr, ten);
- rules.addTreeEdge(engine.tx().traversal(), ten, vs);
-
- List<Vertex> vertices = new ArrayList<Vertex>(Arrays.asList(cr, ten, vs));
- Introspector crIn = dbser.getVertexProperties(cr);
- Introspector tenIn = dbser.getVertexProperties(ten);
- Introspector vsIn = dbser.getVertexProperties(vs);
- List<Introspector> intros = new ArrayList<Introspector>(Arrays.asList(crIn, tenIn, vsIn));
-
- dbser.setCachedURIs(vertices, intros);
-
- assertEquals("/cloud-infrastructure/cloud-regions/cloud-region/me/123",
- (String)cr.property(AAIProperties.AAI_URI.toString()).value());
- assertEquals("/cloud-infrastructure/cloud-regions/cloud-region/me/123/tenants/tenant/453",
- (String)ten.property(AAIProperties.AAI_URI.toString()).value());
- assertEquals("/cloud-infrastructure/cloud-regions/cloud-region/me/123/tenants/tenant/453/vservers/vserver/vs1",
- (String)vs.property(AAIProperties.AAI_URI.toString()).value());
- engine.rollback();
- }
-
- @Test
- public void getEdgeBetweenTest() throws AAIException {
- engine.startTransaction();
-
- Vertex cr = engine.tx().addVertex("aai-node-type", "cloud-region", "cloud-owner", "me", "cloud-region-id", "123");
- Vertex ten = engine.tx().addVertex("aai-node-type", "tenant", "tenant-id", "453");
- EdgeRules rules = EdgeRules.getInstance();
- rules.addTreeEdge(engine.tx().traversal(), cr, ten);
-
- Edge e = dbser.getEdgeBetween(EdgeType.TREE, ten, cr);
- assertEquals("has", e.label());
- engine.rollback();
- }
-
- @Test
- public void deleteEdgeTest() throws AAIException, UnsupportedEncodingException {
- engine.startTransaction();
-
- Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf");
- Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
- EdgeRules rules = EdgeRules.getInstance();
- rules.addEdge(engine.tx().traversal(), gvnf, vnfc);
-
- Introspector relData = loader.introspectorFromName("relationship-data");
- relData.setValue("relationship-key", "vnfc.vnfc-name");
- relData.setValue("relationship-value", "a-name");
- Introspector relationship = loader.introspectorFromName("relationship");
- relationship.setValue("related-to", "vnfc");
- relationship.setValue("related-link", "/network/vnfcs/vnfc/a-name");
- relationship.setValue("relationship-data",relData);
-
- assertTrue(dbser.deleteEdge(relationship, gvnf));
-
- assertFalse(engine.tx().traversal().V(gvnf).both("uses").hasNext());
- assertFalse(engine.tx().traversal().V(vnfc).both("uses").hasNext());
- engine.rollback();
- }
-
- @Test
- public void createEdgeTest() throws AAIException, UnsupportedEncodingException {
- engine.startTransaction();
-
- Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf");
- Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
-
- //sunny day case
- Introspector relData = loader.introspectorFromName("relationship-data");
- relData.setValue("relationship-key", "vnfc.vnfc-name");
- relData.setValue("relationship-value", "a-name");
- Introspector relationship = loader.introspectorFromName("relationship");
- relationship.setValue("related-to", "vnfc");
- relationship.setValue("related-link", "/network/vnfcs/vnfc/a-name");
- relationship.setValue("relationship-data",relData);
-
- assertTrue(dbser.createEdge(relationship, gvnf));
- assertTrue(engine.tx().traversal().V(gvnf).both("uses").hasNext());
- assertTrue(engine.tx().traversal().V(vnfc).both("uses").hasNext());
-
- //rainy day case, edge to nonexistant object
- Introspector relData2 = loader.introspectorFromName("relationship-data");
- relData2.setValue("relationship-key", "vnfc.vnfc-name");
- relData2.setValue("relationship-value", "b-name");
- Introspector relationship2 = loader.introspectorFromName("relationship");
- relationship2.setValue("related-to", "vnfc");
- relationship2.setValue("related-link", "/network/vnfcs/vnfc/b-name");
- relationship2.setValue("relationship-data",relData2);
-
- thrown.expect(AAIException.class);
- thrown.expectMessage("Node of type vnfc. Could not find object at: /network/vnfcs/vnfc/b-name");
- try {
- dbser.createEdge(relationship2, gvnf);
- } finally {
- engine.rollback();
- }
- }
-
- @Test
- public void serializeSingleVertexTopLevelTest() throws AAIException, UnsupportedEncodingException {
- engine.startTransaction();
-
- Introspector gvnf = loader.introspectorFromName("generic-vnf");
- Vertex gvnfVert = dbser.createNewVertex(gvnf);
-
- gvnf.setValue("vnf-id", "myvnf");
- dbser.serializeSingleVertex(gvnfVert, gvnf, "test");
- assertTrue(engine.tx().traversal().V().has("aai-node-type","generic-vnf").has("vnf-id","myvnf").hasNext());
- engine.rollback();
- }
-
- @Test
- public void serializeSingleVertexChildTest() throws AAIException, UnsupportedEncodingException {
- engine.startTransaction();
-
- Vertex cr = engine.tx().addVertex("aai-node-type", "cloud-region", "cloud-owner", "me", "cloud-region-id", "123");
- Introspector tenIn = loader.introspectorFromName("tenant");
- Vertex ten = dbser.createNewVertex(tenIn);
- EdgeRules rules = EdgeRules.getInstance();
- rules.addTreeEdge(engine.tx().traversal(), cr, ten);
-
- tenIn.setValue("tenant-id", "453");
- tenIn.setValue("tenant-name", "mytenant");
-
- dbser.serializeSingleVertex(ten, tenIn, "test");
-
- assertTrue(engine.tx().traversal().V().has("aai-node-type","tenant").has("tenant-id","453").has("tenant-name","mytenant").hasNext());
- engine.rollback();
- }
-} \ No newline at end of file
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java
deleted file mode 100644
index fb3c0469..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgePropertyMapTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============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.serialization.db;
-
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-public class EdgePropertyMapTest {
-
- @Test
- public void run() {
- Map<String, String> map = new EdgePropertyMap<>();
- map.put("direction", "OUT");
- map.put("test", "hello");
- map.put("isParent", "${direction}");
- map.put("SVC-INFRA", "!${direction}");
-
- assertEquals("normal retrieval", "hello", map.get("test"));
- assertEquals("variable retrieval", "OUT", map.get("isParent"));
- assertEquals("negate variable retrieval", "IN", map.get("SVC-INFRA"));
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
deleted file mode 100644
index 0257e6b1..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/EdgeRulesTest.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*-
- * ============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.serialization.db;
-
-
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Test;
-import org.openecomp.aai.AAISetup;
-import static org.junit.Assert.assertEquals;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
-
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Version;
-import org.openecomp.aai.serialization.db.exceptions.EdgeMultiplicityException;
-import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
-
-import com.google.common.collect.Multimap;
-
-public class EdgeRulesTest extends AAISetup {
-
- //set thrown.expect to whatever a specific test needs
- //this establishes a default of expecting no exceptions to be thrown
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void verifyOutDirection() throws AAIException, NoEdgeRuleFoundException {
- EdgeRules rules = EdgeRules.getInstance();
- EdgeRule rule = rules.getEdgeRule(EdgeType.TREE, "cloud-region", "flavor");
-
- assertEquals("out direction", rule.getDirection(), Direction.OUT);
- }
-
- @Test
- public void verifyOutFlippedDirection() throws AAIException, NoEdgeRuleFoundException {
- EdgeRules rules = EdgeRules.getInstance();
- EdgeRule rule = rules.getEdgeRule(EdgeType.TREE, "flavor", "cloud-region");
-
- assertEquals("in direction", rule.getDirection(), Direction.IN);
- }
-
- @Test
- public void verifyInDirection() throws AAIException, NoEdgeRuleFoundException {
- EdgeRules rules = EdgeRules.getInstance();
- EdgeRule rule = rules.getEdgeRule(EdgeType.COUSIN, "model-ver", "model-element");
-
- assertEquals("in direction", rule.getDirection(), Direction.IN);
- }
-
- @Test
- public void verifyInFlippedDirection() throws AAIException, NoEdgeRuleFoundException {
- EdgeRules rules = EdgeRules.getInstance();
- EdgeRule rule = rules.getEdgeRule(EdgeType.COUSIN, "model-element", "model-ver");
-
- assertEquals("out direction", rule.getDirection(), Direction.OUT);
- }
- @Test
- public void verifyMultipleGet() throws AAIException {
- EdgeRules rules = EdgeRules.getInstance();
- Map<String, EdgeRule> ruleMap = rules.getEdgeRules("model-element", "model-ver");
- assertEquals("has isA rule", "isA", ruleMap.get("isA").getLabel());
- assertEquals("has startsWith rule", "startsWith", ruleMap.get("startsWith").getLabel());
- }
-
- @Test
- public void verifyMultipleGetSingleRule() throws AAIException {
- EdgeRules rules = EdgeRules.getInstance();
- Map<String, EdgeRule> ruleMap = rules.getEdgeRules("availability-zone", "complex");
- assertEquals("has groupsResourcesIn rule", "groupsResourcesIn", ruleMap.get("groupsResourcesIn").getLabel());
- }
-
- @Test
- public void verifyOldEdgeRule() throws AAIException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
- assertEquals(true, EdgeRules.getInstance().hasEdgeRule("model-element", "model-ver"));
- assertEquals(true, EdgeRules.getInstance(Version.v8).hasEdgeRule("pserver", "complex"));
- assertEquals(false, EdgeRules.getInstance(Version.v8).hasEdgeRule("model-element", "model-ver"));
- }
-
- @Test
- public void hasEdgeRuleVertexTest() {
- Graph graph = TinkerGraph.open();
- Vertex v1 = graph.addVertex("aai-node-type", "cloud-region");
- Vertex v2 = graph.addVertex("aai-node-type", "tenant");
- assertEquals(true, EdgeRules.getInstance().hasEdgeRule(v1, v2));
- }
-
- @Test
- public void getEdgeRuleByTypeAndVertices() throws AAIException {
- Graph graph = TinkerGraph.open();
- Vertex v1 = graph.addVertex("aai-node-type", "cloud-region");
- Vertex v2 = graph.addVertex("aai-node-type", "tenant");
- EdgeRules rules = EdgeRules.getInstance();
- EdgeRule rule = rules.getEdgeRule(EdgeType.TREE, v1, v2);
- assertEquals(true, "OUT".equalsIgnoreCase(rule.getContains()));
- assertEquals(true, "NONE".equalsIgnoreCase(rule.getDeleteOtherV()));
- assertEquals(true, MultiplicityRule.ONE2MANY.equals(rule.getMultiplicityRule()));
- assertEquals(true, "IN".equalsIgnoreCase(rule.getServiceInfrastructure()));
- assertEquals(true, "OUT".equalsIgnoreCase(rule.getPreventDelete()));
- }
-
- @Test
- public void addTreeEdgeTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- Vertex v1 = graph.addVertex(T.id, "1", "aai-node-type", "cloud-region");
- Vertex v2 = graph.addVertex(T.id, "10", "aai-node-type", "tenant");
- EdgeRules rules = EdgeRules.getInstance();
- GraphTraversalSource g = graph.traversal();
- rules.addTreeEdge(g, v1, v2);
- assertEquals(true, g.V(v1).out("has").has("aai-node-type", "tenant").hasNext());
-
- Vertex v3 = graph.addVertex(T.id, "2", "aai-node-type", "cloud-region");
- assertEquals(null, rules.addTreeEdgeIfPossible(g, v3, v2));
- }
-
- @Test
- public void addCousinEdgeTest() throws AAIException {
- Graph graph = TinkerGraph.open();
- Vertex v1 = graph.addVertex(T.id, "1", "aai-node-type", "flavor");
- Vertex v2 = graph.addVertex(T.id, "10", "aai-node-type", "vserver");
- EdgeRules rules = EdgeRules.getInstance(Version.getLatest());
- GraphTraversalSource g = graph.traversal();
- rules.addEdge(g, v1, v2);
- assertEquals(true, g.V(v2).out("hasFlavor").has("aai-node-type", "flavor").hasNext());
-
- Vertex v3 = graph.addVertex(T.id, "2", "aai-node-type", "flavor");
- assertEquals(null, rules.addEdgeIfPossible(g, v3, v2));
- }
-
- @Test
- public void multiplicityViolationTest() throws AAIException {
- thrown.expect(EdgeMultiplicityException.class);
- thrown.expectMessage("multiplicity rule violated: only one edge can exist with label: uses between vf-module and volume-group");
-
- Graph graph = TinkerGraph.open();
- Vertex v1 = graph.addVertex(T.id, "1", "aai-node-type", "vf-module");
- Vertex v2 = graph.addVertex(T.id, "10", "aai-node-type", "volume-group");
- EdgeRules rules = EdgeRules.getInstance(Version.getLatest());
- GraphTraversalSource g = graph.traversal();
-
- rules.addEdge(g, v2, v1);
- Vertex v3 = graph.addVertex(T.id, "3", "aai-node-type", "vf-module");
- rules.addEdge(g, v2, v3);
- }
-
- @Test
- public void getChildrenTest() {
- EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test.json");
- Set<EdgeRule> children = rules.getChildren("foo");
- assertEquals(2, children.size());
- boolean sawBazRule = false;
- boolean sawQuuxRule = false;
- for (EdgeRule r : children) {
- if ("isVeryHappyAbout".equals(r.getLabel())) {
- sawBazRule = true;
- } else if ("dancesWith".equals(r.getLabel())) {
- sawQuuxRule = true;
- }
- }
- assertEquals(true, sawBazRule && sawQuuxRule);
- }
-
- @Test
- public void getAllRulesTest() {
- EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test.json");
- Multimap<String, EdgeRule> allRules = rules.getAllRules();
- assertEquals(3, allRules.size());
- assertEquals(true, allRules.containsKey("foo|bar"));
- assertEquals(true, allRules.containsKey("foo|bar"));
- assertEquals(true, allRules.containsKey("quux|foo"));
- }
-
- @Test
- public void getAllRulesMissingPropertyTest() {
- EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json");
-
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between foo and bar is missing property delete-other-v.");
- rules.getAllRules();
- }
-
- @Test
- public void getChildrenMissingPropertyTest() {
- EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json");
-
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between quux and foo is missing property SVC-INFRA.");
- rules.getChildren("foo");
- }
-
- @Test
- public void getEdgeRuleMissingPropertyTest() throws AAIException {
- EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json");
-
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("org.openecomp.aai.exceptions.AAIException: Rule between quux and foo is missing property SVC-INFRA.");
- rules.getEdgeRules("foo", "quux");
- }
-
- @Test
- public void verifyAllRules() {
- // This will cause every rule in the real json files to be verified
- // so if any required properties are missing, the verification builds
- // will catch it and incorrect rules can't get merged in.
- for (Version v : Version.values()) {
- EdgeRules rules = EdgeRules.getInstance(v);
- rules.getAllRules();
- }
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java
deleted file mode 100644
index f9a511a2..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============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.serialization.queryformats;
-
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.io.IoCore;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.openecomp.aai.db.props.AAIProperties;
-import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-import static org.mockito.Matchers.isA;
-import static org.mockito.Mockito.when;
-
-public class QueryFormatTestHelper {
-
-
- public static final String testResources = "src/test/resources/org/openecomp/aai/serialization/queryformats/";
- public static final String graphsonResources = "src/test/resources/org/openecomp/aai/serialization/queryformats/graphson/";
-
-
- public static void mockPathed(UrlBuilder mock) throws AAIFormatVertexException {
- Answer<String> answer = new Answer<String>() {
- public String answer(InvocationOnMock invocation) throws Throwable {
- Vertex v = invocation.getArgumentAt(0, Vertex.class);
-
- return v.<String>property(AAIProperties.AAI_URI).orElse("urimissing");
- }
- };
- when(mock.pathed(isA(Vertex.class))).thenAnswer(answer);
-
- }
-
- public static Graph loadGraphson(String fileName) throws IOException {
- final Graph graph = TinkerGraph.open();
- graph.io(IoCore.graphson()).readGraph(QueryFormatTestHelper.graphsonResources + fileName);
-
- return graph;
- }
-
- public static void setFinalStatic(Field field, Object newValue) throws Exception {
- field.setAccessible(true);
- // remove final modifier from field
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- field.set(null, newValue);
- }
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java
deleted file mode 100644
index 766274cd..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/SimpleFormatTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * ============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.serialization.queryformats;
-
-import com.google.gson.JsonObject;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.aai.dbmap.DBConnectionType;
-import org.openecomp.aai.exceptions.AAIException;
-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.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.engines.QueryStyle;
-import org.openecomp.aai.serialization.engines.TitanDBEngine;
-import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
-
-import java.io.UnsupportedEncodingException;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.*;
-
-public class SimpleFormatTest {
-
- @Mock
- private UrlBuilder urlBuilder;
-
- private Graph graph;
- private TransactionalGraphEngine dbEngine;
- private Loader loader;
- private DBSerializer serializer;
- private RawFormat simpleFormat;
- private Vertex vfModule;
- private final ModelType factoryType = ModelType.MOXY;
-
- @Before
- public void setUp() throws Exception {
-
- MockitoAnnotations.initMocks(this);
-
- graph = TinkerGraph.open();
-
- vfModule = graph.addVertex(
- T.label, "vf-module",
- T.id, "5",
- "aai-node-type", "vf-module",
- "vf-module-id", "vf-module-id-val-68205",
- "vf-module-name", "example-vf-module-name-val-68205",
- "heat-stack-id", "example-heat-stack-id-val-68205",
- "orchestration-status", "example-orchestration-status-val-68205",
- "is-base-vf-module", "true",
- "resource-version", "1498166571906",
- "model-invariant-id", "fe8aac07-ce6c-4f9f-aa0d-b561c77da9e8",
- "model-invariant-id-local", "fe8aac07-ce6c-4f9f-aa0d-b561c77da9e8",
- "model-version-id", "0d23052d-8ffe-433e-a25d-da5da027bb7c",
- "model-version-id-local", "0d23052d-8ffe-433e-a25d-da5da027bb7c",
- "widget-model-id", "example-widget-model-id-val-68205",
- "widget-model-version", "example-widget--model-version-val-68205",
- "contrail-service-instance-fqdn", "example-contrail-service-instance-fqdn-val-68205"
- );
- }
-
- @Test
- public void testCreatePropertiesObjectReturnsProperProperties() throws AAIFormatVertexException, AAIException {
-
- createLoaderEngineSetup();
- serializer = new DBSerializer(Version.v10, dbEngine, factoryType, "Junit");
- simpleFormat = new RawFormat.Builder(loader, serializer, urlBuilder).nodesOnly(true).depth(0).modelDriven().build();
-
- assertNotNull(dbEngine.tx());
- assertNotNull(dbEngine.asAdmin());
-
- JsonObject json = simpleFormat.createPropertiesObject(vfModule);
-
- assertTrue(json.has("model-invariant-id"));
- assertTrue(json.has("model-version-id"));
-
- assertFalse(json.has("model-invariant-id-local"));
- assertFalse(json.has("model-version-id-local"));
-
- }
-
- @Ignore
- @Test(expected = AAIFormatVertexException.class)
- public void testCreatePropertiesObjectThrowsExceptionIfSerializationFails() throws AAIFormatVertexException, AAIException, UnsupportedEncodingException {
-
- serializer = mock(DBSerializer.class);
- loader = mock(Loader.class);
-
- simpleFormat = new RawFormat.Builder(loader, serializer, urlBuilder).nodesOnly(true).depth(0).build();
-
- when(serializer.dbToObject(anyObject(), anyObject(), anyInt(), anyBoolean(), anyString()))
- .thenThrow(new AAIException("Test Exception"));
-
- simpleFormat.createPropertiesObject(vfModule);
- }
-
- @Ignore
- @Test(expected = AAIFormatVertexException.class)
- public void testCreatePropertiesObjectThrowsExceptionIfUnknownObject() throws AAIFormatVertexException, AAIException, UnsupportedEncodingException {
-
- loader = mock(Loader.class);
- serializer = mock(DBSerializer.class);
-
- simpleFormat = new RawFormat.Builder(loader, serializer, urlBuilder).nodesOnly(true).depth(0).build();
-
- when(loader.introspectorFromName(anyString()))
- .thenThrow(new AAIUnknownObjectException("Test Exception"));
-
- simpleFormat.createPropertiesObject(vfModule);
- }
-
- public void createLoaderEngineSetup(){
-
- if(loader == null){
- loader = LoaderFactory.createLoaderForVersion(factoryType, Version.v10);
- dbEngine = spy(new TitanDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader));
-
- TransactionalGraphEngine.Admin spyAdmin = spy(dbEngine.asAdmin());
-
- when(dbEngine.tx()).thenReturn(graph);
- when(dbEngine.asAdmin()).thenReturn(spyAdmin);
-
- when(spyAdmin.getReadOnlyTraversalSource()).thenReturn(graph.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance())));
- when(spyAdmin.getTraversalSource()).thenReturn(graph.traversal());
- }
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java
deleted file mode 100644
index 3eade856..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjectorTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============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.serialization.queryformats.utils;
-
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.queryformats.Resource;
-import org.openecomp.aai.serialization.queryformats.Resource.Builder;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-
-import static org.junit.Assert.assertEquals;
-
-public class QueryParamInjectorTest {
-
-
- @Mock private Loader loader;
- @Mock private DBSerializer serializer;
- @Mock private UrlBuilder urlBuilder;
-
- @Test
- public void test() throws AAIException {
- MockitoAnnotations.initMocks(this);
- QueryParamInjector injector = QueryParamInjector.getInstance();
-
- Builder b = new Resource.Builder(loader, serializer, urlBuilder);
- MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
- params.putSingle("nodesOnly", "true");
- params.putSingle("depth", "10");
- params.putSingle("invalid", "1000");
- injector.injectParams(b, params);
-
- assertEquals("is nodes only", true, b.isNodesOnly());
- assertEquals("is depth 10", 10, b.getDepth());
- }
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java
deleted file mode 100644
index 605bbcd9..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilderTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * ============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.serialization.queryformats.utils;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.aai.AAISetup;
-import org.openecomp.aai.introspection.Version;
-import org.openecomp.aai.serialization.db.DBSerializer;
-import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-import org.openecomp.aai.util.AAIConstants;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-public class UrlBuilderTest extends AAISetup {
-
- @Mock
- private DBSerializer serializer;
- @Mock
- private Vertex v;
-
- private static final String uri = "/test/uri";
- private static final Object vId = new Long(123);
- private static final String protocolAndHost = "http://localhost/aai/";
-
- @Before
- public void before() throws UnsupportedEncodingException, URISyntaxException {
- MockitoAnnotations.initMocks(this);
- when(serializer.getURIForVertex(any(Vertex.class))).thenReturn(new URI(uri));
- when(v.id()).thenReturn(vId);
- }
-
- @Test
- public void v11Pathed() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException {
- Version version = Version.v11;
- UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost);
- String result = builder.pathed(v);
-
- assertEquals("has no protocol and host", AAIConstants.AAI_APP_ROOT + version + uri, result);
-
- }
-
- @Test
- public void v11Id() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException {
- Version version = Version.v11;
- UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost);
- String result = builder.id(v);
-
- assertEquals("has no protocol and host", AAIConstants.AAI_APP_ROOT + version + "/resources/id/" + vId, result);
-
- }
-
- @Test
- public void beforeV11Pathed() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException {
- Version version = Version.v10;
- UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost);
- String result = builder.pathed(v);
-
- assertEquals("has protocol and host", protocolAndHost + version + uri, result);
-
- }
-
- @Test
- public void beforeV11Id() throws UnsupportedEncodingException, URISyntaxException, AAIFormatVertexException {
- Version version = Version.v10;
- UrlBuilder builder = new UrlBuilder(version, serializer, protocolAndHost);
- String result = builder.id(v);
-
- assertEquals("has protocol and host", protocolAndHost + version + "/resources/id/" + vId, result);
-
- }
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java
deleted file mode 100644
index c4440527..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertexTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*-
- * ============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.serialization.tinkerpop;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
-import org.apache.tinkerpop.gremlin.structure.*;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.aai.serialization.db.EdgeProperty;
-import org.openecomp.aai.serialization.engines.query.GraphTraversalQueryEngine;
-
-import static org.junit.Assert.assertEquals;
-
-@Ignore
-public class TreeBackedVertexTest {
-
- private Graph graph = TinkerGraph.open();
- private Object startKey = null;
- private Tree<Element> tree = null;
- private Tree<Element> treeDepth1 = null;
- private Tree<Element> treeDepth0NodeOnly = null;
-
- @Before
- public void configure() {
- GraphTraversalSource g = graph.traversal();
-
- startKey = g.addV(T.label, "vserver").as("v1").property("test", "hello")
- .addV(T.label, "vserver").as("v2")
- .addV(T.label, "interface").property("name", "interface 1").as("v7").addInE("hasChild", "v2").property(EdgeProperty.CONTAINS.toString(), true)
- .addV(T.label, "pserver").property("name", "pserver 1").as("v4").addOutE("runsOn", "v1").property(EdgeProperty.CONTAINS.toString(), false)
- .addV(T.label, "interface").property("name", "interface 2").as("v3").addInE("hasChild", "v1").property(EdgeProperty.CONTAINS.toString(), true)
- .addV(T.label, "address").property("name", "address 1").addInE("hasChild", "v3").property(EdgeProperty.CONTAINS.toString(), true)
- .addV(T.label, "address").property("name", "address 2").addInE("hasChild", "v3").property(EdgeProperty.CONTAINS.toString(), true)
- .addV(T.label, "complex").property("name", "complex 1").addInE("locatedIn", "v4").property(EdgeProperty.CONTAINS.toString(), false)
- .addV(T.label, "interface").property("name", "interface 3").addInE("hasChild", "v4").property(EdgeProperty.CONTAINS.toString(), true)
- .addV(T.label, "subnet").property("name", "subnet 1").as("v5").addInE("in", "v3").property(EdgeProperty.CONTAINS.toString(), false)
- .addV(T.label, "address").property("name", "address 3").as("v6").addInE("hasChild", "v5").property(EdgeProperty.CONTAINS.toString(), true)
- .select("v1").next();
-
- tree = new GraphTraversalQueryEngine(g).findSubGraph((Vertex)startKey);
- treeDepth1 = new GraphTraversalQueryEngine(g).findSubGraph((Vertex)startKey, 1, false);
- treeDepth0NodeOnly = new GraphTraversalQueryEngine(g).findSubGraph((Vertex)startKey, 0, true);
- }
-
- @Ignore
- @Test
- public void oneHopViaEdges() {
-
- //BulkSet set = (BulkSet)result;
- TreeBackedVertex v = new TreeBackedVertex((Vertex)tree.getObjectsAtDepth(1).iterator().next(), tree);
-
-
- assertEquals("locate child", v.edges(Direction.OUT).next().inVertex().property("name").orElse(""), "interface 2");
- assertEquals("locate cousin", v.edges(Direction.IN).next().outVertex().property("name").orElse(""), "pserver 1");
-
-
- }
-
- @Ignore
- @Test
- public void oneHopViaVertices() {
-
- //BulkSet set = (BulkSet)result;
- TreeBackedVertex v = new TreeBackedVertex((Vertex)tree.getObjectsAtDepth(1).iterator().next(), tree);
-
-
- assertEquals("locate child", "interface 2", v.vertices(Direction.OUT).next().property("name").orElse(""));
- assertEquals("locate cousin", "pserver 1", v.vertices(Direction.IN).next().property("name").orElse(""));
-
- }
-
- @Ignore
- @Test
- public void twoHopCousinViaVertices() {
-
- //BulkSet set = (BulkSet)result;
- TreeBackedVertex v = new TreeBackedVertex((Vertex)tree.getObjectsAtDepth(1).iterator().next(), tree);
-
-
- assertEquals("locate child", "subnet 1", v.vertices(Direction.OUT).next().vertices(Direction.OUT, "in").next().property("name").orElse(""));
-
- }
-
- @Test
- public void walkVerticesRestrictedDepth() {
-
- //BulkSet set = (BulkSet)result;
- TreeBackedVertex v = new TreeBackedVertex((Vertex)treeDepth1.getObjectsAtDepth(1).iterator().next(), treeDepth1);
-
-
- assertEquals("nothing returned", false, v.vertices(Direction.OUT).next()
- .vertices(Direction.OUT, "hasChild").hasNext());
-
- }
-
- @Test
- public void walkVertices() {
- TreeBackedVertex v = new TreeBackedVertex((Vertex)tree.getObjectsAtDepth(1).iterator().next(), tree);
- assertEquals("locate child", "address 2", v.vertices(Direction.OUT).next()
- .vertices(Direction.OUT, "hasChild").next().property("name").orElse(""));
- }
-
- @Test
- public void walkEdges() {
- TreeBackedVertex v = new TreeBackedVertex((Vertex)tree.getObjectsAtDepth(1).iterator().next(), tree);
-
- assertEquals("locate child", "address 2", v.edges(Direction.OUT).next().inVertex()
- .edges(Direction.OUT, "hasChild").next().inVertex().property("name").orElse(""));
- }
-
- @Test
- public void noEdgesFoudWithLabelVertices() {
- TreeBackedVertex v = new TreeBackedVertex((Vertex)tree.getObjectsAtDepth(1).iterator().next(), tree);
-
- assertEquals("missing hello label", false , v.vertices(Direction.OUT, "hello").hasNext());
- }
-
- @Test
- public void noEdgesFoudWithLabelEdges() {
- TreeBackedVertex v = new TreeBackedVertex((Vertex)tree.getObjectsAtDepth(1).iterator().next(), tree);
-
- assertEquals("missing hello label", false , v.edges(Direction.OUT, "hello").hasNext());
- }
-
- @Test
- public void depthZeroNodeOnly() {
- TreeBackedVertex v = new TreeBackedVertex((Vertex)treeDepth0NodeOnly.getObjectsAtDepth(1).iterator().next(), treeDepth0NodeOnly);
- assertEquals("no edges returned", false, v.edges(Direction.BOTH).hasNext());
- }
-
-}
diff --git a/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java b/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java
deleted file mode 100644
index 230efaaf..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/util/GenerateXsdTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============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.util;
-
-import org.junit.Test;
-import org.openecomp.aai.introspection.Version;
-
-public class GenerateXsdTest {
-
- @Test
- public void testGenerationOfXsdAndYaml() throws Exception {
-
- GenerateXsd generateXsd = new GenerateXsd();
- System.setProperty("gen_version", Version.getLatest().toString());
- System.setProperty("gen_type", "XSD");
- System.setProperty("yamlresponses_url", "");
- System.setProperty("yamlresponses_label", "");
-
- generateXsd.main(new String[]{});
-
- System.setProperty("gen_version", Version.getLatest().toString());
- System.setProperty("gen_type", "YAML");
-
- String wikiLink = System.getProperty("aai.wiki.link");
-
- if(wikiLink == null){
- wikiLink = "https://wiki.onap.org/";
- }
-
- System.setProperty("yamlresponses_url", wikiLink);
- System.setProperty("yamlresponses_label", "Response codes found in [response codes]");
-
- generateXsd.main(new String[]{});
- }
-
-}
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
deleted file mode 100644
index 51636271..00000000
--- a/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============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 org.junit.Before;
-import org.junit.Test;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-
-import static org.junit.Assert.assertEquals;
-
-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"));
- }
-}