summaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
Diffstat (limited to 'aai-core')
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/IntrospectorTestSpec.java56
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java22
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java64
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java172
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java372
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java572
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java236
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java94
8 files changed, 794 insertions, 794 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/IntrospectorTestSpec.java b/aai-core/src/test/java/org/onap/aai/introspection/IntrospectorTestSpec.java
index 3a875062..44cbe6cc 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/IntrospectorTestSpec.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/IntrospectorTestSpec.java
@@ -26,32 +26,32 @@ import static org.junit.Assert.assertEquals;
public abstract class IntrospectorTestSpec extends AAISetup {
-
-
- /**
- * Container test set.
- *
- * @param wrappedPortGroups the wrapped port groups
- * @throws AAIUnknownObjectException
- */
- protected void containerTestSet(Introspector wrappedPortGroups) throws AAIUnknownObjectException {
-
- assertEquals(
- "isContainer",
- true,
- wrappedPortGroups.isContainer());
-
- assertEquals(
- "newInstanceOfNestedProperty",
- "PortGroup",
- wrappedPortGroups.newInstanceOfNestedProperty("port-group").getClass().getSimpleName());
-
- assertEquals(
- "isComplexGenericType",
- true,
- wrappedPortGroups.isComplexGenericType("port-group"));
-
-
- }
-
+
+
+ /**
+ * Container test set.
+ *
+ * @param wrappedPortGroups the wrapped port groups
+ * @throws AAIUnknownObjectException
+ */
+ protected void containerTestSet(Introspector wrappedPortGroups) throws AAIUnknownObjectException {
+
+ assertEquals(
+ "isContainer",
+ true,
+ wrappedPortGroups.isContainer());
+
+ assertEquals(
+ "newInstanceOfNestedProperty",
+ "PortGroup",
+ wrappedPortGroups.newInstanceOfNestedProperty("port-group").getClass().getSimpleName());
+
+ assertEquals(
+ "isComplexGenericType",
+ true,
+ wrappedPortGroups.isComplexGenericType("port-group"));
+
+
+ }
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java b/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java
index e5ecaee6..463c9174 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java
@@ -27,21 +27,21 @@ import org.springframework.test.annotation.DirtiesContext;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class MoxyEngineTest extends IntrospectorTestSpec {
- /**
- * Container object.
- * @throws AAIUnknownObjectException
- */
- @Test
- public void containerObject() throws AAIUnknownObjectException {
-
+ /**
+ * Container object.
+ * @throws AAIUnknownObjectException
+ */
+ @Test
+ public void containerObject() throws AAIUnknownObjectException {
+
Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
Introspector obj = loader.introspectorFromName("port-groups");
this.containerTestSet(obj);
- }
-
-
-
+ }
+
+
+
}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java b/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java
index 882b67e9..190e3243 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/PropertyPredicatesTest.java
@@ -35,40 +35,40 @@ import static org.junit.Assert.assertThat;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class PropertyPredicatesTest extends AAISetup {
- private Loader loader;
- private ModelType introspectorFactoryType = ModelType.MOXY;
- private Introspector obj;
-
- @Before
- public void setup() throws Exception {
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
- obj = loader.introspectorFromName("generic-vnf");
- }
-
- @Test
- public void includeInTestGeneration() throws AAIUnknownObjectException {
-
- Set<String> props = obj.getProperties(PropertyPredicates.includeInTestGeneration());
+ private Loader loader;
+ private ModelType introspectorFactoryType = ModelType.MOXY;
+ private Introspector obj;
+
+ @Before
+ public void setup() throws Exception {
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ obj = loader.introspectorFromName("generic-vnf");
+ }
+
+ @Test
+ public void includeInTestGeneration() throws AAIUnknownObjectException {
+
+ Set<String> props = obj.getProperties(PropertyPredicates.includeInTestGeneration());
- assertThat("props not found", props,
- not(hasItems("model-invariant-id", "model-version-id")));
- }
-
- @Test
- public void isVisible() throws AAIUnknownObjectException {
-
- Set<String> props = obj.getProperties(PropertyPredicates.isVisible());
+ assertThat("props not found", props,
+ not(hasItems("model-invariant-id", "model-version-id")));
+ }
+
+ @Test
+ public void isVisible() throws AAIUnknownObjectException {
+
+ Set<String> props = obj.getProperties(PropertyPredicates.isVisible());
- assertThat("props not found", props, hasItems("model-invariant-id", "model-version-id"));
- }
-
- @Test
- public void all() throws AAIUnknownObjectException {
-
- Set<String> props = obj.getProperties();
+ assertThat("props not found", props, hasItems("model-invariant-id", "model-version-id"));
+ }
+
+ @Test
+ public void all() throws AAIUnknownObjectException {
+
+ Set<String> props = obj.getProperties();
- assertThat("all found", props, hasItems("model-invariant-id", "model-version-id"));
- }
-
+ assertThat("all found", props, hasItems("model-invariant-id", "model-version-id"));
+ }
+
}
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
index f0d39f9f..c7d4cf82 100644
--- 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
@@ -34,98 +34,98 @@ 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 Loader loader;
+
+ private static CreateExample createExample;
+ private Loader loader;
- private static boolean classLoaded = false;
-
-
- @BeforeClass
- public static void setUp() {
-
-
- }
-
-
- @Before
- public void createLoaderVersion(){
- if(!classLoaded){
- loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getAppRootVersion());
- createExample = new CreateExample(loader, "edge-prop-names");
- classLoaded = false;
- }
- }
-
- @Test
- public void testGetExampleObject() throws AAIException {
- Introspector introspector = loader.introspectorFromName("edge-prop-names");
- Introspector res = createExample.getExampleObject();
- assertEquals(introspector.getName(), res.getName());
- }
+ private static boolean classLoaded = false;
+
+
+ @BeforeClass
+ public static void setUp() {
+
+
+ }
+
+
+ @Before
+ public void createLoaderVersion(){
+ if(!classLoaded){
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getAppRootVersion());
+ createExample = new CreateExample(loader, "edge-prop-names");
+ classLoaded = false;
+ }
+ }
+
+ @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 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 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 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 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 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);
- }
+ @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 c94afd29..f9911295 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
@@ -63,199 +63,199 @@ import static org.mockito.Mockito.when;
public class DataCopyTest extends AAISetup{
-
-
- private static JanusGraph graph;
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- 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();
+
+
+ private static JanusGraph graph;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ 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();
-
- @Parameterized.Parameter(value = 0)
- public QueryStyle queryStyle;
+
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
- @Parameterized.Parameters(name = "QueryStyle.{0}")
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {QueryStyle.TRAVERSAL},
- {QueryStyle.TRAVERSAL_URI}
- });
- }
-
-
- @BeforeClass
- public static void setup() throws NoSuchFieldException, SecurityException, Exception {
- graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
-
- 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", 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();
- }
-
- @AfterClass
- public static void tearDown() {
- graph.tx().rollback();
- graph.close();
- }
-
- @Before
- public void initMock() {
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
- MockitoAnnotations.initMocks(this);
- dbEngine = new JanusGraphDBEngine(
- queryStyle,
- type,
- loader);
- }
-
- @Test
- public void runPopulatePersonaModelVer() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- final Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "myId");
- obj.setValue("model-invariant-id", "key1");
- obj.setValue("model-version-id", "key2");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- runner.execute(obj, self);
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL},
+ {QueryStyle.TRAVERSAL_URI}
+ });
+ }
+
+
+ @BeforeClass
+ public static void setup() throws NoSuchFieldException, SecurityException, Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+
+ 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", 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();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ graph.tx().rollback();
+ graph.close();
+ }
+
+ @Before
+ public void initMock() {
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ MockitoAnnotations.initMocks(this);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ }
+
+ @Test
+ public void runPopulatePersonaModelVer() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "myId");
+ obj.setValue("model-invariant-id", "key1");
+ obj.setValue("model-version-id", "key2");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
+
+ runner.execute(obj, self);
- assertEquals("value populated", "testValue", obj.getValue("persona-model-version"));
-
- g.tx().rollback();
-
-
- }
-
- @Test
- public void verifyNestedSideEffect() throws URISyntaxException, AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, IOException {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- final Introspector obj = loader.unmarshal("customer", this.getJsonString("nested-case.json"));
- //System.out.println(obj.marshal(true));
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.tx()).thenReturn(g);
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- when(uriQuery.isDependent()).thenReturn(false);
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- Vertex v= serializer.createNewVertex(obj);
- serializer.serializeToDb(obj, v, uriQuery, obj.getURI(), "test");
-
- assertEquals("nested value populated", "testValue", g.traversal().V().has("service-instance-id", "nested-instance-key").next().property("persona-model-version").orElse(""));
+ assertEquals("value populated", "testValue", obj.getValue("persona-model-version"));
+
+ g.tx().rollback();
+
+
+ }
+
+ @Test
+ public void verifyNestedSideEffect() throws URISyntaxException, AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, IOException {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.unmarshal("customer", this.getJsonString("nested-case.json"));
+ //System.out.println(obj.marshal(true));
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.tx()).thenReturn(g);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ when(uriQuery.isDependent()).thenReturn(false);
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ Vertex v= serializer.createNewVertex(obj);
+ serializer.serializeToDb(obj, v, uriQuery, obj.getURI(), "test");
+
+ assertEquals("nested value populated", "testValue", g.traversal().V().has("service-instance-id", "nested-instance-key").next().property("persona-model-version").orElse(""));
- g.tx().rollback();
+ g.tx().rollback();
- }
-
- @Test
- public void expectedMissingPropertyExceptionInURI() throws AAIException, UnsupportedEncodingException {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- final Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "myId");
- obj.setValue("model-invariant-id", "key1");
+ }
+
+ @Test
+ public void expectedMissingPropertyExceptionInURI() throws AAIException, UnsupportedEncodingException {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "myId");
+ obj.setValue("model-invariant-id", "key1");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- thrown.expect(AAIMissingRequiredPropertyException.class);
- runner.execute(obj, self);
- }
-
- @Test
- public void expectedMissingPropertyExceptionForResultingObject() throws AAIException, UnsupportedEncodingException {
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- final Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "myId");
- obj.setValue("model-invariant-id", "key3");
- obj.setValue("model-version-id", "key4");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
+
+ thrown.expect(AAIMissingRequiredPropertyException.class);
+ runner.execute(obj, self);
+ }
+
+ @Test
+ public void expectedMissingPropertyExceptionForResultingObject() throws AAIException, UnsupportedEncodingException {
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "myId");
+ obj.setValue("model-invariant-id", "key3");
+ obj.setValue("model-version-id", "key4");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- thrown.expect(AAIMissingRequiredPropertyException.class);
- runner.execute(obj, self);
- }
-
- @Test
- public void expectNoProcessingWithNoProperties() throws AAIException, UnsupportedEncodingException {
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- final Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "myId");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
+
+ thrown.expect(AAIMissingRequiredPropertyException.class);
+ runner.execute(obj, self);
+ }
+
+ @Test
+ public void expectNoProcessingWithNoProperties() throws AAIException, UnsupportedEncodingException {
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "myId");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
-
- runner.execute(obj, self);
-
- assertEquals("no model-version-id", true, obj.getValue("model-version-id") == null);
- assertEquals("no model-invariant-id", true, obj.getValue("model-invariant-id") == null);
-
- }
-
- private String getJsonString(String filename) throws IOException {
-
-
- FileInputStream is = new FileInputStream("src/test/resources/oxm/sideeffect/" + filename);
- String s = IOUtils.toString(is, "UTF-8");
- IOUtils.closeQuietly(is);
-
- return s;
- }
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataCopy.class).build();
+
+ runner.execute(obj, self);
+
+ assertEquals("no model-version-id", true, obj.getValue("model-version-id") == null);
+ assertEquals("no model-invariant-id", true, obj.getValue("model-invariant-id") == null);
+
+ }
+
+ private String getJsonString(String filename) throws IOException {
+
+
+ FileInputStream is = new FileInputStream("src/test/resources/oxm/sideeffect/" + filename);
+ String s = IOUtils.toString(is, "UTF-8");
+ IOUtils.closeQuietly(is);
+
+ return s;
+ }
}
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 c1218298..5b9a0fa6 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
@@ -64,303 +64,303 @@ import static org.mockito.Mockito.when;
@RunWith(value = Parameterized.class)
public class DataLinkTest extends DataLinkSetup {
- private static JanusGraph graph;
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
- private static Loader loader;
- private static TransactionalGraphEngine dbEngine;
- @Mock private QueryParser parser;
- @Mock private Vertex self;
- @Mock private VertexProperty<String> prop;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
+ private static JanusGraph graph;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private static Loader loader;
+ private static TransactionalGraphEngine dbEngine;
+ @Mock private QueryParser parser;
+ @Mock private Vertex self;
+ @Mock private VertexProperty<String> prop;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
-
- @Parameterized.Parameter(value = 0)
- public QueryStyle queryStyle;
+
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
- @Parameterized.Parameters(name = "QueryStyle.{0}")
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {QueryStyle.TRAVERSAL},
- {QueryStyle.TRAVERSAL_URI}
- });
- }
-
- @BeforeClass
- public static void setup() throws NoSuchFieldException, SecurityException, Exception {
- graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
-
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL},
+ {QueryStyle.TRAVERSAL_URI}
+ });
+ }
+
+ @BeforeClass
+ public static void setup() throws NoSuchFieldException, SecurityException, Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+
- 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",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", 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", 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().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",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", 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", 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();
- /*Commented for SysOut issues
- */
- //graph.traversal().V().has("aai-uri","/network/vpn-bindings/vpn-binding/deleteKey").properties().forEachRemaining(p->System.out.println(p.key() +" : " + p.value()));
-
- }
-
- @AfterClass
- public static void tearDown() {
- graph.tx().rollback();
- graph.close();
- }
-
- @Before
- public void initMock() {
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
- MockitoAnnotations.initMocks(this);
- dbEngine = new JanusGraphDBEngine(
- queryStyle,
- type,
- loader);
- }
-
- @Test
- public void verifyCreationOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "addKey");
- obj.setValue("global-route-target", "key1");
- obj.setValue("route-target-role", "key2");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
-// Graph g = graph.newTransaction();
-// GraphTraversalSource traversal = g;
- // System.out.println("Begin method inventory:");
- Iterator<Vertex> vertexItr = traversal.V();
- while( vertexItr != null && vertexItr.hasNext() ){
- Vertex v = vertexItr.next();
- // System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
- for(String key: v.keys()) {
- // System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+";id= "+v.id());
- }
- Direction d = null;
- Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
- while( edgeItr != null && edgeItr.hasNext() ){
- Edge e = edgeItr.next();
- //System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
- }
- }
- //System.out.println("End method inventory:");
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
-
- runner.execute(obj, self);
+ /*Commented for SysOut issues
+ */
+ //graph.traversal().V().has("aai-uri","/network/vpn-bindings/vpn-binding/deleteKey").properties().forEachRemaining(p->System.out.println(p.key() +" : " + p.value()));
+
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ graph.tx().rollback();
+ graph.close();
+ }
+
+ @Before
+ public void initMock() {
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ MockitoAnnotations.initMocks(this);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ }
+
+ @Test
+ public void verifyCreationOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
+ final Introspector obj = loader.introspectorFromName("vpn-binding");
+ obj.setValue("vpn-id", "addKey");
+ obj.setValue("global-route-target", "key1");
+ obj.setValue("route-target-role", "key2");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+// Graph g = graph.newTransaction();
+// GraphTraversalSource traversal = g;
+ // System.out.println("Begin method inventory:");
+ Iterator<Vertex> vertexItr = traversal.V();
+ while( vertexItr != null && vertexItr.hasNext() ){
+ Vertex v = vertexItr.next();
+ // System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
+ for(String key: v.keys()) {
+ // System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+";id= "+v.id());
+ }
+ Direction d = null;
+ Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
+ while( edgeItr != null && edgeItr.hasNext() ){
+ Edge e = edgeItr.next();
+ //System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
+ }
+ }
+ //System.out.println("End method inventory:");
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(spy.tx()).thenReturn(g);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
+
+ runner.execute(obj, self);
- assertEquals("route-target vertex found", true, traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "key1").has("route-target-role", "key2").has("linked", true).hasNext());
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyModificationOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "modifyKey");
- obj.setValue("global-route-target", "modifyTargetKey2");
- obj.setValue("route-target-role", "modifyRoleKey2");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
-// Graph g = graph.newTransaction();
-// GraphTraversalSource traversal = g;
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- Iterator<Vertex> vertexItr = traversal.V();
- while( vertexItr != null && vertexItr.hasNext() ){
- Vertex v = vertexItr.next();
- //System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
- for(String key: v.keys()) {
- //System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id());
- }
- Direction d = null;
- Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
- while( edgeItr != null && edgeItr.hasNext() ){
- Edge e = edgeItr.next();
- // System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
- }
- }
- // System.out.println("End method inventory:");
+ assertEquals("route-target vertex found", true, traversal.V()
+ .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "key1").has("route-target-role", "key2").has("linked", true).hasNext());
+ g.tx().rollback();
+
+ }
+
+ @Test
+ public void verifyModificationOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
+ final Introspector obj = loader.introspectorFromName("vpn-binding");
+ obj.setValue("vpn-id", "modifyKey");
+ obj.setValue("global-route-target", "modifyTargetKey2");
+ obj.setValue("route-target-role", "modifyRoleKey2");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+// Graph g = graph.newTransaction();
+// GraphTraversalSource traversal = g;
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ Iterator<Vertex> vertexItr = traversal.V();
+ while( vertexItr != null && vertexItr.hasNext() ){
+ Vertex v = vertexItr.next();
+ //System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
+ for(String key: v.keys()) {
+ //System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id());
+ }
+ Direction d = null;
+ Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
+ while( edgeItr != null && edgeItr.hasNext() ){
+ Edge e = edgeItr.next();
+ // System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
+ }
+ }
+ // System.out.println("End method inventory:");
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
-// when(spy.tx()).thenReturn(graph);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
- //System.out.println("Traversal Source: "+traversal.toString());
- vertexItr = traversal.V();
- // System.out.println("Begin method inventory:");
- while( vertexItr != null && vertexItr.hasNext() ){
- Vertex v = vertexItr.next();
- //System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
- for(String key: v.keys()) {
- // System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id());
- }
- Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
- while( edgeItr != null && edgeItr.hasNext() ){
- Edge e = edgeItr.next();
- //System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
- }
- }
- //System.out.println("End method inventory:");
- try {
- runner.execute(obj, self);
- } catch(Exception e) {
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+// when(spy.tx()).thenReturn(graph);
+ when(spy.tx()).thenReturn(g);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
+ //System.out.println("Traversal Source: "+traversal.toString());
+ vertexItr = traversal.V();
+ // System.out.println("Begin method inventory:");
+ while( vertexItr != null && vertexItr.hasNext() ){
+ Vertex v = vertexItr.next();
+ //System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
+ for(String key: v.keys()) {
+ // System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id());
+ }
+ Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
+ while( edgeItr != null && edgeItr.hasNext() ){
+ Edge e = edgeItr.next();
+ //System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
+ }
+ }
+ //System.out.println("End method inventory:");
+ try {
+ runner.execute(obj, self);
+ } catch(Exception e) {
- }
-// runner.execute(obj, self);
- //System.out.println("=================\n");
- vertexItr = traversal.V();
- while( vertexItr != null && vertexItr.hasNext() ){
- Vertex v = vertexItr.next();
- //System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
- for(String key: v.keys()) {
- // System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id());
- }
- Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
- while( edgeItr != null && edgeItr.hasNext() ){
- Edge e = edgeItr.next();
- // System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
- }
- }
- assertThat("new route-target vertex found with/or without link", traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").hasNext(),is(true));
- assertThat("new route-target vertex found", traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").has("linked", true).hasNext(),is(true));
- assertThat("previous link removed", traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").has("linked").hasNext(),is(not(true)));
- assertThat("previous vertex still exists", traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").hasNext(),is(true));
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyDeleteOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "deleteKey");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(adminSpy.getReadOnlyTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
-
- runner.execute(obj, self);
+ }
+// runner.execute(obj, self);
+ //System.out.println("=================\n");
+ vertexItr = traversal.V();
+ while( vertexItr != null && vertexItr.hasNext() ){
+ Vertex v = vertexItr.next();
+ //System.out.println("\nnodeType="+v.<String>property("aai-node-type"));
+ for(String key: v.keys()) {
+ // System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id());
+ }
+ Iterator<Edge> edgeItr = v.edges(Direction.BOTH);
+ while( edgeItr != null && edgeItr.hasNext() ){
+ Edge e = edgeItr.next();
+ // System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id());
+ }
+ }
+ assertThat("new route-target vertex found with/or without link", traversal.V()
+ .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").hasNext(),is(true));
+ assertThat("new route-target vertex found", traversal.V()
+ .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").has("linked", true).hasNext(),is(true));
+ assertThat("previous link removed", traversal.V()
+ .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").has("linked").hasNext(),is(not(true)));
+ assertThat("previous vertex still exists", traversal.V()
+ .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").hasNext(),is(true));
+ g.tx().rollback();
+
+ }
+
+ @Test
+ public void verifyDeleteOfVertex() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
+ final Introspector obj = loader.introspectorFromName("vpn-binding");
+ obj.setValue("vpn-id", "deleteKey");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(traversal);
+ when(spy.tx()).thenReturn(g);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build();
+
+ runner.execute(obj, self);
- assertEquals("route-target vertex not found", false, traversal.V()
- .has(AAIProperties.NODE_TYPE, "route-target")
- .has("global-route-target", "deleteTargetKey")
- .has("route-target-role", "deleteRoleKey")
- .has("linked", true)
- .hasNext()
- );
+ assertEquals("route-target vertex not found", false, traversal.V()
+ .has(AAIProperties.NODE_TYPE, "route-target")
+ .has("global-route-target", "deleteTargetKey")
+ .has("route-target-role", "deleteRoleKey")
+ .has("linked", true)
+ .hasNext()
+ );
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyPropertyPopulation() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "getKey");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- SideEffectRunner runner = new SideEffectRunner
- .Builder(spy, serializer).addSideEffect(DataLinkReader.class).build();
-
- runner.execute(obj, self);
+ g.tx().rollback();
+
+ }
+
+ @Test
+ public void verifyPropertyPopulation() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
+ final Introspector obj = loader.introspectorFromName("vpn-binding");
+ obj.setValue("vpn-id", "getKey");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(spy.tx()).thenReturn(g);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ SideEffectRunner runner = new SideEffectRunner
+ .Builder(spy, serializer).addSideEffect(DataLinkReader.class).build();
+
+ runner.execute(obj, self);
- assertEquals("both properties have been populated in target object", true, obj.getValue("global-route-target").equals("getTargetKey") && obj.getValue("route-target-role").equals("getRoleKey"));
- g.tx().rollback();
-
- }
-
- @Test
- public void verifyPropertyPopulationWithV10OnlyPut() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
- final Introspector obj = loader.introspectorFromName("vpn-binding");
- obj.setValue("vpn-id", "getKeyNoLink");
- final Introspector routeTargets = loader.introspectorFromName("route-targets");
- obj.setValue("route-targets", routeTargets.getUnderlyingObject());
- List<Object> targets = routeTargets.getValue("route-target");
- final Introspector routeTargetOne = loader.introspectorFromName("route-target");
- routeTargetOne.setValue("global-route-target", "getTargetKeyNoLink");
- routeTargetOne.setValue("route-target-role", "getRoleKeyNoLink");
- targets.add(routeTargetOne.getUnderlyingObject());
- final Introspector routeTargetTwo = loader.introspectorFromName("route-target");
- routeTargetTwo.setValue("global-route-target", "getTargetKeyNoLink2");
- routeTargetTwo.setValue("route-target-role", "getRoleKeyNoLink2");
- targets.add(routeTargetTwo.getUnderlyingObject());
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.tx()).thenReturn(g);
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
- when(spy.tx()).thenReturn(g);
- when(parser.isDependent()).thenReturn(false);
- when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
- when(prop.orElse(null)).thenReturn(obj.getURI());
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- Vertex v = serializer.createNewVertex(obj);
- serializer.serializeToDb(obj, v, parser, obj.getURI(), "testing");
- Vertex routeTargetOneV = traversal.V().has("global-route-target", "getTargetKeyNoLink").next();
- Vertex routeTargetTwoV = traversal.V().has("global-route-target", "getTargetKeyNoLink2").next();
+ assertEquals("both properties have been populated in target object", true, obj.getValue("global-route-target").equals("getTargetKey") && obj.getValue("route-target-role").equals("getRoleKey"));
+ g.tx().rollback();
+
+ }
+
+ @Test
+ public void verifyPropertyPopulationWithV10OnlyPut() throws URISyntaxException, AAIException, UnsupportedEncodingException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, MalformedURLException {
+ final Introspector obj = loader.introspectorFromName("vpn-binding");
+ obj.setValue("vpn-id", "getKeyNoLink");
+ final Introspector routeTargets = loader.introspectorFromName("route-targets");
+ obj.setValue("route-targets", routeTargets.getUnderlyingObject());
+ List<Object> targets = routeTargets.getValue("route-target");
+ final Introspector routeTargetOne = loader.introspectorFromName("route-target");
+ routeTargetOne.setValue("global-route-target", "getTargetKeyNoLink");
+ routeTargetOne.setValue("route-target-role", "getRoleKeyNoLink");
+ targets.add(routeTargetOne.getUnderlyingObject());
+ final Introspector routeTargetTwo = loader.introspectorFromName("route-target");
+ routeTargetTwo.setValue("global-route-target", "getTargetKeyNoLink2");
+ routeTargetTwo.setValue("route-target-role", "getRoleKeyNoLink2");
+ targets.add(routeTargetTwo.getUnderlyingObject());
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.tx()).thenReturn(g);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(spy.tx()).thenReturn(g);
+ when(parser.isDependent()).thenReturn(false);
+ when(self.<String>property(AAIProperties.AAI_URI)).thenReturn(prop);
+ when(prop.orElse(null)).thenReturn(obj.getURI());
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ Vertex v = serializer.createNewVertex(obj);
+ serializer.serializeToDb(obj, v, parser, obj.getURI(), "testing");
+ Vertex routeTargetOneV = traversal.V().has("global-route-target", "getTargetKeyNoLink").next();
+ Vertex routeTargetTwoV = traversal.V().has("global-route-target", "getTargetKeyNoLink2").next();
- assertEquals("first route target put has linked", true, routeTargetOneV.property(AAIProperties.LINKED).orElse(false));
- assertEquals("second route target put does not have linked", false, routeTargetTwoV.property(AAIProperties.LINKED).orElse(false));
+ assertEquals("first route target put has linked", true, routeTargetOneV.property(AAIProperties.LINKED).orElse(false));
+ assertEquals("second route target put does not have linked", false, routeTargetTwoV.property(AAIProperties.LINKED).orElse(false));
- g.tx().rollback();
-
- }
+ g.tx().rollback();
+
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java
index bfa77283..5cd1fb53 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java
@@ -58,125 +58,125 @@ import static org.mockito.Mockito.when;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class PrivateEdgeTest extends AAISetup{
- private static JanusGraph graph;
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
- private Loader loader;
- private static TransactionalGraphEngine dbEngine;
-
-
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
+ private static JanusGraph graph;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private static TransactionalGraphEngine dbEngine;
+
+
+
+ @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},
- {QueryStyle.TRAVERSAL_URI}
- });
- }
-
- @BeforeClass
- public static void setup() throws Exception {
-
- graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
-
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
-
-
-
- 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", "key100",
- AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key100").as("v5")
- .addV("aai-node-type", "model-ver",
- "model-ver", "myValue",
- "model-version-id", "key200",
- "model-version", "testValue",
- AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key100/model-vers/model-ver/key200")
- .addOutE("org.onap.relationships.inventory.BelongsTo", "v5",
- EdgeProperty.CONTAINS.toString(), true
- )
- .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();
- }
-
- @AfterClass
- public static void tearDown() {
- graph.tx().rollback();
- graph.close();
- }
-
- @Before
- public void initMock() {
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
- MockitoAnnotations.initMocks(this);
- dbEngine = new JanusGraphDBEngine(
- queryStyle,
- type,
- loader);
- }
-
- @Test
- public void testWhenPrivateEdgeThrowsExceptionWhenHavingOnlyOnePartOfKey() throws Exception {
-
- final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
- final Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "myId");
- obj.setValue("model-invariant-id", "key1");
- TransactionalGraphEngine spy = spy(dbEngine);
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Graph g = graph.newTransaction();
- GraphTraversalSource traversal = g.traversal();
- when(spy.asAdmin()).thenReturn(adminSpy);
- when(adminSpy.getTraversalSource()).thenReturn(traversal);
-
- Vertex selfV = traversal.addV(
- "aai-node-type", "generic-vnf",
- "vnf-id", "myId",
- "aai-uri",obj.getURI(),
- "model-invariant-id", "key1"
- ).next();
-
- thrown.expectMessage(containsString("Cannot complete privateEdge uri"));
- DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
- PrivateEdge privateEdge = new PrivateEdge(obj, selfV, spy, serializer);
- privateEdge.execute();
-
- List<Edge> edgeList = traversal.E().has("private", true).toList();
-
- assertNull(edgeList);
- assertThat(edgeList, is(not(empty())));
- assertThat(edgeList.size(), is(1));
-
- g.tx().rollback();
- }
+ @Parameterized.Parameter(value = 0)
+ public QueryStyle queryStyle;
+
+ @Parameterized.Parameters(name = "QueryStyle.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {QueryStyle.TRAVERSAL},
+ {QueryStyle.TRAVERSAL_URI}
+ });
+ }
+
+ @BeforeClass
+ public static void setup() throws Exception {
+
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+
+
+
+ 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", "key100",
+ AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key100").as("v5")
+ .addV("aai-node-type", "model-ver",
+ "model-ver", "myValue",
+ "model-version-id", "key200",
+ "model-version", "testValue",
+ AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key100/model-vers/model-ver/key200")
+ .addOutE("org.onap.relationships.inventory.BelongsTo", "v5",
+ EdgeProperty.CONTAINS.toString(), true
+ )
+ .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();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ graph.tx().rollback();
+ graph.close();
+ }
+
+ @Before
+ public void initMock() {
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ MockitoAnnotations.initMocks(this);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ }
+
+ @Test
+ public void testWhenPrivateEdgeThrowsExceptionWhenHavingOnlyOnePartOfKey() throws Exception {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "myId");
+ obj.setValue("model-invariant-id", "key1");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+
+ Vertex selfV = traversal.addV(
+ "aai-node-type", "generic-vnf",
+ "vnf-id", "myId",
+ "aai-uri",obj.getURI(),
+ "model-invariant-id", "key1"
+ ).next();
+
+ thrown.expectMessage(containsString("Cannot complete privateEdge uri"));
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
+ PrivateEdge privateEdge = new PrivateEdge(obj, selfV, spy, serializer);
+ privateEdge.execute();
+
+ List<Edge> edgeList = traversal.E().has("private", true).toList();
+
+ assertNull(edgeList);
+ assertThat(edgeList, is(not(empty())));
+ assertThat(edgeList.size(), is(1));
+
+ g.tx().rollback();
+ }
}
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java b/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java
index dac04769..0902aec8 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java
@@ -39,53 +39,53 @@ import static org.junit.Assert.assertEquals;
public class IntrospectorValidationTest extends AAISetup {
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private Loader loader;
- private IntrospectorValidator validator;
- @Autowired
- private LoaderFactory loaderFactory;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private Loader loader;
+ private IntrospectorValidator validator;
+ @Autowired
+ private LoaderFactory loaderFactory;
- @Before
- public void createValidator() throws Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getRelatedLinkVersion());
- validator = new IntrospectorValidator.Builder()
- .validateRequired(false)
- .restrictDepth(10000)
- .build();
- }
- @Ignore
- @Test
- public void verifySuccessWhenEmpty() throws AAIException {
- Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "key1");
- validator.validate(obj);
- List<Issue> issues = validator.getIssues();
- assertEquals("no issues found", true, issues.isEmpty());
- }
+ @Before
+ public void createValidator() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getRelatedLinkVersion());
+ validator = new IntrospectorValidator.Builder()
+ .validateRequired(false)
+ .restrictDepth(10000)
+ .build();
+ }
+ @Ignore
+ @Test
+ public void verifySuccessWhenEmpty() throws AAIException {
+ Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "key1");
+ validator.validate(obj);
+ List<Issue> issues = validator.getIssues();
+ assertEquals("no issues found", true, issues.isEmpty());
+ }
- @Ignore
- @Test
- public void verifyRequiresSingleFieldFailure() throws AAIException {
- Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "key1");
- obj.setValue("model-invariant-id", "id1");
- validator.validate(obj);
- List<Issue> issues = validator.getIssues();
- assertEquals("issues found", true, issues.size() == 1);
- Issue issue = issues.get(0);
- assertEquals("found expected issue", IssueType.DEPENDENT_PROP_NOT_FOUND, issue.getType());
- }
- @Ignore
- @Test
- public void verifyRequiresSuccess() throws AAIException {
- Introspector obj = loader.introspectorFromName("generic-vnf");
- obj.setValue("vnf-id", "key1");
- obj.setValue("model-invariant-id", "id1");
- obj.setValue("model-version-id", "version-id1");
- validator.validate(obj);
- List<Issue> issues = validator.getIssues();
- assertEquals("no issues found", true, issues.isEmpty());
- }
+ @Ignore
+ @Test
+ public void verifyRequiresSingleFieldFailure() throws AAIException {
+ Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "key1");
+ obj.setValue("model-invariant-id", "id1");
+ validator.validate(obj);
+ List<Issue> issues = validator.getIssues();
+ assertEquals("issues found", true, issues.size() == 1);
+ Issue issue = issues.get(0);
+ assertEquals("found expected issue", IssueType.DEPENDENT_PROP_NOT_FOUND, issue.getType());
+ }
+ @Ignore
+ @Test
+ public void verifyRequiresSuccess() throws AAIException {
+ Introspector obj = loader.introspectorFromName("generic-vnf");
+ obj.setValue("vnf-id", "key1");
+ obj.setValue("model-invariant-id", "id1");
+ obj.setValue("model-version-id", "version-id1");
+ validator.validate(obj);
+ List<Issue> issues = validator.getIssues();
+ assertEquals("no issues found", true, issues.isEmpty());
+ }
}