package org.onap.aai.serialization.db;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.UnsupportedEncodingException;
-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;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.onap.aai.AAISetup;
import org.onap.aai.DataLinkSetup;
-import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.db.props.AAIProperties;
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.parsers.query.QueryParser;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.test.annotation.DirtiesContext;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class DbAliasTest extends DataLinkSetup {
private SchemaVersion version;
private final ModelType introspectorFactoryType = ModelType.MOXY;
- private final DBConnectionType type = DBConnectionType.REALTIME;
private Loader loader;
private TransactionalGraphEngine dbEngine;
- @Parameterized.Parameter(value = 0)
+ @Parameterized.Parameter
public QueryStyle queryStyle;
@Parameterized.Parameters(name = "QueryStyle.{0}")
}
@Before
- public void setup() throws Exception {
+ public void setup() {
version = schemaVersions.getDepthVersion();
graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
+ dbEngine = new JanusGraphDBEngine(queryStyle, loader);
}
@After
}
@Test
- public void checkOnWrite() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException,
- IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException,
- NoSuchMethodException, InterruptedException {
+ public void checkOnWrite() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException, IllegalArgumentException {
final String property = "persona-model-customization-id";
String dbPropertyName = property;
TransactionalGraphEngine spy = spy(this.dbEngine);
spy.getQueryBuilder().createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1"));
Introspector obj = loader.introspectorFromName("generic-vnf");
Vertex v = g.addVertex();
+ v.property("aai-uri", "abc");
+ v.property("aai-uuid", "b");
+ v.property(AAIProperties.CREATED_TS, 123L);
+ v.property(AAIProperties.SOURCE_OF_TRUTH, "sot");
+ v.property(AAIProperties.RESOURCE_VERSION, "123");
+ v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot");
+ v.property(AAIProperties.LAST_MOD_TS, 123L);
Object id = v.id();
obj.setValue("vnf-id", "key1");
obj.setValue(property, "hello");
}
@Test
- public void checkOnRead() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException,
- IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException,
- NoSuchMethodException, InterruptedException, MalformedURLException {
+ public void checkOnRead() throws AAIException, UnsupportedEncodingException, SecurityException, IllegalArgumentException {
final String property = "persona-model-customization-id";
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Vertex v = graph.traversal().addV("vnf-id", "key1", "model-customization-id", "hello").next();
+ Vertex v = graph.traversal().addV().property("vnf-id", "key1").property("model-customization-id", "hello").next();
graph.tx().commit();
Graph g = graph.newTransaction();
GraphTraversalSource traversal = g.traversal();