summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2018-03-24 21:59:03 -0400
committerKajur, Harish (vk250x) <vk250x@att.com>2018-03-26 08:48:18 -0400
commitf1a8fb1bc04f5d685f2b31d35db605f6fa054f60 (patch)
treea5e432ad396ec3f2587993a69099890ed723e0d8 /aai-core/src/test
parentb1264ad4012f67664d71982a0eaad7e9bcce34f4 (diff)
Add plugin to check coverage
Get line coverage to 50% and ensure it doesn't go down Issue-ID: AAI-498 Change-Id: Ib466b7e2b7cb6d2f888e3b58c2073bb02ab6f809 Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-core/src/test')
-rw-r--r--aai-core/src/test/java/org/onap/aai/AAIJunitRunner.java7
-rw-r--r--aai-core/src/test/java/org/onap/aai/HttpTestUtil.java21
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/MoxyLoaderTest.java77
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/PojoStrategyTest.java65
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/VersionTest.java50
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java118
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java36
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java49
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java79
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java94
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java125
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java70
-rw-r--r--aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java24
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java130
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java19
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java94
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java78
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/CloudRegionTest.java19
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/GenericVnfLInterfaceTest.java24
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java21
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/PserverTest.java20
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/TenantTest.java23
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java129
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java16
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java195
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java18
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/AAIConfigTest.java125
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/AutoGenerateHtmlTest.java35
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/GenerateXsdTest.java294
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java71
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java22
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteFootnoteSetTest.java83
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteOperationTest.java82
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeDescriptionTest.java392
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeRuleSetTest.java243
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/GetOperationTest.java107
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java278
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/PatchOperationTest.java82
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/PutOperationTest.java84
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/PutRelationPathSetTest.java223
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java564
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/XSDJavaTypeTest.java101
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java826
43 files changed, 4671 insertions, 542 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/AAIJunitRunner.java b/aai-core/src/test/java/org/onap/aai/AAIJunitRunner.java
index 41a2f424..94fce5d4 100644
--- a/aai-core/src/test/java/org/onap/aai/AAIJunitRunner.java
+++ b/aai-core/src/test/java/org/onap/aai/AAIJunitRunner.java
@@ -19,16 +19,15 @@
*/
package org.onap.aai;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.InitializationError;
+import org.junit.runners.Parameterized;
import org.onap.aai.util.AAIConstants;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
-public class AAIJunitRunner extends BlockJUnit4ClassRunner {
+public class AAIJunitRunner extends Parameterized {
- public AAIJunitRunner(Class<?> klass) throws InitializationError {
+ public AAIJunitRunner(Class<?> klass) throws Throwable {
super(klass);
setProps();
modifyOxmHome();
diff --git a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
index 7284593e..943ebad5 100644
--- a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -41,7 +41,9 @@ import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import javax.ws.rs.core.*;
import java.io.UnsupportedEncodingException;
import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doReturn;
@@ -54,6 +56,7 @@ public class HttpTestUtil extends RESTAPI {
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
private static final String EMPTY = "";
+ private final QueryStyle queryStyle;
protected HttpHeaders httpHeaders;
protected UriInfo uriInfo;
@@ -64,6 +67,10 @@ public class HttpTestUtil extends RESTAPI {
protected List<String> aaiRequestContextList;
protected List<MediaType> outputMediaTypes;
+ public HttpTestUtil(QueryStyle qs) {
+ this.queryStyle = qs;
+ }
+
public void init(){
httpHeaders = Mockito.mock(HttpHeaders.class);
@@ -114,7 +121,7 @@ public class HttpTestUtil extends RESTAPI {
if(arr != null && arr.length > 1){
if(arr[0].matches("^v\\d+")){
- version = Version.valueOf(arr[0]);
+ version = Version.getVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
}
}
@@ -125,7 +132,7 @@ public class HttpTestUtil extends RESTAPI {
Mockito.when(uriInfo.getPath()).thenReturn(uri);
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
dbEngine = httpEntry.getDbEngine();
@@ -206,7 +213,7 @@ public class HttpTestUtil extends RESTAPI {
if(arr != null && arr.length > 1){
if(arr[0].matches("^v\\d+")){
- version = Version.valueOf(arr[0]);
+ version = Version.getVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
}
}
@@ -216,7 +223,7 @@ public class HttpTestUtil extends RESTAPI {
}
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
dbEngine = httpEntry.getDbEngine();
@@ -287,7 +294,7 @@ public class HttpTestUtil extends RESTAPI {
if(arr != null && arr.length > 1){
if(arr[0].matches("^v\\d+")){
- version = Version.valueOf(arr[0]);
+ version = Version.getVersion(arr[0]);
if(!uri.contains("relationship-list/relationship")){
uri = uri.replaceAll("^v\\d+", "");
}
@@ -300,7 +307,7 @@ public class HttpTestUtil extends RESTAPI {
Mockito.when(uriInfo.getPath()).thenReturn(uri);
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
dbEngine = httpEntry.getDbEngine();
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/MoxyLoaderTest.java b/aai-core/src/test/java/org/onap/aai/introspection/MoxyLoaderTest.java
new file mode 100644
index 00000000..95a4bb61
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/introspection/MoxyLoaderTest.java
@@ -0,0 +1,77 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.introspection;
+
+import org.junit.Test;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.restcore.MediaType;
+
+import static org.junit.Assert.assertEquals;
+
+public class MoxyLoaderTest extends IntrospectorTestSpec {
+
+ /**
+ * Container object.
+ * @throws AAIUnknownObjectException
+ */
+ @Test
+ public void testMethodsForExceptions() throws AAIUnknownObjectException {
+
+ MoxyLoader loader = (MoxyLoader) LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9);
+ String payload = "{\"att-uuid\":\"wr148d\",\"application\":\"testApp\",\"application-vendor\":\"testVendor\",\"application-version\":\"versionTest\"}";
+ Boolean exceptionThrownForIntrospector = false;
+ Boolean exceptionThrownForLoaderMethods = false;
+ Boolean exceptionThrownForUnmarshalling = false;
+ Boolean exceptionThrownForObjectFromName = false;
+ try {
+ loader.getAllObjects();
+ loader.getJAXBContext();
+ }catch(Exception e){
+ exceptionThrownForLoaderMethods = true;
+ }
+ try{
+ loader.introspectorFromName("TEST");
+ }catch(Exception e){
+ exceptionThrownForIntrospector = true;
+ }
+ try {
+ loader.unmarshal("vnf-image", payload, MediaType.APPLICATION_JSON_TYPE);
+ loader.unmarshal("vnf-image", null, MediaType.APPLICATION_JSON_TYPE);
+ loader.unmarshal("vnf-image", "{}", MediaType.APPLICATION_JSON_TYPE);
+ }catch(Exception e){
+ exceptionThrownForUnmarshalling = true;
+ }
+ try{
+ loader.objectFromName(null);
+ loader.objectFromName("test");
+ }catch(Exception e) {
+ exceptionThrownForObjectFromName = true;
+ }
+
+ assertEquals(false, exceptionThrownForLoaderMethods);
+ assertEquals(true, exceptionThrownForIntrospector);
+ assertEquals(true, exceptionThrownForUnmarshalling);
+ assertEquals(true, exceptionThrownForObjectFromName);
+
+ }
+
+
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/PojoStrategyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/PojoStrategyTest.java
index d30b51b0..1c68d087 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/PojoStrategyTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/PojoStrategyTest.java
@@ -39,4 +39,69 @@ public class PojoStrategyTest {
assertEquals("", volumegroup.getMetadata(ObjectMetadata.NAMESPACE));
}
+ @Test
+ public void testGetWithBogusValue(){
+ Introspector cloudregion = IntrospectorFactory.newInstance(ModelType.POJO, new CloudRegion());
+ assertEquals(null, cloudregion.get("test"));
+ }
+
+ @Test
+ public void testSetWithValue(){
+ Introspector cloudregion = IntrospectorFactory.newInstance(ModelType.POJO, new CloudRegion());
+ cloudregion.set("cloudOwner", "test");
+ assertEquals("test", cloudregion.get("cloudOwner"));
+ }
+
+ @Test
+ public void testHasProperty(){
+ Introspector cloudregion = IntrospectorFactory.newInstance(ModelType.POJO, new CloudRegion());
+ assertEquals( true, cloudregion.hasProperty("test"));
+ }
+
+ @Test
+ public void testMethodsforExceptions(){
+ PojoStrategy ps = new PojoStrategy(new CloudRegion());
+ Exception ex = null;
+ Boolean exceptionThrownForKeys = false;
+ Boolean exceptionThrownForProcessKeys = false;
+ try{
+ ps.findKey();
+ ps.getKeys();
+ }catch(Exception e){
+ exceptionThrownForKeys= true;
+ }
+ try {
+ ps.getProperties();
+ ps.getRequiredProperties();
+ ps.getClass("TEST");
+ ps.getGenericTypeClass("TEST");
+ ps.getJavaClassName();
+ ps.getUnderlyingObject();
+ ps.clone();
+ ps.getChildName();
+ ps.getObjectId();
+ ps.getPropertyMetadata("TEST");
+ ps.getName();
+ ps.getVersion();
+ }catch(Exception e){
+ ex = e;
+ }
+
+
+ try{
+ ps.preProcessKey("TEST/TEST/TEST");
+ }catch(Exception e){
+ exceptionThrownForProcessKeys = true;
+ }
+ try{
+ ps.set("TEST", new Object());
+ }catch(Exception e){
+
+ }
+ assertEquals(null, ex);
+ assertEquals(true, exceptionThrownForKeys);
+ assertEquals(true, exceptionThrownForProcessKeys);
+ }
+
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/VersionTest.java b/aai-core/src/test/java/org/onap/aai/introspection/VersionTest.java
new file mode 100644
index 00000000..3fec8701
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/introspection/VersionTest.java
@@ -0,0 +1,50 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.introspection;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.endsWith;
+import static org.junit.Assert.*;
+
+public class VersionTest {
+
+ @Test
+ public void isLatest() throws Exception {
+ assertTrue(Version.isLatest(Version.getVersion("latest")));
+ }
+
+ @Test
+ public void getLatest() throws Exception {
+ assertEquals(Version.getVersion("latest"), Version.getLatest());
+ }
+
+ @Test
+ public void getVersionLatestString() throws Exception {
+ assertEquals(Version.getLatest(), Version.getVersion("latest"));
+ }
+
+ @Test
+ public void getVersion() throws Exception {
+ assertEquals(Version.v13, Version.getVersion("v13"));
+ }
+
+} \ No newline at end of file
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java b/aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java
new file mode 100644
index 00000000..8c373052
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java
@@ -0,0 +1,118 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.introspection.generator;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class CreateExampleTest extends AAISetup {
+
+ private static CreateExample createExample;
+ private static Loader loader;
+
+ @BeforeClass
+ public static void setUp() {
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v11);
+ createExample = new CreateExample(loader, "edge-prop-names");
+ }
+
+ @Test
+ public void testGetExampleObject() throws AAIException {
+ Introspector introspector = loader.introspectorFromName("edge-prop-names");
+ Introspector res = createExample.getExampleObject();
+ assertEquals(introspector.getName(), res.getName());
+ }
+
+ @Test
+ public void testProcessPrimitiveString() throws AAIUnknownObjectException {
+ String propName = "direction";
+ Introspector introspector = loader.introspectorFromName("edge-prop-names");
+ createExample.processPrimitive(propName, introspector);
+ }
+
+ @Test
+ public void testProcessPrimitiveLong() throws AAIUnknownObjectException {
+ String propName = "vlan-id-inner";
+ Introspector introspector = loader.introspectorFromName("ctag-assignment");
+ createExample.processPrimitive(propName, introspector);
+ }
+
+ @Test
+ public void testProcessPrimitiveBoolean() throws AAIUnknownObjectException {
+ String propName = "in-maint";
+ Introspector introspector = loader.introspectorFromName("vserver");
+ createExample.processPrimitive(propName, introspector);
+ }
+
+ @Test
+ public void testProcessPrimitiveInteger() throws AAIUnknownObjectException {
+ String propName = "module-index";
+ Introspector introspector = loader.introspectorFromName("vf-module");
+ createExample.processPrimitive(propName, introspector);
+ }
+
+ @Test
+ public void testProcessPrimitiveList() throws AAIUnknownObjectException {
+ String propName = "ipaddress-v4-vig";
+ Introspector introspector = loader.introspectorFromName("vig-server");
+ createExample.processPrimitiveList(propName, introspector);
+ }
+
+ @Test
+ public void testProcessComplexObj() {
+ // empty method
+ Introspector introspector = Mockito.mock(Introspector.class);
+ createExample.processComplexObj(introspector);
+ }
+
+ @Test
+ public void testModifyComplexList() {
+ // empty method
+ List<Introspector> introList = new ArrayList<Introspector>();
+ List<Object> objList = new ArrayList<Object>();
+ Introspector introspector = Mockito.mock(Introspector.class);
+ createExample.modifyComplexList(introList, objList, introspector, introspector);
+ }
+
+ @Test
+ public void testCreateComplexObjIfNull() {
+ boolean res = createExample.createComplexObjIfNull();
+ assertTrue(res);
+ }
+
+ @Test
+ public void testCreateComplexListSize() {
+ Introspector introspector = Mockito.mock(Introspector.class);
+ int res = createExample.createComplexListSize(introspector, introspector);
+ assertEquals(1, res);
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java
index 250c34cd..27efbdb2 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java
@@ -28,6 +28,8 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.junit.*;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.aai.db.props.AAIProperties;
@@ -48,25 +50,36 @@ import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+@RunWith(value = Parameterized.class)
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();
+ @Rule public ExpectedException thrown = ExpectedException.none();
+
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
@BeforeClass
@@ -75,16 +88,11 @@ public class DataCopyTest {
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")
+ graph.traversal().addV("aai-node-type", "model", "model-invariant-id", "key1", AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key1").as("v1")
+ .addV("aai-node-type", "model-ver", "model-ver", "myValue", "model-version-id", "key2", "model-version", "testValue", AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key1/model-vers/model-ver/key2")
.addOutE("org.onap.relationships.inventory.BelongsTo", "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")
+ .addV("aai-node-type", "model", "model-invariant-id", "key3", AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3").as("v2")
+ .addV("aai-node-type", "model-ver", "model-ver", "myValue", "model-version-id", "key4", AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3/model-vers/model-ver/key4")
.addOutE("org.onap.relationships.inventory.BelongsTo", "v2", EdgeProperty.CONTAINS.toString(), true)
.next();
graph.tx().commit();
@@ -99,6 +107,10 @@ public class DataCopyTest {
@Before
public void initMock() {
MockitoAnnotations.initMocks(this);
+ dbEngine = new TitanDBEngine(
+ queryStyle,
+ type,
+ loader);
}
@Test
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java
index 3b58f449..59fe8b86 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java
@@ -27,6 +27,8 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.junit.*;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.aai.AAISetup;
@@ -45,18 +47,20 @@ import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+@RunWith(value = Parameterized.class)
public class DataLinkTest extends AAISetup {
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;
@@ -65,32 +69,39 @@ public class DataLinkTest extends AAISetup {
@Mock private VertexProperty<String> prop;
@Rule
public ExpectedException thrown = ExpectedException.none();
-
+
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
@BeforeClass
public static void setup() throws NoSuchFieldException, SecurityException, Exception {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
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)
+
+ graph.traversal().addV("aai-node-type", "vpn-binding", "vpn-id", "addKey", AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/addKey").as("v1")
+ .addV("aai-node-type", "vpn-binding", "vpn-id", "modifyKey", AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/modifyKey").as("v2")
+ .addV("aai-node-type", "route-target", "global-route-target", "modifyTargetKey", "route-target-role", "modifyRoleKey", "linked", true, AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/modifyKey/route-targets/route-target/modifyTargetKey/modifyRoleKey")
.addOutE("org.onap.relationships.inventory.BelongsTo", "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)
+ .addV("aai-node-type", "vpn-binding", "vpn-id", "deleteKey",AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/deleteKey").as("v3" )
+ .addV("aai-node-type", "route-target", "global-route-target", "deleteTargetKey", "route-target-role", "deleteRoleKey", "linked", true, AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/deleteKey/route-targets/route-target/deleteTargetKey/deleteRoleKey")
.addOutE("org.onap.relationships.inventory.BelongsTo", "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)
+ .addV("aai-node-type", "vpn-binding", "vpn-id", "getKey", AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKey").as("v4")
+ .addV("aai-node-type", "route-target", "global-route-target", "getTargetKey", "route-target-role", "getRoleKey", "linked", true, AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKey/route-targets/route-target/getTargetKeyNoLink/getRoleKeyNoLink")
.addOutE("org.onap.relationships.inventory.BelongsTo", "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")
+ .addV("aai-node-type", "vpn-binding", "vpn-id", "getKeyNoLink", AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKeyNoLink").as("v5")
+ .addV("aai-node-type", "route-target", "global-route-target", "getTargetKeyNoLink", "route-target-role", "getRoleKeyNoLink", AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKeyNoLink/route-targets/route-target/getTargetKeyNoLink/getRoleKeyNoLink")
.addOutE("org.onap.relationships.inventory.BelongsTo", "v5", EdgeProperty.CONTAINS.toString(), true)
.next();
graph.tx().commit();
+
+ graph.traversal().V().has("aai-uri","/network/vpn-bindings/vpn-binding/deleteKey").properties().forEachRemaining(p->System.out.println(p.key() +" : " + p.value()));
}
@AfterClass
@@ -102,6 +113,10 @@ public class DataLinkTest extends AAISetup {
@Before
public void initMock() {
MockitoAnnotations.initMocks(this);
+ dbEngine = new TitanDBEngine(
+ queryStyle,
+ type,
+ loader);
}
@Test
@@ -129,7 +144,6 @@ public class DataLinkTest extends AAISetup {
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();
}
@@ -194,6 +208,7 @@ public class DataLinkTest extends AAISetup {
.has("linked", true)
.hasNext()
);
+
g.tx().rollback();
}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java
new file mode 100644
index 00000000..89b1257f
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/DefaultFieldsTest.java
@@ -0,0 +1,79 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.introspection.tools;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class DefaultFieldsTest extends AAISetup {
+
+ private Loader loader;
+ private Issue issue;
+ private DefaultFields defaultFields;
+
+ @Before
+ public void setup() {
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
+ issue = new Issue();
+ defaultFields = new DefaultFields();
+ }
+
+ @Test
+ public void testDefaultFieldOfPserverIsSucccessfullyResolved() throws AAIUnknownObjectException {
+
+ Introspector pserver = loader.introspectorFromName("pserver");
+ assertNotNull("Unable to load the template introspector", pserver);
+
+ issue.setDetail("Some message");
+ issue.setType(IssueType.MISSING_REQUIRED_PROP);
+ issue.setPropName("in-maint");
+ issue.setIntrospector(pserver);
+
+ boolean isResolved = defaultFields.resolveIssue(issue);
+
+ assertTrue("Unable to resolve the pserver in-maint default field issue", isResolved);
+ assertEquals("Introspector didn't successfully modify the pserver in-maint", false,
+ pserver.getValue("in-maint"));
+ }
+
+ @Test
+ public void testDefaultFieldResolverShouldFailWhenResolveOnNonDefaultField() throws AAIUnknownObjectException {
+
+ Introspector pserver = loader.introspectorFromName("pserver");
+ assertNotNull("Unable to load the template introspector", pserver);
+
+ issue.setDetail("Some message");
+ issue.setType(IssueType.MISSING_REQUIRED_PROP);
+ issue.setPropName("hostname");
+ issue.setIntrospector(pserver);
+
+ boolean isResolved = defaultFields.resolveIssue(issue);
+
+ assertFalse("It shouldn't be resolving this issue as hostname is required key", isResolved);
+ }
+} \ No newline at end of file
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java
new file mode 100644
index 00000000..817934f0
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/InjectKeysFromURITest.java
@@ -0,0 +1,94 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.introspection.tools;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+
+import java.net.URI;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.eclipse.persistence.jpa.jpql.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class InjectKeysFromURITest extends AAISetup {
+
+ private Loader loader;
+ private Issue issue;
+ private InjectKeysFromURI ik;
+
+ @Before
+ public void setup() {
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
+ issue = new Issue();
+ }
+ @Test
+ public void testInjectKeysFromURIOfPserverIsNotResolved() throws AAIUnknownObjectException {
+ try {
+ ik = new InjectKeysFromURI(loader, new URI("/aai/v12/cloud-infrastructure/complexes"));
+ }catch(Exception e) {
+ fail("InjectKeys instantiation threw an exception");
+ }
+
+ Introspector pserver = loader.introspectorFromName("pserver");
+ pserver.setValue("in-maint",false);
+ pserver.setValue("hostname", "pserver2");
+ assertNotNull("Unable to load the template introspector", pserver);
+
+ issue.setDetail("Some message");
+ issue.setType(IssueType.MISSING_KEY_PROP);
+ issue.setPropName("in-maint");
+ issue.setIntrospector(pserver);
+
+ Boolean issueResolved = ik.resolveIssue(issue);
+
+ assertFalse("Unable to resolve the pserver in-maint issue", issueResolved);
+ assertEquals("Introspector didn't successfully modify the pserver in-maint", false,
+ pserver.getValue("in-maint"));
+ }
+ @Test
+ public void testInjectKeysFromURIOfPserverSuccessfullyResolved() throws AAIUnknownObjectException {
+ try {
+ ik = new InjectKeysFromURI(loader, new URI("/aai/v12/cloud-infrastructure/pservers/pserver/pserver1"));
+ }catch(Exception e) {
+ fail("InjectKeys instantiation threw an exception");
+ }
+
+ Introspector pserver = loader.introspectorFromName("pserver");
+ assertNotNull("Unable to load the template introspector", pserver);
+
+ issue.setDetail("Some message");
+ issue.setType(IssueType.MISSING_KEY_PROP);
+ issue.setPropName("hostname");
+ issue.setIntrospector(pserver);
+
+ Boolean issueResolved = ik.resolveIssue(issue);
+
+ assertTrue("Unable to resolve the pserver hostname default field issue", issueResolved);
+ assertEquals("Introspector didn't successfully modify the pserver hostname", "pserver1",
+ pserver.getValue("hostname"));
+ }
+
+} \ No newline at end of file
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java
new file mode 100644
index 00000000..7c0539b8
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java
@@ -0,0 +1,125 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.introspection.tools;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.eclipse.persistence.jpa.jpql.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class IntrospectorValidatorTest extends AAISetup {
+
+ private Loader loader;
+ private Issue issue;
+ private Introspector introspector;
+ private IntrospectorValidator.Builder b;
+ private IntrospectorValidator iv;
+
+ @Before
+ public void setup() {
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
+ issue = new Issue();
+ try {
+ introspector = loader.introspectorFromName("pserver");
+ }catch(Exception e){
+ fail("Introspector instantiation call threw an exception " + e);
+ }
+ b = new IntrospectorValidator.Builder();
+ iv = b.build();
+
+ b.addResolver(new IssueResolver() {
+ @Override
+ public boolean resolveIssue(Issue issue) {
+ return true;
+ }
+ });
+ //this method does nothing
+ iv.processPrimitiveList("TEST",introspector);
+ }
+
+ public void setupIssue(String message, IssueType type, String propName, Introspector introspector){
+ issue.setDetail(message);
+ issue.setType(type);
+ issue.setPropName(propName);
+ issue.setIntrospector(introspector);
+ }
+
+ @Test
+ public void testIntrospectorValidatorMaxDepth() throws AAIUnknownObjectException {
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ b.restrictDepth(4);
+ assertEquals("Maximum Depth should be 4", 4, b.getMaximumDepth());
+ }
+
+ @Test
+ public void testIntrospectorValidatorValidationRequired() throws AAIUnknownObjectException {
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ b.validateRequired(true);
+ assertTrue("Validation should be required", b.getValidateRequired());
+ }
+
+ @Test
+ public void testIntrospectorValidatorValidatedFalse() throws AAIUnknownObjectException{
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ try {
+ assertFalse("Not currently validated", iv.validate(introspector));
+ }catch (Exception e){
+ fail("Introspector validate call threw an exception " + e);
+ }
+ }
+
+ @Test
+ public void testIntrospectorValidatorResolveIssues() throws AAIUnknownObjectException{
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ assertTrue("Introspector call to resolve issues should return true", iv.resolveIssues());
+ }
+
+ @Test
+ public void testIntrospectorValidatorGetIssues() throws AAIUnknownObjectException{
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ iv.getIssues();
+ }
+
+ @Test
+ public void testIntrospectorValidatorProcessComplexObject() throws AAIUnknownObjectException{
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ iv.processComplexObj(introspector);
+ }
+
+ @Test
+ public void testIntrospectorValidatorCreateComplexListSize() throws AAIUnknownObjectException{
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ assertEquals("create complex list size should return 0", 0, iv.createComplexListSize(introspector, introspector));
+ }
+
+ @Test
+ public void testIntrospectorValidatorGetResolvers() throws AAIUnknownObjectException{
+ setupIssue("Some message", IssueType.MISSING_REQUIRED_PROP, "hostname", introspector );
+ assertNotNull("Get resolvers should not be null", b.getResolvers());
+ }
+
+} \ No newline at end of file
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java
new file mode 100644
index 00000000..cddaf649
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/RemoveNonVisiblePropertyTest.java
@@ -0,0 +1,70 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.introspection.tools;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
+
+public class RemoveNonVisiblePropertyTest extends AAISetup {
+
+ private Loader loader;
+ private Issue issue;
+ private RemoveNonVisibleProperty rn;
+
+ @Before
+ public void setup(){
+ rn = new RemoveNonVisibleProperty();
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
+ }
+
+ @Test
+ public void testNonVisiblePropertyResolved() throws AAIUnknownObjectException {
+ Introspector introspector = loader.introspectorFromName("pserver");
+ issue = new Issue();
+ issue.setDetail("Some message");
+ issue.setType(IssueType.PROPERTY_NOT_VISIBLE);
+ issue.setPropName("in-maint");
+ issue.setIntrospector(introspector);
+ assertTrue("Nonvisible property should be removed", rn.resolveIssue(issue));
+ assertNull("Introspector did not remove the non visible property", introspector.getValue("in-maint"));
+ }
+
+ @Test
+ public void testNonVisiblePropertyNotResolved() throws AAIUnknownObjectException {
+ Introspector introspector = loader.introspectorFromName("pserver");
+ issue = new Issue();
+ issue.setDetail("Some message");
+ issue.setType(IssueType.MISSING_REQUIRED_PROP);
+ issue.setPropName("in-maint");
+ issue.setIntrospector(introspector);
+ assertFalse("Nonvisible property not present so should not have been removed", rn.resolveIssue(issue));
+ }
+
+
+} \ No newline at end of file
diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java
index b1ddcf6c..02e9efa1 100644
--- a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java
+++ b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java
@@ -27,6 +27,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAISetup;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
@@ -44,6 +46,8 @@ import javax.ws.rs.core.UriBuilder;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import static org.hamcrest.CoreMatchers.containsString;
@@ -51,13 +55,23 @@ import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
+@RunWith(value = Parameterized.class)
public class GraphTraversalTest extends AAISetup {
private TransactionalGraphEngine dbEngine;
private TransactionalGraphEngine dbEnginev9;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
+
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
+ @Rule public ExpectedException thrown = ExpectedException.none();
/**
* Configure.
@@ -68,12 +82,12 @@ public class GraphTraversalTest extends AAISetup {
@Before
public void configure() throws Exception {
dbEngine =
- new TitanDBEngine(QueryStyle.TRAVERSAL,
+ new TitanDBEngine(queryStyle,
LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST),
false);
dbEnginev9 =
- new TitanDBEngine(QueryStyle.TRAVERSAL,
+ new TitanDBEngine(queryStyle,
LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9),
false);
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
new file mode 100644
index 00000000..97255f9e
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
@@ -0,0 +1,130 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.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.onap.aai.AAISetup;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.db.EdgeType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+public class ExcludeQueryTest 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.createEdgeTraversal(EdgeType.TREE, "cloud-region","availability-zone").getVerticesExcludeByProperty("hypervisor-type", "hypervisortype-11").store("x").cap("x").unfold().dedup();
+ }
+
+ @Test
+ public void gremlinQueryExcludeTest() throws AAIException {
+ Graph graph = TinkerGraph.open();
+ EdgeRules rules = EdgeRules.getInstance();
+ GraphTraversalSource g = graph.traversal();
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
+ Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+ Vertex availibityzone11 = graph.addVertex(T.label, "availability-zone", T.id, "11", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-11", "hypervisor-type", "hypervisortype-11");
+
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
+ Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
+ Vertex availibityzone12 = graph.addVertex(T.label, "availability-zone", T.id, "12", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-12", "hypervisor-type", "hypervisortype-12");
+
+ rules.addTreeEdge(g, cloudregion, availibityzone);
+ rules.addTreeEdge(g, cloudregion, availibityzone11);
+
+
+
+ rules.addTreeEdge(g, cloudregion1, availibityzone1);
+ rules.addTreeEdge(g, cloudregion1, availibityzone12);
+
+ List<Vertex> expected = new ArrayList<>();
+ expected.add(availibityzone);
+
+ GremlinTraversal<Vertex> qb = new GremlinTraversal<>(loader, g, cloudregion);
+ QueryBuilder q = buildTestQuery(qb);
+
+ List<Vertex> results = q.toList();
+
+ assertTrue("results match", expected.containsAll(results) && results.containsAll(expected));
+ }
+
+ @Test
+ public void traversalQueryExcludeTest() throws AAIException {
+ Graph graph = TinkerGraph.open();
+ EdgeRules rules = EdgeRules.getInstance();
+ GraphTraversalSource g = graph.traversal();
+
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
+ Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+ Vertex availibityzone11 = graph.addVertex(T.label, "availability-zone", T.id, "11", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-11", "hypervisor-type", "hypervisortype-11");
+
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
+ Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
+ Vertex availibityzone12 = graph.addVertex(T.label, "availability-zone", T.id, "12", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-12", "hypervisor-type", "hypervisortype-12");
+
+ rules.addTreeEdge(g, cloudregion, availibityzone);
+ rules.addTreeEdge(g, cloudregion, availibityzone11);
+
+
+
+ rules.addTreeEdge(g, cloudregion1, availibityzone1);
+ rules.addTreeEdge(g, cloudregion1, availibityzone12);
+
+ List<Vertex> expected = new ArrayList<>();
+ expected.add(availibityzone);
+
+
+
+
+ TraversalQuery<Vertex> qb = new TraversalQuery<>(loader, g, cloudregion);
+ 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/onap/aai/query/builder/GremlinTraversalTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
index 98ac0dee..3632543f 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
@@ -19,28 +19,39 @@
*/
package org.onap.aai.query.builder;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
public class GremlinTraversalTest extends QueryBuilderTestAbstraction {
@Override
- protected QueryBuilder<Edge> getNewEdgeTraversal(Vertex v) {
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
return new GremlinTraversal<>(loader, g, v, testEdgeRules);
}
@Override
- protected QueryBuilder<Edge> getNewEdgeTraversal() {
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
return new GremlinTraversal<>(loader, g, testEdgeRules);
}
@Override
- protected QueryBuilder<Vertex> getNewVertexTraversal(Vertex v) {
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
return new GremlinTraversal<>(loader, g, v, testEdgeRules);
}
@Override
- protected QueryBuilder<Vertex> getNewVertexTraversal() {
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
+ return new GremlinTraversal<>(loader, g, testEdgeRules);
+ }
+
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
+ return new GremlinTraversal<>(loader, g, v, testEdgeRules);
+ }
+
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
return new GremlinTraversal<>(loader, g, testEdgeRules);
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
index bd8f078a..9cdab403 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
@@ -19,17 +19,10 @@
*/
package org.onap.aai.query.builder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
+import com.thinkaurelius.titan.core.TitanFactory;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -42,10 +35,15 @@ import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.serialization.db.EdgeType;
-
-import com.thinkaurelius.titan.core.TitanFactory;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
public abstract class QueryBuilderTestAbstraction extends AAISetup {
protected static Loader loader;
@@ -83,7 +81,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Vertex vnfc = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
testEdgeRules.addEdge(g, gvnf, vnfc, "uses");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
assertEquals(vnfc, tQ.next());
@@ -98,7 +96,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
testEdgeRules.addEdge(g, lInterface, logicalLink, "sourceLInterface");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(lInterface);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
tQ.createEdgeTraversal(EdgeType.COUSIN, "l-interface", "logical-link");
Vertex next = tQ.next();
@@ -107,7 +105,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
}
-
+
@Test
public void createEdgeLinterfaceToLogicalLinkIntrospectorTraversal() throws AAIException {
@@ -115,7 +113,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
testEdgeRules.addEdge(g, lInterface, logicalLink, "sourceLInterface");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(lInterface);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
tQ.createEdgeTraversal(EdgeType.COUSIN, loader.introspectorFromName("l-interface"), loader.introspectorFromName("logical-link"));
Vertex next = tQ.next();
@@ -132,7 +130,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Vertex logicalLink = g.addV("aai-node-type","logical-link","link-name","logical-link-a").next();
testEdgeRules.addEdge(g, lInterface, logicalLink, "sourceLInterface");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(lInterface);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
tQ.createEdgeTraversal(EdgeType.COUSIN, lInterface, loader.introspectorFromName("logical-link"));
Vertex next = tQ.next();
@@ -150,7 +148,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, gvnf, vnfc1);
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
List<Vertex> list = tQ.toList();
@@ -169,10 +167,10 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, vce, vnfc1);
- QueryBuilder<Vertex> tQ1 = getNewVertexTraversal(vce);
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "vnfc");
- QueryBuilder<Vertex> tQ2 = getNewVertexTraversal(vnfc1);
+ QueryBuilder<Vertex> tQ2 = getNewVertexTraversalWithTestEdgeRules(vnfc1);
tQ2.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "vce");
List<Vertex> list1 = tQ1.toList();
@@ -194,7 +192,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, vce, pserver);
- QueryBuilder<Vertex> tQ1 = getNewVertexTraversal(vce);
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
tQ1.createEdgeTraversal(EdgeType.COUSIN, "vce", "pserver");
List<Vertex> list = tQ1.toList();
@@ -215,7 +213,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, gvnf, vnfc1);
testEdgeRules.addEdge(g, gvnf, vnfc2, "re-uses");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "vnfc");
List<Vertex> list = tQ.toList();
@@ -237,7 +235,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, gvnf, vnfc1);
testEdgeRules.addEdge(g, pserver, vnfc1);
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(vnfc1);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(vnfc1);
tQ.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "generic-vnf");
List<Vertex> list = tQ.toList();
@@ -305,7 +303,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, gvnf, pserver);
testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").dedup();
List<Vertex> list = tQ.toList();
@@ -345,7 +343,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, gvnf, pserver);
testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver").store("x").cap("x").unfold();
List<Vertex> list = tQ.toList();
@@ -385,7 +383,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, gvnf, pserver);
testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver");
List<Vertex> list = tQ.toList();
@@ -405,7 +403,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
testEdgeRules.addEdge(g, gvnf, complex);
testEdgeRules.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "complex");
List<Vertex> list = tQ.toList();
@@ -424,7 +422,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e = testEdgeRules.addEdge(g, vce, pserver);
- QueryBuilder<Edge> tQ1 = getNewEdgeTraversal(vce);
+ QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce);
tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "pserver");
List<Edge> list = tQ1.toList();
@@ -443,7 +441,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e = testEdgeRules.addEdge(g, vce, vnfc1);
- QueryBuilder<Edge> tQ1 = getNewEdgeTraversal(vce);
+ QueryBuilder<Edge> tQ1 = getNewEdgeTraversalWithTestEdgeRules(vce);
tQ1.getEdgesBetween(EdgeType.COUSIN, "vce", "vnfc");
List<Edge> list1 = tQ1.toList();
@@ -463,7 +461,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e1 = testEdgeRules.addEdge(g, gvnf, pserver);
Edge e2 = testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "pserver");
List<Edge> list = tQ.toList();
@@ -484,7 +482,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e1 = testEdgeRules.addEdge(g, gvnf, complex);
Edge e2 = testEdgeRules.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "complex");
List<Edge> list = tQ.toList();
@@ -506,7 +504,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e1 = testEdgeRules.addEdge(g, gvnf, vnfc1);
Edge e2 = testEdgeRules.addEdge(g, gvnf, vnfc2, "re-uses");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetween(EdgeType.COUSIN, "generic-vnf", "vnfc");
List<Edge> list = tQ.toList();
@@ -524,10 +522,10 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e1 = testEdgeRules.addEdge(g, gvnf, pserver);
- Edge e2 = testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ testEdgeRules.addEdge(g, gvnf, pserver);
+ testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.emptyList());
}
@@ -541,7 +539,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e1 = testEdgeRules.addEdge(g, gvnf, pserver);
Edge e2 = testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.singletonList("generic-vnf-pserver-B"));
List<Edge> list = tQ.toList();
@@ -561,7 +559,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e1 = testEdgeRules.addEdge(g, gvnf, pserver);
Edge e2 = testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Arrays.asList("generic-vnf-pserver-B", "generic-vnf-pserver-A"));
List<Edge> list = tQ.toList();
@@ -577,10 +575,10 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Vertex gvnf = getVertex();
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.emptyList());
- List<Edge> list = tQ.toList();
+ tQ.toList();
}
@@ -589,8 +587,8 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Vertex gvnf = g.addV("aai-node-type","generic-vnf","vnf-id","gvnf").next();
Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
- Edge e1 = testEdgeRules.addEdge(g, gvnf, pserver);
- Edge e2 = testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
+ testEdgeRules.addEdge(g, gvnf, pserver);
+ testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
return gvnf;
}
@@ -603,7 +601,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e1 = testEdgeRules.addEdge(g, gvnf, pserver);
Edge e2 = testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Collections.singletonList("generic-vnf-pserver-B"));
List<Edge> list = tQ.toList();
@@ -623,7 +621,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
Edge e1 = testEdgeRules.addEdge(g, gvnf, pserver);
Edge e2 = testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Edge> tQ = getNewEdgeTraversal(gvnf);
+ QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.getEdgesBetweenWithLabels(EdgeType.COUSIN, "generic-vnf", "pserver", Arrays.asList("generic-vnf-pserver-B", "generic-vnf-pserver-A"));
List<Edge> list = tQ.toList();
@@ -634,13 +632,17 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup {
}
- protected abstract QueryBuilder<Edge> getNewEdgeTraversal(Vertex v);
+ protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v);
- protected abstract QueryBuilder<Edge> getNewEdgeTraversal();
+ protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules();
- protected abstract QueryBuilder<Vertex> getNewVertexTraversal(Vertex v);
+ protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v);
- protected abstract QueryBuilder<Vertex> getNewVertexTraversal();
+ protected abstract QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules();
+
+ protected abstract QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v);
+
+ protected abstract QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules();
}
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
index d5a0e4ab..1eeca6f0 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
@@ -19,16 +19,9 @@
*/
package org.onap.aai.query.builder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
@@ -36,63 +29,86 @@ import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.serialization.db.EdgeType;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class TraversalQueryTest extends QueryBuilderTestAbstraction {
@Override
- protected QueryBuilder<Edge> getNewEdgeTraversal(Vertex v) {
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v) {
return new TraversalQuery<>(loader, g, v, testEdgeRules);
}
@Override
- protected QueryBuilder<Edge> getNewEdgeTraversal() {
+ protected QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules() {
return new TraversalQuery<>(loader, g, testEdgeRules);
}
@Override
- protected QueryBuilder<Vertex> getNewVertexTraversal(Vertex v) {
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules(Vertex v) {
return new TraversalQuery<>(loader, g, v, testEdgeRules);
}
@Override
+ protected QueryBuilder<Vertex> getNewVertexTraversalWithTestEdgeRules() {
+ return new TraversalQuery<>(loader, g, testEdgeRules);
+ }
+
+
protected QueryBuilder<Vertex> getNewVertexTraversal() {
+ return new TraversalQuery<>(loader, g);
+ }
+
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules(Vertex v) {
+ return new TraversalQuery<>(loader, g, v, testEdgeRules);
+ }
+
+ @Override
+ protected QueryBuilder<Tree> getNewTreeTraversalWithTestEdgeRules() {
return new TraversalQuery<>(loader, g, testEdgeRules);
}
@Test
public void unionQuery() {
- QueryBuilder<Vertex> tQ = new TraversalQuery<>(loader, g);
- QueryBuilder<Vertex> tQ2 = new TraversalQuery<>(loader, g);
- QueryBuilder<Vertex> tQ3 = new TraversalQuery<>(loader, g);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversal();
+ QueryBuilder<Vertex> tQ2 = getNewVertexTraversal();
+ QueryBuilder<Vertex> tQ3 = getNewVertexTraversal();
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());
-
+
}
@Test
public void traversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
- QueryBuilder<Vertex> tQ = new TraversalQuery<>(loader, g);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversal();
QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1")).getQueryBuilder();
GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf");
GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start().has("aai-node-type", "generic-vnf");
-
+
assertEquals("query object", expected.toString(), builder.getQuery().toString());
assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString());
-
+
}
@Test
public void nestedTraversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
-
- QueryBuilder<Vertex> tQ = new TraversalQuery<>(loader, g);
+
+ QueryBuilder<Vertex> tQ = getNewVertexTraversal();
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")
@@ -119,7 +135,7 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
testEdgeRules.addEdge(g, gvnf, vnfc1);
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
List<Vertex> list = tQ.toList();
@@ -138,10 +154,10 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
testEdgeRules.addEdge(g, vce, vnfc1);
- QueryBuilder<Vertex> tQ1 = new TraversalQuery<>(loader, g, vce, testEdgeRules);
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
tQ1.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
- QueryBuilder<Vertex> tQ2 = new TraversalQuery<>(loader, g, vnfc1, testEdgeRules);
+ QueryBuilder<Vertex> tQ2 = getNewVertexTraversalWithTestEdgeRules(vnfc1);
tQ2.createEdgeTraversal(EdgeType.COUSIN, "vnfc", "vnf");
List<Vertex> list1 = tQ1.toList();
@@ -163,7 +179,7 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
testEdgeRules.addEdge(g, vce, pserver);
- QueryBuilder<Vertex> tQ1 = new TraversalQuery<>(loader, g, vce, testEdgeRules);
+ QueryBuilder<Vertex> tQ1 = getNewVertexTraversalWithTestEdgeRules(vce);
tQ1.createEdgeTraversal(EdgeType.COUSIN, "vnf", "pserver");
List<Vertex> list = tQ1.toList();
@@ -184,7 +200,7 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
testEdgeRules.addEdge(g, gvnf, vnfc1);
testEdgeRules.addEdge(g, gvnf, vnfc2, "re-uses");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "vnfc");
List<Vertex> list = tQ.toList();
@@ -205,7 +221,7 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
testEdgeRules.addEdge(g, gvnf, pserver);
testEdgeRules.addEdge(g, gvnf, pserver, "generic-vnf-pserver-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "pserver");
List<Vertex> list = tQ.toList();
@@ -225,7 +241,7 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
testEdgeRules.addEdge(g, gvnf, complex);
testEdgeRules.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
- QueryBuilder<Vertex> tQ = getNewVertexTraversal(gvnf);
+ QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "vnf", "complex");
List<Vertex> list = tQ.toList();
@@ -235,7 +251,7 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
}
-
-
+
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/CloudRegionTest.java b/aai-core/src/test/java/org/onap/aai/rest/CloudRegionTest.java
index 5abe4daf..6ffc10f6 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/CloudRegionTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/CloudRegionTest.java
@@ -24,14 +24,18 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAIJunitRunner;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.core.Response;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
import static org.junit.Assert.assertEquals;
@@ -40,14 +44,24 @@ import static org.junit.Assert.assertEquals;
* children nodes associated to it then you should be able to
* remove the cloud region without removing the individual child nodes first
*/
-@RunWith(AAIJunitRunner.class)
+@RunWith(value = AAIJunitRunner.class)
public class CloudRegionTest {
private HttpTestUtil httpTestUtil;
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
@Before
public void setUp(){
- httpTestUtil = new HttpTestUtil();
+ httpTestUtil = new HttpTestUtil(queryStyle);
}
@Ignore("Test is failing due to the deletion of node with children not correct will be fixed soon")
@@ -70,5 +84,4 @@ public class CloudRegionTest {
response = httpTestUtil.doDelete(cloudRegionUri, resourceVersion);
assertEquals("Expected the cloud region to be deleted", 204, response.getStatus());
}
-
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/GenericVnfLInterfaceTest.java b/aai-core/src/test/java/org/onap/aai/rest/GenericVnfLInterfaceTest.java
index 9f8045b8..14ff6d5a 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/GenericVnfLInterfaceTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/GenericVnfLInterfaceTest.java
@@ -23,25 +23,40 @@ import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAIJunitRunner;
+import org.onap.aai.AAISetup;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
-@RunWith(AAIJunitRunner.class)
-public class GenericVnfLInterfaceTest {
+@RunWith(value = AAIJunitRunner.class)
+public class GenericVnfLInterfaceTest extends AAISetup {
private HttpTestUtil httpTestUtil;
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
@Before
public void setUp(){
- httpTestUtil = new HttpTestUtil();
+ httpTestUtil = new HttpTestUtil(queryStyle);
}
@Test
@@ -57,7 +72,8 @@ public class GenericVnfLInterfaceTest {
response = httpTestUtil.doGet("/aai/v12/network/generic-vnfs/generic-vnf/vnf1");
assertEquals("Expecting the generic vnf to be updated", 200, response.getStatus());
- resource = response.getEntity().toString().replaceAll("ipv1\",\"resource-version\":\"\\d+\"", "ipv2\"");
+ resource = response.getEntity().toString();
+ resource = resource.replaceAll("ipv1\",\"resource-version\":\"\\d+\"", "ipv2\"");
response = httpTestUtil.doPut("/aai/v12/network/generic-vnfs/generic-vnf/vnf1", resource);
assertEquals("Expecting the generic vnf to be updated", 200, response.getStatus());
diff --git a/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java b/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java
index ed7d8e36..279b9c73 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java
@@ -25,20 +25,17 @@ import com.jayway.jsonpath.JsonPath;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAIJunitRunner;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
-import org.onap.aai.introspection.*;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.core.Response;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
@RunWith(AAIJunitRunner.class)
public class HPACapabilityTest {
@@ -47,9 +44,19 @@ public class HPACapabilityTest {
private HttpTestUtil httpTestUtil;
private Map<String, String> templateValuesMap;
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
@Before
public void setup() {
- httpTestUtil = new HttpTestUtil();
+ httpTestUtil = new HttpTestUtil(queryStyle);
templateValuesMap = new HashMap<>();
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java b/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java
index d97c706b..32c7483f 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java
@@ -25,29 +25,43 @@ import com.jayway.jsonpath.JsonPath;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAIJunitRunner;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
import org.onap.aai.introspection.*;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-@RunWith(AAIJunitRunner.class)
+@RunWith(value = AAIJunitRunner.class)
public class PserverTest {
private static EELFLogger logger = EELFManager.getInstance().getLogger(PserverTest.class);
private HttpTestUtil httpTestUtil;
private Map<String, String> relationshipMap;
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
@Before
- public void setup(){
- httpTestUtil = new HttpTestUtil();
+ public void setUp(){
+ httpTestUtil = new HttpTestUtil(queryStyle);
relationshipMap = new HashMap<>();
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/TenantTest.java b/aai-core/src/test/java/org/onap/aai/rest/TenantTest.java
index d454c783..72ea49ad 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/TenantTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/TenantTest.java
@@ -24,28 +24,37 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAIJunitRunner;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
import javax.ws.rs.core.Response;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
import static org.junit.Assert.assertEquals;
-@RunWith(AAIJunitRunner.class)
+@RunWith(value = AAIJunitRunner.class)
public class TenantTest {
private HttpTestUtil httpTestUtil;
-
private Map<String, String> templateValuesMap;
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
@Before
- public void setup(){
- httpTestUtil = new HttpTestUtil();
+ public void setUp(){
+ httpTestUtil = new HttpTestUtil(queryStyle);
templateValuesMap = new HashMap<>();
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
index cf6f1774..6ff75c7f 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
@@ -19,41 +19,40 @@
*/
package org.onap.aai.rest.db;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.javatuples.Pair;
import org.junit.Before;
import org.junit.FixMethodOrder;
-import org.junit.runners.MethodSorters;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.junit.runners.Parameterized;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
-import org.onap.aai.domain.yang.Pserver;
-import org.onap.aai.domain.yang.Pservers;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import javax.ws.rs.core.*;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.*;
-import java.util.stream.Collectors;
-
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.when;
+@RunWith(value = Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class HttpEntryTest extends AAISetup {
@@ -67,6 +66,16 @@ public class HttpEntryTest extends AAISetup {
VALID_HTTP_STATUS_CODES.add(204);
}
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
private HttpHeaders httpHeaders;
private UriInfo uriInfo;
@@ -114,7 +123,7 @@ public class HttpEntryTest extends AAISetup {
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
- private Response getResponse(HttpEntry httpEntry, Loader loader, TransactionalGraphEngine dbEngine, HttpMethod method, String uri, String content) throws UnsupportedEncodingException, AAIException {
+ private Response doRequest(HttpEntry httpEntry, Loader loader, TransactionalGraphEngine dbEngine, HttpMethod method, String uri, String content) throws UnsupportedEncodingException, AAIException {
URI uriObject = UriBuilder.fromPath(uri).build();
QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
String objType = uriQuery.getResultType();
@@ -144,13 +153,13 @@ public class HttpEntryTest extends AAISetup {
public void test1PutOnPserver() throws UnsupportedEncodingException, AAIException {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
String content = "{\"hostname\":\"junit-test1\"}";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
dbEngine.commit();
assertEquals("Expected the pserver to be created", 201, response.getStatus());
}
@@ -159,13 +168,13 @@ public class HttpEntryTest extends AAISetup {
public void test2PutOnPserverNoPInterface() throws UnsupportedEncodingException, AAIException {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
String uri = "/cloud-infrastructure/pservers/pserver/junit-test2";
String content = "{\"hostname\":\"junit-test2\"}";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
dbEngine.commit();
assertEquals("Expected the pserver to be created", 201, response.getStatus());
}
@@ -174,13 +183,13 @@ public class HttpEntryTest extends AAISetup {
public void test3PutOnPInterface() {
try {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
String uri = "/cloud-infrastructure/pservers/pserver/junit-test1/p-interfaces/p-interface/p1";
String content = "{\"interface-name\":\"p1\"}";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
dbEngine.commit();
assertEquals("Expected the p-interface to be created", 201, response.getStatus());
} catch (UnsupportedEncodingException | AAIException e) {
@@ -195,7 +204,7 @@ public class HttpEntryTest extends AAISetup {
public void test4GetOnPserver() throws UnsupportedEncodingException, AAIException {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
@@ -203,7 +212,7 @@ public class HttpEntryTest extends AAISetup {
String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
String content = "{\"hostname\":\"junit-test1\", \"equip-type\":\"junit-equip-type\"}";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
dbEngine.commit();
assertEquals("Expected the pserver to be returned", 200, response.getStatus());
}
@@ -212,13 +221,13 @@ public class HttpEntryTest extends AAISetup {
public void test5MergePatchOnPserver() throws UnsupportedEncodingException, AAIException {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
String content = "{\"hostname\":\"junit-test1\", \"equip-type\":\"junit-equip-type\"}";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.MERGE_PATCH, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.MERGE_PATCH, uri, content);
dbEngine.commit();
assertEquals("Expected the pserver to be updated", 200, response.getStatus());
}
@@ -226,7 +235,7 @@ public class HttpEntryTest extends AAISetup {
private int doDelete(String resourceVersion, String uri, String nodeType) throws UnsupportedEncodingException, AAIException {
queryParameters.add("resource-version", resourceVersion);
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
@@ -256,14 +265,14 @@ public class HttpEntryTest extends AAISetup {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
URI uriObject = UriBuilder.fromPath("/cloud-infrastructure/pservers/pserver/junit-test1").build();
String uri = "/cloud-infrastructure/pservers/pserver/junit-test1";
String content = "";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
dbEngine.commit();
String msg = response.getEntity().toString();
JsonObject jsonObj = new JsonParser().parse(msg).getAsJsonObject();
@@ -279,13 +288,13 @@ public class HttpEntryTest extends AAISetup {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
String uri = "/cloud-infrastructure/pservers/pserver/junit-test2";
String content = "";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
dbEngine.commit();
String msg = response.getEntity().toString();
JsonObject jsonObj = new JsonParser().parse(msg).getAsJsonObject();
@@ -301,13 +310,13 @@ public class HttpEntryTest extends AAISetup {
public void test8FailedGetOnPserver() throws UnsupportedEncodingException, AAIException {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
String uri = "/cloud-infrastructure/pservers/pserver/junit-test2";
String content = "";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
dbEngine.commit();
assertEquals("Expected the pserver to be deleted", 404, response.getStatus());
@@ -317,55 +326,89 @@ public class HttpEntryTest extends AAISetup {
public void putEdgeTest() throws UnsupportedEncodingException, AAIException {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
//Put pserver
String uri = "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver";
String content = "{\"hostname\":\"junit-edge-test-pserver\"}";
- getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
//Put complex
uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex";
content = "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
//PutEdge
uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/relationship-list/relationship";
content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + Version.getLatest().toString() + "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
dbEngine.rollback();
//System.out.println(response.getEntity().toString());
- assertEquals("Expected the pserver to be created", 200, response.getStatus());
+ assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
}
@Test
public void putEdgeWrongLabelTest() throws UnsupportedEncodingException, AAIException {
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
Loader loader = httpEntry.getLoader();
TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
//Put pserver
String uri = "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver";
String content = "{\"hostname\":\"junit-edge-test-pserver\"}";
- getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
//Put complex
uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex";
content = "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
- getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
//PutEdge
uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/relationship-list/relationship";
content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + Version.getLatest().toString() + "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver\",\"relationship-label\":\"junk\"}";
- Response response = getResponse(httpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
dbEngine.rollback();
String msg = response.getEntity().toString();
assertEquals("Expected the pserver to be created", 400, response.getStatus());
- assertTrue(msg.contains("ERR.5.4.6107"));
- assertTrue(msg.contains("Required Edge-property not found in input data:no COUSIN edge rule between complex and pserver with label junk"));
+ assertThat(msg, containsString("ERR.5.4.6107"));
+ assertThat(msg, containsString("Required Edge-property not found in input data:no COUSIN edge rule between complex and pserver with label junk"));
+
+ }
+
+ @Test
+ public void relatedToTest() throws UnsupportedEncodingException, AAIException {
+
+ DBConnectionType type = DBConnectionType.REALTIME;
+ HttpEntry httpEntry = new HttpEntry(Version.getLatest(), ModelType.MOXY, queryStyle, type);
+ Loader loader = httpEntry.getLoader();
+ TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
+
+ //Put pserver
+ String uri = "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver";
+ String content = "{\"hostname\":\"junit-edge-test-pserver\"}";
+ doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+ //Put complex
+ uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex";
+ content = "{\"physical-location-id\":\"junit-edge-test-complex\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
+ doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
+
+ //PutEdge
+ uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/relationship-list/relationship";
+ content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + Version.getLatest().toString() + "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}";
+ doRequest(httpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
+
+ //getRelatedTo
+ uri = "/cloud-infrastructure/complexes/complex/junit-edge-test-complex/related-to/pservers";
+ content = "";
+ Response response = doRequest(httpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
+ String respBody = response.getEntity().toString();
+
+ dbEngine.rollback();
+ assertEquals("Expected the pserver to be created", 200, response.getStatus());
+ assertThat("Related to pserver is returned.", respBody, containsString("\"hostname\":\"junit-edge-test-pserver\""));
}
-}
+} \ No newline at end of file
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java
index e00c7eb3..27d14c94 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java
@@ -27,6 +27,8 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
@@ -42,6 +44,8 @@ import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -49,17 +53,27 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+@RunWith(value = Parameterized.class)
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;
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
@Before
public void setup() throws Exception {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java
index cff374ca..3cf43b4a 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java
@@ -19,40 +19,35 @@
*/
package org.onap.aai.serialization.db;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Field;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-
+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.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.*;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.junit.*;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.onap.aai.AAISetup;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.Introspector;
-import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
+import org.onap.aai.introspection.*;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TitanDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import com.thinkaurelius.titan.core.TitanFactory;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+@RunWith(value = Parameterized.class)
public class DbSerializerTest extends AAISetup {
//to use, set thrown.expect to whatever your test needs
@@ -65,7 +60,6 @@ public class DbSerializerTest extends AAISetup {
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;
@@ -74,15 +68,25 @@ public class DbSerializerTest extends AAISetup {
TransactionalGraphEngine spy;
TransactionalGraphEngine.Admin adminSpy;
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL}
+ });
+ }
+
@BeforeClass
public static void init() throws Exception {
graph = TitanFactory.build().set("storage.backend", "inmemory").open();
- createGraph();
}
@Before
public void setup() throws Exception {
+ //createGraph();
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(queryStyle, type, loader);
spy = spy(dbEngine);
@@ -93,29 +97,6 @@ public class DbSerializerTest extends AAISetup {
dbser = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST");
}
- public static 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();
- EdgeRules.getInstance().addEdge(g, l3interipv4addresslist_1, subnet_2);
- EdgeRules.getInstance().addEdge(g, l3interipv6addresslist_3, subnet_4);
- EdgeRules.getInstance().addTreeEdge(g, subnet_5, l3network_6);
- }
-
@Test
public void testFindDeletableDoesNotReturnDuplicates() throws AAIException {
@@ -166,8 +147,33 @@ public class DbSerializerTest extends AAISetup {
graph.close();
}
+
+ public void subnetSetup() 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();
+ EdgeRules.getInstance().addEdge(g, l3interipv4addresslist_1, subnet_2);
+ EdgeRules.getInstance().addEdge(g, l3interipv6addresslist_3, subnet_4);
+ EdgeRules.getInstance().addTreeEdge(g, subnet_5, l3network_6);
+ }
+
@Test
public void subnetDelWithInEdgesIpv4Test() throws AAIException {
+ subnetSetup();
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]";
/*
@@ -182,6 +188,7 @@ public class DbSerializerTest extends AAISetup {
@Test
public void subnetDelWithInEdgesIpv6Test() throws AAIException {
+ subnetSetup();
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]";
/*
@@ -195,6 +202,7 @@ public class DbSerializerTest extends AAISetup {
@Test
public void subnetDelWithInEdgesL3network() throws AAIException {
+ subnetSetup();
String expected_message = "";
/*
@@ -278,6 +286,37 @@ public class DbSerializerTest extends AAISetup {
}
@Test
+ public void serializeToDbNewVertexAndEdgeAAIUUIDTest() throws AAIException, UnsupportedEncodingException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, URISyntaxException {
+ String testName = new Object() {}.getClass().getEnclosingMethod().getName();
+ EdgeRules ers = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test.json");
+ DBSerializer localDbser = getDBSerializerWithSpecificEdgeRules(ers);
+
+ engine.startTransaction();
+
+ engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","vnfc-" + testName, AAIProperties.AAI_URI, "/network/vnfcs/vnfc/vnfc-" + testName);
+
+ Introspector relationship = loader.introspectorFromName("relationship");
+ relationship.setValue("related-to", "vnfc");
+ relationship.setValue("related-link", "/network/vnfcs/vnfc/vnfc-" + testName);
+
+ Introspector relationshipList = loader.introspectorFromName("relationship-list");
+ relationshipList.setValue("relationship", Collections.singletonList(relationship.getUnderlyingObject()));
+
+ Introspector gvnfObj = loader.introspectorFromName("generic-vnf");
+ Vertex gvnf = localDbser.createNewVertex(gvnfObj);
+ gvnfObj.setValue("relationship-list", relationshipList.getUnderlyingObject());
+ gvnfObj.setValue("vnf-id", "vnf-" + testName);
+
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI("/network/generic-vnfs/generic-vnf/vnf-" + testName));
+
+ localDbser.serializeToDb(gvnfObj, gvnf, uriQuery, null, "test");
+ assertTrue("Generic-vnf has uuid ", gvnf.property(AAIProperties.AAI_UUID).isPresent());
+ assertTrue("Edge has uuid ", gvnf.edges(Direction.BOTH).next().property(AAIProperties.AAI_UUID).isPresent());
+
+
+ }
+
+ @Test
public void verifyResourceVersion_SunnyDayTest() throws AAIException {
engine.startTransaction();
@@ -400,8 +439,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
EdgeRules rules = EdgeRules.getInstance();
rules.addEdge(engine.tx().traversal(), gvnf, vnfc);
@@ -424,8 +463,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
//sunny day case
Introspector relData = loader.introspectorFromName("relationship-data");
@@ -446,8 +485,8 @@ public class DbSerializerTest extends AAISetup {
public void createCousinEdgeThatShouldBeTreeTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
engine.startTransaction();
- Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf");
- Vertex vf = engine.tx().addVertex("aai-node-type","vf-module","vf-module-id","vf-id");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vf = engine.tx().addVertex("aai-node-type","vf-module","vf-module-id","vf-id", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf/vf-modules/vf-module/vf-id");
EdgeRules.getInstance().addTreeEdge(engine.tx().traversal(), gvnf, vf);
@@ -475,7 +514,7 @@ public class DbSerializerTest extends AAISetup {
public void createEdgeNodeDoesNotExistExceptionTest() throws AAIException, UnsupportedEncodingException {
engine.startTransaction();
- Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
//rainy day case, edge to non-existent object
Introspector relData = loader.introspectorFromName("relationship-data");
@@ -579,8 +618,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
//sunny day case
Introspector relData = loader.introspectorFromName("relationship-data");
@@ -603,8 +642,8 @@ public class DbSerializerTest extends AAISetup {
engine.startTransaction();
- Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf");
- engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
Introspector relData = loader.introspectorFromName("relationship-data");
relData.setValue("relationship-key", "vnfc.vnfc-name");
@@ -630,8 +669,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
ers.addEdge(graph.traversal(), gvnf, vnfc, "re-uses");
Introspector relData = loader.introspectorFromName("relationship-data");
@@ -658,8 +697,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
ers.addEdge(graph.traversal(), gvnf, vnfc, "uses");
Introspector relData = loader.introspectorFromName("relationship-data");
@@ -692,8 +731,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
Introspector relData = loader.introspectorFromName("relationship-data");
relData.setValue("relationship-key", "vnfc.vnfc-name");
@@ -722,8 +761,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
ers.addEdge(graph.traversal(), gvnf, vnfc, "uses");
ers.addEdge(graph.traversal(), gvnf, vnfc, "re-uses");
ers.addEdge(graph.traversal(), gvnf, vnfc, "over-uses");
@@ -756,8 +795,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
ers.addEdge(graph.traversal(), gvnf, vnfc, "uses");
ers.addEdge(graph.traversal(), gvnf, vnfc, "re-uses");
ers.addEdge(graph.traversal(), gvnf, vnfc, "over-uses");
@@ -791,8 +830,8 @@ public class DbSerializerTest extends AAISetup {
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");
+ Vertex gvnf = engine.tx().addVertex("aai-node-type","generic-vnf","vnf-id","myvnf", "aai-uri", "/network/generic-vnfs/generic-vnf/myvnf");
+ Vertex vnfc = engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
ers.addEdge(graph.traversal(), gvnf, vnfc, "uses");
ers.addEdge(graph.traversal(), gvnf, vnfc, "re-uses");
ers.addEdge(graph.traversal(), gvnf, vnfc, "over-uses");
@@ -819,7 +858,7 @@ public class DbSerializerTest extends AAISetup {
engine.startTransaction();
- engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
+ engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "vnfc");
@@ -858,7 +897,7 @@ public class DbSerializerTest extends AAISetup {
engine.startTransaction();
- engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
+ engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "vnfc");
@@ -897,7 +936,7 @@ public class DbSerializerTest extends AAISetup {
engine.startTransaction();
- engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
+ engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "vnfc");
@@ -926,7 +965,7 @@ public class DbSerializerTest extends AAISetup {
DBSerializer localDbser = getDBSerializerWithSpecificEdgeRules(ers);
engine.startTransaction();
- engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
+ engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
Introspector relationship;
Introspector relationshipList;
@@ -982,7 +1021,8 @@ public class DbSerializerTest extends AAISetup {
DBSerializer localDbser = getDBSerializerWithSpecificEdgeRules(ers);
engine.startTransaction();
- engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name");
+ engine.tx().addVertex("aai-node-type","vnfc","vnfc-name","a-name", "aai-uri", "/network/vnfcs/vnfc/a-name");
+
Introspector relationship;
Introspector relationshipList;
@@ -1145,14 +1185,15 @@ public class DbSerializerTest extends AAISetup {
ModelType.MOXY, "AAI-TEST");
engine.startTransaction();
- Vertex gv = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "id1");
- Vertex lint = engine.tx().addVertex("aai-node-type", "l-interface", "interface-name", "name1");
+ Vertex gv = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "id1", "aai-uri", "/network/generic-vnfs/generic-vnf/id1");
+ Vertex lint = engine.tx().addVertex("aai-node-type", "l-interface");
rules.addTreeEdge(engine.tx().traversal(), gv, lint);
Introspector lintIntro = loader.introspectorFromName("l-interface");
+ lintIntro.setValue("interface-name", "name1");
lintIntro.setValue("interface-role", "actor");
URI lintURI = new URI("/network/generic-vnfs/generic-vnf/id1/l-interfaces/l-interface/name1");
- QueryParser uriQuery = dbEngine.getQueryBuilder(gv).createQueryFromURI(lintURI);
+ QueryParser uriQuery = engine.getQueryBuilder(gv).createQueryFromURI(lintURI);
dbser.serializeToDb(lintIntro, lint, uriQuery, "test-identifier", "AAI-TEST");
assertTrue(engine.tx().traversal().V(lint).has("interface-role", "actor").hasNext());
@@ -1174,4 +1215,4 @@ public class DbSerializerTest extends AAISetup {
assertTrue("very-fast".equals(res.getValue("speed-value")));
assertTrue("things".equals(res.getValue("service-provider-bandwidth-up-units")));
}
-} \ No newline at end of file
+}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java
index 81d4c885..60691acb 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java
@@ -157,7 +157,6 @@ public class EdgeRulesTest extends AAISetup {
assertEquals(true, "IN".equalsIgnoreCase(rule.getContains()));
assertEquals(true, "NONE".equalsIgnoreCase(rule.getDeleteOtherV()));
assertEquals(true, MultiplicityRule.MANY2ONE.equals(rule.getMultiplicityRule()));
- assertEquals(true, "OUT".equalsIgnoreCase(rule.getServiceInfrastructure()));
assertEquals(true, "IN".equalsIgnoreCase(rule.getPreventDelete()));
}
@@ -242,23 +241,6 @@ public class EdgeRulesTest extends AAISetup {
}
@Test
- public void getChildrenMissingPropertyTest() {
- EdgeRules rules = EdgeRules.getInstance("/dbedgerules/DbEdgeRules_test_broken.json");
-
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("org.onap.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);
- 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
diff --git a/aai-core/src/test/java/org/onap/aai/util/AAIConfigTest.java b/aai-core/src/test/java/org/onap/aai/util/AAIConfigTest.java
new file mode 100644
index 00000000..deefdc1b
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/AAIConfigTest.java
@@ -0,0 +1,125 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.exceptions.AAIException;
+
+public class AAIConfigTest extends AAISetup {
+
+ @BeforeClass
+ public static void setUp() throws AAIException {
+ AAIConfig.init();
+ }
+
+ @Test
+ public void testGetDefaultBools() {
+ HashMap<String,ArrayList<String>> res = AAIConfig.getDefaultBools();
+ assertNotNull(res);
+ assertEquals(6, res.size());
+ assertEquals("in-maint", res.get("generic-vnf").get(0));
+ assertEquals("is-closed-loop-disabled", res.get("generic-vnf").get(1));
+ assertEquals("is-bound-to-vpn", res.get("l3-network").get(0));
+ assertEquals("in-maint", res.get("pserver").get(0));
+ assertEquals("dhcp-enabled", res.get("subnet").get(0));
+ assertEquals("in-maint", res.get("vserver").get(0));
+ assertEquals("is-closed-loop-disabled", res.get("vserver").get(1));
+ assertEquals("in-maint", res.get("vnfc").get(0));
+ assertEquals("is-closed-loop-disabled", res.get("vnfc").get(1));
+ }
+
+ @Test
+ public void testGetConfigFile() {
+ String res = AAIConfig.getConfigFile();
+ assertNotNull(res);
+ assertTrue(res.endsWith("aaiconfig.properties"));
+ }
+
+ @Test
+ public void testGetStringStringReturnDefaultvalue() {
+ String res = AAIConfig.get("key", "result");
+ assertNotNull(res);
+ assertEquals("result", res);
+ }
+
+ @Test(expected = AAIException.class)
+ public void testGetStringInvalidKey() throws AAIException {
+ AAIConfig.get("key");
+ }
+
+ @Test(expected = AAIException.class)
+ public void testGetStringEmptyResponse() throws AAIException {
+ AAIConfig.get("aai.response.null");
+ }
+
+ @Test
+ public void testGetStringReloadConfig() throws AAIException {
+ String res = AAIConfig.get("aai.config.nodename");
+ assertNotNull(res);
+ assertEquals(AAIConfig.getNodeName(), res);
+ }
+
+ @Test
+ public void testGetServerProps() {
+ Properties res = AAIConfig.getServerProps();
+ assertNotNull(res);
+ }
+
+ @Test
+ public void testGetNodeName() throws UnknownHostException {
+ InetAddress ip = InetAddress.getLocalHost();
+ String res = AAIConfig.getNodeName();
+ assertNotNull(res);
+ assertEquals(ip.getHostName(), res);
+ }
+
+ @Test
+ public void testIsEmpty() {
+ boolean res = AAIConfig.isEmpty("hllo world");
+ assertFalse(res);
+ }
+
+ @Test
+ public void testIsEmptyEmpty() {
+ boolean res = AAIConfig.isEmpty("");
+ assertTrue(res);
+ }
+
+ @Test
+ public void testIsEmptyNull() {
+ boolean res = AAIConfig.isEmpty(null);
+ assertTrue(res);
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/AutoGenerateHtmlTest.java b/aai-core/src/test/java/org/onap/aai/util/AutoGenerateHtmlTest.java
new file mode 100644
index 00000000..f2f9f61a
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/AutoGenerateHtmlTest.java
@@ -0,0 +1,35 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import freemarker.template.TemplateException;
+
+public class AutoGenerateHtmlTest {
+
+ @Test(expected=NullPointerException.class)
+ public void testMain() throws IOException, TemplateException {
+ AutoGenerateHtml.main(new String[] {});
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/GenerateXsdTest.java b/aai-core/src/test/java/org/onap/aai/util/GenerateXsdTest.java
index 6fa55559..f8ede632 100644
--- a/aai-core/src/test/java/org/onap/aai/util/GenerateXsdTest.java
+++ b/aai-core/src/test/java/org/onap/aai/util/GenerateXsdTest.java
@@ -19,271 +19,81 @@
*/
package org.onap.aai.util;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
-import java.io.StringReader;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
import org.onap.aai.introspection.Version;
+import org.onap.aai.util.genxsd.HTMLfromOXM;
+import org.onap.aai.util.genxsd.HTMLfromOXMTest;
+import org.onap.aai.util.genxsd.XSDElementTest;
+import org.onap.aai.util.genxsd.YAMLfromOXM;
+import org.onap.aai.util.genxsd.YAMLfromOXMTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class GenerateXsdTest {
- private static final int maxSizeForXml = 20000;
- private String testXML;
+ private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class");
+ private String testXML;
@Before
public void setUp() throws Exception {
//PowerMockito.mockStatic(GenerateXsd.class);
- StringBuilder sb = new StringBuilder(maxSizeForXml);
- addNamespace(sb);
- addRelationshipList(sb);
- addRelationship(sb);
- addRelatedToProperty(sb);
- addRelationshipData(sb);
- addBusiness(sb);
- addCustomers(sb);
- addCustomer(sb);
- addServiceSubscriptions(sb);
- addServiceSubscription(sb);
- addEndOfXML(sb);
- testXML = sb.toString();
- }
-
- private void addNamespace(StringBuilder sb){
- sb.append("<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org.v11\" xml-mapping-metadata-complete=\"true\">\n");
- sb.append("<xml-schema element-form-default=\"QUALIFIED\">\n");
- sb.append("<xml-ns namespace-uri=\"http://org.onap.aai.inventory/v11\" />\n");
- sb.append("</xml-schema>\n");
- sb.append("<java-types>\n");
- sb.append("<java-type name=\"Inventory\">\n");
- sb.append("<xml-root-element name=\"inventory\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"business\" name=\"business\" type=\"inventory.aai.onap.org.v11.Business\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addRelationshipList(StringBuilder sb ) {
- sb.append("<java-type name=\"RelationshipList\">\n");
- sb.append("<xml-root-element name=\"relationship-list\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationship\" name=\"relationship\" type=\"inventory.aai.onap.org.v11.Relationship\" />/n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addRelationship(StringBuilder sb ) {
- sb.append("<java-type name=\"Relationship\">\n");
- sb.append("<xml-root-element name=\"relationship\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"relatedTo\" name=\"related-to\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate type of node.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"relatedLink\" name=\"related-link\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"URL to the object in A&amp;AI.\" />");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationshipData\" name=\"relationship-data\" type=\"inventory.aai.onap.org.v11.RelationshipData\" />\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relatedToProperty\" name=\"related-to-property\" type=\"inventory.aai.onap.org.v11.RelatedToProperty\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addRelatedToProperty(StringBuilder sb) {
- sb.append("<java-type name=\"RelatedToProperty\">\n");
- sb.append("<xml-root-element name=\"related-to-property\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"propertyKey\" name=\"property-key\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Key part of a key/value pair\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"propertyValue\" name=\"property-value\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Value part of a key/value pair\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
+ XSDElementTest x = new XSDElementTest();
+ x.setUp();
+ testXML = x.getTestXML();
}
- private void addRelationshipData(StringBuilder sb){
- sb.append("<java-type name=\"RelationshipData\">\n");
- sb.append("<xml-root-element name=\"relationship-data\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"relationshipKey\" name=\"relationship-key\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate an attribute.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"relationshipValue\" name=\"relationship-value\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Value of the attribute.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addBusiness(StringBuilder sb){
- sb.append("<java-type name=\"Business\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Namespace for business related constructs\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("<xml-root-element name=\"business\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"customers\" name=\"customers\" type=\"inventory.aai.onap.org.v11.Customers\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addCustomers(StringBuilder sb){
- sb.append("<java-type name=\"Customers\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Collection of customer identifiers to provide linkage back to BSS information.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("<xml-root-element name=\"customers\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"customer\" name=\"customer\" type=\"inventory.aai.onap.org.v11.Customer\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"maximumDepth\" value=\"0\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addCustomer(StringBuilder sb){
- sb.append("<java-type name=\"Customer\">\n");
- sb.append("<xml-root-element name=\"customer\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"globalCustomerId\" name=\"global-customer-id\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Global customer id used across ECOMP to uniquely identify customer.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"subscriberName\" name=\"subscriber-name\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Subscriber name, an alternate way to retrieve a customer.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"subscriberType\" name=\"subscriber-type\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Subscriber type, a way to provide VID with only the INFRA customers.\" />\n");
- sb.append("<xml-property name=\"defaultValue\" value=\"CUST\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n");
- sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n");
- sb.append("<xml-property name=\"nameProps\" value=\"subscriber-name\" />\n");
- sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-name,global-customer-id,subscriber-type\" />\n");
- sb.append("<xml-property name=\"searchable\" value=\"global-customer-id,subscriber-name\" />\n");
- sb.append("<xml-property name=\"uniqueProps\" value=\"global-customer-id\" />\n");
- sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
- sb.append("<xml-property name=\"namespace\" value=\"business\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addServiceSubscriptions(StringBuilder sb){
- sb.append("<java-type name=\"ServiceSubscriptions\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Collection of objects that group service instances.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("<xml-root-element name=\"service-subscriptions\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"serviceSubscription\" name=\"service-subscription\" type=\"inventory.aai.onap.org.v11.ServiceSubscription\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
- private void addServiceSubscription(StringBuilder sb){
- sb.append("<java-type name=\"ServiceSubscription\">\n");
- sb.append("<xml-root-element name=\"service-subscription\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"serviceType\" name=\"service-type\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Value defined by orchestration to identify this service across ECOMP.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"tempUbSubAccountId\" name=\"temp-ub-sub-account-id\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"This property will be deleted from A&amp;AI in the near future. Only stop gap solution.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Object that group service instances.\" />\n");
- sb.append("<xml-property name=\"indexedProps\" value=\"service-type\" />\n");
- sb.append("<xml-property name=\"dependentOn\" value=\"customer\" />\n");
- sb.append("<xml-property name=\"container\" value=\"service-subscriptions\" />\n");
- sb.append("<xml-property name=\"crossEntityReference\" value=\"service-instance,service-type\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addEndOfXML(StringBuilder sb){
- sb.append("</java-types>\n");
- sb.append("</xml-bindings>\n");
- }
-
-
@Test
- public void test_processOxmFile() {
+ public void test_generateSwaggerFromOxmFile( ) {
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ String fileContent = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ fileContent = swagger.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug(fileContent);
+ assertThat(fileContent, is(new YAMLfromOXMTest().YAMLresult()));
+ }
-
- GenerateXsd generateXsd = new GenerateXsd();
-
- //GenerateXsd generateXsdSpy = PowerMockito.spy(generateXsd);
-
- //generateXsdSpy.processOxmFile(null, Version.getLatest(), testXML);
-
- String xsdResult = generateXsd.processOxmFile(null, Version.getLatest(), testXML);
+ @Test
+ public void test_generateXSDFromOxmFile( ) {
- String relationshipListExpected = " <xs:element name=\"relationship-list\">\n <xs:complexType>\n <xs:sequence>\n <xs:element ref=\"tns:relationship\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n </xs:sequence>\n </xs:complexType>\n </xs:element>";
- String relatedToPropertyExpected = " <xs:element name=\"related-to-property\">\n <xs:complexType>\n <xs:sequence>\n <xs:element name=\"property-key\" type=\"xs:string\" minOccurs=\"0\">\n <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Key part of a key/value pair\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n </xs:element>\n"
- + " <xs:element name=\"property-value\" type=\"xs:string\" minOccurs=\"0\">\n <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Value part of a key/value pair\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n </xs:element>\n </xs:sequence>\n </xs:complexType>\n </xs:element>";
- assertNotNull(xsdResult);
+ Version v = Version.v11;
+ String fileContent = null;
+ try {
+ HTMLfromOXM xsd = new HTMLfromOXM(testXML, v);
+ fileContent = xsd.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug(fileContent);
+ assertThat(fileContent, is(new HTMLfromOXMTest().HTMLresult()));
}
+
@Test
- public void test_generateSwaggerFromOxmFile( ) {
-
+ public void testGetAPIVersion() {
+ GenerateXsd.apiVersion=Version.v11.name();
+ assertThat(GenerateXsd.getAPIVersion(),is("v11"));
+ }
- GenerateXsd generateXsd = new GenerateXsd();
+ @Test
+ public void testGetYamlDir() {
+ assertThat(GenerateXsd.getYamlDir(),is("../aai-schema/src/main/resources/aai_swagger_yaml"));
+ }
- String customerOperation = " /business/customers/customer/{global-customer-id}:\n get:\n tags:\n - Business\n summary: returns customer";
- String relationshipListDefinition = " relationship-list:\n properties:\n relationship:\n type: array\n items: \n $ref: \"#/definitions/relationship\"";
- String swaggerResult = generateXsd.generateSwaggerFromOxmFile(null, testXML);
- assertNotNull(swaggerResult);
+ @Test
+ public void testGetResponsesUrl() {
+ assertNull(GenerateXsd.getResponsesUrl());
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java b/aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
new file mode 100644
index 00000000..d9fd1d6b
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
@@ -0,0 +1,71 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.Test;
+import org.onap.aai.restcore.JettyObfuscationConversionCommandLineUtil;
+
+public class JettyObfuscationConversionCommandLineUtilTest {
+
+ private final ByteArrayOutputStream testOut = new ByteArrayOutputStream();
+
+ /**
+ * Test.
+ */
+ @Test
+ public void test() {
+ //setup, this will catch main's print statements for evaluation
+ System.setOut(new PrintStream(testOut));
+
+ /* ------ TEST OBFUSCATION ----*/
+ JettyObfuscationConversionCommandLineUtil.main(new String[]{"-e", "hello world"});
+ /*
+ * testOut was also catching any logging statements which interfered with result checking.
+ * This regex business was the workaround - it tries to find the expected value in
+ * the results and asserts against that.
+ */
+ String obfResult = testOut.toString();
+ String obfExpected = "OBF:1thf1ugo1x151wfw1ylz11tr1ymf1wg21x1h1uh21th7";
+ Pattern obfExpectPat = Pattern.compile(obfExpected);
+ Matcher obfMatch = obfExpectPat.matcher(obfResult);
+ assertTrue(obfMatch.find());
+
+ testOut.reset(); //clear out previous result
+
+ /* ------ TEST DEOBFUSCATION ----- */
+ JettyObfuscationConversionCommandLineUtil.main(new String[]{"-d", obfExpected});
+ String deobfResult = testOut.toString();
+ String deobfExpected = "hello world";
+ Pattern deobfExpectPat = Pattern.compile(deobfExpected);
+ Matcher deobfMatch = deobfExpectPat.matcher(deobfResult);
+ assertTrue(deobfMatch.find());
+
+ //clean up, resets to stdout
+ System.setOut(null);
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java b/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java
index 5bd7984a..d3725f48 100644
--- a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java
+++ b/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java
@@ -112,7 +112,7 @@ public class StoreNotificationEventTest extends AAISetup {
eh.setSourceName("source");
eh.setSequenceNumber("23");
eh.setSeverity("ALERT");
- eh.setVersion("v11");
+ eh.setVersion("v12");
String res = sne.storeEvent(eh, object);
@@ -126,7 +126,7 @@ public class StoreNotificationEventTest extends AAISetup {
assertTrue(res.contains("\"sequence-number\" : \"23\""));
assertTrue(res.contains("\"severity\" : \"ALERT\""));
assertTrue(res.contains("\"event-type\" : \"surprise\""));
- assertTrue(res.contains("\"version\" : \"v11\""));
+ assertTrue(res.contains("\"version\" : \"v12\""));
assertTrue(res.contains("\"action\" : \"action!\""));
assertTrue(res.contains("\"entity-link\" : \"entity-link\""));
assertTrue(res.contains("\"entity\""));
@@ -140,20 +140,20 @@ public class StoreNotificationEventTest extends AAISetup {
public void testStoreDynamicEventNullObj() throws AAIException {
DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class);
DynamicJAXBContext notificationJaxbContext = Mockito.mock(DynamicJAXBContext.class);
- sne.storeDynamicEvent(notificationJaxbContext, "v11", eventHeader, null);
+ sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, null);
}
- @Test(expected = AAIException.class)
+ @Test(expected = Exception.class)
public void testStoreDynamicEventAAIException() throws Exception {
DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class);
DynamicEntity obj = Mockito.mock(DynamicEntity.class);
DynamicJAXBContext notificationJaxbContext = Mockito.mock(DynamicJAXBContext.class);
ClassLoader cl = getClass().getClassLoader();
- InputStream is = cl.getResourceAsStream("oxm/aai_oxm_v11.xml");
+ InputStream is = cl.getResourceAsStream("oxm/aai_oxm_v12.xml");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, is);
DynamicJAXBContext notificationJaxbContextReal = DynamicJAXBContextFactory.createContextFromOXM(cl, properties);
- DynamicType dtReal = notificationJaxbContextReal.getDynamicType("inventory.aai.onap.org.v11.NotificationEvent");
+ DynamicType dtReal = notificationJaxbContextReal.getDynamicType("inventory.aai.onap.org.v12.NotificationEvent");
DynamicType dt = Mockito.mock(DynamicType.class);
DynamicEntity notificationEventReal = dtReal.newDynamicEntity();
JAXBMarshaller marshaller = Mockito.mock(JAXBMarshaller.class);
@@ -163,7 +163,7 @@ public class StoreNotificationEventTest extends AAISetup {
Mockito.when(notificationJaxbContext.createMarshaller()).thenReturn(marshaller);
Mockito.doNothing().when(marshaller).marshal(Mockito.any(DynamicJAXBContext.class), Mockito.any(StringWriter.class));
- sne.storeDynamicEvent(notificationJaxbContext, "v11", eventHeader, obj);
+ sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, obj);
}
@Test(expected = AAIException.class)
@@ -174,7 +174,7 @@ public class StoreNotificationEventTest extends AAISetup {
@Test
public void testStoreEventIntrospector() throws Exception {
- Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v11);
+ Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v12);
Introspector eventHeader = loader.introspectorFromName("notification-event-header");
eventHeader.setValue("id", "123");
eventHeader.setValue("timestamp", "current-time");
@@ -185,7 +185,7 @@ public class StoreNotificationEventTest extends AAISetup {
eventHeader.setValue("source-name", "source");
eventHeader.setValue("sequence-number", "23");
eventHeader.setValue("severity", "ALERT");
- eventHeader.setValue("version", "v11");
+ eventHeader.setValue("version", "v12");
Introspector obj = loader.introspectorFromName("notification-event");
@@ -201,7 +201,7 @@ public class StoreNotificationEventTest extends AAISetup {
assertTrue(res.contains("\"sequence-number\":\"23\""));
assertTrue(res.contains("\"severity\":\"ALERT\""));
assertTrue(res.contains("\"event-type\":\"surprise\""));
- assertTrue(res.contains("\"version\":\"v11\""));
+ assertTrue(res.contains("\"version\":\"v12\""));
assertTrue(res.contains("\"action\":\"action!\""));
assertTrue(res.contains("\"entity-link\":\"entity-link\""));
assertTrue(res.contains("\"notification-event\""));
@@ -209,7 +209,7 @@ public class StoreNotificationEventTest extends AAISetup {
@Test
public void testStoreEventIntrospectorEmptyEventHeader() throws Exception {
- Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v11);
+ Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v12);
Introspector eventHeader = loader.introspectorFromName("notification-event-header");
Introspector obj = loader.introspectorFromName("notification-event");
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteFootnoteSetTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteFootnoteSetTest.java
new file mode 100644
index 00000000..3c1e825d
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteFootnoteSetTest.java
@@ -0,0 +1,83 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@RunWith(Parameterized.class)
+public class DeleteFootnoteSetTest {
+ String targetNode;
+ String flavor;
+ String result;
+ DeleteFootnoteSet footnotes = null;
+
+ @Parameters
+ public static Collection<String[]> testConditions() {
+ String inputs [][] = {
+ {"vserver","(1)", "\n -(1) IF this VSERVER node is deleted, this FROM node is DELETED also\n"},
+ {"ctag-pool","(2)", "\n -(2) IF this CTAG-POOL node is deleted, this TO node is DELETED also\n"},
+ {"pserver","(3)", "\n -(3) IF this FROM node is deleted, this PSERVER is DELETED also\n"},
+ {"oam-network","(4)", "\n -(4) IF this TO node is deleted, this OAM-NETWORK is DELETED also\n"},
+ {"dvs-switch","(1)", "\n -(1) IF this DVS-SWITCH node is deleted, this FROM node is DELETED also\n"},
+ {"availability-zone","(3)", "\n -(3) IF this FROM node is deleted, this AVAILABILITY-ZONE is DELETED also\n"}
+ };
+ return (Arrays.asList(inputs));
+ }
+
+ public DeleteFootnoteSetTest(String targetNode, String flavor, String result) {
+ super();
+ this.targetNode = targetNode;
+ this.flavor = flavor;
+ this.result=result;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ footnotes = new DeleteFootnoteSet(this.targetNode);
+ }
+
+ @Test
+ public void testDeleteFootnoteSet() {
+ assertThat(footnotes.targetNode, is(this.targetNode));
+ }
+
+ @Test
+ public void testAdd() {
+ footnotes.add(this.flavor);
+ assertThat(footnotes.footnotes.size(), is(1));
+ }
+
+ @Test
+ public void testToString() {
+ footnotes.add(this.flavor);
+ assertThat(footnotes.toString(), is(this.result));
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteOperationTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteOperationTest.java
new file mode 100644
index 00000000..501babe3
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/DeleteOperationTest.java
@@ -0,0 +1,82 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class DeleteOperationTest {
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
+
+ @Parameters
+ public static Collection<String []> testConditions() {
+ String inputs [][] = {
+ {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n"," delete:\n tags:\n - Network\n summary: delete an existing generic-vnf\n description: delete an existing generic-vnf\n operationId: deleteNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n - name: resource-version\n in: query\n description: resource-version for concurrency\n required: true\n type: string\n"},
+ {"CloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver","vserver","CloudInfrastructure","/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}"," - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__\n"," delete:\n tags:\n - CloudInfrastructure\n summary: delete an existing vserver\n description: delete an existing vserver\n operationId: deleteCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__\n - name: resource-version\n in: query\n description: resource-version for concurrency\n required: true\n type: string\n"},
+// if ( StringUtils.isEmpty(tag) )
+ {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n",""},
+// Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
+ {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",""},
+// {"","ctag-pool","","","",""},
+// {"","pserver","","","",""},
+// {"","oam-network","","","",""},
+// {"","dvs-switch","","","",""},
+// {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
+
+ public DeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams=pathParams;
+ this.result = result;
+ }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+
+ }
+
+ @Test
+ public void testToString() {
+ DeleteOperation delete = new DeleteOperation(useOpId, xmlRootElementName, tag, path, pathParams);
+ String modResult = delete.toString();
+ assertThat(modResult, is(this.result));
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeDescriptionTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeDescriptionTest.java
new file mode 100644
index 00000000..d57dc4aa
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeDescriptionTest.java
@@ -0,0 +1,392 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.JsonPath;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class EdgeDescriptionTest {
+ private DocumentContext jsonContext;
+ private EdgeRuleSet edgeSet;
+ private Collection<EdgeDescription>edges;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ String json = "{"
+ + " \"rules\": ["
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"complex\","
+ + " \"label\": \"org.onap.relationships.inventory.LocatedIn\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"this description\""
+ + " },"
+/*
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"service-capability\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"cloud-region\","
+ + " \"label\": \"org.onap.relationships.inventory.BelongsTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"!${direction}\","
+ + " \"delete-other-v\": \"!${direction}\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"NONE\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"ctag-pool\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"dvs-switch\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"generic-vnf\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"pserver\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.MemberOf\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"vce\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+*/
+ + " ]}";
+ jsonContext = JsonPath.parse(json);
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ String nodeName = "availability-zone";
+ edges = edgeSet.getEdgeRules(nodeName);
+ }
+
+ @Test
+ public void testGetDeleteOtherV() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"NONE";
+ for (EdgeDescription ed : edges) {
+ String modResult = ed.getRuleKey() + "-" + ed.getDeleteOtherV();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetDeleteOtherV() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"IN";
+ for (EdgeDescription ed : edges) {
+ ed.setDeleteOtherV("IN");
+ String modResult = ed.getRuleKey() + "-" + ed.getDeleteOtherV();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetPreventDelete() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"IN";
+ for (EdgeDescription ed : edges) {
+ String modResult = ed.getRuleKey() + "-" + ed.getPreventDelete();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetPreventDelete() {
+ for (EdgeDescription ed : edges) {
+ String target = "availability-zone"+"|"+"complex"+"-"+"OUT";
+ ed.setPreventDelete("OUT");
+ String modResult = ed.getRuleKey() + "-" + ed.getPreventDelete();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetAlsoDeleteFootnote() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"";
+ for (EdgeDescription ed : edges) {
+ String modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
+ assertThat(modResult, is(target));
+ ed.setDeleteOtherV("IN");
+ target = "availability-zone"+"|"+"complex"+"-"+"(4)";
+ modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
+ assertThat(modResult, is(target));
+ target = "availability-zone"+"|"+"complex"+"-"+"(1)";
+ modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getTo());
+ assertThat(modResult, is(target));
+ ed.setDeleteOtherV("OUT");
+ target = "availability-zone"+"|"+"complex"+"-"+"(2)";
+ modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
+ assertThat(modResult, is(target));
+ target = "availability-zone"+"|"+"complex"+"-"+"(3)";
+ modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getTo());
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetTo() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"complex";
+ for (EdgeDescription ed : edges) {
+ String modResult = ed.getRuleKey() + "-" + ed.getTo();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetTo() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"jazz";
+ for (EdgeDescription ed : edges) {
+ ed.setTo("jazz");
+ String modResult = ed.getRuleKey() + "-" + ed.getTo();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetFrom() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"availability-zone";
+ for (EdgeDescription ed : edges) {
+ String modResult = ed.getRuleKey() + "-" + ed.getFrom();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetFrom() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"jazz";
+ for (EdgeDescription ed : edges) {
+ ed.setFrom("jazz");
+ String modResult = ed.getRuleKey() + "-" + ed.getFrom();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetRuleKey() {
+ for (EdgeDescription ed : edges) {
+ String target = ed.getFrom()+"|"+ed.getTo();
+ String modResult = ed.getRuleKey();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetMultiplicity() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"MANY2ONE";
+ for (EdgeDescription ed : edges) {
+ String modResult = ed.getRuleKey() + "-" + ed.getMultiplicity();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetDirection() {
+ for (EdgeDescription ed : edges) {
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+"OUT";
+ String modResult = ed.getRuleKey() + "-" + ed.getDirection();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetDescription() {
+ for (EdgeDescription ed : edges) {
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+"this description";
+ String modResult = ed.getRuleKey() + "-" + ed.getDescription();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetRuleKey() {
+ for (EdgeDescription ed : edges) {
+ ed.setRuleKey("A|B");
+ String target = "A|B";
+ String modResult = ed.getRuleKey();
+ assertThat(modResult, is(target));
+ } }
+
+ @Test
+ public void testSetType() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"CHILD";
+ for (EdgeDescription ed : edges) {
+ ed.setType(EdgeDescription.LineageType.CHILD);
+ String modResult = ed.getRuleKey() + "-" + ed.getType();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetDirection() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"IN";
+ for (EdgeDescription ed : edges) {
+ ed.setDirection("IN");
+ String modResult = ed.getRuleKey() + "-" + ed.getDirection();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetMultiplicity() {
+ String target = "availability-zone"+"|"+"complex"+"-"+"ONE2MANY";
+ for (EdgeDescription ed : edges) {
+ ed.setTo("ONE2MANY");
+ String modResult = ed.getRuleKey() + "-" + ed.getTo();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetDescription() {
+ for (EdgeDescription ed : edges) {
+ ed.setDescription("a new description");
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+"a new description";
+ String modResult = ed.getRuleKey() + "-" + ed.getDescription();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetRelationshipDescription() {
+ for (EdgeDescription ed : edges) {
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+"( availability-zone LocatedIn complex, MANY2ONE)\n this description";
+ String modResult = ed.getRuleKey() + "-" + ed.getRelationshipDescription("FROM",ed.getTo());
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetType() {
+ for (EdgeDescription ed : edges) {
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+"UNRELATED";
+ String modResult = ed.getRuleKey() + "-" + ed.getType();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetLabel() {
+ for (EdgeDescription ed : edges) {
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+"org.onap.relationships.inventory.LocatedIn";
+ String modResult = ed.getRuleKey() + "-" + ed.getLabel();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testGetShortLabel() {
+ for (EdgeDescription ed : edges) {
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+"LocatedIn";
+ String modResult = ed.getRuleKey() + "-" + ed.getShortLabel();
+ assertThat(modResult, is(target));
+ }
+ }
+
+ @Test
+ public void testSetLabel() {
+ String newLabel = "New label";
+ for (EdgeDescription ed : edges) {
+ ed.setLabel(newLabel);
+ String target = ed.getFrom()+"|"+ed.getTo()+"-"+newLabel;
+ String modResult = ed.getRuleKey() + "-" + ed.getLabel();
+ assertThat(modResult, not(equalTo("org.onap.relationships.inventory.LocatedIn")));
+ assertThat(modResult, is(target));
+ }
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeRuleSetTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeRuleSetTest.java
new file mode 100644
index 00000000..3668cf36
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/EdgeRuleSetTest.java
@@ -0,0 +1,243 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.JsonPath;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class EdgeRuleSetTest {
+ private static File edgesFile = new File("edges.json");
+ private static String nodeName = "availability-zone";
+ private DocumentContext jsonContext;
+ private String json;
+ private EdgeRuleSet edgeSet;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ json = "{"
+ + " \"rules\": ["
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"complex\","
+ + " \"label\": \"org.onap.relationships.inventory.LocatedIn\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"this description\""
+ + " },"
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"service-capability\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"cloud-region\","
+ + " \"label\": \"org.onap.relationships.inventory.BelongsTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"!${direction}\","
+ + " \"delete-other-v\": \"!${direction}\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"NONE\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"ctag-pool\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"dvs-switch\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"generic-vnf\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"vf-module\","
+ + " \"to\": \"vnfc\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"ONE2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"pserver\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.MemberOf\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"vce\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " ]}";
+ FileWriter file = new FileWriter(edgesFile);
+ file.write(json);
+ file.flush();
+ file.close();
+ jsonContext = JsonPath.parse(json);
+
+ }
+
+ @Test
+ public void testEdgeRuleSetFile() throws FileNotFoundException, IOException {
+ this.edgeSet = new EdgeRuleSet(edgesFile);
+ Collection<EdgeDescription>edges = edgeSet.getEdgeRules(nodeName);
+ assertThat(edges.size(), is(8));
+ }
+
+ @Test
+ public void testEdgeRuleSetDocumentContext() {
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ Collection<EdgeDescription>edges = edgeSet.getEdgeRules(nodeName);
+ assertThat(edges.size(), is(8));
+ }
+
+ @Test
+ public void testGetEdgeRules() {
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ Collection<EdgeDescription>edges = edgeSet.getEdgeRules(nodeName);
+ assertThat(edges.size(), is(8));
+ }
+
+ @Test
+ public void testGetEdgeRulesTO() {
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ Collection<EdgeDescription>edges = edgeSet.getEdgeRulesTO(nodeName);
+ assertThat(edges.size(), is(5));
+ }
+
+ @Test
+ public void testGetEdgeRulesFROM() {
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ Collection<EdgeDescription>edges = edgeSet.getEdgeRulesFROM(nodeName);
+ assertThat(edges.size(), is(3));
+ }
+
+ @Test
+ public void testGetEdgeRulesFromJson() {
+ String fromRulesPath = "$['rules'][?(@['from']=='" + nodeName + "')]";
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ Collection<EdgeDescription> edges = edgeSet.getEdgeRulesFromJson( fromRulesPath, true );
+ assertThat(edges.size(), is(3));
+ }
+
+ @Test
+ public void testPreventDeleteRules() {
+ String target = "AVAILABILITY-ZONE cannot be deleted if related to CTAG-POOL,DVS-SWITCH,GENERIC-VNF,PSERVER,VCE\n";
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ String fromDeleteRules = edgeSet.preventDeleteRules(nodeName);
+ assertThat(fromDeleteRules, is(target));
+ }
+
+ @Test
+ public void testFromDeleteRules() {
+ String target = "VF-MODULE cannot be deleted if related to VNFC\n";
+ this.edgeSet = new EdgeRuleSet(jsonContext);
+ String fromDeleteRules = edgeSet.fromDeleteRules("vf-module");
+ assertThat(fromDeleteRules, is(target));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ edgesFile.delete();
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/GetOperationTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/GetOperationTest.java
new file mode 100644
index 00000000..79a243d9
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/GetOperationTest.java
@@ -0,0 +1,107 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Vector;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class GetOperationTest {
+ private static final Logger logger = LoggerFactory.getLogger("GetOperationTest.class");
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
+
+ @Parameters
+ public static Collection<String []> testConditions() {
+ String inputs [][] = {
+ {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"," /network/generic-vnfs/generic-vnf/{vnf-id}:\n get:\n tags:\n - Network\n summary: returns generic-vnf\n description: returns generic-vnf\n operationId: getNetworkGenericVnfsGenericVnf\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/getDefinitions/generic-vnf\"\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"},
+ {"CloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver","vserver","CloudInfrastructure","/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}"," - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__"," /cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}:\n get:\n tags:\n - CloudInfrastructure\n summary: returns vserver\n description: returns vserver\n operationId: getCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/getDefinitions/vserver\"\n \"default\":\n null parameters:\n - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__"},
+ {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",""},
+ {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__"," /cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces:\n get:\n tags:\n - CloudInfrastructure\n summary: returns p-interfaces\n description: returns p-interfaces\n operationId: getCloudInfrastructurePserversPserverPInterfaces\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/getDefinitions/p-interfaces\"\n \"default\":\n null parameters:\n - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__ - name: interface-name\n in: query\n description:\n required: false\n type: string - name: prov-status\n in: query\n description:\n required: false\n type: string"},
+ // {"","ctag-pool","","","",""},
+// {"","pserver","","","",""},
+// {"","oam-network","","","",""},
+// {"","dvs-switch","","","",""},
+// {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
+
+ public GetOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams=pathParams;
+ this.result = result;
+ }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ String container = "p-interfaces";
+ String queryProps[] = {
+ " - name: interface-name\n in: query\n description:\n required: false\n type: string",
+ " - name: prov-status\n in: query\n description:\n required: false\n type: string"
+ };
+ Vector<String> containerProps = new Vector<String>();
+ for(String prop : queryProps) {
+ containerProps.add(prop);
+ }
+ GetOperation.addContainerProps(container, containerProps);
+ }
+
+ @Test
+ public void testAddContainerProps() {
+ String container = this.xmlRootElementName;
+ String prop = " - name: "+container+"\n in: query\n description:\n required: false\n type: string";
+ Vector<String> queryProps = new Vector<String>();
+ queryProps.add(prop);
+ for(String p : queryProps) {
+ logger.debug("qProp="+p);
+ }
+ logger.debug("Done="+this.xmlRootElementName);
+ GetOperation.addContainerProps(container, queryProps);
+ assertThat(GetOperation.containers.get(container).get(0), is(prop));
+ }
+
+ @Test
+ public void testToString() {
+ GetOperation get = new GetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
+ String modResult = get.toString();
+ assertThat(modResult, is(this.result));
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java
new file mode 100644
index 00000000..a3cba5eb
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/HTMLfromOXMTest.java
@@ -0,0 +1,278 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.introspection.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class HTMLfromOXMTest {
+ private static final Logger logger = LoggerFactory.getLogger("HTMLfromOXMTest.class");
+ private String testXML;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ XSDElementTest x = new XSDElementTest();
+ x.setUp();
+ testXML = x.testXML;
+ }
+
+ @Test
+ public void testGetDocumentHeader() {
+ Version v = Version.v11;
+ String header = null;
+ try {
+ HTMLfromOXM swagger = new HTMLfromOXM(testXML, v);
+ header = swagger.getDocumentHeader();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("Header:");
+ logger.debug(header);
+ assertThat(header, is(HTMLheader()));
+ }
+
+ @Test
+ public void testProcess() {
+ Version v = Version.v11;
+ String fileContent = null;
+ try {
+ HTMLfromOXM xsd = new HTMLfromOXM(testXML, v);
+ fileContent = xsd.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("FileContent-I:");
+ logger.debug(fileContent);
+ assertThat(fileContent, is(HTMLresult()));
+ }
+
+ @Test
+ public void testHTMLfromOXMFileVersion() throws IOException {
+ String outfileName = "testXML.xml";
+ File XMLfile = new File(outfileName);
+ XMLfile.createNewFile();
+ BufferedWriter bw = null;
+ Charset charset = Charset.forName("UTF-8");
+ Path path = Paths.get(outfileName);
+ bw = Files.newBufferedWriter(path, charset);
+ bw.write(testXML);
+ bw.close();
+ Version v = Version.v11;
+ String fileContent = null;
+ try {
+ HTMLfromOXM xsd = new HTMLfromOXM(testXML, v);
+ fileContent = xsd.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ XMLfile.delete();
+ logger.debug("FileContent-I:");
+ logger.debug(fileContent);
+ assertThat(fileContent, is(HTMLresult()));
+ }
+
+ @Test
+ public void testHTMLfromOXMStringVersion() {
+ Version v = Version.v11;
+ String fileContent = null;
+ try {
+ HTMLfromOXM xsd = new HTMLfromOXM(testXML, v);
+ fileContent = xsd.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("FileContent-II:");
+ logger.debug(fileContent);
+ assertThat(fileContent, is(HTMLresult()));
+ }
+
+ @Test
+ public void testProcessJavaTypeElement() {
+ String target = "Element=java-type/Customer";
+ Version v = Version.v11;
+ Element customer = null;
+ try {
+ HTMLfromOXM xsd = new HTMLfromOXM(testXML, v);
+ xsd.process();
+ customer = xsd.getJavaTypeElementSwagger("Customer");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("Element:");
+ logger.debug("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"));
+ assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target)); }
+
+ public String HTMLresult() {
+ StringBuilder sb = new StringBuilder(32368);
+ sb.append(HTMLheader());
+ sb.append(HTMLdefs());
+ return sb.toString();
+ }
+
+ public String HTMLheader() {
+ StringBuilder sb = new StringBuilder(1500);
+ sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
+ sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://org.openecomp.aai.inventory/v11\" xmlns:tns=\"http://org.openecomp.aai.inventory/v11\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\nxmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"\r\n");
+ sb.append(" jaxb:version=\"2.1\"\r\n");
+ sb.append(" xmlns:annox=\"http://annox.dev.java.net\"\r\n");
+ sb.append(" jaxb:extensionBindingPrefixes=\"annox\">\n\n");
+ return sb.toString();
+ }
+ public String HTMLdefs() {
+ StringBuilder sb = new StringBuilder(1500);
+ sb.append(" <xs:element name=\"service-subscription\">\n");
+ sb.append(" <xs:complexType>\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" <xs:sequence>\n");
+ sb.append(" <xs:element name=\"service-type\" type=\"xs:string\">\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Value defined by orchestration to identify this service across ECOMP.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"temp-ub-sub-account-id\" type=\"xs:string\" minOccurs=\"0\">\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"This property will be deleted from A&amp;AI in the near future. Only stop gap solution.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" </xs:sequence>\n");
+ sb.append(" </xs:complexType>\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"service-subscriptions\">\n");
+ sb.append(" <xs:complexType>\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" <xs:sequence>\n");
+ sb.append(" <xs:element ref=\"tns:service-subscription\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n");
+ sb.append(" </xs:sequence>\n");
+ sb.append(" </xs:complexType>\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"customer\">\n");
+ sb.append(" <xs:complexType>\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" <xs:sequence>\n");
+ sb.append(" <xs:element name=\"global-customer-id\" type=\"xs:string\">\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Global customer id used across ECOMP to uniquely identify customer.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"subscriber-name\" type=\"xs:string\">\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber name, an alternate way to retrieve a customer.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\">\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element ref=\"tns:service-subscriptions\" minOccurs=\"0\"/>\n");
+ sb.append(" </xs:sequence>\n");
+ sb.append(" </xs:complexType>\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"customers\">\n");
+ sb.append(" <xs:complexType>\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" <xs:sequence>\n");
+ sb.append(" <xs:element ref=\"tns:customer\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n");
+ sb.append(" </xs:sequence>\n");
+ sb.append(" </xs:complexType>\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"business\">\n");
+ sb.append(" <xs:complexType>\n");
+ sb.append(" <xs:annotation>\r\n");
+ sb.append(" <xs:appinfo>\r\n");
+ sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>\r\n");
+ sb.append(" </xs:appinfo>\r\n");
+ sb.append(" </xs:annotation>\r\n");
+ sb.append(" <xs:sequence>\n");
+ sb.append(" <xs:element ref=\"tns:customers\" minOccurs=\"0\"/>\n");
+ sb.append(" </xs:sequence>\n");
+ sb.append(" </xs:complexType>\n");
+ sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"inventory\">\n");
+ sb.append(" <xs:complexType>\n");
+ sb.append(" <xs:sequence>\n");
+ sb.append(" <xs:element ref=\"tns:business\" minOccurs=\"0\"/>\n");
+ sb.append(" </xs:sequence>\n");
+ sb.append(" </xs:complexType>\n");
+ sb.append(" </xs:element>\n");
+ sb.append("</xs:schema>\n");
+ return sb.toString();
+ }
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/PatchOperationTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/PatchOperationTest.java
new file mode 100644
index 00000000..7bfaebf5
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/PatchOperationTest.java
@@ -0,0 +1,82 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class PatchOperationTest {
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
+
+ @Parameters
+ public static Collection<String []> testConditions() {
+ String inputs [][] = {
+ {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"," patch:\n tags:\n - Network\n summary: update an existing generic-vnf\n description: |\n Update an existing generic-vnf\n #\n Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n The PUT operation will entirely replace an existing object.\n The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n #\n Other differences between PUT and PATCH are:\n #\n - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n operationId: UpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__ - name: body\n in: body\n description: generic-vnf object that needs to be updated.\n required: true\n schema:\n $ref: \"#/patchDefinitions/generic-vnf\"\n"},
+ {"CloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver","vserver","CloudInfrastructure","/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}"," - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__"," patch:\n tags:\n - CloudInfrastructure\n summary: update an existing vserver\n description: |\n Update an existing vserver\n #\n Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n The PUT operation will entirely replace an existing object.\n The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n #\n Other differences between PUT and PATCH are:\n #\n - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n operationId: UpdateCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__ - name: body\n in: body\n description: vserver object that needs to be updated.\n required: true\n schema:\n $ref: \"#/patchDefinitions/vserver\"\n"},
+// if ( StringUtils.isEmpty(tag) )
+ {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",""},
+// Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
+ {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",""},
+ // {"","ctag-pool","","","",""},
+// {"","pserver","","","",""},
+// {"","oam-network","","","",""},
+// {"","dvs-switch","","","",""},
+// {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
+
+ public PatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams=pathParams;
+ this.result = result;
+ }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+
+ }
+
+ @Test
+ public void testToString() {
+ PatchOperation patch = new PatchOperation(useOpId, xmlRootElementName, tag, path, pathParams);
+ String modResult = patch.toString();
+ assertThat(modResult, is(this.result));
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/PutOperationTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/PutOperationTest.java
new file mode 100644
index 00000000..b7cced06
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/PutOperationTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.onap.aai.introspection.Version;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class PutOperationTest {
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
+ private static Version v = Version.getLatest();
+
+ @Parameters
+ public static Collection<String []> testConditions() {
+ String inputs [][] = {
+ {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"," put:\n tags:\n - Network\n summary: create or update an existing generic-vnf\n description: |\n Create or update an existing generic-vnf.\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n operationId: createOrUpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__ - name: body\n in: body\n description: generic-vnf object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/"+v.name()+"/NetworkGenericVnfsGenericVnf.json)\n required: true\n schema:\n $ref: \"#/definitions/generic-vnf\"\n"},
+ {"CloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver","vserver","CloudInfrastructure","/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}"," - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__"," put:\n tags:\n - CloudInfrastructure\n summary: create or update an existing vserver\n description: |\n Create or update an existing vserver.\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n operationId: createOrUpdateCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: cloud-owner\n in: path\n description: Identifies the vendor and cloud name, e.g., att-aic. First part of composite key should be formatted as vendor-cloudname\n required: true\n type: string\n example: __CLOUD-OWNER__\n - name: cloud-region-id\n in: path\n description: Identifier used by the vendor for the region. Second part of composite key\n required: true\n type: string\n example: __CLOUD-REGION-ID__\n - name: tenant-id\n in: path\n description: Unique id relative to the cloud-region.\n required: true\n type: string\n example: __TENANT-ID__\n - name: vserver-id\n in: path\n description: Unique identifier for this vserver relative to its tenant\n required: true\n type: string\n example: __VSERVER-ID__ - name: body\n in: body\n description: vserver object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/"+v.name()+"/CloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver.json)\n required: true\n schema:\n $ref: \"#/definitions/vserver\"\n"},
+// if ( StringUtils.isEmpty(tag) )
+ {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",""},
+// Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
+ {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",""},
+ // {"","ctag-pool","","","",""},
+// {"","pserver","","","",""},
+// {"","oam-network","","","",""},
+// {"","dvs-switch","","","",""},
+// {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
+
+ public PutOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams=pathParams;
+ this.result = result;
+ }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+
+ }
+
+ @Test
+ public void testToString() {
+ PutOperation put = new PutOperation(useOpId, xmlRootElementName, tag, path, pathParams, Version.getLatest());
+ String modResult = put.toString();
+ assertThat(modResult, is(this.result));
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/PutRelationPathSetTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/PutRelationPathSetTest.java
new file mode 100644
index 00000000..6b8750fb
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/PutRelationPathSetTest.java
@@ -0,0 +1,223 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.JsonPath;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.util.GenerateXsd;
+
+import java.io.File;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class PutRelationPathSetTest {
+ private DocumentContext jsonContext;
+ private String json;
+ private EdgeRuleSet edgeRuleSet;
+ private Version v = Version.getLatest();
+ private File relationsFile = new File(GenerateXsd.getYamlDir() + "/relations/" + v.name()+"/createOrUpdateCloudInfrastructureCloudRegionsCloudRegionAvailabilityZonesAvailabilityZone.json");
+ private String target = "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/availability-zones/availability-zone/{availability-zone-name}/relationship-list/relationship";
+ private String opId = "createOrUpdateCloudInfrastructureCloudRegionsCloudRegionAvailabilityZonesAvailabilityZoneRelationshipListRelationship";
+ private String path = "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/availability-zones/availability-zone/{availability-zone-name}/relationship-list/relationship";
+ PutRelationPathSet prp = null;
+
+
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ json = "{"
+ + " \"rules\": ["
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"complex\","
+ + " \"label\": \"org.onap.relationships.inventory.LocatedIn\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"this description\""
+ + " },"
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"service-capability\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"availability-zone\","
+ + " \"to\": \"cloud-region\","
+ + " \"label\": \"org.onap.relationships.inventory.BelongsTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"!${direction}\","
+ + " \"delete-other-v\": \"!${direction}\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"NONE\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"ctag-pool\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"dvs-switch\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"generic-vnf\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"vf-module\","
+ + " \"to\": \"vnfc\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"ONE2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"pserver\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.MemberOf\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " {"
+ + " \"from\": \"vce\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\","
+ + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\","
+ + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\","
+ + " \"description\":\"\""
+ + " },"
+ + " ]}";
+ jsonContext = JsonPath.parse(json);
+ this.edgeRuleSet = new EdgeRuleSet(jsonContext);
+ DeleteOperation.deletePaths.put("/cloud-infrastructure/pservers/pserver/{hostname}","pserver");
+ DeleteOperation.deletePaths.put("/network/vces/vce/{vnf-id}","vce");
+ DeleteOperation.deletePaths.put("/cloud-infrastructure/complexes/complex/{physical-location-id}","complex");
+ DeleteOperation.deletePaths.put("/service-design-and-creation/service-capabilities/service-capability/{service-type}/{vnf-type}","service-capability");
+ DeleteOperation.deletePaths.put("/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}","cloud-region");
+ DeleteOperation.deletePaths.put("/network/generic-vnfs/generic-vnf/{vnf-id}","generic-vnf");
+ DeleteOperation.deletePaths.put("/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/dvs-switches/dvs-switch/{switch-name}","dvs-switch");
+ DeleteOperation.deletePaths.put("/cloud-infrastructure/complexes/complex/{physical-location-id}/ctag-pools/ctag-pool/{target-pe}/{availability-zone-name}","ctag-pool");
+
+ DeleteOperation.deletePaths.put(path.replace("/relationship-list/relationship", ""),"availability-zone");
+ PutRelationPathSet.add(opId, path);
+ }
+
+ @Test
+ public void testAdd() {
+ PutRelationPathSet.add(opId, path);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ assertThat(PutRelationPathSet.putRelationPaths.get(opId), is(target));
+ }
+
+ @Test
+ public void testPutRelationPathSet() {
+
+ this.prp = new PutRelationPathSet(v);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ prp.generateRelations(edgeRuleSet);
+ assertTrue(this.relationsFile.exists());
+ this.relationsFile.delete();
+ }
+
+ @Test
+ public void testPutRelationPathSetStringString() {
+ this.prp = new PutRelationPathSet(opId, path, v);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ }
+
+ @Test
+ public void testGenerateRelations() {
+ PutRelationPathSet prp = new PutRelationPathSet(opId, "availability-zone", v);
+ prp.generateRelations(edgeRuleSet);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ assertThat(PutRelationPathSet.putRelationPaths.get(opId), is(target));
+ assertTrue(this.relationsFile.exists());
+ this.relationsFile.delete();
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java
new file mode 100644
index 00000000..ccae8578
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDElementTest.java
@@ -0,0 +1,564 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.apache.commons.lang.StringUtils;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.collection.IsIn.in;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+import static org.hamcrest.core.Every.everyItem;
+import static org.junit.Assert.assertThat;
+
+public class XSDElementTest {
+ private static final Logger logger = LoggerFactory.getLogger("XSDElementTest.class");
+ private static final int maxSizeForXml = 20000;
+ protected String testXML;
+ protected Document doc = null;
+ protected NodeList javaTypeNodes=null;
+
+ public String getTestXML() {
+ return testXML;
+ }
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ StringBuilder sb = new StringBuilder(maxSizeForXml);
+ addNamespace(sb);
+ addBusiness(sb);
+ addCustomers(sb);
+ addCustomer(sb);
+ addServiceSubscriptions(sb);
+ addServiceSubscription(sb);
+ addEndOfXML(sb);
+ testXML = sb.toString();
+ init();
+ }
+
+ private void addNamespace(StringBuilder sb){
+ sb.append("<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org.v11\" xml-mapping-metadata-complete=\"true\">\n");
+ sb.append("<xml-schema element-form-default=\"QUALIFIED\">\n");
+ sb.append("<xml-ns namespace-uri=\"http://org.onap.aai.inventory/v11\" />\n");
+ sb.append("</xml-schema>\n");
+ sb.append("<java-types>\n");
+ sb.append("<java-type name=\"Inventory\">\n");
+ sb.append("<xml-root-element name=\"inventory\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element java-attribute=\"business\" name=\"business\" type=\"inventory.aai.onap.org.v11.Business\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addBusiness(StringBuilder sb){
+ sb.append("<java-type name=\"Business\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Namespace for business related constructs\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("<xml-root-element name=\"business\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element java-attribute=\"customers\" name=\"customers\" type=\"inventory.aai.onap.org.v11.Customers\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addCustomers(StringBuilder sb){
+ sb.append("<java-type name=\"Customers\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Collection of customer identifiers to provide linkage back to BSS information.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("<xml-root-element name=\"customers\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"customer\" name=\"customer\" type=\"inventory.aai.onap.org.v11.Customer\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"maximumDepth\" value=\"0\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addCustomer(StringBuilder sb){
+ sb.append("<java-type name=\"Customer\">\n");
+ sb.append("<xml-root-element name=\"customer\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element java-attribute=\"globalCustomerId\" name=\"global-customer-id\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Global customer id used across ECOMP to uniquely identify customer.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"subscriberName\" name=\"subscriber-name\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Subscriber name, an alternate way to retrieve a customer.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"subscriberType\" name=\"subscriber-type\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Subscriber type, a way to provide VID with only the INFRA customers.\" />\n");
+ sb.append("<xml-property name=\"defaultValue\" value=\"CUST\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n");
+// sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n");
+ sb.append("<xml-property name=\"nameProps\" value=\"subscriber-name\" />\n");
+ sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-name,global-customer-id,subscriber-type\" />\n");
+ sb.append("<xml-property name=\"searchable\" value=\"global-customer-id,subscriber-name\" />\n");
+ sb.append("<xml-property name=\"uniqueProps\" value=\"global-customer-id\" />\n");
+ sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
+ sb.append("<xml-property name=\"namespace\" value=\"business\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addServiceSubscriptions(StringBuilder sb){
+ sb.append("<java-type name=\"ServiceSubscriptions\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Collection of objects that group service instances.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("<xml-root-element name=\"service-subscriptions\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"serviceSubscription\" name=\"service-subscription\" type=\"inventory.aai.onap.org.v11.ServiceSubscription\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+ private void addServiceSubscription(StringBuilder sb){
+ sb.append("<java-type name=\"ServiceSubscription\">\n");
+ sb.append("<xml-root-element name=\"service-subscription\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element java-attribute=\"serviceType\" name=\"service-type\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Value defined by orchestration to identify this service across ECOMP.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"tempUbSubAccountId\" name=\"temp-ub-sub-account-id\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"This property will be deleted from A&amp;AI in the near future. Only stop gap solution.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+// sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Object that group service instances.\" />\n");
+ sb.append("<xml-property name=\"indexedProps\" value=\"service-type\" />\n");
+ sb.append("<xml-property name=\"dependentOn\" value=\"customer\" />\n");
+ sb.append("<xml-property name=\"container\" value=\"service-subscriptions\" />\n");
+ sb.append("<xml-property name=\"crossEntityReference\" value=\"service-instance,service-type\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addRelationshipList(StringBuilder sb ) {
+ sb.append("<java-type name=\"RelationshipList\">\n");
+ sb.append("<xml-root-element name=\"relationship-list\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationship\" name=\"relationship\" type=\"inventory.aai.onap.org.v11.Relationship\" />/n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addRelationship(StringBuilder sb ) {
+ sb.append("<java-type name=\"Relationship\">\n");
+ sb.append("<xml-root-element name=\"relationship\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element java-attribute=\"relatedTo\" name=\"related-to\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate type of node.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"relatedLink\" name=\"related-link\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"URL to the object in A&amp;AI.\" />");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationshipData\" name=\"relationship-data\" type=\"inventory.aai.onap.org.v11.RelationshipData\" />\n");
+ sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relatedToProperty\" name=\"related-to-property\" type=\"inventory.aai.onap.org.v11.RelatedToProperty\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addRelatedToProperty(StringBuilder sb) {
+ sb.append("<java-type name=\"RelatedToProperty\">\n");
+ sb.append("<xml-root-element name=\"related-to-property\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element java-attribute=\"propertyKey\" name=\"property-key\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Key part of a key/value pair\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"propertyValue\" name=\"property-value\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Value part of a key/value pair\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addRelationshipData(StringBuilder sb){
+ sb.append("<java-type name=\"RelationshipData\">\n");
+ sb.append("<xml-root-element name=\"relationship-data\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append("<xml-element java-attribute=\"relationshipKey\" name=\"relationship-key\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate an attribute.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("<xml-element java-attribute=\"relationshipValue\" name=\"relationship-value\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Value of the attribute.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+
+
+ private void addEndOfXML(StringBuilder sb){
+ sb.append("</java-types>\n");
+ sb.append("</xml-bindings>\n");
+ }
+
+ public void init() throws ParserConfigurationException, SAXException, IOException, AAIException {
+ DocumentBuilder dBuilder = null;
+ try {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ dbFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ dBuilder = dbFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw e;
+ }
+ try {
+ InputSource isInput = new InputSource(new StringReader(testXML));
+ doc = dBuilder.parse(isInput);
+ } catch (SAXException e) {
+ throw e;
+ } catch (IOException e) {
+ throw e;
+ }
+
+ NodeList bindingsNodes = doc.getElementsByTagName("xml-bindings");
+ Element bindingElement;
+ NodeList javaTypesNodes;
+ Element javaTypesElement;
+
+ if ( bindingsNodes == null || bindingsNodes.getLength() == 0 ) {
+ throw new AAIException("OXM file error: missing <binding-nodes> in XML");
+ }
+
+ bindingElement = (Element) bindingsNodes.item(0);
+ javaTypesNodes = bindingElement.getElementsByTagName("java-types");
+ if ( javaTypesNodes.getLength() < 1 ) {
+ throw new AAIException("OXM file error: missing <binding-nodes><java-types> in XML");
+ }
+ javaTypesElement = (Element) javaTypesNodes.item(0);
+
+ javaTypeNodes = javaTypesElement.getElementsByTagName("java-type");
+ if ( javaTypeNodes.getLength() < 1 ) {
+ throw new AAIException("OXM file error: missing <binding-nodes><java-types><java-type> in XML");
+ }
+ logger.debug(testXML);
+ }
+ @Test
+ public void testXSDElement() {
+ // repeat of testGetIndexedProps() which uses the constructor
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("subscriber-name");
+ target.add("global-customer-id");
+ target.add("subscriber-type");
+ target.add("service-type");
+
+ Vector<String> indexedProps = new Vector<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ indexedProps.addAll(javaTypeElement.getIndexedProps());
+ }
+ assertThat(new ArrayList<>(indexedProps),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ }
+
+ @Test
+ public void testName() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("ServiceSubscriptions");
+ target.add("ServiceSubscription");
+ target.add("Inventory");
+ target.add("Business");
+ target.add("Customers");
+ target.add("Customer");
+ ArrayList<String> names = new ArrayList<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ names.add(javaTypeElement.name());
+ }
+ logger.debug(String.join("|", names));
+ assertThat(names,both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ }
+
+ @Test
+ public void testGetAddTypes() {
+ HashMap<String,ArrayList<String>> map = new HashMap<String,ArrayList<String>>();
+ HashMap<String,ArrayList<String>> target = new HashMap<String,ArrayList<String>>();
+ target.put("Customer", new ArrayList<>(Arrays.asList("ServiceSubscriptions", "RelationshipList")));
+ target.put("Customer", new ArrayList<>(Arrays.asList("ServiceSubscriptions")));
+ target.put("Business", new ArrayList<>(Arrays.asList("Customers")));
+ target.put("Inventory", new ArrayList<>(Arrays.asList("Business")));
+ target.put("Customers", new ArrayList<>(Arrays.asList("Customer")));
+ target.put("ServiceSubscription", new ArrayList<>(Arrays.asList("RelationshipList")));
+ target.put("ServiceSubscription", new ArrayList<>(Arrays.asList()));
+ target.put("ServiceSubscriptions", new ArrayList<>(Arrays.asList("ServiceSubscription")));
+
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ ArrayList<String> addTypes = new ArrayList<String>();
+ NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
+ String name=javaTypeElement.name();
+ for ( int j = 0; j < xmlElementNodes.getLength(); ++j ) {
+ XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
+ addTypes.addAll(xmlElement.getAddTypes("v11"));
+ map.put(name,addTypes);
+ }
+ }
+ for(String key : map.keySet()) {
+ assertThat("Expected for key:"+key, map.get(key),equalTo(target.get(key)));
+ }
+ }
+/*
+ @Test
+ public void testGetRequiredElements() {
+ HashMap<String,ArrayList<String>> map = new HashMap<String,ArrayList<String>>();
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("global-customer-id\n");
+ target.add("subscriber-name\n");
+ target.add("subscriber-type");
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ ArrayList<String> requiredItems = new ArrayList<String>();
+ String name=javaTypeElement.name();
+ requiredItems.addAll(javaTypeElement.getRequiredElements("v11"));
+ map.put(name,requiredItems);
+ }
+ for(String key : map.keySet()) {
+ assertThat(map.get(key),equalTo(target));
+ }
+ }
+*/
+ @Test
+ public void testGetPathDescriptionProperty() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("Namespace for business related constructs");
+ target.add("Collection of customer identifiers to provide linkage back to BSS information.");
+ target.add("customer identifiers to provide linkage back to BSS information.");
+ target.add("Collection of objects that group service instances.");
+ target.add("Object that group service instances.");
+ List<String> descs = new ArrayList<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if(javaTypeElement.getPathDescriptionProperty() != null)
+ descs.add(javaTypeElement.getPathDescriptionProperty());
+ }
+ logger.debug(String.join("|", descs));
+ assertThat(new ArrayList<>(descs),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ }
+
+ @Test
+ public void testGetIndexedProps() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("subscriber-name");
+ target.add("global-customer-id");
+ target.add("subscriber-type");
+ target.add("service-type");
+
+ Vector<String> indexedProps = new Vector<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ indexedProps.addAll(javaTypeElement.getIndexedProps());
+ }
+ assertThat(new ArrayList<>(indexedProps),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ }
+
+ @Test
+ public void testGetContainerProperty() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("service-subscriptions");
+ target.add("customers");
+ List<String> containers = new ArrayList<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if(javaTypeElement.getContainerProperty() != null)
+ containers.add(javaTypeElement.getContainerProperty());
+ }
+ logger.debug(String.join("|", containers));
+ assertThat(new ArrayList<>(containers),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ }
+
+ @Test
+ public void testGetQueryParamYAML() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(" - name: global-customer-id\n in: query\n description:\n required: false\n type: string\n");
+ target.add(" - name: subscriber-name\n in: query\n description:\n required: false\n type: string\n");
+ target.add(" - name: subscriber-type\n in: query\n description:\n required: false\n type: string\n");
+ Vector<String> indexedProps = new Vector<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if(javaTypeElement.getContainerProperty() != null) {
+ indexedProps.addAll(javaTypeElement.getIndexedProps());
+ String container = javaTypeElement.getContainerProperty();
+ Vector<String> containerProps = new Vector<String>();
+ NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
+ for ( int j = 0; j < xmlElementNodes.getLength(); ++j ) {
+ XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
+ if(indexedProps.contains(xmlElement.name()))
+ containerProps.add(xmlElement.getQueryParamYAML());
+ }
+ GetOperation.addContainerProps(container, containerProps);
+ }
+ }
+/*
+ List<String> queryParams = new ArrayList<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if(javaTypeElement.getQueryParamYAML() != null)
+ queryParams.add(javaTypeElement.getQueryParamYAML());
+ }
+*/
+ assertThat(GetOperation.containers.get("customers"),equalTo( target));
+ }
+
+ @Test
+ public void testGetPathParamYAML() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(" - name: Inventory\n in: path\n description: Inventory\n required: true\n example: __INVENTORY__\n");
+ target.add(" - name: Business\n in: path\n description: Business\n required: true\n example: __BUSINESS__\n");
+ target.add(" - name: Customers\n in: path\n description: Customers\n required: true\n example: __CUSTOMERS__\n");
+ target.add(" - name: Customer\n in: path\n description: Customer\n required: true\n example: __CUSTOMER__\n");
+ target.add(" - name: ServiceSubscriptions\n in: path\n description: ServiceSubscriptions\n required: true\n example: __SERVICESUBSCRIPTIONS__\n");
+ target.add(" - name: ServiceSubscription\n in: path\n description: ServiceSubscription\n required: true\n example: __SERVICESUBSCRIPTION__\n");
+ List<String> pathParams = new ArrayList<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if(javaTypeElement.getPathParamYAML(javaTypeElement.name()) != null)
+ pathParams.add(javaTypeElement.getPathParamYAML(javaTypeElement.name()));
+ }
+ logger.debug(String.join("|", pathParams));
+ assertThat(new ArrayList<>(pathParams),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ }
+
+ @Test
+ public void testGetHTMLAnnotation() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"Business\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n");
+ target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"Customers\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n");
+ target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"Customer\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n");
+ target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"ServiceSubscriptions\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n");
+ target.add(" <xs:annotation>\r\n <xs:appinfo>\r\n <annox:annotate target=\"ServiceSubscription\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>\r\n </xs:appinfo>\r\n </xs:annotation>\r\n");
+ List<String> annotes = new ArrayList<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if(StringUtils.isNotEmpty(javaTypeElement.getHTMLAnnotation(javaTypeElement.name(),"")))
+ annotes.add(javaTypeElement.getHTMLAnnotation(javaTypeElement.name(), " "));
+ }
+ logger.debug("result:");
+ logger.debug(String.join("|", annotes));
+ logger.debug("Expected:");
+ logger.debug(String.join("|", target));
+ assertThat(new ArrayList<>(annotes),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+
+ }
+
+ @Test
+ public void testGetTypePropertyYAML() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(" Inventory:\n type: ");
+ target.add(" Business:\n type: description: Namespace for business related constructs\n");
+ target.add(" Customers:\n type: description: Collection of customer identifiers to provide linkage back to BSS information.\n");
+ target.add(" Customer:\n type: description: customer identifiers to provide linkage back to BSS information.\n");
+ target.add(" ServiceSubscriptions:\n type: description: Collection of objects that group service instances.\n");
+ target.add(" ServiceSubscription:\n type: description: Object that group service instances.\n");
+ List<String> types = new ArrayList<String>();
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if(javaTypeElement.getTypePropertyYAML() != null)
+ types.add(javaTypeElement.getTypePropertyYAML());
+ }
+ assertThat(new ArrayList<>(types),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ }
+
+ @Test
+ public void testIsStandardType() {
+ HashMap<String,ArrayList<String>> map = new HashMap<String,ArrayList<String>>();
+ HashMap<String,ArrayList<String>> target = new HashMap<String,ArrayList<String>>();
+ target.put("Customer", new ArrayList<>(Arrays.asList("global-customer-id","subscriber-name", "subscriber-type","resource-version")));
+ target.put("Business", new ArrayList<>());
+ target.put("Inventory", new ArrayList<>());
+ target.put("Customers", new ArrayList<>());
+ target.put("ServiceSubscriptions", new ArrayList<>());
+ target.put("ServiceSubscription", new ArrayList<>(Arrays.asList("service-type", "temp-ub-sub-account-id", "resource-version")));
+
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ ArrayList<String> addTypes = new ArrayList<String>();
+ NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
+ String name=javaTypeElement.name();
+ for ( int j = 0; j < xmlElementNodes.getLength(); ++j ) {
+ XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
+ if(xmlElement.isStandardType())
+ addTypes.add(xmlElement.name());
+ }
+ map.put(name,addTypes);
+ }
+ for(String key : map.keySet()) {
+ assertThat(map.get(key),equalTo(target.get(key)));
+ }
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDJavaTypeTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDJavaTypeTest.java
new file mode 100644
index 00000000..7a2f9be9
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/XSDJavaTypeTest.java
@@ -0,0 +1,101 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Element;
+
+import java.util.HashMap;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class XSDJavaTypeTest extends XSDElementTest {
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Test
+ public void testXSDJavaTypeElement() {
+ HashMap<String,String> map = new HashMap<String,String>();
+ HashMap<String,String> target = new HashMap<String,String>();
+ target.put("Customer", "global-customer-id");
+ target.put("Business", "customers");
+ target.put("Inventory", "business");
+ target.put("Customers","customer");
+ target.put("ServiceSubscriptions", "service-subscription");
+ target.put("ServiceSubscription", "service-type");
+
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ XSDJavaType javaType = new XSDJavaType(javaTypeElement);
+ map.put(javaType.name(),javaType.getItemName());
+ }
+ for(String key : map.keySet()) {
+ assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
+ }
+ }
+
+ @Test
+ public void testGetItemName() {
+ HashMap<String,String> map = new HashMap<String,String>();
+ HashMap<String,String> target = new HashMap<String,String>();
+ target.put("Customer", "global-customer-id");
+ target.put("Business", "customers");
+ target.put("Inventory", "business");
+ target.put("Customers","customer");
+ target.put("ServiceSubscriptions", "service-subscription");
+ target.put("ServiceSubscription", "service-type");
+
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ XSDJavaType javaType = new XSDJavaType(javaTypeElement);
+ map.put(javaType.name(),javaType.getItemName());
+ }
+ for(String key : map.keySet()) {
+ assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
+ }
+ }
+
+ @Test
+ public void testGetArrayType() {
+ HashMap<String,String> map = new HashMap<String,String>();
+ HashMap<String,String> target = new HashMap<String,String>();
+ target.put("Customer", null);
+ target.put("Business", null);
+ target.put("Inventory", null);
+ target.put("Customers","customer");
+ target.put("ServiceSubscriptions", "service-subscription");
+ target.put("ServiceSubscription", null);
+
+ for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ XSDJavaType javaType = new XSDJavaType(javaTypeElement);
+ map.put(javaType.name(),javaType.getArrayType());
+ }
+ for(String key : map.keySet()) {
+ assertThat(map.get(key),equalTo(target.get(key)));
+ }
+ }
+
+}
diff --git a/aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java b/aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java
new file mode 100644
index 00000000..665c770b
--- /dev/null
+++ b/aai-core/src/test/java/org/onap/aai/util/genxsd/YAMLfromOXMTest.java
@@ -0,0 +1,826 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.util.genxsd;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.introspection.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class YAMLfromOXMTest {
+ private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
+ private String testXML;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ XSDElementTest x = new XSDElementTest();
+ x.setUp();
+ testXML = x.testXML;
+ logger.debug(testXML);
+ }
+
+ @Test
+ public void testGetDocumentHeader() {
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ String header = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ swagger.process();
+ header = swagger.getDocumentHeader();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Header:\n"+header,header, is(YAMLheader()));
+ }
+
+ @Test
+ public void testProcess() {
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ String fileContent = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ fileContent = swagger.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
+ }
+
+ @Test
+ public void testYAMLfromOXMFileVersionFile() throws IOException {
+ String outfileName = "testXML.xml";
+ File XMLfile = new File(outfileName);
+ XMLfile.createNewFile();
+ BufferedWriter bw = null;
+ Charset charset = Charset.forName("UTF-8");
+ Path path = Paths.get(outfileName);
+ bw = Files.newBufferedWriter(path, charset);
+ bw.write(testXML);
+ bw.close();
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ String fileContent = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(XMLfile, v, edgeRuleFile);
+ fileContent = swagger.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ XMLfile.delete();
+ assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
+ }
+
+ @Test
+ public void testYAMLfromOXMStringVersionFile() {
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ String fileContent = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ fileContent = swagger.process();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
+ }
+
+ @Test
+ public void testAppendDefinitions() {
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ String definitions = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ swagger.process();
+ definitions = swagger.appendDefinitions();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Definitions:\n"+definitions,definitions, is(YAMLdefs()+YAMLpatchDefs()+YAMLgetDefs()));
+ }
+
+ @Test
+ public void testGetXMLRootElementName() {
+ String target = "RootElement=customer";
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ Element customer = null;
+ String root = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ swagger.process();
+ customer = swagger.getJavaTypeElementSwagger("Customer");
+ root = swagger.getXMLRootElementName(customer);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("RootElement="+root, is(target));
+ }
+
+ @Test
+ public void testGetXmlRootElementName() {
+ String target = "RootElement=customer";
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ String root = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ swagger.process();
+ root = swagger.getXmlRootElementName("Customer");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("RootElement="+root, is(target));
+ }
+
+ @Test
+ public void testGetJavaTypeElementSwagger() {
+ String target = "Element=java-type/Customer";
+ Version v = Version.v11;
+ String apiVersion = v.toString();
+ Element customer = null;
+ File edgeRuleFile = new File("../aai-core" + "/src/main/resources/dbedgerules/DbEdgeRules_" + apiVersion + ".json");
+ try {
+ YAMLfromOXM swagger = new YAMLfromOXM(testXML, v, edgeRuleFile);
+ swagger.process();
+ customer = swagger.getJavaTypeElementSwagger("Customer");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
+ }
+
+ public String YAMLresult() {
+ StringBuilder sb = new StringBuilder(32368);
+ sb.append(YAMLheader());
+ sb.append(YAMLops());
+ sb.append(YAMLdefs());
+ sb.append(YAMLpatchDefs());
+ sb.append(YAMLgetDefs());
+ return sb.toString();
+ }
+ public String YAMLheader() {
+ StringBuilder sb = new StringBuilder(1500);
+ sb.append("swagger: \"2.0\"\n");
+ sb.append("info:\n");
+ sb.append(" description: |\n");
+ sb.append("\n");
+ sb.append(" [Differences versus the previous schema version](apidocs/aai_swagger_v11.diff)\n");
+ sb.append("\n");
+ sb.append(" Copyright &copy; 2017 AT&amp;T Intellectual Property. All rights reserved.\n");
+ sb.append("\n");
+ sb.append(" Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License.\n");
+ sb.append("\n");
+ sb.append(" You may obtain a copy of the License at\n");
+ sb.append("\n");
+ sb.append(" (https://creativecommons.org/licenses/by/4.0/)\n");
+ sb.append("\n");
+ sb.append(" Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; 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.\n");
+ sb.append("\n");
+ sb.append(" ECOMP and OpenECOMP are trademarks and service marks of AT&amp;T Intellectual Property.\n");
+ sb.append("\n");
+ sb.append(" This document is best viewed with Firefox or Chrome. Nodes can be found by appending /#/definitions/node-type-to-find to the path to this document. Edge definitions can be found with the node definitions.\n");
+ sb.append(" version: \"v11\"\n");
+ sb.append(" title: Active and Available Inventory REST API\n");
+ sb.append(" license:\n");
+ sb.append(" name: Apache 2.0\n");
+ sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html\n");
+ sb.append(" contact:\n");
+ sb.append(" name:\n");
+ sb.append(" url:\n");
+ sb.append(" email:\n");
+ sb.append("host:\n");
+ sb.append("basePath: /aai/v11\n");
+ sb.append("schemes:\n");
+ sb.append(" - https\n");
+ sb.append("paths:\n");
+ return sb.toString();
+ }
+
+ public String YAMLops() {
+ StringBuilder sb = new StringBuilder(16384);
+ sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns service-subscription\n");
+ sb.append(" description: returns service-subscription\n");
+ sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Value defined by orchestration to identify this service across ECOMP.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" put:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: create or update an existing service-subscription\n");
+ sb.append(" description: |\n");
+ sb.append(" Create or update an existing service-subscription.\n");
+ sb.append(" #\n");
+ sb.append(" Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
+ sb.append(" operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Value defined by orchestration to identify this service across ECOMP.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(" description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ sb.append(" patch:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: update an existing service-subscription\n");
+ sb.append(" description: |\n");
+ sb.append(" Update an existing service-subscription\n");
+ sb.append(" #\n");
+ sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
+ sb.append(" The PUT operation will entirely replace an existing object.\n");
+ sb.append(" The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n");
+ sb.append(" #\n");
+ sb.append(" Other differences between PUT and PATCH are:\n");
+ sb.append(" #\n");
+ sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
+ sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
+ sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
+ sb.append(" operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Value defined by orchestration to identify this service across ECOMP.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(" description: service-subscription object that needs to be updated.\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
+ sb.append(" delete:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: delete an existing service-subscription\n");
+ sb.append(" description: delete an existing service-subscription\n");
+ sb.append(" operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Value defined by orchestration to identify this service across ECOMP.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" - name: resource-version\n");
+ sb.append(" in: query\n");
+ sb.append(" description: resource-version for concurrency\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns service-subscriptions\n");
+ sb.append(" description: returns service-subscriptions\n");
+ sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/getDefinitions/service-subscriptions\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: query\n");
+ sb.append(" description:\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" /business/customers/customer/{global-customer-id}:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns customer\n");
+ sb.append(" description: returns customer\n");
+ sb.append(" operationId: getBusinessCustomersCustomer\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/getDefinitions/customer\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" put:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: create or update an existing customer\n");
+ sb.append(" description: |\n");
+ sb.append(" Create or update an existing customer.\n");
+ sb.append(" #\n");
+ sb.append(" Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
+ sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(" description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/relations/v11/BusinessCustomersCustomer.json)\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" patch:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: update an existing customer\n");
+ sb.append(" description: |\n");
+ sb.append(" Update an existing customer\n");
+ sb.append(" #\n");
+ sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
+ sb.append(" The PUT operation will entirely replace an existing object.\n");
+ sb.append(" The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n");
+ sb.append(" #\n");
+ sb.append(" Other differences between PUT and PATCH are:\n");
+ sb.append(" #\n");
+ sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
+ sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
+ sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
+ sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(" description: customer object that needs to be updated.\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
+ sb.append(" delete:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: delete an existing customer\n");
+ sb.append(" description: delete an existing customer\n");
+ sb.append(" operationId: deleteBusinessCustomersCustomer\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: resource-version\n");
+ sb.append(" in: query\n");
+ sb.append(" description: resource-version for concurrency\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" /business/customers:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns customers\n");
+ sb.append(" description: returns customers\n");
+ sb.append(" operationId: getBusinessCustomers\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/getDefinitions/customers\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: query\n");
+ sb.append(" description:\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" - name: subscriber-name\n");
+ sb.append(" in: query\n");
+ sb.append(" description:\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" - name: subscriber-type\n");
+ sb.append(" in: query\n");
+ sb.append(" description:\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ return sb.toString();
+ }
+ public String YAMLdefs() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append("definitions:\n");
+ sb.append(" business:\n");
+ sb.append(" description: |\n");
+ sb.append(" Namespace for business related constructs\n");
+ sb.append(" properties:\n");
+ sb.append(" customers:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" customer:\n");
+ sb.append(" description: |\n");
+ sb.append(" customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(" - FROM service-subscription( service-subscription BelongsTo customer, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - global-customer-id\n");
+ sb.append(" - subscriber-name\n");
+ sb.append(" - subscriber-type\n");
+ sb.append(" properties:\n");
+ sb.append(" global-customer-id:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" subscriber-name:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
+ sb.append(" subscriber-type:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ sb.append(" customers:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" properties:\n");
+ sb.append(" customer:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" inventory:\n");
+ sb.append(" properties:\n");
+ sb.append(" business:\n");
+ sb.append(" type: object\n");
+ sb.append(" $ref: \"#/definitions/business\"\n");
+ sb.append(" nodes:\n");
+ sb.append(" properties:\n");
+ sb.append(" inventory-item-data:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/definitions/inventory-item-data\"\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" description: |\n");
+ sb.append(" Object that group service instances.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(" - TO customer( service-subscription BelongsTo customer, MANY2ONE)(4)\n");
+ sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
+ sb.append(" - FROM service-instance( service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
+ sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - service-type\n");
+ sb.append(" properties:\n");
+ sb.append(" service-type:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Value defined by orchestration to identify this service across ECOMP.\n");
+ sb.append(" temp-ub-sub-account-id:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of objects that group service instances.\n");
+ sb.append(" properties:\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ return sb.toString();
+ }
+ public String YAMLpatchDefs() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append("patchDefinitions:\n");
+ sb.append(" business:\n");
+ sb.append(" description: |\n");
+ sb.append(" Namespace for business related constructs\n");
+ sb.append(" properties:\n");
+ sb.append(" customers:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
+ sb.append(" customer:\n");
+ sb.append(" description: |\n");
+ sb.append(" customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(" - FROM service-subscription( service-subscription BelongsTo customer, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - global-customer-id\n");
+ sb.append(" - subscriber-name\n");
+ sb.append(" - subscriber-type\n");
+ sb.append(" properties:\n");
+ sb.append(" global-customer-id:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" subscriber-name:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
+ sb.append(" subscriber-type:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
+ sb.append(" customers:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" properties:\n");
+ sb.append(" customer:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/patchDefinitions/customer\"\n");
+ sb.append(" inventory:\n");
+ sb.append(" properties:\n");
+ sb.append(" business:\n");
+ sb.append(" type: object\n");
+ sb.append(" $ref: \"#/patchDefinitions/business\"\n");
+ sb.append(" nodes:\n");
+ sb.append(" properties:\n");
+ sb.append(" inventory-item-data:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/patchDefinitions/inventory-item-data\"\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" description: |\n");
+ sb.append(" Object that group service instances.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(" - TO customer( service-subscription BelongsTo customer, MANY2ONE)(4)\n");
+ sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
+ sb.append(" - FROM service-instance( service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
+ sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - service-type\n");
+ sb.append(" properties:\n");
+ sb.append(" service-type:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Value defined by orchestration to identify this service across ECOMP.\n");
+ sb.append(" temp-ub-sub-account-id:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of objects that group service instances.\n");
+ sb.append(" properties:\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/patchDefinitions/service-subscription\"\n");
+ return sb.toString();
+ }
+ public String YAMLgetDefs() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append("getDefinitions:\n");
+ sb.append(" business:\n");
+ sb.append(" description: |\n");
+ sb.append(" Namespace for business related constructs\n");
+ sb.append(" properties:\n");
+ sb.append(" customers:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/getDefinitions/customer\"\n");
+ sb.append(" customer:\n");
+ sb.append(" description: |\n");
+ sb.append(" customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(" - FROM service-subscription( service-subscription BelongsTo customer, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - global-customer-id\n");
+ sb.append(" - subscriber-name\n");
+ sb.append(" - subscriber-type\n");
+ sb.append(" properties:\n");
+ sb.append(" global-customer-id:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Global customer id used across ECOMP to uniquely identify customer.\n");
+ sb.append(" subscriber-name:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
+ sb.append(" subscriber-type:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
+ sb.append(" customers:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" properties:\n");
+ sb.append(" customer:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/getDefinitions/customer\"\n");
+ sb.append(" inventory:\n");
+ sb.append(" properties:\n");
+ sb.append(" business:\n");
+ sb.append(" type: object\n");
+ sb.append(" $ref: \"#/getDefinitions/business\"\n");
+ sb.append(" nodes:\n");
+ sb.append(" properties:\n");
+ sb.append(" inventory-item-data:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/getDefinitions/inventory-item-data\"\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" description: |\n");
+ sb.append(" Object that group service instances.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(" - TO customer( service-subscription BelongsTo customer, MANY2ONE)(4)\n");
+ sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
+ sb.append(" - FROM service-instance( service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
+ sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - service-type\n");
+ sb.append(" properties:\n");
+ sb.append(" service-type:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Value defined by orchestration to identify this service across ECOMP.\n");
+ sb.append(" temp-ub-sub-account-id:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of objects that group service instances.\n");
+ sb.append(" properties:\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/getDefinitions/service-subscription\"\n");
+ return sb.toString();
+ }
+}