summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-06-08 00:11:22 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-06-08 00:11:49 -0400
commit3539b3d39458b0b12fec158290a90cc5060f64eb (patch)
treeb811cab0f25dcf151cc6036c0721df963ed259d6 /aai-traversal/src/test
parentef8823de263dd7c599ea7d8c5c6f0a56252b02ed (diff)
[AAI-ONAP] Keep the latest code in sync
Change-Id: Iebcff01ef3b79d04d14837d842fec0a1d6148703 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-traversal/src/test')
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java104
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java111
2 files changed, 46 insertions, 169 deletions
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java
deleted file mode 100644
index e0ad9fc..0000000
--- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/DbEdgeGroupTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.openecomp.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.aai.dbgraphgen;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.junit.Test;
-
-public class DbEdgeGroupTest {
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleMany2Many() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "l-interface", "logical-link"));
- }
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleMany2ManyRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "logical-link", "l-interface"));
- }
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleOne2One() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertFalse((Boolean)method.invoke(new DbEdgeGroup(), "l-interface", "sriov-vf"));
- }
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleOne2OneRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertFalse((Boolean)method.invoke(new DbEdgeGroup(), "sriov-vf", "l-interface"));
- }
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleMany2One() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertTrue((Boolean)method.invoke(new DbEdgeGroup(), "cloud-region", "complex"));
- }
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleMany2OneRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "complex", "cloud-region"));
- }
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleOne2Many() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertTrue(!(Boolean)method.invoke(new DbEdgeGroup(), "cloud-region", "tenant"));
- }
-
- @Test
- public void additionalEdgeWouldBreakMultEdgeRuleOne2ManyRev() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- Method method = DbEdgeGroup.class.getDeclaredMethod("additionalEdgeWouldBreakMultEdgeRule", String.class, String.class);
- method.setAccessible(true);
-
- assertFalse((Boolean)method.invoke(new DbEdgeGroup(), "tenant", "cloud-region"));
- }
-}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
index 30aa812..7579218 100644
--- a/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
+++ b/aai-traversal/src/test/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -19,68 +19,49 @@
*/
package org.openecomp.aai.dbgraphgen;
-//package org.openecomp.aai.dbgen;
-//
-//import java.util.ArrayList;
-//
-//import org.junit.BeforeClass;
-//import org.junit.Rule;
-//import org.junit.Test;
-//import org.junit.rules.ExpectedException;
-//
-//import org.openecomp.aai.exceptions.AAIException;
-//import org.openecomp.aai.ingestModel.DbMaps;
-//import org.openecomp.aai.ingestModel.IngestModelMoxyOxm;
-//import org.openecomp.aai.util.AAIConstants;
-//
-//public class ModelBasedProcessingTest {
-//
-// private static DbMaps dbMaps = null;
-// private static ModelBasedProcessing processor;
-// @BeforeClass
-// public static void configure() throws Exception {
-// System.setProperty("AJSC_HOME", ".");
-// System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
-// ArrayList<String> apiVersions = new ArrayList<String>();
-// apiVersions.add("v9");
-// apiVersions.add("v8");
-// apiVersions.add("v7");
-// apiVersions.add("v2");
-// IngestModelMoxyOxm m = new IngestModelMoxyOxm();
-// m.init(apiVersions);
-//
-// dbMaps = m.dbMapsContainer.get(AAIConstants.AAI_DEFAULT_API_VERSION);
-// processor = new ModelBasedProcessing();
-//
-// }
-//
-// @Rule
-// public ExpectedException expectedEx = ExpectedException.none();
-//
-// @Test
-// public void check4EdgeRuleThrowsExceptionWhenNodeTypeADoesNotExist() throws Exception {
-// String nodeTypeA = "cccomplex";
-// String nodeTypeB = "pserver";
-// expectedEx.expect(AAIException.class);
-// expectedEx.expectMessage("AAI_6115");
-// processor.check4EdgeRule(nodeTypeA, nodeTypeB, dbMaps);
-// }
-//
-// @Test
-// public void check4EdgeRuleThrowsExceptionWhenNodeTypeBDoesNotExist() throws Exception {
-// String nodeTypeA = "complex";
-// String nodeTypeB = "ppppserver";
-// expectedEx.expect(AAIException.class);
-// expectedEx.expectMessage("AAI_6115");
-// processor.check4EdgeRule(nodeTypeA, nodeTypeB, dbMaps);
-// }
-//
-// @Test
-// public void check4EdgeRuleThrowsExceptionWhenNoRuleExists() throws Exception {
-// String nodeTypeA = "complex";
-// String nodeTypeB = "service";
-// expectedEx.expect(AAIException.class);
-// expectedEx.expectMessage("AAI_6120");
-// processor.check4EdgeRule(nodeTypeA, nodeTypeB, dbMaps);
-// }
-//}
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.serialization.db.DBSerializer;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+
+public class ModelBasedProcessingTest {
+
+ @Mock private static TransactionalGraphEngine dbEngine;
+ private static Loader loader;
+ @Mock private static DBSerializer serializer;
+ @BeforeClass
+ public static void configure() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+
+ }
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testPropNameChange() throws AAIUnknownObjectException {
+ String result;
+ ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id");
+ assertEquals("result has -local tacked on the end as it should", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "vnf-id");
+ assertEquals("result does NOT have -local tacked on the end as it should", "vnf-id", result);
+ result = processor.getPropNameWithAliasIfNeeded("generic-vnf", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX);
+ assertEquals("property not modified because it already includes the right suffix", "model-invariant-id" + AAIProperties.DB_ALIAS_SUFFIX, result);
+ }
+}