summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/test')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java132
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/AAISetup.java1
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java31
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java31
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java35
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java10
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java301
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java17
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java11
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java65
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslContextTest.java117
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV1Test.java (renamed from aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java)191
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java591
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeLabelTest.java62
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeTest.java79
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java11
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/history/AbstractSpringHistoryRestTest.java138
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java246
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java476
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java744
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java467
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java476
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java770
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ClosedLoopQueryTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceSummaryTest.java104
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceVnfVfModuleModelsTest.java111
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcInstanceQueryTest.java101
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcSubscriptionTest.java89
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetVnfVlanByCircuitIdTest.java89
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetVserverDetailTest.java122
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetWlBundleIdQueryTest.java100
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java6
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java200
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java30
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java7
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java7
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java23
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java5
-rw-r--r--aai-traversal/src/test/resources/application-onap-test.properties4
-rw-r--r--aai-traversal/src/test/resources/application-test.properties5
-rw-r--r--aai-traversal/src/test/resources/logback.xml328
-rw-r--r--aai-traversal/src/test/resources/schema-ingest.properties4
49 files changed, 6063 insertions, 510 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
index 7f5b1d8..6d2d5ff 100644
--- a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
@@ -21,12 +21,16 @@ package org.onap.aai;
import com.jayway.jsonpath.JsonPath;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.*;
import org.onap.aai.config.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.queryformats.Format;
import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
@@ -38,14 +42,12 @@ import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
import org.springframework.web.client.RestTemplate;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.fail;
/**
@@ -68,6 +70,8 @@ public class AAIGremlinQueryTest {
@ClassRule
public static final SpringClassRule springClassRule = new SpringClassRule();
+ private static final Logger logger = LoggerFactory.getLogger(AAIGremlinQueryTest.class);
+
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
@@ -158,16 +162,88 @@ public class AAIGremlinQueryTest {
String result = JsonPath.read(responseEntity.getBody().toString(), "$.results[0].result");
assertThat(result, is("1"));
+
+ }
+
+ @Test
+ public void testPserverCountUsingGremlinReturnsJsonWhenAcceptIsMissing() throws Exception {
+
+ headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.set("Accept", "");
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ Map<String, String> gremlinQueryMap = new HashMap<>();
+ gremlinQueryMap.put("gremlin-query", "g.V().has('hostname', 'test-pserver').count()");
+
+ String payload = PayloadUtil.getTemplatePayload("gremlin-query.json", gremlinQueryMap);
+
+ ResponseEntity responseEntity = null;
+
+ String endpoint = "/aai/v11/query?format=console";
+
+ httpEntity = new HttpEntity(payload, headers);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+
+ String result = JsonPath.read(responseEntity.getBody().toString(), "$.results[0].result");
+ assertThat(result, is("1"));
}
@Test
+ public void testPserverGremlinFormatsWithXmlResponse() throws Exception {
+
+ Map<String, String> gremlinQueryMap = new HashMap<>();
+ gremlinQueryMap.put("gremlin-query", "g.V().has('hostname', 'test-pserver')");
+
+ String payload = PayloadUtil.getTemplatePayload("gremlin-query.json", gremlinQueryMap);
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML));
+ httpEntity = new HttpEntity(payload, headers);
+ String endpoint = "/aai/v11/query?format=count";
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+ assertThat(responseEntity.getBody().toString(), containsString("<results><result><pserver>1</pserver></result></results>"));
+
+ gremlinQueryMap.put("gremlin-query", "g.V().has('hostname', 'test-pserver')");
+ payload = PayloadUtil.getTemplatePayload("gremlin-query.json", gremlinQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+
+ Format[] formats = new Format[]{
+ Format.graphson,
+ Format.pathed,
+ Format.id,
+ Format.resource,
+ Format.simple,
+ Format.resource_and_url,
+ Format.console,
+ Format.raw,
+ Format.count
+ };
+
+ for(Format format : formats){
+
+ endpoint = "/aai/v11/query?format=" + format.toString();
+
+ logger.debug("Current endpoint being executed {}", endpoint);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+
+ String responseBody = responseEntity.getBody().toString();
+ logger.debug("Response from the gremlin query: {}", responseBody);
+ assertThat(responseBody, containsString("<results><result>"));
+ assertThat(responseBody, is(not(containsString("<result><result>"))));
+ }
+ }
+ @Test
public void testPserverCountUsingDsl() throws Exception {
Map<String, String> dslQuerymap = new HashMap<>();
dslQuerymap.put("dsl-query", "pserver*('hostname', 'test-pserver')");
String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQuerymap);
- ResponseEntity responseEntity = null;
+ ResponseEntity responseEntity;
String endpoint = "/aai/v11/dsl?format=console";
@@ -179,6 +255,50 @@ public class AAIGremlinQueryTest {
assertThat(result, containsString("v["));
}
+ @Test
+ public void testPserverDslFormatsWithXmlResponse() throws Exception {
+
+ Map<String, String> dslQuerymap = new HashMap<>();
+ dslQuerymap.put("dsl-query", "pserver*('hostname', 'test-pserver')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQuerymap);
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML));
+ httpEntity = new HttpEntity(payload, headers);
+ String endpoint = "/aai/v11/dsl?format=count";
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+ assertThat(responseEntity.getBody().toString(), containsString("<results><result><pserver>1</pserver></result></results>"));
+
+ httpEntity = new HttpEntity(payload, headers);
+
+ Format[] formats = new Format[]{
+ Format.graphson,
+ Format.pathed,
+ Format.id,
+ Format.resource,
+ Format.simple,
+ Format.resource_and_url,
+ Format.console,
+ Format.raw,
+ Format.count
+ };
+
+ for(Format format : formats){
+
+ endpoint = "/aai/v11/dsl?format=" + format.toString();
+
+ logger.debug("Current endpoint being executed {}", endpoint);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+
+ String responseBody = responseEntity.getBody().toString();
+ logger.debug("Response from the dsl query: {}", responseBody);
+ assertThat(responseBody, containsString("<results><result>"));
+ assertThat(responseBody, is(not(containsString("<result><result>"))));
+ }
+ }
+
@After
public void tearDown() {
@@ -191,7 +311,7 @@ public class AAIGremlinQueryTest {
g.V().has("source-of-truth", "JUNIT")
.toList()
- .forEach(v -> v.remove());
+ .forEach(Vertex::remove);
} catch(Exception ex){
success = false;
diff --git a/aai-traversal/src/test/java/org/onap/aai/AAISetup.java b/aai-traversal/src/test/java/org/onap/aai/AAISetup.java
index d43cde9..a13384a 100644
--- a/aai-traversal/src/test/java/org/onap/aai/AAISetup.java
+++ b/aai-traversal/src/test/java/org/onap/aai/AAISetup.java
@@ -61,6 +61,7 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule;
RestBeanConfig.class,
SearchConfiguration.class,
DslConfiguration.class,
+ XmlFormatTransformerConfiguration.class,
GremlinServerSingleton.class
})
@TestPropertySource(properties = {
diff --git a/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java
index cfe15a1..f12c8c3 100644
--- a/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -19,12 +19,9 @@
*/
package org.onap.aai;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.javatuples.Pair;
import org.mockito.Mockito;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
@@ -37,12 +34,15 @@ import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.ws.rs.core.*;
-import javax.xml.validation.Schema;
import java.io.UnsupportedEncodingException;
import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doReturn;
@@ -50,7 +50,7 @@ import static org.mockito.Mockito.when;
public class HttpTestUtil extends RESTAPI {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(HttpTestUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger(HttpTestUtil.class);
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
@@ -116,7 +116,7 @@ public class HttpTestUtil extends RESTAPI {
SchemaVersion version = null;
- if(arr != null && arr.length > 1){
+ if(arr.length > 1){
if(arr[0].matches("^v\\d+")){
version = new SchemaVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
@@ -128,10 +128,8 @@ public class HttpTestUtil extends RESTAPI {
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
- DBConnectionType type = DBConnectionType.REALTIME;
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
- // HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
dbEngine = resourceHttpEntry.getDbEngine();
@@ -210,7 +208,7 @@ public class HttpTestUtil extends RESTAPI {
SchemaVersion version = null;
- if(arr != null && arr.length > 1){
+ if(arr.length > 1){
if(arr[0].matches("^v\\d+")){
version = new SchemaVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
@@ -221,11 +219,8 @@ public class HttpTestUtil extends RESTAPI {
version = schemaVersions.getDefaultVersion();
}
- DBConnectionType type = DBConnectionType.REALTIME;
-
- //HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
dbEngine = resourceHttpEntry.getDbEngine();
@@ -295,7 +290,7 @@ public class HttpTestUtil extends RESTAPI {
SchemaVersion version = null;
- if(arr != null && arr.length > 1){
+ if(arr.length > 1){
if(arr[0].matches("^v\\d+")){
version = new SchemaVersion(arr[0]);
if(!uri.contains("relationship-list/relationship")){
@@ -309,10 +304,8 @@ public class HttpTestUtil extends RESTAPI {
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
- DBConnectionType type = DBConnectionType.REALTIME;
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
- // HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
dbEngine = resourceHttpEntry.getDbEngine();
diff --git a/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java b/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
index 76a1277..7703df9 100644
--- a/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
@@ -19,7 +19,8 @@
*/
package org.onap.aai;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import org.junit.Before;
import org.junit.Test;
@@ -49,7 +50,7 @@ import static org.junit.Assert.assertThat;
@Import(TraversalTestConfiguration.class)
public class QueryParameterTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(QueryParameterTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(QueryParameterTest.class);
private HttpTestUtil httpTestUtil;
diff --git a/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java b/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java
index 552feb6..32ab70e 100644
--- a/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java
+++ b/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java
@@ -19,7 +19,8 @@
*/
package org.onap.aai;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
@@ -46,7 +47,7 @@ import java.security.KeyStore;
@TestConfiguration
public class TraversalTestConfiguration {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(TraversalTestConfiguration.class);
+ private static final Logger logger = LoggerFactory.getLogger(TraversalTestConfiguration.class);
@Autowired
private Environment env;
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
index 1f05785..80f6d34 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -19,11 +19,8 @@
*/
package org.onap.aai.dbgraphgen;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
@@ -35,28 +32,27 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.aai.AAISetup;
-import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
import org.onap.aai.setup.SchemaVersion;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class ModelBasedProcessingTest extends AAISetup{
private SchemaVersion version;
private static final ModelType introspectorFactoryType = ModelType.MOXY;
private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private static final DBConnectionType type = DBConnectionType.REALTIME;
-
+
private static final String TRANSACTION_ID = "transaction-1";
private static final String FROM_APP_ID = "JUNIT";
private static final String API_VERSION = "1.0";
@@ -104,9 +100,8 @@ public class ModelBasedProcessingTest extends AAISetup{
public void init() throws AAIException {
MockitoAnnotations.initMocks(this);
version = schemaVersions.getDefaultVersion();
- //rules = EdgeRules.getInstance();
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- TransactionalGraphEngine newDbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
+ TransactionalGraphEngine newDbEngine = new JanusGraphDBEngine(queryStyle, loader);
dbEngine = Mockito.spy(newDbEngine);
serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
admin = Mockito.spy(dbEngine.asAdmin());
@@ -408,8 +403,7 @@ public class ModelBasedProcessingTest extends AAISetup{
strList.add("1");
strList.add("2");
strList.add("3");
- String listString = strList.toString();
- return listString;
+ return strList.toString();
}
@Test
@@ -876,12 +870,9 @@ public class ModelBasedProcessingTest extends AAISetup{
Vertex modelV = serviceGraph.addVertex(T.label, "model", T.id, "66", AAI_NODE_TYPE, "model", "model-invariant-id", "model-invariant-id-1", "model-type", "widget");
Vertex modelVerV = serviceGraph.addVertex(T.label, MODEL_VESION_NODE_VALUE, T.id, "67", AAI_NODE_TYPE, MODEL_VESION_NODE_VALUE,
MODEL_VERSION_ID_KEY, MODEL_VERSION_ID_VALUE,MODEL_NAME_ID_KEY, MODEL_NAME_ID_VALUE, "model-version", "model-version-1");
- //Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "68", AAI_NODE_TYPE, "model-element");
GraphTraversalSource gts = serviceGraph.traversal();
edgeSer.addTreeEdge(gts, modelV, modelVerV);
- //rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- //rules4Service.addEdge(gts, modelElementV, modelVerV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java
index 243fc6e..7839496 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java
@@ -21,23 +21,18 @@ package org.onap.aai.dbgraphmap;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.extensions.AAIExtensionMap;
-import org.onap.aai.introspection.*;
-import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.rest.util.AAIExtensionMap;
import org.onap.aai.util.AAIConstants;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.*;
-
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -48,8 +43,8 @@ import java.util.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.*;
-import org.onap.aai.AAISetup;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class SearchGraphNamedQueryTest extends AAISetup{
@@ -92,6 +87,7 @@ public class SearchGraphNamedQueryTest extends AAISetup{
File dir = new File(widgetPath);
File[] files = dir.listFiles();
+ assert files != null;
for ( File file : files) {
try {
Path path = Paths.get(widgetPath + AAIConstants.AAI_FILESEP + file.getName());
@@ -114,6 +110,7 @@ public class SearchGraphNamedQueryTest extends AAISetup{
File dir = new File(namedQueryPath);
File[] files = dir.listFiles();
+ assert files != null;
for ( File file : files) {
try {
Path path = Paths.get(namedQueryPath + AAIConstants.AAI_FILESEP + file.getName());
@@ -160,8 +157,8 @@ public class SearchGraphNamedQueryTest extends AAISetup{
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Collections.singletonList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Collections.singletonList("JUNIT"));
when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
@@ -201,10 +198,10 @@ public class SearchGraphNamedQueryTest extends AAISetup{
aaiExtMap.setServletRequest(request);
- response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
+ response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, aaiExtMap);
System.out.println("response was\n" + response.getEntity().toString());
assertEquals("Expected success from query", 200, response.getStatus());
- boolean hasLinkName = response.getEntity().toString().indexOf(linkName) > 0 ? true : false;
+ boolean hasLinkName = response.getEntity().toString().indexOf(linkName) > 0;
assertTrue("Response contains linkName", hasLinkName );
}
@@ -235,9 +232,9 @@ public class SearchGraphNamedQueryTest extends AAISetup{
aaiExtMap.setServletRequest(request);
- response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
+ response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, aaiExtMap);
assertEquals("Expected success from query", 200, response.getStatus());
- boolean hasModelName = response.getEntity().toString().indexOf("junit-model-name") > 0 ? true : false;
+ boolean hasModelName = response.getEntity().toString().indexOf("junit-model-name") > 0;
assertTrue("Response contains modelName from model-ver", hasModelName );
}
@@ -316,9 +313,9 @@ public class SearchGraphNamedQueryTest extends AAISetup{
aaiExtMap.setServletRequest(request);
- response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
+ response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, aaiExtMap);
assertEquals("Expected success from query", 200, response.getStatus());
- boolean hasModelName = response.getEntity().toString().indexOf("example-model-name-val-closed-loop") > 0 ? true : false;
+ boolean hasModelName = response.getEntity().toString().indexOf("example-model-name-val-closed-loop") > 0;
assertTrue("Response contains modelName from model-ver", hasModelName );
}
@@ -382,9 +379,9 @@ public class SearchGraphNamedQueryTest extends AAISetup{
aaiExtMap.setServletRequest(request);
- response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
+ response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, aaiExtMap);
assertEquals("Expected success from query", 200, response.getStatus());
- boolean hasModelName = response.getEntity().toString().indexOf("example-model-name-val-component-list") > 0 ? true : false;
+ boolean hasModelName = response.getEntity().toString().indexOf("example-model-name-val-component-list") > 0;
assertTrue("Response contains modelName from model-ver", hasModelName );
}
} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
index 94a89a9..2b4ec18 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
@@ -19,32 +19,29 @@
*/
package org.onap.aai.dbgraphmap;
-import org.janusgraph.core.JanusGraph;
-import org.janusgraph.graphdb.types.system.EmptyVertex;
-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.eclipse.persistence.dynamic.DynamicEntity;
+import org.janusgraph.graphdb.types.system.EmptyVertex;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.extensions.AAIExtensionMap;
-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.relationship.RelationshipToURI;
+import org.onap.aai.rest.util.AAIExtensionMap;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.util.GenericQueryBuilder;
import org.onap.aai.util.NodesQueryBuilder;
-
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.*;
import java.net.URI;
@@ -52,7 +49,8 @@ import java.util.*;
import java.util.stream.Stream;
import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class SearchGraphTest extends AAISetup{
@@ -65,7 +63,6 @@ public class SearchGraphTest extends AAISetup{
private SchemaVersion version;
private final static ModelType introspectorFactoryType = ModelType.MOXY;
private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
static {
VALID_HTTP_STATUS_CODES.add(200);
@@ -85,11 +82,7 @@ public class SearchGraphTest extends AAISetup{
private List<MediaType> outputMediaTypes;
private Loader loader;
- private JanusGraph graph;
-
- private Graph tx;
- private GraphTraversalSource g;
private TransactionalGraphEngine dbEngine;
@Before
@@ -116,8 +109,8 @@ public class SearchGraphTest extends AAISetup{
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Collections.singletonList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Collections.singletonList("JUNIT"));
when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
@@ -130,7 +123,7 @@ public class SearchGraphTest extends AAISetup{
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
+ dbEngine = new JanusGraphDBEngine(queryStyle, loader);
}
@Test(expected = AAIException.class)
@@ -187,9 +180,6 @@ public class SearchGraphTest extends AAISetup{
@Test(expected = AAIException.class)
public void testRunGenericQueryFailWhenInvalidRelationshipList2() throws AAIException {
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
List<String> includeStrings = new ArrayList<>();
includeStrings.add("cloud-region");
@@ -207,9 +197,6 @@ public class SearchGraphTest extends AAISetup{
List<String> keys = new ArrayList<>();
keys.add("cloud-region.cloud-owner:test-aic");
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
UrlBuilder urlBuilder = new UrlBuilder(version, serializer, schemaVersions, basePath);
Response response = searchGraph.runGenericQuery(new GenericQueryBuilder().setHeaders(httpHeaders)
@@ -218,43 +205,21 @@ public class SearchGraphTest extends AAISetup{
System.out.println(response);
}
-
- /*@Test(expected = NullPointerException.class)
- public void createSearchResults() throws AAIException {
-
- List<Vertex> keys = new ArrayList<>();
- Vertex vertex=new EmptyVertex();
- keys.add(vertex);
-
-
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
- Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys);
- System.out.println(response);
- }*/
@Test
public void createSearchResults1() throws Exception {
List<Vertex> keys = new ArrayList<>();
Vertex vertex=new EmptyVertex();
keys.add(vertex);
- DBSerializer ds=mock(DBSerializer.class);
UrlBuilder urlBuilder=mock(UrlBuilder.class);
when(urlBuilder.pathed(vertex)).thenReturn("cloud-region");
Stream<Vertex> stream=mock(Stream.class);
when(stream.isParallel()).thenReturn(true);
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
+
RelationshipToURI relationshipToURI=mock(RelationshipToURI.class);
URI uri =new URI("");
when(relationshipToURI.getUri()).thenReturn(uri);
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- // UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
Introspector response = searchGraph.createSearchResults(loader, urlBuilder, keys);
System.out.println(response);
}
@@ -262,13 +227,6 @@ public class SearchGraphTest extends AAISetup{
public void executeModelOperationTest() throws Exception{
Vertex vertex=new EmptyVertex();
vertex.property("model-name");
- Map<String,Object> mapObj=new HashMap<String,Object>();
- mapObj.put("modle-version",vertex);
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- startNodeFilterArrayOfHashes.add(mapObj);
- List<org.onap.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.onap.aai.dbgraphgen.ResultSet>();
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
AAIExtensionMap map=mock(AAIExtensionMap.class);
HttpServletRequest servletRequest=mock(HttpServletRequest.class);
@@ -277,12 +235,7 @@ public class SearchGraphTest extends AAISetup{
DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class);
when(modelAndNamedQuerySearch.isSet("topNodeType")).thenReturn(true);
-
-/* when(processor.queryByModel("9999","model-ver","model-version-id",
- "model-inv-id","modelname","aai",
- startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/
-
- searchGraph.executeModelOperation("","","",type,true,
+ searchGraph.executeModelOperation("","","",true,
map);
}
@@ -290,13 +243,6 @@ public class SearchGraphTest extends AAISetup{
public void executeModelOperationXMLTest() throws Exception{
Vertex vertex=new EmptyVertex();
vertex.property("model-name");
- Map<String,Object> mapObj=new HashMap<String,Object>();
- mapObj.put("modle-version",vertex);
- List<Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<>();
- startNodeFilterArrayOfHashes.add(mapObj);
- List<org.onap.aai.dbgraphgen.ResultSet> resultSet=new ArrayList<org.onap.aai.dbgraphgen.ResultSet>();
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- // ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
AAIExtensionMap map=mock(AAIExtensionMap.class);
HttpServletRequest servletRequest=mock(HttpServletRequest.class);
@@ -305,19 +251,16 @@ public class SearchGraphTest extends AAISetup{
DynamicEntity modelAndNamedQuerySearch=mock(DynamicEntity.class);
when(modelAndNamedQuerySearch.isSet("queryParameters")).thenReturn(true);
-/* when(processor.queryByModel("9999","model-ver","model-version-id",
- "model-inv-id","modelname","aai",
- startNodeFilterArrayOfHashes,"aai-ver")).thenReturn(resultSet);*/
- searchGraph.executeModelOperation("","","",type,true,
+ searchGraph.executeModelOperation("","","",true,
map);
}
@Test
public void runNodesQueryTest() throws AAIException{
UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
+ List<String> filter=new ArrayList<>();
filter.add("model:EQUALS:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
+ List<String> edgeFilter=new ArrayList<>();
edgeFilter.add("model:DOES-NOT-EXIST:DOES-NOT-EXIST:AAI");
Response response= searchGraph.runNodesQuery(new NodesQueryBuilder().setHeaders(httpHeaders).setTargetNodeType("model-ver").setEdgeFilterParams(edgeFilter)
.setFilterParams(filter).setDbEngine(dbEngine).setLoader(loader).setUrlBuilder(urlBuilder));
@@ -341,7 +284,7 @@ public class SearchGraphTest extends AAISetup{
UrlBuilder urlBuilder=mock(UrlBuilder.class);
List<String> filter=new ArrayList<String>();
filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST");
- List<String> edgeFilter=new ArrayList<String>();
+ List<String> edgeFilter=new ArrayList<>();
searchGraph.runNodesQuery(new NodesQueryBuilder().setHeaders(httpHeaders).setTargetNodeType("model-ver").setEdgeFilterParams(edgeFilter)
.setFilterParams(filter).setDbEngine(dbEngine).setLoader(loader).setUrlBuilder(urlBuilder));
}
@@ -349,9 +292,9 @@ public class SearchGraphTest extends AAISetup{
@Test
public void runNodesQueryTestGreaterThan3() throws AAIException{
UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
+ List<String> filter=new ArrayList<>();
filter.add("model:DOES-NOT-EQUAL:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
+ List<String> edgeFilter=new ArrayList<>();
searchGraph.runNodesQuery(new NodesQueryBuilder().setHeaders(httpHeaders).setTargetNodeType("model-ver").setEdgeFilterParams(edgeFilter)
.setFilterParams(filter).setDbEngine(dbEngine).setLoader(loader).setUrlBuilder(urlBuilder));
}
@@ -359,9 +302,9 @@ public class SearchGraphTest extends AAISetup{
@Test
public void runNodesQueryTestGreaterThanExists() throws AAIException{
UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
+ List<String> filter=new ArrayList<>();
filter.add("model:EXISTS:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
+ List<String> edgeFilter=new ArrayList<>();
searchGraph.runNodesQuery(new NodesQueryBuilder().setHeaders(httpHeaders).setTargetNodeType("model-ver").setEdgeFilterParams(edgeFilter)
.setFilterParams(filter).setDbEngine(dbEngine).setLoader(loader).setUrlBuilder(urlBuilder));
}
@@ -369,9 +312,9 @@ public class SearchGraphTest extends AAISetup{
@Test(expected = AAIException.class)
public void runNodesQueryTestGreaterThanDoesNotExists() throws AAIException{
UrlBuilder urlBuilder=mock(UrlBuilder.class);
- List<String> filter=new ArrayList<String>();
+ List<String> filter=new ArrayList<>();
filter.add("model:DOES_NOT_EXIST:DOES-NOT-EXIST:AAI");
- List<String> edgeFilter=new ArrayList<String>();
+ List<String> edgeFilter=new ArrayList<>();
searchGraph.runNodesQuery(new NodesQueryBuilder().setHeaders(httpHeaders).setTargetNodeType("model-ver").setEdgeFilterParams(edgeFilter)
.setFilterParams(filter).setDbEngine(dbEngine).setLoader(loader).setUrlBuilder(urlBuilder));
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
index b767dbb..b82d751 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
@@ -19,10 +19,9 @@
*/
package org.onap.aai.rest;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.*;
@@ -47,12 +46,12 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule;
import org.springframework.web.client.RestTemplate;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Collections;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
@TestPropertySource(locations = "classpath:application-test.properties")
-@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
@Import(TraversalTestConfiguration.class)
public abstract class AbstractSpringRestTest {
@@ -96,7 +95,7 @@ public abstract class AbstractSpringRestTest {
headers.add("Real-Time", "true");
headers.add("X-FromAppId", "JUNIT");
headers.add("X-TransactionId", "JUNIT");
- String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
+ String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes(StandardCharsets.UTF_8));
headers.add("Authorization", "Basic " + authorization);
httpEntity = new HttpEntity(headers);
baseUrl = "http://localhost:" + randomPort;
@@ -120,8 +119,7 @@ public abstract class AbstractSpringRestTest {
GraphTraversalSource g = transaction.traversal();
g.V().has("source-of-truth", P.within("JUNIT", "AAI-EXTENSIONS"))
.toList()
- .stream()
- .forEach(v -> v.remove());
+ .forEach(Vertex::remove);
} catch(Exception ex){
success = false;
} finally {
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
index e4576ae..7918eb3 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
@@ -19,43 +19,32 @@
*/
package org.onap.aai.rest;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.junit.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraphTransaction;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.Ignore;
+import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.TraversalConstants;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.util.UriComponentsBuilder;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.jayway.jsonpath.JsonPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.*;
+
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.*;
public class DslConsumerTest extends AbstractSpringRestTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslConsumerTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(DslConsumerTest.class);
@Override
public void createTestGraph() {
@@ -65,7 +54,7 @@ public class DslConsumerTest extends AbstractSpringRestTest {
GraphTraversalSource g = transaction.traversal();
g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-dsl")
.property("in-maint", false).property("source-of-truth", "JUNIT")
- .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver").next();
+ .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver-dsl").next();
} catch (Exception ex) {
success = false;
} finally {
@@ -85,13 +74,71 @@ public class DslConsumerTest extends AbstractSpringRestTest {
Map<String, String> dslQueryMap = new HashMap<>();
dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')");
String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ headers.add("X-Dsl-Version", "V1");
httpEntity = new HttpEntity(payload, headers);
ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
String.class);
LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
System.out.println(responseEntity.getBody());
assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
- assertEquals("Expected the response to be 500", HttpStatus.OK, responseEntity.getStatusCode());
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML));
+ httpEntity = new HttpEntity(payload, headers);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+
+ // Make sure that there are no two result <result><result>
+ assertThat(responseEntity.getBody().toString(), is(not(containsString("<result><result>"))));
+ assertThat(responseEntity.getBody().toString(), is(containsString("<results><result>")));
+ }
+
+ @Test
+ public void testDslQueryV2() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=console";
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl') > complex*");
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ headers.add("X-Dsl-Version", "V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML));
+ httpEntity = new HttpEntity(payload, headers);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+
+ // Make sure that there are no two result <result><result>
+ assertThat(responseEntity.getBody().toString(), is(not(containsString("<result><result>"))));
+ assertThat(responseEntity.getBody().toString(), is(containsString("<results><result>")));
+ }
+
+ @Test
+ public void testDslQueryV2Aggregate() throws Exception {
+ String endpoint = "/aai/v17/dsl?format=aggregate";
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')");
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ System.out.println("Payload" + payload);
+ headers.add("X-Dsl-Version", "V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+ System.out.println(responseEntity.getBody());
+ assertNotNull("Response from /aai/v17/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
}
@Test
@@ -107,10 +154,10 @@ public class DslConsumerTest extends AbstractSpringRestTest {
httpEntity = new HttpEntity(payload, headers);
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- assertEquals("Expected the response to be 404", HttpStatus.NOT_FOUND,
+ assertEquals("Expected the response to be 404", HttpStatus.BAD_REQUEST,
responseEntity.getStatusCode());
}
-
+
@Test
public void testDslQueryOverride() throws Exception {
Map<String, String> dslQuerymap = new HashMap<>();
@@ -125,8 +172,198 @@ public class DslConsumerTest extends AbstractSpringRestTest {
headers.add("X-DslOverride", AAIConfig.get(TraversalConstants.DSL_OVERRIDE));
httpEntity = new HttpEntity(payload, headers);
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
- assertEquals("Expected the response to be 404", HttpStatus.NOT_FOUND,
+ assertEquals("Expected the response to be 404", HttpStatus.BAD_REQUEST,
+ responseEntity.getStatusCode());
+ }
+
+
+ @Test
+ public void testSelectedPropertiesNotRequiredOnDSLStartNode() throws Exception {
+ Map<String, String> dslQuerymap = new HashMap<>();
+ dslQuerymap.put("dsl-query", "pserver*('equip-model','abc')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQuerymap);
+
+ String endpoint = "/aai/v11/dsl?format=console";
+
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+
+ assertEquals("Expected the response to be " + HttpStatus.OK, HttpStatus.OK,
+ responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testAPropertyIsRequiredOnDSLStartNode() throws Exception {
+ Map<String, String> dslQuerymap = new HashMap<>();
+ dslQuerymap.put("dsl-query", "pserver*");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQuerymap);
+
+ String endpoint = "/aai/v11/dsl?format=console";
+
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+
+ assertEquals("Expected the response to be " + HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST,
responseEntity.getStatusCode());
}
+
+ @Test
+ public void testDslQueryProcessingV2_WithSimpleFormat_WithAsTreeQueryParameter() throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver{'hostname', 'ptnii-equip-name', 'in-maint'}('hostname','test-pserver-dsl')");
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ String endpoint = "/aai/v16/dsl?format=simple&depth=0&nodesOnly=true&as-tree=true";
+
+ // Add header with V2 to use the {} feature as a part of dsl query
+ headers.add("X-DslApiVersion","V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ String responseString = responseEntity.getBody().toString();
+
+ // Extract the properties array from the response and compare in assert statements
+ JsonParser jsonParser = new JsonParser();
+ JsonObject results = jsonParser.parse(responseString).getAsJsonObject();
+ JsonArray resultsArray = results.get("results").getAsJsonArray();
+ JsonObject resultsValue = resultsArray.get(0).getAsJsonObject();
+ JsonObject properties = resultsValue.get("properties").getAsJsonObject();
+ assertEquals(2, properties.size());
+ assertTrue(properties.get("hostname").toString().equals("\"test-pserver-dsl\""));
+ assertTrue(properties.get("in-maint").toString().equals("false"));
+ headers.remove("X-DslApiVersion");
+ }
+
+ @Test
+ public void testDslQueryProcessingV2_WithSimpleFormat_WithoutAsTreeQueryParameter() throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver{'hostname', 'ptnii-equip-name', 'in-maint'}('hostname','test-pserver-dsl')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ String endpoint = "/aai/v16/dsl?format=simple&depth=0&nodesOnly=true";
+
+ // Add header with V2 to use the {} feature as a part of dsl query
+ headers.add("X-DslApiVersion","V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ String responseString = responseEntity.getBody().toString();
+ // Extract the properties array from the response and compare in assert statements
+ JsonParser jsonParser = new JsonParser();
+ JsonObject results = jsonParser.parse(responseString).getAsJsonObject();
+ JsonArray resultsArray = results.get("results").getAsJsonArray();
+ JsonObject resultsValue = resultsArray.get(0).getAsJsonObject();
+ JsonObject properties = resultsValue.get("properties").getAsJsonObject();
+ assertEquals(2, properties.size());
+ assertTrue(properties.get("hostname").toString().equals("\"test-pserver-dsl\""));
+ assertTrue(properties.get("in-maint").toString().equals("false"));
+ headers.remove("X-DslApiVersion");
+ }
+
+ @Test
+ public void testDslQueryProcessingV2_WithResourceFormat_WithAsTreeQueryParameter() throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver{'hostname', 'ptnii-equip-name', 'in-maint'}('hostname','test-pserver-dsl')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ String endpoint = "/aai/v16/dsl?format=resource&depth=0&nodesOnly=true&as-tree=true";
+
+ // Add header with V2 to use the {} feature as a part of dsl query
+ headers.add("X-DslApiVersion","V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ String responseString = responseEntity.getBody().toString();
+
+ // Extract the properties array from the response and compare in assert statements
+ JsonParser jsonParser = new JsonParser();
+ JsonObject results = jsonParser.parse(responseString).getAsJsonObject();
+ JsonArray resultsArray = results.get("results").getAsJsonArray();
+ JsonObject resultsValue = resultsArray.get(0).getAsJsonObject();
+ JsonObject properties = resultsValue.get("pserver").getAsJsonObject();
+ assertEquals(2, properties.size());
+ assertTrue(properties.get("hostname").toString().equals("\"test-pserver-dsl\""));
+ assertTrue(properties.get("in-maint").toString().equals("false"));
+ headers.remove("X-DslApiVersion");
+ }
+
+ @Ignore
+ @Test
+ public void testDslQueryProcessingV2_WithResourceFormat_WithoutAsTreeQueryParameter() throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver{'hostname', 'ptnii-equip-name', 'in-maint'}('hostname','test-pserver-dsl')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ String endpoint = "/aai/v16/dsl?format=resource&depth=0&nodesOnly=true";
+
+ // Add header with V2 to use the {} feature as a part of dsl query
+ headers.add("X-DslApiVersion","V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ String responseString = responseEntity.getBody().toString();
+
+ // Extract the properties array from the response and compare in assert statements
+ JsonParser jsonParser = new JsonParser();
+ JsonObject results = jsonParser.parse(responseString).getAsJsonObject();
+ JsonArray resultsArray = results.get("results").getAsJsonArray();
+ JsonObject resultsValue = resultsArray.get(0).getAsJsonObject();
+ JsonObject properties = resultsValue.get("pserver").getAsJsonObject();
+ assertEquals(2, properties.size());
+ assertTrue(properties.get("hostname").toString().equals("\"test-pserver-dsl\""));
+ assertTrue(properties.get("in-maint").toString().equals("false"));
+ headers.remove("X-DslApiVersion");
+ }
+
+ @Test
+ public void testDslQueryProcessingV2_WithResourceAndUrlFormat_WithAsTreeQueryParameter() throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver{'hostname', 'ptnii-equip-name', 'in-maint'}('hostname','test-pserver-dsl')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ String endpoint = "/aai/v16/dsl?format=resource_and_url&depth=0&nodesOnly=true&as-tree=true";
+
+ // Add header with V2 to use the {} feature as a part of dsl query
+ headers.add("X-DslApiVersion","V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ String responseString = responseEntity.getBody().toString();
+
+ // Extract the properties array from the response and compare in assert statements
+ JsonParser jsonParser = new JsonParser();
+ JsonObject results = jsonParser.parse(responseString).getAsJsonObject();
+ JsonArray resultsArray = results.get("results").getAsJsonArray();
+ JsonObject resultsValue = resultsArray.get(0).getAsJsonObject();
+ JsonObject properties = resultsValue.get("pserver").getAsJsonObject();
+ assertEquals(2, properties.size());
+ assertTrue(properties.get("hostname").toString().equals("\"test-pserver-dsl\""));
+ assertTrue(properties.get("in-maint").toString().equals("false"));
+ headers.remove("X-DslApiVersion");
+ }
+
+ @Ignore
+ @Test
+ public void testDslQueryProcessingV2_WithResourceAndUrlFormat_WithoutAsTreeQueryParameter() throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver{'hostname', 'ptnii-equip-name', 'in-maint'}('hostname','test-pserver-dsl')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ String endpoint = "/aai/v16/dsl?format=resource_and_url&depth=0&nodesOnly=true";
+
+ // Add header with V2 to use the {} feature as a part of dsl query
+ headers.add("X-DslApiVersion","V2");
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ String responseString = responseEntity.getBody().toString();
+
+ // Extract the properties array from the response and compare in assert statements
+ JsonParser jsonParser = new JsonParser();
+ JsonObject results = jsonParser.parse(responseString).getAsJsonObject();
+ JsonArray resultsArray = results.get("results").getAsJsonArray();
+ JsonObject resultsValue = resultsArray.get(0).getAsJsonObject();
+ JsonObject properties = resultsValue.get("pserver").getAsJsonObject();
+ assertEquals(2, properties.size());
+ assertTrue(properties.get("hostname").toString().equals("\"test-pserver-dsl\""));
+ assertTrue(properties.get("in-maint").toString().equals("false"));
+ headers.remove("X-DslApiVersion");
+ }
+
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
index 7a6f101..c965407 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
@@ -19,7 +19,10 @@
*/
package org.onap.aai.rest;
-import com.att.eelf.configuration.EELFLogger;
+import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.transforms.XmlFormatTransformer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import com.jayway.jsonpath.JsonPath;
import org.janusgraph.core.JanusGraph;
@@ -34,6 +37,7 @@ import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.setup.SchemaVersion;
+import org.springframework.test.context.ContextConfiguration;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.*;
@@ -47,9 +51,10 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
public class GfpVserverDataStoredQueryTest extends AAISetup{
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(GfpVserverDataStoredQueryTest.class);
+ private static final Logger logger = LoggerFactory.getLogger(GfpVserverDataStoredQueryTest.class);
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
@@ -102,7 +107,7 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{
assertEquals("Expecting the cloud region to be created", 201, response.getStatus());
logger.info("Successfully created the cloud region with linterface");
- queryConsumer = new QueryConsumer(traversalUriHttpEntry, schemaVersions, gremlinServerSingleton, basePath);
+ queryConsumer = new QueryConsumer(traversalUriHttpEntry, schemaVersions, gremlinServerSingleton, new XmlFormatTransformer(), basePath);
httpHeaders = mock(HttpHeaders.class);
@@ -164,12 +169,10 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{
Response response = queryConsumer.executeQuery(
payload,
version.toString(),
- query,
"resource_and_url", "" +
"no_op",
httpHeaders,
uriInfo,
- httpServletRequest,
"-1",
"-1"
);
@@ -203,12 +206,10 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{
Response response = queryConsumer.executeQuery(
payload,
version.toString(),
- query,
"resource_and_url", "" +
"no_op",
httpHeaders,
uriInfo,
- httpServletRequest,
"-1",
"-1"
);
@@ -243,12 +244,10 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{
Response response = queryConsumer.executeQuery(
payload,
version.toString(),
- query,
"resource_and_url", "" +
"no_op",
httpHeaders,
uriInfo,
- httpServletRequest,
"-1",
"-1"
);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java
index b894985..cf81b47 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/QueryConsumerTest.java
@@ -42,8 +42,8 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException;
import java.util.Base64;
@@ -56,8 +56,7 @@ import javax.ws.rs.core.Response;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
@@ -66,7 +65,7 @@ import static org.junit.Assert.fail;
@Import(TraversalTestConfiguration.class)
public class QueryConsumerTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(QueryConsumerTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(QueryConsumerTest.class);
private HttpTestUtil httpTestUtil;
private String pserverUri;
@@ -123,7 +122,7 @@ public class QueryConsumerTest {
Response response = httpTestUtil.doPut(complexUri, complexPayload);
}
- //@Test
+// @Test
public void testRequiredAGood() throws Exception {
String endpoint = "/aai/v14/query?format=pathed";
Map<String, String> cloudRegionMap = new HashMap<>();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
index 43ac7c2..10ff7b9 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
@@ -19,22 +19,45 @@
*/
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraphTransaction;
import org.junit.Test;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.onap.aai.dbmap.AAIGraph;
+import org.springframework.http.*;
import org.springframework.web.util.UriComponentsBuilder;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
+import java.util.Collections;
+
+import static org.junit.Assert.*;
+
public class RecentApiTest extends AbstractSpringRestTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(RecentApiTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(RecentApiTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-recents")
+ .property("in-maint", false).property("source-of-truth", "JUNIT")
+ .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver-recents").next();
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
@Test
public void testRecentsQuery() {
@@ -44,10 +67,28 @@ public class RecentApiTest extends AbstractSpringRestTest {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("hours", "190");
ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
String.class);
- LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
- assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity);
- assertEquals("Expected the response to be 400", HttpStatus.OK, responseEntity.getStatusCode());
+ LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+
+ // Check different application xml headers for accept
+ headers.set("Accept", "application/xml");
+ httpEntity = new HttpEntity(headers);
+
+ responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+ LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+
+ headers.set("Accept", "application/xml; charset=UTF-8");
+ httpEntity = new HttpEntity(headers);
+ responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+ LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
}
@Test
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java
index d53fa56..6980753 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java
@@ -19,7 +19,8 @@
*/
package org.onap.aai.rest;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import org.junit.Test;
import org.springframework.http.*;
@@ -34,7 +35,7 @@ import static org.junit.Assert.assertNotNull;
public class SearchProviderRestTest extends AbstractSpringRestTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SearchProviderRestTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(SearchProviderRestTest.class);
@Test
public void testNodesQueryInvalidData() {
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslContextTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslContextTest.java
index de81104..e85e250 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslContextTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslContextTest.java
@@ -20,20 +20,127 @@
package org.onap.aai.rest.dsl;
-import static org.junit.Assert.assertNull;
-
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import java.util.Deque;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
public class DslContextTest {
DslContext dslContext;
@Before
- public void setUp()
- {
+ public void setUp() {
+
dslContext= new DslContext();
+ dslContext.setCtx(null);
+ }
+
+ @Test
+ public void testGetCtx() {
+ assertNull(dslContext.getCtx());
+ }
+
+ @Test
+ public void testSetUnionStart() {
+ dslContext.setUnionStart(true);
+ }
+
+ @Test
+ public void testGetLimitQuery() {
+ assertNotNull(dslContext.getLimitQuery());
+ }
+
+ @Test
+ public void testSetLimitQuery() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("abc");
+ dslContext.setLimitQuery(builder);
+ dslContext.setStartNodeFlag(true);
+ dslContext.setUnionStart(true);
+ dslContext.setUnionStartNodes(null);
+ assertNotNull(dslContext);
+ }
+
+ @Test
+ public void testIsStartNode() {
+ Assert.assertFalse(dslContext.isStartNode());
+ }
+
+ @Test
+ public void testGetStartNode() {
+ dslContext.setStartNode("xyz");
+ Assert.assertEquals(dslContext.getStartNode(), "xyz");
+ }
+
+ @Test
+ public void testGetStartNodeKeys() {
+ Assert.assertNotNull(dslContext.getStartNodeKeys());
+ }
+
+ @Test
+ public void testGetCurrentNode() {
+ dslContext.setCurrentNode("blah");
+ Assert.assertEquals(dslContext.getCurrentNode(), "blah");
}
-
+
+ @Test
+ public void testGetPreviousNode() {
+ dslContext.setPreviousNode("blah");
+ Assert.assertEquals(dslContext.getPreviousNode(), "blah");
+ }
+
+ @Test
+ public void testisTraversal() {
+ dslContext.setTraversal(false);
+ Assert.assertFalse(dslContext.isTraversal());
+ }
+
+ @Test
+ public void testGetWhereQuery() {
+ dslContext.setWhereQuery(true);
+ Assert.assertTrue(dslContext.isWhereQuery());
+ }
+
+ @Test
+ public void testIsUnionQuery() {
+ dslContext.setUnionQuery(true);
+ Assert.assertTrue(dslContext.isUnionQuery());
+ }
+
+ @Test
+ public void testIsUnionStart() {
+ dslContext.setUnionStart(true);
+ Assert.assertTrue(dslContext.isUnionStart());
+ }
+
+ @Test
+ public void testUnionStart() throws Exception {
+ assertNotNull(dslContext.getUnionStartNodes());
+ }
+
+ @Test
+ public void testGetWhereStartNode() {
+ dslContext.setWhereStartNode("blah");
+ Assert.assertEquals(dslContext.getWhereStartNode(), "blah");
+ }
+
+ @Test
+ public void testIsValidationFlag() {
+ Assert.assertTrue(dslContext.isValidationFlag());
+ }
+
+ @Test
+ public void testSetValidationFlag()
+ {
+ dslContext.setValidationFlag(true);
+ Assert.assertTrue(dslContext.isValidationFlag());
+ }
+
@Test
public void testUnionStartNodes()
{
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV1Test.java
index 340f8f8..9d36ac7 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV1Test.java
@@ -19,29 +19,125 @@
*/
package org.onap.aai.rest.dsl;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.aai.AAISetup;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.rest.enums.QueryVersion;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* The Class DslMain.
*/
-public class DslQueryProcessorTest extends AAISetup {
+public class DslQueryProcessorV1Test extends AAISetup {
@Rule
public ExpectedException expectedEx = ExpectedException.none();
@Test
+ public void dbAliasTest() throws AAIException {
+ String aaiQuery = "logical-link* ('model-invariant-id','invid')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'logical-link').getVerticesByProperty('model-invariant-id-local','invid')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void apostropheTest() throws AAIException {
+ String aaiQuery = "logical-link*('link-id','dsl\\'link')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'logical-link').getVerticesByProperty('link-id','dsl\\'link')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void parseCancellationExceptionTest() throws AAIException {
+ boolean thrown = false;
+ String aaiQuery = "logical-link*('link-id','dsl\\'link)";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'logical-link').getVerticesByProperty('link-id','dsl\\'link')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ try {
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1, aaiQuery).get("query").toString();
+ } catch (AAIException e) {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+
+ @Test
+ public void cloudRegionFromVnf() throws AAIException {
+ String aaiQuery = "generic-vnf*('vnf-name','xyz') > [ vnfc* > vserver* > [pserver*, tenant* > cloud-region*], "+
+ "vserver* > [pserver*, tenant* > cloud-region*] ]";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-name','xyz').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x')."
+ +"createEdgeTraversal(EdgeType.COUSIN, 'vnfc','vserver').store('x').union(builder.newInstance().createEdgeTraversal"
+ +"(EdgeType.COUSIN, 'vserver','pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver','tenant')"
+ +".store('x').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region').store('x')),builder.newInstance().createEdgeTraversal"
+ +"(EdgeType.COUSIN, 'generic-vnf','vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver'"
+ +",'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').store('x').createEdgeTraversal"
+ +"(EdgeType.TREE, 'tenant','cloud-region').store('x'))).cap('x').unfold().dedup()";
+
+
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegionSites() throws AAIException {
+ String aaiQuery = "cloud-region*('cloud-owner','xyz') > complex*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner'"
+ +",'xyz').store('x').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','complex').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void pserverWithNoComplexTest() throws AAIException {
+ String aaiQuery = "pserver*('hostname','xyz')!(> complex)";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','xyz').where(builder.newInstance().not("
+ +"builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void pserverWhereNotTest() throws AAIException {
+ String aaiQuery = "pserver('hostname','xyz')>vserver*!(> vnfc > configuration))";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','xyz').createEdgeTraversal" +
+ "(EdgeType.COUSIN, 'pserver','vserver').where(builder.newInstance().not(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,"+
+ " 'vserver','vnfc').createEdgeTraversal(EdgeType.COUSIN, 'vnfc','configuration'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
public void singleNode1() throws AAIException {
String aaiQuery = "cloud-region* !('cloud-owner','coid')";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ ".store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -52,7 +148,7 @@ public class DslQueryProcessorTest extends AAISetup {
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ ".store('x').cap('x').unfold().dedup().limit(10)";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -62,7 +158,7 @@ public class DslQueryProcessorTest extends AAISetup {
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coidhello:?_-)(!@#$%^&*+={}[]|/.<,')"
+ ".store('x').cap('x').unfold().dedup().limit(10)";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -75,7 +171,7 @@ public class DslQueryProcessorTest extends AAISetup {
expectedEx.expect(org.onap.aai.exceptions.AAIException.class);
expectedEx.expectMessage("DSL Syntax Error while processing the query");
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
}
@Test
@@ -88,7 +184,7 @@ public class DslQueryProcessorTest extends AAISetup {
expectedEx.expect(org.onap.aai.exceptions.AAIException.class);
expectedEx.expectMessage("DSL Syntax Error while processing the query");
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
}
@Test
@@ -98,7 +194,7 @@ public class DslQueryProcessorTest extends AAISetup {
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ ".getVerticesByProperty('cloud-region-id','cr id').store('x').cap('x').unfold().dedup().limit(10)";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -115,7 +211,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".getVerticesByProperty('cloud-region-id','One'))"
+ ".createEdgeTraversal(EdgeType.TREE, 'generic-vnf','entitlement').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -129,7 +225,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".getVerticesByProperty('cloud-region-id','One'))"
+ ".createEdgeTraversalWithLabels( 'generic-vnf','service-instance', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.ComposedOf'))).store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -137,7 +233,7 @@ public class DslQueryProcessorTest extends AAISetup {
public void complex_az_fromComplexTest() throws AAIException {
String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ availability-zone* , complex*]";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ ".union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region','availability-zone').store('x')"
@@ -150,7 +246,7 @@ public class DslQueryProcessorTest extends AAISetup {
public void complex_az_fromComplexTestWithLabels() throws AAIException {
String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ ('org.onap.relationships.inventory.BelongsTo')availability-zone* , ('org.onap.relationships.inventory.LocatedIn')complex*]";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ ".union(builder.newInstance().createEdgeTraversalWithLabels( 'cloud-region','availability-zone', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).store('x')"
@@ -165,7 +261,7 @@ public class DslQueryProcessorTest extends AAISetup {
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('data-center-code','data-center-code-name')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x').cap('x').unfold().dedup()";
String aaiQuery = "complex('data-center-code','data-center-code-name') > cloud-region*";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -177,7 +273,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').getVerticesByProperty('cloud-region-version','crv')"
+ ".store('x').cap('x').unfold().dedup()";
String aaiQuery = "complex('data-center-code','data-center-code-name') > cloud-region*('cloud-region-version','crv')";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -192,7 +288,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".store('x').cap('x').unfold().dedup()";
String aaiQuery = "image('application-vendor','F5') > vserver (> generic-vnf('vnf-name','ZALL1MMSC03')) > tenant > cloud-region*";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -206,7 +302,7 @@ public class DslQueryProcessorTest extends AAISetup {
+ ".store('x').cap('x').unfold().dedup()";
String aaiQuery = "image('application-vendor','vendor') > vserver(> generic-vnf('nf-type', 'nfType') ) > tenant > cloud-region*";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -223,7 +319,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "generic-vnf('vnf-id','vnfId') > vnfc* > vserver* > tenant* > cloud-region*";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -237,7 +333,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "cloud-region*('cloud-owner','co') > complex*";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -256,7 +352,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "generic-vnf*('vnf-id','vnfId') > [ pserver* > complex*, "
+ " vserver > pserver* > complex* " + "]";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -273,7 +369,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "generic-vnf*('vnf-id','vnfId') > [ pserver* , "
+ " vserver > pserver* ] > complex*";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -294,7 +390,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "customer('global-customer-id', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') > service-subscription('service-subscription-id', 'Nimbus') "
+ " > service-instance('service-instance-id','sid') > generic-vnf* "
+ " > [ vnfc* , vserver*, pserver* , pnf* ]";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -308,7 +404,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "generic-vnf*('vnf-id','vnfId') (> [ pserver('hostname','hostname1'), "
+ " vserver > pserver('hostname','hostname1')])";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
@@ -318,7 +414,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "cloud-region* ('cloud-owner')";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -327,7 +423,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "cloud-region* ('cloud-owner','cloud-owner1','cloud-owner2')";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner', new ArrayList<>(Arrays.asList('cloud-owner1','cloud-owner2'))).store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -336,7 +432,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "cloud-region* !('cloud-owner','cloud-owner1','cloud-owner2')";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList('cloud-owner1','cloud-owner2'))).store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -345,7 +441,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "cloud-region* !('cloud-owner',' ',' null ')";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList(' ',' null '))).store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -353,7 +449,7 @@ public class DslQueryProcessorTest extends AAISetup {
public void hasPropertyIntegerTest() throws AAIException {
String aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > vlan-tag*('vlan-id-inner', 20)";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','MTN61a').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -363,7 +459,7 @@ public class DslQueryProcessorTest extends AAISetup {
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','logical-link').store('x').createEdgeTraversal('logical-link','l-interface').store('x')cap('x').unfold().dedup()";
expectedEx.expect(org.onap.aai.exceptions.AAIException.class);
expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: vserver, logical-link");
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -371,7 +467,7 @@ public class DslQueryProcessorTest extends AAISetup {
public void multipleEdgeRuleTest() throws AAIException {
String aaiQuery = "vserver('vserver-id','abc') > l-interface* > lag-interface*";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').store('x').createEdgeTraversal( 'l-interface','lag-interface').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -379,7 +475,7 @@ public class DslQueryProcessorTest extends AAISetup {
public void multipleEdgeRuleTestWithLabels() throws AAIException {
String aaiQuery = "vserver('vserver-id','abc') > l-interface* > ('org.onap.relationships.inventory.BelongsTo') lag-interface*";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').store('x').createEdgeTraversalWithLabels( 'l-interface','lag-interface', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -388,7 +484,7 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "cloud-region* !('cloud-owner')";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -402,7 +498,7 @@ public class DslQueryProcessorTest extends AAISetup {
".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'),builder.newInstance()." +
"createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'))))).store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -416,7 +512,7 @@ public class DslQueryProcessorTest extends AAISetup {
".createEdgeTraversalWithLabels( 'vserver','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1'),builder.newInstance()." +
"createEdgeTraversalWithLabels( 'vserver','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1'))))).store('x').createEdgeTraversalWithLabels( 'generic-vnf','allotted-resource', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.PartOf'))).cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -446,9 +542,38 @@ public class DslQueryProcessorTest extends AAISetup {
String aaiQuery = "generic-vnf*('vnf-id','vnfId') > [ pserver* , "
+ " vserver > pserver* ] > complex* > [ availability-zone > cloud-region*, cloud-region*, " +
" ctag-pool* > [ availability-zone* > complex* , generic-vnf* > availability-zone* > complex*, vpls-pe* > complex*] > cloud-region*] > tenant* " ;
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(builderQuery, query);
}
+ @Test
+ public void booleanPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region ('cloud-owner','cloud-owner1') > zone*('in-maint',true)";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','cloud-owner1').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','zone').getVerticesByBooleanProperty('in-maint',true).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void upperCaseBooleanPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region ('cloud-owner','cloud-owner1') > zone*('in-maint',TRUE)";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','cloud-owner1').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','zone').getVerticesByBooleanProperty('in-maint',true).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void booleanPropertyTest() throws AAIException {
+ String aaiQuery = "cloud-region ('cloud-owner','cloud-owner1') > zone*('in-maint')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','cloud-owner1').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','zone').getVerticesByProperty('in-maint').store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test(expected = AAIException.class)
+ public void filterOnUnion_vserverFromTentantFromCloudRegion_BadRequest() throws AAIException {
+ String aaiQuery = "cloud-region('cloud-owner', 'test-aic')>[tenant*('tenant-id', 'tenant1'), tenant*('tenant-id', 'tenant2')]('tenant-name', 'tenant1')>[vserver*]";
+ dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ }
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java
new file mode 100644
index 0000000..85da551
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java
@@ -0,0 +1,591 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.dsl;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.aai.AAISetup;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.rest.enums.QueryVersion;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * The Class DslMain.
+ */
+public class DslQueryProcessorV2Test extends AAISetup {
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+ @Test
+ public void dbAliasTest() throws AAIException {
+ String aaiQuery = "logical-link* ('model-invariant-id','invid')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'logical-link').getVerticesByProperty('model-invariant-id-local','invid')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegionFromVnf() throws AAIException {
+ String aaiQuery = "generic-vnf*('vnf-name','xyz') [> vnfc* > vserver* [>pserver*, > tenant* > cloud-region*], "+
+ "> vserver* [> pserver*, >tenant* > cloud-region*] ]";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-name','xyz').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x')."
+ +"createEdgeTraversal(EdgeType.COUSIN, 'vnfc','vserver').store('x').union(builder.newInstance().createEdgeTraversal"
+ +"(EdgeType.COUSIN, 'vserver','pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver','tenant')"
+ +".store('x').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region').store('x')),builder.newInstance().createEdgeTraversal"
+ +"(EdgeType.COUSIN, 'generic-vnf','vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver'"
+ +",'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').store('x').createEdgeTraversal"
+ +"(EdgeType.TREE, 'tenant','cloud-region').store('x'))).cap('x').unfold().dedup()";
+
+
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegionFromVnfWithDirection() throws AAIException {
+ String aaiQuery = "generic-vnf*('vnf-name','xyz') [>> vnfc* >> vserver* [>>pserver*, >> tenant* >> cloud-region*], "+
+ ">> vserver* [>> pserver*, >>tenant* >> cloud-region*] ]";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-name','xyz').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x')."
+ +"createEdgeTraversal(EdgeType.COUSIN, 'vnfc','vserver').store('x').union(builder.newInstance().createEdgeTraversal"
+ +"(EdgeType.COUSIN, 'vserver','pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver','tenant')"
+ +".store('x').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region').store('x')),builder.newInstance().createEdgeTraversal"
+ +"(EdgeType.COUSIN, 'generic-vnf','vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver'"
+ +",'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').store('x').createEdgeTraversal"
+ +"(EdgeType.TREE, 'tenant','cloud-region').store('x'))).cap('x').unfold().dedup()";
+
+
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+ @Test
+ public void cloudRegionSites() throws AAIException {
+ String aaiQuery = "cloud-region*('cloud-owner','xyz') > complex*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner'"
+ +",'xyz').store('x').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','complex').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void pserverWithNoComplexTest() throws AAIException {
+ String aaiQuery = "pserver*('hostname','xyz')!(> complex)";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','xyz').where(builder.newInstance().not("
+ +"builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void pserverWhereNotTest() throws AAIException {
+ String aaiQuery = "pserver('hostname','xyz')>vserver*!(> vnfc > configuration))";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','xyz').createEdgeTraversal" +
+ "(EdgeType.COUSIN, 'pserver','vserver').where(builder.newInstance().not(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,"+
+ " 'vserver','vnfc').createEdgeTraversal(EdgeType.COUSIN, 'vnfc','configuration'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void singleNode1() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void singleNodeLimit() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid') LIMIT 10";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".store('x').cap('x').unfold().dedup().limit(10)";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void specialCharacterTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coidhello:?_-)(!@#$%^&*+={}[]|/.<,') LIMIT 10";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coidhello:?_-)(!@#$%^&*+={}[]|/.<,')"
+ + ".store('x').cap('x').unfold().dedup().limit(10)";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void singleNodeLimitBlah() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid') LIMIT blah";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".getVerticesByProperty('cloud-region-id','cr id').store('x').cap('x').unfold().dedup().limit(10)";
+
+ expectedEx.expect(AAIException.class);
+ expectedEx.expectMessage("DSL Syntax Error while processing the query");
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ }
+
+ @Test
+ public void singleNodeLimitNull() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid') LIMIT ";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".getVerticesByProperty('cloud-region-id','cr id').store('x').cap('x').unfold().dedup().limit(10)";
+
+ expectedEx.expect(AAIException.class);
+ expectedEx.expectMessage("DSL Syntax Error while processing the query");
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ }
+
+ @Test
+ public void cloudRegion1Test() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','coid')('cloud-region-id','cr id') LIMIT 10";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
+ + ".getVerticesByProperty('cloud-region-id','cr id').store('x').cap('x').unfold().dedup().limit(10)";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_entitlementTest() throws AAIException {
+
+ /*
+ A store within a where makes no sense
+ */
+ String aaiQuery = "generic-vnf('vnf-id','vnfId') ( > vserver > tenant > cloud-region('cloud-region-id','One')) > entitlement*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".getVerticesByProperty('cloud-region-id','One'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'generic-vnf','entitlement').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_entitlementTestWithLabels() throws AAIException {
+
+ String aaiQuery = "generic-vnf('vnf-id','vnfId') (> ('tosca.relationships.HostedOn') vserver > ('org.onap.relationships.inventory.BelongsTo') tenant > ('org.onap.relationships.inventory.BelongsTo') cloud-region('cloud-region-id','One')) > ('org.onap.relationships.inventory.ComposedOf')service-instance*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where("
+ + "builder.newInstance().createEdgeTraversalWithLabels( 'generic-vnf','vserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).createEdgeTraversalWithLabels( 'vserver','tenant', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).createEdgeTraversalWithLabels( 'tenant','cloud-region', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo')))"
+ + ".getVerticesByProperty('cloud-region-id','One'))"
+ + ".createEdgeTraversalWithLabels( 'generic-vnf','service-instance', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.ComposedOf'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void complex_az_fromComplexTest() throws AAIException {
+
+ String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') [> availability-zone* ,> complex*]";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ + ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region','availability-zone').store('x')"
+ + ",builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','complex').store('x')).cap('x').unfold().dedup()";
+
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void complex_az_fromComplexTestWithLabels() throws AAIException {
+
+ String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') [> ('org.onap.relationships.inventory.BelongsTo')availability-zone* ,> ('org.onap.relationships.inventory.LocatedIn')complex*]";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ + ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ + ".union(builder.newInstance().createEdgeTraversalWithLabels( 'cloud-region','availability-zone', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).store('x')"
+ + ",builder.newInstance().createEdgeTraversalWithLabels( 'cloud-region','complex', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.LocatedIn'))).store('x')).cap('x').unfold().dedup()";
+
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromComplex1Test() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('data-center-code','data-center-code-name')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x').cap('x').unfold().dedup()";
+ String aaiQuery = "complex('data-center-code','data-center-code-name') > cloud-region*";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromComplex2Test() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('data-center-code','data-center-code-name')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').getVerticesByProperty('cloud-region-version','crv')"
+ + ".store('x').cap('x').unfold().dedup()";
+ String aaiQuery = "complex('data-center-code','data-center-code-name') > cloud-region*('cloud-region-version','crv')";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromNfTypeTest() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','F5')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver')"
+ + ".where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver','generic-vnf').getVerticesByProperty('vnf-name','ZALL1MMSC03'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "image('application-vendor','F5') > vserver (> generic-vnf('vnf-name','ZALL1MMSC03')) > tenant > cloud-region*";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloudRegion_fromNfTypeVendorVersionTest() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','vendor')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver').where("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver','generic-vnf').getVerticesByProperty('nf-type','nfType')"
+ + ").createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region')"
+ + ".store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "image('application-vendor','vendor') > vserver(> generic-vnf('nf-type', 'nfType') ) > tenant > cloud-region*";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloud_region_fromVnfTest() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vnfc','vserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','tenant').store('x')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'tenant','cloud-region').store('x')"
+ + ".cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf('vnf-id','vnfId') > vnfc* > vserver* > tenant* > cloud-region*";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void cloud_region_sitesTest() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')."
+ + "getVerticesByProperty('cloud-owner','co').store('x').createEdgeTraversal(EdgeType.COUSIN, "
+ + "'cloud-region','complex').store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "cloud-region*('cloud-owner','co') > complex*";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void complex_fromVnf2Test() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').store('x').union("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ").cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') [ > pserver* > complex*, "
+ + " >vserver > pserver* > complex* " + "]";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void complex_fromVnfTest2() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').store('x').union("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x'))"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ".cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') [> pserver* , "
+ + " > vserver > pserver* ] > complex*";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void fn_topology1Test() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'customer')"
+ + ".getVerticesByProperty('global-customer-id','a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'customer','service-subscription').getVerticesByProperty('service-subscription-id','Nimbus')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'service-subscription','service-instance').getVerticesByProperty('service-instance-id','sid')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'service-instance','generic-vnf').store('x')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pnf').store('x')).cap('x').unfold().dedup()";
+
+ String aaiQuery = "customer('global-customer-id', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') > service-subscription('service-subscription-id', 'Nimbus') "
+ + " > service-instance('service-instance-id','sid') > generic-vnf* "
+ + " [> vnfc* ,> vserver*,> pserver* ,> pnf* ]";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void vnf_Dsl() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where(builder.newInstance().union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver')"
+ + ".getVerticesByProperty('hostname','hostname1'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'))).store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') ( [> pserver('hostname','hostname1'), "
+ + " > vserver > pserver('hostname','hostname1')])";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void hasPropertyTest() throws AAIException {
+ String aaiQuery = "cloud-region* ('cloud-owner')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region* ('cloud-owner','cloud-owner1','cloud-owner2')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner', new ArrayList<>(Arrays.asList('cloud-owner1','cloud-owner2'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasNotPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','cloud-owner1','cloud-owner2')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList('cloud-owner1','cloud-owner2'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasNotPropertyNullValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner',' ',' null ')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList(' ',' null '))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasPropertyIntegerTest() throws AAIException {
+ String aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > vlan-tag*('vlan-id-inner', 20)";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','MTN61a').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void directionalityTest() throws AAIException {
+ String aaiQuery = "cloud-region('cloud-region-id','abc') >> complex* >> l3-network*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-region-id','abc').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','complex').store('x').createEdgeTraversal(EdgeType.COUSIN, 'complex','l3-network').store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void enterSelectFilterTest() throws AAIException {
+ String aaiQuery = "cloud-region*('cloud-region-id','whp3a'){'cloud-region-id'}";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-region-id','whp3a').store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2, aaiQuery).get("query").toString();
+ assertEquals(query, dslQuery);
+ }
+
+
+ @Test
+ public void returnSpecificPropsAndAllForDifferentVertices() throws AAIException {
+ String aaiQuery = "cloud-region{'cloud-owner'}('cloud-region-id','new-r111egion-111111') > [ l3-network*, vlan-tag*]";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-region-id','new-r111egion-111111').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag').store('x')).cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2, aaiQuery).get("query").toString();
+ assertEquals(query, dslQuery);
+ }
+
+ @Test
+ public void groupingAttributesTestForAggregate() throws AAIException {
+ String aaiQuery = "cloud-region{'cloud-owner'}('cloud-owner','att-nc')('cloud-region-id','wah2a') > vip-ipv6-address-list > [subnet{'subnet-name'}, instance-group{'id'}]";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','wah2a').store('x').createEdgeTraversal(EdgeType.TREE, 'cloud-region','vip-ipv6-address-list').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv6-address-list','subnet').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv6-address-list','instance-group').store('x')).cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2, aaiQuery).get("query").toString();
+ assertEquals(query, dslQuery);
+ }
+
+ @Test
+ public void multipleEdgeRuleTest() throws AAIException {
+ String aaiQuery = "vserver('vserver-id','abc') > l-interface* > lag-interface*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').store('x').createEdgeTraversal( 'l-interface','lag-interface').store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void multipleEdgeRuleTestWithLabels() throws AAIException {
+ String aaiQuery = "vserver('vserver-id','abc') > l-interface* > ('org.onap.relationships.inventory.BelongsTo') lag-interface*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'vserver').getVerticesByProperty('vserver-id','abc').createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').store('x').createEdgeTraversalWithLabels( 'l-interface','lag-interface', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.BelongsTo'))).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasNotPropertyTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void overlyNestedQueryTest() throws AAIException {
+ //String aaiQuery = "generic-vnf*('vnf-id','vnfId') (> [ pserver('hostname','hostname1'), vserver (> [ pserver('hostname','hostname1'), pserver('hostname','hostname1')])]) > vserver";
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') ( [> pserver('hostname','hostname1'), > vserver ( [> pserver('hostname','hostname1'), > pserver('hostname','hostname1')])]) > vserver";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where(builder.newInstance().union" +
+ "(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').getVerticesByProperty('hostname','hostname1')," +
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').where(builder.newInstance().union(builder.newInstance()" +
+ ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'),builder.newInstance()." +
+ "createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'))))).store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void overlyNestedQueryTestWithLabels() throws AAIException {
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') ( [> ('tosca.relationships.HostedOn')pserver('hostname','hostname1'),> ('tosca.relationships.HostedOn')vserver ( [> ('tosca.relationships.HostedOn')pserver('hostname','hostname1'),> ('tosca.relationships.HostedOn')pserver('hostname','hostname1')])]) > ('org.onap.relationships.inventory.PartOf')allotted-resource";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').where(builder.newInstance().union" +
+ "(builder.newInstance().createEdgeTraversalWithLabels( 'generic-vnf','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1')," +
+ "builder.newInstance().createEdgeTraversalWithLabels( 'generic-vnf','vserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).where(builder.newInstance().union(builder.newInstance()" +
+ ".createEdgeTraversalWithLabels( 'vserver','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1'),builder.newInstance()." +
+ "createEdgeTraversalWithLabels( 'vserver','pserver', new ArrayList<>(Arrays.asList('tosca.relationships.HostedOn'))).getVerticesByProperty('hostname','hostname1'))))).store('x').createEdgeTraversalWithLabels( 'generic-vnf','allotted-resource', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.PartOf'))).cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void nestedUnionQueryTest() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').store('x').union("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').store('x'))"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x')"
+ + ".union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'complex','availability-zone')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'availability-zone','cloud-region').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'complex','ctag-pool').store('x').union("
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'ctag-pool','availability-zone').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'availability-zone','complex').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'ctag-pool','generic-vnf').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','availability-zone').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'availability-zone','complex').store('x'),"
+ + "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'ctag-pool','vpls-pe').store('x')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vpls-pe','complex').store('x'))"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x'))"
+ + ".createEdgeTraversal(EdgeType.TREE, 'cloud-region','tenant').store('x')"
+ + ".cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf*('vnf-id','vnfId') [> pserver* , "
+ + " > vserver > pserver* ] > complex* [> availability-zone > cloud-region*,> cloud-region*, " +
+ " > ctag-pool* [ > availability-zone* > complex* , > generic-vnf* > availability-zone* > complex*,> vpls-pe* > complex*] > cloud-region*] > tenant* " ;
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void booleanPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region ('cloud-owner','cloud-owner1') > zone*('in-maint',true)";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','cloud-owner1').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','zone').getVerticesByBooleanProperty('in-maint',true).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void upperCaseBooleanPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region ('cloud-owner','cloud-owner1') > zone*('in-maint',TRUE)";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','cloud-owner1').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','zone').getVerticesByBooleanProperty('in-maint',true).store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void booleanPropertyTest() throws AAIException {
+ String aaiQuery = "cloud-region ('cloud-owner','cloud-owner1') > zone*('in-maint')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','cloud-owner1').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','zone').getVerticesByProperty('in-maint').store('x').cap('x').unfold().dedup()";
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ assertEquals(dslQuery, query);
+ }
+
+ @Test(expected = AAIException.class)
+ public void filterOnUnion_vserverFromTentantFromCloudRegion_BadRequest() throws AAIException {
+ String aaiQuery = "cloud-region('cloud-owner', 'test-aic')>[tenant*('tenant-id', 'tenant1'), tenant*('tenant-id', 'tenant2')]('tenant-name', 'tenant1')>[vserver*]";
+ dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString();
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeLabelTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeLabelTest.java
new file mode 100644
index 0000000..9664342
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeLabelTest.java
@@ -0,0 +1,62 @@
+/**
+ * ============LICENSE_START==================================================
+ * org.onap.aai
+ * ===========================================================================
+ * Copyright © 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+package org.onap.aai.rest.dsl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class EdgeLabelTest {
+
+ private static EdgeLabel edgeLabel;
+ private static EdgeLabel edgeLabel1;
+
+ @Before
+ public void setUp() throws Exception {
+ edgeLabel = new EdgeLabel("label", true);
+ edgeLabel1 = new EdgeLabel("org.onap.relationships.inventory.Uses", false);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void getLabel() {
+ assertEquals(edgeLabel.getLabel(), "label");
+ }
+
+ @Test
+ public void setLabel() {
+ edgeLabel1.setLabel("org.onap.relationships.inventory.Uses");
+ }
+
+ @Test
+ public void isExactMatch() {
+ assertFalse(edgeLabel1.isExactMatch());
+ }
+
+ @Test
+ public void setExactMatch() {
+ edgeLabel1.setExactMatch(false);
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeTest.java
new file mode 100644
index 0000000..4378085
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/EdgeTest.java
@@ -0,0 +1,79 @@
+/**
+ * ============LICENSE_START==================================================
+ * org.onap.aai
+ * ===========================================================================
+ * Copyright © 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+package org.onap.aai.rest.dsl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.rest.enums.EdgeDirection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class EdgeTest {
+
+ Edge edge;
+ Edge edge2;
+ @Before
+ public void setUp() throws Exception {
+ EdgeDirection dir = EdgeDirection.OUT;
+ EdgeDirection both = EdgeDirection.BOTH;
+ EdgeLabel label = new EdgeLabel("org.onap.relationships.inventory.Uses", true);
+ List<EdgeLabel> labelList = new ArrayList<EdgeLabel>();
+ edge = new Edge(dir, labelList);
+ edge2 = new Edge(both, labelList);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void getLabels() {
+ assertNotNull(edge.getLabels());
+ }
+
+ @Test
+ public void setLabels() {
+ EdgeLabel label = new EdgeLabel("org.onap.relationships.inventory.Uses", true);
+ List<EdgeLabel> labelList = new ArrayList<EdgeLabel>();
+ labelList.add(label);
+ edge.setLabels(labelList);
+ }
+
+ @Test
+ public void getDirection() {
+ assertEquals(edge2.getDirection(), EdgeDirection.BOTH);
+ assertEquals(edge.getDirection(), EdgeDirection.OUT);
+ }
+
+ @Test
+ public void setDirection() {
+ edge.setDirection(EdgeDirection.OUT);
+ }
+
+ @Test
+ public void testToString() {
+ assertNotNull(edge.getDirection().toString());
+ assertNotNull(edge.toString());
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
index 822643e..e8fee37 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
@@ -22,6 +22,7 @@ package org.onap.aai.rest.dsl;
import org.junit.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.rest.enums.QueryVersion;
import static org.junit.Assert.assertEquals;
@@ -37,7 +38,7 @@ public class ProdDslTest extends AAISetup {
+ ".getVerticesByProperty('cloud-region-id','value').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag')"
+ ".getVerticesByProperty('vlan-id-outer','value').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -49,7 +50,7 @@ public class ProdDslTest extends AAISetup {
+ ".createEdgeTraversal(EdgeType.TREE, 'pserver','p-interface')"
+ ".createEdgeTraversal(EdgeType.TREE, 'p-interface','sriov-pf').getVerticesByProperty('pf-pci-id','0000:ee:00.0').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -61,7 +62,7 @@ public class ProdDslTest extends AAISetup {
+ ".createEdgeTraversal(EdgeType.TREE, 'l-interface','sriov-vf')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'sriov-vf','sriov-pf').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -75,7 +76,7 @@ public class ProdDslTest extends AAISetup {
+ ".createEdgeTraversal( 'l-interface','lag-interface').getVerticesByProperty('interface-name','bond1')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'lag-interface','p-interface').createEdgeTraversal(EdgeType.TREE, 'p-interface','sriov-pf').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
@@ -88,7 +89,7 @@ public class ProdDslTest extends AAISetup {
+ ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','vserver').getVerticesByProperty('vserver-name','value')"
+ ".createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').createEdgeTraversal(EdgeType.COUSIN, 'l-interface','cp').createEdgeTraversal(EdgeType.COUSIN, 'cp','vlan-tag').store('x').cap('x').unfold().dedup()";
- String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString();
assertEquals(dslQuery, query);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/AbstractSpringHistoryRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/AbstractSpringHistoryRestTest.java
new file mode 100644
index 0000000..f671135
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/AbstractSpringHistoryRestTest.java
@@ -0,0 +1,138 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.history;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.*;
+import org.onap.aai.TraversalApp;
+import org.onap.aai.TraversalTestConfiguration;
+import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.nodes.NodeIngestor;
+import org.onap.aai.util.AAIConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+import java.util.Collections;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
+@TestPropertySource(
+ locations = "classpath:application-test.properties",
+ properties = {
+ "history.enabled=true",
+ "history.truncate.window.days = " + Integer.MAX_VALUE
+ }
+)
+@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
+@Import(TraversalTestConfiguration.class)
+public abstract class AbstractSpringHistoryRestTest {
+
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
+
+ @Autowired
+ protected RestTemplate restTemplate;
+
+ @Autowired
+ protected NodeIngestor nodeIngestor;
+
+ @LocalServerPort
+ protected int randomPort;
+
+ protected HttpEntity httpEntity;
+
+ protected String baseUrl;
+ protected HttpHeaders headers ;
+
+ @BeforeClass
+ public static void setupConfig() throws AAIException {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
+ }
+
+ @Before
+ public void setup() throws AAIException, UnsupportedEncodingException {
+
+ AAIConfig.init();
+ AAIGraph.getInstance();
+
+ createTestGraph();
+ headers = new HttpHeaders();
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
+ headers.add("Authorization", "Basic " + authorization);
+ httpEntity = new HttpEntity(headers);
+ baseUrl = "http://localhost:" + randomPort;
+ }
+
+ /*
+ * Inheritors please override this one
+ */
+ public void createTestGraph(){
+
+ }
+
+ @After
+ public void tearDown(){
+
+ JanusGraph janusGraph = AAIGraph.getInstance().getGraph();
+ JanusGraphTransaction transaction = janusGraph.newTransaction();
+
+ boolean success = true;
+
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.V().toList()
+ .forEach(Vertex::remove);
+ } catch(Exception ex){
+ success = false;
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ }
+ }
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java
new file mode 100644
index 0000000..7cf8138
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java
@@ -0,0 +1,246 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.history;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+@Ignore("The state format requires the history schema to be loaded. " +
+ "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " +
+ "This needs to be addressed.")
+public class CQAllChildernFromPnfStateTest extends AbstractSpringHistoryRestTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CQAllChildernFromPnfStateTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+
+ Vertex pnf1 = g.addV()
+ .property(AAIProperties.NODE_TYPE, "pnf",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.AAI_URI, "/network/pnfs/pnf/pnf-1",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("pnf-name", "pnf-1",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("in-maint", false,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("pnf-id", "pnf-1-id",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .next();
+
+ Vertex pint1 = g.addV()
+ .property(AAIProperties.NODE_TYPE, "p-interface",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.AAI_URI, "/network/pnfs/pnf/pnf-1/p-interfaces/p-interface/pint-1",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("interface-name", "pint-1",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .next();
+
+ Vertex lint1 = g.addV()
+ .property(AAIProperties.NODE_TYPE, "l-interface",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.AAI_URI, "/network/pnfs/pnf/pnf-1/p-interfaces/p-interface/pint-1/l-interfaces/l-interface/lint-1",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("interface-name", "lint-1",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .next();
+
+ pint1.addEdge("tosca.relationships.network.BindsTo", pnf1,
+ "start-ts", 100L,
+ "private", false,
+ "aai-uuid", "e713ce2c-62d5-4555-a481-95619cb158aa",
+ "prevent-delete", "NONE",
+ "delete-other-v", "IN",
+ "source-of-truth", "JUNIT-EDGE-C",
+ "start-tx-id", "JUNIT-EDGE-C",
+ "contains-other-v", "IN");
+
+ lint1.addEdge("tosca.relationships.network.BindsTo", pint1,
+ "start-ts", 100L,
+ "private", false,
+ "aai-uuid", "e713ce2c-62d5-4555-a481-95619cb158ab",
+ "prevent-delete", "NONE",
+ "delete-other-v", "IN",
+ "source-of-truth", "JUNIT-EDGE-C",
+ "start-tx-id", "JUNIT-EDGE-C",
+ "contains-other-v", "IN");
+
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ private JsonArray executeCustomQuery(String endpoint, String queryName, String... startUris) throws Exception {
+ JsonObject payload = new JsonObject();
+ JsonArray start = new JsonArray();
+ Arrays.stream(startUris).forEach(start::add);
+ payload.add("start", start);
+ payload.addProperty("query", "query/" + queryName);
+ httpEntity = new HttpEntity(payload.toString(), headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+ return results;
+ }
+
+ private JsonArray executeGremlin(String endpoint, String query) throws Exception {
+ JsonObject payload = new JsonObject();
+ payload.addProperty("gremlin", query);
+ httpEntity = new HttpEntity(payload.toString(), headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+ return results;
+ }
+
+ private void verifyResultUris(JsonArray results, String... uris) {
+ Set<String> expected = new HashSet<>(Arrays.asList(uris));
+ final Set<String> actualEquipType = new HashSet<>();
+ for (JsonElement result : results) {
+ actualEquipType.add(result.getAsJsonObject().get("uri").getAsString());
+ }
+ assertThat("Verify results uri's", actualEquipType, is(expected));
+ }
+
+
+ @Test
+ public void pnfChildrenQueryTest() throws Exception {
+ JsonArray results = executeCustomQuery("/aai/v14/query?format=state", "allchildren-fromPnf", "/network/pnfs/pnf/pnf-1");
+ verifyResultUris(results, "/network/pnfs/pnf/pnf-1", "/network/pnfs/pnf/pnf-1/p-interfaces/p-interface/pint-1", "/network/pnfs/pnf/pnf-1/p-interfaces/p-interface/pint-1/l-interfaces/l-interface/lint-1");
+ }
+
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java
new file mode 100644
index 0000000..5b2c8da
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java
@@ -0,0 +1,476 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.history;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+@Ignore("The lifecycle format requires the history schema to be loaded. " +
+ "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " +
+ "This needs to be addressed.")
+public class DslConsumerHistoryLifecycleEdgeTest extends AbstractSpringHistoryRestTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DslConsumerHistoryLifecycleEdgeTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+
+ Vertex pserver = g.addV().property(AAIProperties.NODE_TYPE, "pserver",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("hostname", "test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("in-maint", false,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("equip-type", "ps-type",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .next();
+ Vertex complex = g.addV().property(AAIProperties.NODE_TYPE, "complex",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/complexes/complex/test-complex-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("physical-location-id", "test-complex-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("street", "200 S. Laurel Ave",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("city", "Middletown",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("state", "NJ",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property("zip", "11111",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C" ,
+ AAIProperties.START_TS, 100L
+ )
+ .next();
+
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 100,
+ "private", false,
+ "aai-uuid", "edge1",
+ "end-source-of-truth", "JUNIT-E-D-1",
+ "end-tx-id", "JUNIT-E-D-1",
+ "end-ts", 300,
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-1",
+ "start-tx-id", "JUNIT-E-C-1",
+ "contains-other-v", "NONE"
+ );
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 500,
+ "private", false,
+ "aai-uuid", "edge2",
+ "end-source-of-truth", "JUNIT-E-D-2",
+ "end-tx-id", "JUNIT-E-D-2",
+ "end-ts", 700,
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-2",
+ "start-tx-id", "JUNIT-E-C-2",
+ "contains-other-v", "NONE"
+ );
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 900,
+ "private", false,
+ "aai-uuid", "edge3",
+ "end-source-of-truth", "JUNIT-E-D-3",
+ "end-tx-id", "JUNIT-E-D-3",
+ "end-ts", 1100,
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-3",
+ "start-tx-id", "JUNIT-E-C-3",
+ "contains-other-v", "NONE"
+ );
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 1300,
+ "private", false,
+ "aai-uuid", "edge3",
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-3",
+ "start-tx-id", "JUNIT-E-C-3",
+ "contains-other-v", "NONE"
+ );
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ private JsonArray getResultsForPserverLookupByHostname(String endpoint) throws Exception {
+ return getResultsForPserverLookupByHostnameAndAnother(endpoint, "");
+ }
+
+ private JsonArray getResultsForPserverLookupByHostnameAndAnother(String endpoint, String additionalFilterInParen) throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')" + additionalFilterInParen);
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+ return results;
+ }
+
+
+ private void verifyEquipTypeValues(JsonArray results, String... expectedEquipTypes) {
+ List<String> expected = Arrays.asList(expectedEquipTypes);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("value") && !property.getAsJsonObject().get("value").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("value").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeSoTs(JsonArray results, String... expectedSTOs) {
+ List<String> expected = Arrays.asList(expectedSTOs);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("sot") && !property.getAsJsonObject().get("sot").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("sot").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type SoTs in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeTxId(JsonArray results, String... expectedSTOs) {
+ List<String> expected = Arrays.asList(expectedSTOs);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("tx-id") && !property.getAsJsonObject().get("tx-id").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("tx-id").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type tx-ids in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeTimestamps(JsonArray results, Long... expectedSTOs) {
+ List<Long> expected = Arrays.asList(expectedSTOs);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("timestamp") && !property.getAsJsonObject().get("timestamp").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("timestamp").getAsLong());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type timestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyNodeTimestamps(JsonArray results, Long... nodeTimestamps) {
+ List<Long> expected = Arrays.asList(nodeTimestamps);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("node-actions").getAsJsonArray().forEach(jsonElement ->
+ actualEquipType.add(jsonElement.getAsJsonObject().get("timestamp").getAsLong()));
+ }
+ assertThat("Verify node-changes timestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyRelatedToCreatedTimestamps(JsonArray results, Long... edgeCreatedTimestamps) {
+ List<Long> expected = Arrays.asList(edgeCreatedTimestamps);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("related-to").getAsJsonArray().forEach(jsonElement -> {
+ if (jsonElement.getAsJsonObject().has("timestamp")) {
+ actualEquipType.add(jsonElement.getAsJsonObject().get("timestamp").getAsLong());
+ }
+ });
+ }
+ assertThat("Verify related-to createdtimestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyRelatedToCreatedDeletedTimestamps(JsonArray results, Long... edgeDeletedTimestamps) {
+ List<Long> expected = Arrays.asList(edgeDeletedTimestamps);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("related-to").getAsJsonArray().forEach(jsonElement -> {
+ if (jsonElement.getAsJsonObject().has("end-timestamp")) {
+ actualEquipType.add(jsonElement.getAsJsonObject().get("end-timestamp").getAsLong());
+ }
+ });
+ }
+ assertThat("Verify related-to createdtimestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyRelatedToCount(JsonArray results, int expectedSize) {
+ int actualSize = 0;
+ for (JsonElement result : results) {
+ actualSize += result.getAsJsonObject().get("related-to").getAsJsonArray().size();
+ }
+ assertEquals("Verify related-to count", actualSize, expectedSize);
+ }
+
+ private void verifyRelatedToTxId(JsonArray results) {
+ final Set<JsonObject> withTxId = new HashSet<>();
+ int count = 0;
+ for (JsonElement result : results) {
+ count += result.getAsJsonObject().get("related-to").getAsJsonArray().size();
+ result.getAsJsonObject().get("related-to").getAsJsonArray().forEach(jsonElement -> {
+ if (jsonElement.getAsJsonObject().has("tx-id")) {
+ withTxId.add(jsonElement.getAsJsonObject());
+ }
+ if (jsonElement.getAsJsonObject().has("end-tx-id")) {
+ withTxId.add(jsonElement.getAsJsonObject());
+ }
+ });
+ }
+ assertEquals("Verify no related-to has end-tx-id in state", count, withTxId.size());
+ }
+
+
+ @Test
+ public void lifecycleQueryStartTsBeforeCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 100L);
+ verifyNodeTimestamps(results, 100L);
+ verifyRelatedToCreatedTimestamps(results, 100L, 500L, 900L, 1300L);
+ verifyRelatedToCreatedDeletedTimestamps(results, 300L, 700L, 1100L);
+ verifyRelatedToCount(results, 4);
+ verifyRelatedToTxId(results);
+ }
+
+
+
+ @Test
+ public void lifecycleQueryStartTsBeforeSecondEdgeCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=400";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTxId(results);
+ verifyEquipTypeTimestamps(results);
+ verifyNodeTimestamps(results);
+ verifyRelatedToCreatedTimestamps(results, 500L, 900L, 1300L);
+ verifyRelatedToCreatedDeletedTimestamps(results, 700L, 1100L);
+ verifyRelatedToCount(results, 3);
+ verifyRelatedToTxId(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtSecondEdgeDeletionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=700";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTxId(results);
+ verifyEquipTypeTimestamps(results);
+ verifyNodeTimestamps(results);
+ verifyRelatedToCreatedTimestamps(results, 900L, 1300L);
+ verifyRelatedToCreatedDeletedTimestamps(results, 700L, 1100L);
+ verifyRelatedToCount(results, 3);
+ verifyRelatedToTxId(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterSecondEdgeDeletionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=800";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTxId(results);
+ verifyEquipTypeTimestamps(results);
+ verifyNodeTimestamps(results);
+ verifyRelatedToCreatedTimestamps(results, 900L, 1300L);
+ verifyRelatedToCreatedDeletedTimestamps(results, 1100L);
+ verifyRelatedToCount(results, 2);
+ verifyRelatedToTxId(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtLastEdgeActionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=1300";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTxId(results);
+ verifyEquipTypeTimestamps(results);
+ verifyNodeTimestamps(results);
+ verifyRelatedToCreatedTimestamps(results, 1300L);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 1);
+ verifyRelatedToTxId(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterLastEdgeActionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=1400";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 0, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTxId(results);
+ verifyEquipTypeTimestamps(results);
+ verifyNodeTimestamps(results);
+ verifyRelatedToCreatedTimestamps(results);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 0);
+ verifyRelatedToTxId(results);
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java
new file mode 100644
index 0000000..25e9e84
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java
@@ -0,0 +1,744 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.history;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+@Ignore("The lifecycle format requires the history schema to be loaded. " +
+ "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " +
+ "This needs to be addressed.")
+public class DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest extends AbstractSpringHistoryRestTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ /*
+ Pserver
+ - created pserver @ time 100
+ - equip-type = first-ps-type
+ - update equip-type @ 500
+ - equip-type = first-ps-type-update
+ - deleted pserver @ time 1000
+ */
+ g.addV().property(AAIProperties.NODE_TYPE, "pserver",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 500L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "500",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 500L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("hostname", "test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("in-maint", false,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("equip-type", "first-ps-type",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 500L
+ )
+ .property("equip-type", "first-ps-type-update",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 500L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
+ AAIProperties.START_TX_ID, "JUNIT-D",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.END_TS, 1000L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
+ AAIProperties.START_TX_ID, "JUNIT-D",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 1000L,
+ AAIProperties.END_TS, 1000L
+ )
+ .next();
+
+ /*
+ Pserver
+ - created pserver @ time 10000
+ - equip-type = second-ps-type
+ - delete equip-type @ 13000
+ - recreate equip-type @ 15000
+ - equip-type = second-ps-type-recreated
+ - update equip-type @ 17000
+ - equip-type = second-ps-type-update
+ - delete equip-type @ 20000
+ */
+ g.addV().property(AAIProperties.NODE_TYPE, "pserver",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "10000",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U-1",
+ AAIProperties.END_TX_ID, "JUNIT-U-1",
+ AAIProperties.START_TS, 10000L,
+ AAIProperties.END_TS, 13000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "13000",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-1",
+ AAIProperties.START_TX_ID, "JUNIT-U-1",
+ AAIProperties.END_SOT, "JUNIT-U-2",
+ AAIProperties.END_TX_ID, "JUNIT-U-2",
+ AAIProperties.START_TS, 13000L,
+ AAIProperties.END_TS, 15000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "15000",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-2",
+ AAIProperties.START_TX_ID, "JUNIT-U-2",
+ AAIProperties.END_SOT, "JUNIT-U-3",
+ AAIProperties.END_TX_ID, "JUNIT-U-3",
+ AAIProperties.START_TS, 15000L,
+ AAIProperties.END_TS, 17000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "17000",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-3",
+ AAIProperties.START_TX_ID, "JUNIT-U-3",
+ AAIProperties.END_SOT, "JUNIT-U-4",
+ AAIProperties.END_TX_ID, "JUNIT-U-4",
+ AAIProperties.START_TS, 17000L,
+ AAIProperties.END_TS, 20000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "20000",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-4",
+ AAIProperties.START_TX_ID, "JUNIT-U-4",
+ AAIProperties.START_TS, 20000L
+ )
+ .property("hostname", "test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property("in-maint", true,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property("equip-type", "second-ps-type",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U-1",
+ AAIProperties.END_TX_ID, "JUNIT-U-1",
+ AAIProperties.START_TS, 10000L,
+ AAIProperties.END_TS, 13000L
+ )
+ .property("equip-type", "second-ps-type-recreated",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-2",
+ AAIProperties.START_TX_ID, "JUNIT-U-2",
+ AAIProperties.END_SOT, "JUNIT-U-3",
+ AAIProperties.END_TX_ID, "JUNIT-U-3",
+ AAIProperties.START_TS, 15000L,
+ AAIProperties.END_TS, 17000L
+ )
+ .property("equip-type", "second-ps-type-update",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U-3",
+ AAIProperties.START_TX_ID, "JUNIT-U-3",
+ AAIProperties.START_TS, 17000L,
+ AAIProperties.END_SOT, "JUNIT-U-4",
+ AAIProperties.END_TX_ID, "JUNIT-U-4",
+ AAIProperties.END_TS, 20000L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property(AAIProperties.START_TS, 10000L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .next();
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ private JsonArray getResultsForPserverLookupByHostname(String endpoint) throws Exception {
+ return getResultsForPserverLookupByHostnameAndAnother(endpoint, "");
+ }
+
+ private JsonArray getResultsForPserverLookupByHostnameAndAnother(String endpoint, String additionalFilterInParen) throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')" + additionalFilterInParen);
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+ return results;
+ }
+
+
+ private void verifyEquipTypeValues(JsonArray results, String... expectedEquipTypes) {
+ List<String> expected = Arrays.asList(expectedEquipTypes);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("value") && !property.getAsJsonObject().get("value").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("value").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeSoTs(JsonArray results, String... expectedSTOs) {
+ List<String> expected = Arrays.asList(expectedSTOs);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("sot") && !property.getAsJsonObject().get("sot").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("sot").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type SoTs in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeTxId(JsonArray results, String... expectedSTOs) {
+ List<String> expected = Arrays.asList(expectedSTOs);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("tx-id") && !property.getAsJsonObject().get("tx-id").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("tx-id").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type tx-ids in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeTimestamps(JsonArray results, Long... expectedSTOs) {
+ List<Long> expected = Arrays.asList(expectedSTOs);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("timestamp") && !property.getAsJsonObject().get("timestamp").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("timestamp").getAsLong());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type timestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyNodeTimestamps(JsonArray results, Long... nodeTimestamps) {
+ List<Long> expected = Arrays.asList(nodeTimestamps);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("node-actions").getAsJsonArray().forEach(jsonElement ->
+ actualEquipType.add(jsonElement.getAsJsonObject().get("timestamp").getAsLong()));
+ }
+ assertThat("Verify node-changes timestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyNodeSot(JsonArray results, String... nodeSots) {
+ List<String> expected = Arrays.asList(nodeSots);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("node-actions").getAsJsonArray().forEach(jsonElement ->
+ actualEquipType.add(jsonElement.getAsJsonObject().get("sot").getAsString()));
+ }
+ assertThat("Verify node-changes sot in lifecycle", actualEquipType, is(expected));
+ }
+
+
+ @Test
+ public void lifecycleQueryNoStartOrEndTsTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
+ verifyNodeTimestamps(results, 10000L, 1000L, 100L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+ equipType = "second-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
+ verifyNodeTimestamps(results, 10000L);
+ }
+
+
+
+ @Test
+ public void lifecycleQueryStartTsBeforeCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
+ verifyNodeTimestamps(results, 10000L, 1000L, 100L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+ equipType = "second-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
+ verifyNodeTimestamps(results, 10000L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=100";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
+ verifyNodeTimestamps(results, 10000L, 1000L, 100L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=300";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L);
+ verifyNodeTimestamps(results, 10000L, 1000L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtFirstUpdateTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=500";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L);
+ verifyNodeTimestamps(results, 10000L, 1000L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterFirstUpdateTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=700";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
+ verifyNodeTimestamps(results, 10000L, 1000L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtFirstDeleteTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=1000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
+ verifyNodeTimestamps(results, 10000L, 1000L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterFirstDeleteTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=5000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
+ verifyNodeTimestamps(results, 10000L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtSecondCreateTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=10000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L);
+ verifyNodeTimestamps(results, 10000L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterSecondCreateTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=12000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null);
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtEquipTypeFirstDeleteOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=13000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null);
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterEquipTypeFirstDeleteOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=14000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtEquipTypeRecreateOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=15000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterEquipTypeRecreateOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=16000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtEquipTypeUpdateOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=17000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterEquipTypeUpdateOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=19000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, new String[] {null});
+ verifyEquipTypeSoTs(results, "JUNIT-U-4");
+ verifyEquipTypeTxId(results, "JUNIT-U-4");
+ verifyEquipTypeTimestamps(results, 20000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsOnEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=20000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, new String[] {null});
+ verifyEquipTypeSoTs(results, "JUNIT-U-4");
+ verifyEquipTypeTxId(results, "JUNIT-U-4");
+ verifyEquipTypeTimestamps(results, 20000L);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=22000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 0, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTxId(results);
+ verifyEquipTypeTimestamps(results);
+ verifyNodeTimestamps(results);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsBeforeCreationEndTimeAfterEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=22000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
+ verifyNodeTimestamps(results, 10000L, 1000L, 100L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsBeforeCreationEndTimeAtEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=20000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, null, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-4", "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 20000L, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
+ verifyNodeTimestamps(results, 10000L, 1000L, 100L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsBeforeCreationEndTimeBeforeEquipTypeSecondDeleteOnSecondPsTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=19000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "second-ps-type-update", "second-ps-type-recreated", null, "second-ps-type", "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U-3", "JUNIT-U-2", "JUNIT-U-1", "JUNIT-C", "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 17000L, 15000L, 13000L, 10000L, 500L, 100L);
+ verifyNodeTimestamps(results, 10000L, 1000L, 100L);
+ }
+
+ @Test
+ public void lifecycleQueryStartTsBeforeCreationEndTimeBeforeSecondPsCreateTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50&endTs=9000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+ }
+
+ @Test
+ public void verifyNodeActionsWithNoTimeRangeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+ verifyNodeTimestamps(results, 10000L, 1000L, 100L);
+ verifyNodeSot(results, "JUNIT-C", "JUNIT-D", "JUNIT-C");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java
new file mode 100644
index 0000000..e59573d
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java
@@ -0,0 +1,467 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.history;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+@Ignore("The lifecycle format requires the history schema to be loaded. " +
+ "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " +
+ "This needs to be addressed.")
+public class DslConsumerHistoryLifecycleSingleNodeTest extends AbstractSpringHistoryRestTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DslConsumerHistoryLifecycleSingleNodeTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ /*
+ Pserver
+ - created pserver @ time 100
+ - equip-type = first-ps-type
+ - update equip-type @ 500
+ - equip-type = first-ps-type-update
+ - deleted pserver @ time 1000
+ */
+ g.addV().property(AAIProperties.NODE_TYPE, "pserver",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 500L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "500",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 500L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("hostname", "test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("in-maint", false,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("equip-type", "first-ps-type",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 500L
+ )
+ .property("equip-type", "first-ps-type-update",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 500L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
+ AAIProperties.START_TX_ID, "JUNIT-D",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.END_TS, 1000L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
+ AAIProperties.START_TX_ID, "JUNIT-D",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 1000L,
+ AAIProperties.END_TS, 1000L
+ )
+ .next();
+
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ private JsonArray getResultsForPserverLookupByHostname(String endpoint) throws Exception {
+ return getResultsForPserverLookupByHostnameAndAnother(endpoint, "");
+ }
+
+ private JsonArray getResultsForPserverLookupByHostnameAndAnother(String endpoint, String additionalFilterInParen) throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')" + additionalFilterInParen);
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+ return results;
+ }
+
+
+ private void verifyEquipTypeValues(JsonArray results, String... expectedEquipTypes) {
+ List<String> expected = Arrays.asList(expectedEquipTypes);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("value") && !property.getAsJsonObject().get("value").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("value").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeSoTs(JsonArray results, String... expectedSTOs) {
+ List<String> expected = Arrays.asList(expectedSTOs);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("sot") && !property.getAsJsonObject().get("sot").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("sot").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type SoTs in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeTxId(JsonArray results, String... expectedSTOs) {
+ List<String> expected = Arrays.asList(expectedSTOs);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("tx-id") && !property.getAsJsonObject().get("tx-id").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("tx-id").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type tx-ids in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeTimestamps(JsonArray results, Long... expectedSTOs) {
+ List<Long> expected = Arrays.asList(expectedSTOs);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("timestamp") && !property.getAsJsonObject().get("timestamp").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("timestamp").getAsLong());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type timestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+ private void verifyNodeTimestamps(JsonArray results, Long... nodeTimestamps) {
+ List<Long> expected = Arrays.asList(nodeTimestamps);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("node-actions").getAsJsonArray().forEach(jsonElement ->
+ actualEquipType.add(jsonElement.getAsJsonObject().get("timestamp").getAsLong()));
+ }
+ assertThat("Verify node-changes timestamps in lifecycle", actualEquipType, is(expected));
+ }
+
+
+ @Test
+ public void lifecycleQueryNoStartOrEndTsTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+ equipType = "other-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+
+
+ @Test
+ public void lifecycleQueryStartTsBeforeCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=50";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+ equipType = "other-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=100";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update", "first-ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTxId(results, "JUNIT-U", "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 500L, 100L);
+ verifyNodeTimestamps(results, 1000L, 100L);
+
+ equipType = "other-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=300";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U");
+ verifyEquipTypeTxId(results, "JUNIT-U");
+ verifyEquipTypeTimestamps(results, 500L);
+ verifyNodeTimestamps(results, 1000L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U");
+ verifyEquipTypeTxId(results, "JUNIT-U");
+ verifyEquipTypeTimestamps(results, 500L);
+ verifyNodeTimestamps(results, 1000L);
+
+ equipType = "other-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtUpdateTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=500";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U");
+ verifyEquipTypeTxId(results, "JUNIT-U");
+ verifyEquipTypeTimestamps(results, 500L);
+ verifyNodeTimestamps(results, 1000L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyEquipTypeSoTs(results, "JUNIT-U");
+ verifyEquipTypeTxId(results, "JUNIT-U");
+ verifyEquipTypeTimestamps(results, 500L);
+ verifyNodeTimestamps(results, 1000L);
+
+ equipType = "other-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterUpdateTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=700";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTxId(results);
+ verifyEquipTypeTimestamps(results);
+ verifyNodeTimestamps(results, 1000L);
+
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "other-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAtDeleteTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=1000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+ assertEquals("properties size should be 0", results.get(0).getAsJsonObject().get("properties").getAsJsonArray().size(), 0);
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+ @Test
+ public void lifecycleQueryStartTsAfterDeleteTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=lifecycle&startTs=5000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 0, results.size());
+
+ String equipType = "first-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "other-ps-type-recreated";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java
new file mode 100644
index 0000000..4e122dc
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java
@@ -0,0 +1,476 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.history;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+@Ignore("The state format requires the history schema to be loaded. " +
+ "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " +
+ "This needs to be addressed.")
+public class DslConsumerHistoryStateEdgeTest extends AbstractSpringHistoryRestTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DslConsumerHistoryStateEdgeTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+
+ Vertex pserver = g.addV().property(AAIProperties.NODE_TYPE, "pserver",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("hostname", "test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("in-maint", false,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("equip-type", "ps-type",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .next();
+ Vertex complex = g.addV().property(AAIProperties.NODE_TYPE, "complex",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/complexes/complex/test-complex-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("physical-location-id", "test-complex-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("street", "200 S. Laurel Ave",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("city", "Middletown",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("state", "NJ",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property("zip", "11111",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 100L
+ )
+ .next();
+
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 100,
+ "private", false,
+ "aai-uuid", "edge1",
+ "end-source-of-truth", "JUNIT-E-D-1",
+ "end-tx-id", "JUNIT-E-D-1",
+ "end-ts", 300,
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-1",
+ "start-tx-id", "JUNIT-E-C-1",
+ "contains-other-v", "NONE"
+ );
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 500,
+ "private", false,
+ "aai-uuid", "edge2",
+ "end-source-of-truth", "JUNIT-E-D-2",
+ "end-tx-id", "JUNIT-E-D-2",
+ "end-ts", 700,
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-2",
+ "start-tx-id", "JUNIT-E-C-2",
+ "contains-other-v", "NONE"
+ );
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 900,
+ "private", false,
+ "aai-uuid", "edge3",
+ "end-source-of-truth", "JUNIT-E-D-3",
+ "end-tx-id", "JUNIT-E-D-3",
+ "end-ts", 1100,
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-3",
+ "start-tx-id", "JUNIT-E-C-3",
+ "contains-other-v", "NONE"
+ );
+ pserver.addEdge("org.onap.relationships.inventory.LocatedIn",
+ complex,
+ "start-ts", 1300,
+ "private", false,
+ "aai-uuid", "edge3",
+ "prevent-delete", "IN",
+ "delete-other-v", "NONE",
+ "source-of-truth", "JUNIT-E-C-3",
+ "start-tx-id", "JUNIT-E-C-3",
+ "contains-other-v", "NONE"
+ );
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ private JsonArray getResultsForPserverLookupByHostname(String endpoint) throws Exception {
+ return getResultsForPserverLookupByHostnameAndAnother(endpoint, "");
+ }
+
+ private JsonArray getResultsForPserverLookupByHostnameAndAnother(String endpoint, String additionalFilterInParen) throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')" + additionalFilterInParen);
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+ return results;
+ }
+
+
+ private void verifyEquipTypeValues(JsonArray results, String... expectedEquipTypes) {
+ List<String> expected = Arrays.asList(expectedEquipTypes);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ assertFalse("State format properties should not have end timestamps",
+ property.getAsJsonObject().has("end-timestamp"));
+ if (property.getAsJsonObject().has("value") && !property.getAsJsonObject().get("value").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("value").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type in state", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeSoTs(JsonArray results, String... expectedSTOs) {
+ List<String> expected = Arrays.asList(expectedSTOs);
+ final List<String> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("sot") && !property.getAsJsonObject().get("sot").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("sot").getAsString());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type SoTs in state", actualEquipType, is(expected));
+ }
+
+ private void verifyEquipTypeTimestamps(JsonArray results, Long... expectedSTOs) {
+ List<Long> expected = Arrays.asList(expectedSTOs);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ if (property.getAsJsonObject().has("timestamp") && !property.getAsJsonObject().get("timestamp").isJsonNull()) {
+ actualEquipType.add(property.getAsJsonObject().get("timestamp").getAsLong());
+ } else {
+ actualEquipType.add(null);
+ }
+ }
+ }
+ }
+ assertThat("Verify equip-type timestamps in state", actualEquipType, is(expected));
+ }
+
+ private void verifyRelatedToCreatedTimestamps(JsonArray results, Long... edgeCreatedTimestamps) {
+ List<Long> expected = Arrays.asList(edgeCreatedTimestamps);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("related-to").getAsJsonArray().forEach(jsonElement ->
+ actualEquipType.add(jsonElement.getAsJsonObject().get("timestamp").getAsLong()));
+ }
+ assertThat("Verify related-to createdtimestamps in state", actualEquipType, is(expected));
+ }
+
+ private void verifyRelatedToCreatedDeletedTimestamps(JsonArray results, Long... edgeDeletedTimestamps) {
+ List<Long> expected = Arrays.asList(edgeDeletedTimestamps);
+ final List<Long> actualEquipType = new ArrayList<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("related-to").getAsJsonArray().forEach(jsonElement -> {
+ if (jsonElement.getAsJsonObject().has("end-timestamp")) {
+ actualEquipType.add(jsonElement.getAsJsonObject().get("end-timestamp").getAsLong());
+ }
+ });
+ }
+ assertThat("Verify related-to created timestamps in state", actualEquipType, is(expected));
+ }
+
+ private void verifyRelatedToCount(JsonArray results, int expectedSize) {
+ int actualSize = 0;
+ for (JsonElement result : results) {
+ actualSize += result.getAsJsonObject().get("related-to").getAsJsonArray().size();
+ }
+ assertEquals("Verify related-to count", actualSize, expectedSize);
+ }
+
+ private void verifyAllPropsTxIds(JsonArray results) {
+ final Set<String> propMissingCreatedTxId = new HashSet<>();
+ final Set<String> propContainingEndTxId = new HashSet<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (!property.getAsJsonObject().has("tx-id")) {
+ propMissingCreatedTxId.add(property.getAsJsonObject().get("key").getAsString());
+ }
+ if (property.getAsJsonObject().has("end-tx-id")) {
+ propContainingEndTxId.add(property.getAsJsonObject().get("key").getAsString());
+ }
+ }
+ }
+
+ assertThat("Verify no prop is missing tx-id in state", propMissingCreatedTxId, is(Collections.EMPTY_SET));
+ assertThat("Verify no prop has end-tx-id in state", propContainingEndTxId, is(Collections.EMPTY_SET));
+ }
+
+ private void verifyRelatedToCreatedTxId(JsonArray results) {
+ final Set<JsonObject> edgeMissingCreatedTxId = new HashSet<>();
+ final Set<JsonObject> edgeContainingEndTxId = new HashSet<>();
+ for (JsonElement result : results) {
+ result.getAsJsonObject().get("related-to").getAsJsonArray().forEach(jsonElement -> {
+ if (!jsonElement.getAsJsonObject().has("tx-id")) {
+ edgeMissingCreatedTxId.add(jsonElement.getAsJsonObject());
+ }
+ if (jsonElement.getAsJsonObject().has("end-tx-id")) {
+ edgeContainingEndTxId.add(jsonElement.getAsJsonObject());
+ }
+ });
+ }
+ assertThat("Verify no related-to is missing tx-id in state", edgeMissingCreatedTxId, is(Collections.EMPTY_SET));
+ assertThat("Verify no related-to has end-tx-id in state", edgeContainingEndTxId, is(Collections.EMPTY_SET));
+ }
+
+ @Test
+ public void stateQueryStartTsBeforeCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=50";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 0, results.size());
+
+ verifyEquipTypeValues(results);
+ verifyEquipTypeSoTs(results);
+ verifyEquipTypeTimestamps(results);
+ verifyRelatedToCreatedTimestamps(results);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 0);
+ verifyAllPropsTxIds(results);
+ verifyRelatedToCreatedTxId(results);
+ }
+
+
+
+ @Test
+ public void stateQueryStartTsBeforeSecondEdgeCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=400";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 100L);
+ verifyRelatedToCreatedTimestamps(results);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 0);
+ verifyAllPropsTxIds(results);
+ verifyRelatedToCreatedTxId(results);
+ }
+
+ @Test
+ public void stateQueryStartTsAfterSecondEdgeCreationTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=600";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 100L);
+ verifyRelatedToCreatedTimestamps(results, 500L);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 1);
+ verifyAllPropsTxIds(results);
+ verifyRelatedToCreatedTxId(results);
+ }
+
+ @Test
+ public void stateQueryStartTsAtSecondEdgeDeletionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=700";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 100L);
+ verifyRelatedToCreatedTimestamps(results);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 0);
+ verifyAllPropsTxIds(results);
+ verifyRelatedToCreatedTxId(results);
+ }
+
+ @Test
+ public void stateQueryStartTsAfterSecondEdgeDeletionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=800";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 100L);
+ verifyRelatedToCreatedTimestamps(results);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 0);
+ verifyAllPropsTxIds(results);
+ verifyRelatedToCreatedTxId(results);
+ }
+
+ @Test
+ public void stateQueryStartTsAtLastEdgeActionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=1300";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 100L);
+ verifyRelatedToCreatedTimestamps(results, 1300L);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 1);
+ verifyAllPropsTxIds(results);
+ verifyRelatedToCreatedTxId(results);
+ }
+
+ @Test
+ public void stateQueryStartTsAfterLastEdgeActionTimeTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=1400";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals("Result size", 1, results.size());
+
+ verifyEquipTypeValues(results, "ps-type");
+ verifyEquipTypeSoTs(results, "JUNIT-C");
+ verifyEquipTypeTimestamps(results, 100L);
+ verifyRelatedToCreatedTimestamps(results, 1300L);
+ verifyRelatedToCreatedDeletedTimestamps(results);
+ verifyRelatedToCount(results, 1);
+ verifyAllPropsTxIds(results);
+ verifyRelatedToCreatedTxId(results);
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java
new file mode 100644
index 0000000..bb9584e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java
@@ -0,0 +1,770 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.history;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.*;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+@Ignore("The state format requires the history schema to be loaded. " +
+ "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " +
+ "This needs to be addressed.")
+public class DslConsumerHistoryStateTest extends AbstractSpringHistoryRestTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DslConsumerHistoryStateTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ /*
+ Pserver
+ - created @ time 100
+ - update in-maint/equip-type @ 500
+ - deleted @ time 1000
+ */
+ g.addV().property(AAIProperties.NODE_TYPE, "pserver",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "100",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 500L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "500",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 500L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("hostname", "test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("in-maint", false,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 500L
+ )
+ .property("in-maint", true,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 500L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property("equip-type", "first-ps-type",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 500L
+ )
+ .property("equip-type", "first-ps-type-update",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 500L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
+ AAIProperties.START_TX_ID, "JUNIT-D",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.START_TS, 100L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 100L,
+ AAIProperties.END_TS, 1000L
+ )
+ .property(AAIProperties.END_TS, 1000L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-D",
+ AAIProperties.START_TX_ID, "JUNIT-D",
+ AAIProperties.END_SOT, "JUNIT-D",
+ AAIProperties.END_TX_ID, "JUNIT-D",
+ AAIProperties.START_TS, 1000L,
+ AAIProperties.END_TS, 1000L
+ )
+ .next();
+
+ /*
+ Pserver
+ - created @ time 10000
+ - update in-maint/equip-type @ 15000
+ */
+ g.addV().property(AAIProperties.NODE_TYPE, "pserver",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "10000",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 10000L,
+ AAIProperties.END_TS, 15000L
+ )
+ .property(AAIProperties.RESOURCE_VERSION, "15000",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 15000
+ )
+ .property("hostname", "test-pserver-dsl",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property("in-maint", true,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 10000L,
+ AAIProperties.END_TS, 15000L
+ )
+ .property("in-maint", false,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 15000L
+ )
+ .property("equip-type", "second-ps-type",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.END_SOT, "JUNIT-U",
+ AAIProperties.END_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 10000L,
+ AAIProperties.END_TS, 15000L
+ )
+ .property("equip-type", "second-ps-type-update",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-U",
+ AAIProperties.START_TX_ID, "JUNIT-U",
+ AAIProperties.START_TS, 15000L
+ )
+ .property(AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .property(AAIProperties.START_TS, 10000L,
+ AAIProperties.SOURCE_OF_TRUTH, "JUNIT-C",
+ AAIProperties.START_TX_ID, "JUNIT-C",
+ AAIProperties.START_TS, 10000L
+ )
+ .next();
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ private JsonArray getResultsForPserverLookupByHostname(String endpoint) throws Exception {
+ return getResultsForPserverLookupByHostnameAndAnother(endpoint, "");
+ }
+
+ private JsonArray getResultsForPserverLookupByHostnameAndAnother(String endpoint, String additionalFilterInParen) throws Exception {
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')" + additionalFilterInParen);
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()).getAsJsonObject().getAsJsonArray("results");
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 200", HttpStatus.OK, responseEntity.getStatusCode());
+ return results;
+ }
+
+ private void verifyEquipTypeValues(JsonArray results, String... equipType) {
+ Set<String> expectedEquipTypes = new HashSet<>(Arrays.asList(equipType));
+ final Set<String> actualEquipType = new HashSet<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ assertFalse("State format properties should not have end timestamps",
+ property.getAsJsonObject().has("end-timestamp"));
+ if (property.getAsJsonObject().get("key").getAsString().equals("equip-type")) {
+ actualEquipType.add(property.getAsJsonObject().get("value").getAsString());
+ }
+ }
+ }
+ assertThat("Verify equip-type in state", actualEquipType, is(expectedEquipTypes));
+ }
+
+
+ private void verifyAllPropsTxIds(JsonArray results) {
+ final Set<String> propMissingCreatedTxId = new HashSet<>();
+ final Set<String> propContainingEndTxId = new HashSet<>();
+ for (JsonElement result : results) {
+ for (JsonElement property : result.getAsJsonObject().get("properties").getAsJsonArray()) {
+ if (!property.getAsJsonObject().has("tx-id")) {
+ propMissingCreatedTxId.add(property.getAsJsonObject().get("key").getAsString());
+ }
+ if (property.getAsJsonObject().has("end-tx-id")) {
+ propContainingEndTxId.add(property.getAsJsonObject().get("key").getAsString());
+ }
+ }
+ }
+
+ assertThat("Verify no prop is missing tx-id in state", propMissingCreatedTxId, is(Collections.EMPTY_SET));
+ assertThat("Verify no prop has end-tx-id in state", propContainingEndTxId, is(Collections.EMPTY_SET));
+ }
+
+ @Test
+ public void stateQueryBeforeCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=50";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(0, results.size());
+ }
+
+ @Test
+ public void stateQueryAtCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=100";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAfterCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=200";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAtUpdateTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=500";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAfterUpdateTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=700";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAtDeletionTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=1000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(0, results.size());
+ }
+
+ @Test
+ public void stateQueryAfterDeletionTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=2000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(0, results.size());
+ }
+
+ // WITH endTs=startTs
+ @Test
+ public void stateQueryBeforeCreationWithEndTsTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=50&endTs=50";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(0, results.size());
+ }
+
+ @Test
+ public void stateQueryAtCreationTimeWithEndTsTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=100&endTs=100";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAfterCreationTimeWithEndTsTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=200&endTs=200";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAtUpdateTimeWithEndTsTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=500&endTs=500";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAfterUpdateTimeWithEndTsTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=700&endTs=700";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "first-ps-type-update");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAtDeletionTimeWithEndTsTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=1000&endTs=1000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(0, results.size());
+ }
+
+ @Test
+ public void stateQueryAfterDeletionTimeWithEndTsTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=2000&endTs=2000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(0, results.size());
+ }
+
+ // Second pserver
+
+ @Test
+ public void stateQueryBeforeSecondCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=9000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(0, results.size());
+ }
+
+ @Test
+ public void stateQueryAtSecondCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=10000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "second-ps-type");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAfterSecondCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=12000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "second-ps-type");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAtUpdateAfterSecondCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=15000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "second-ps-type-update");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryAfterUpdateAfterSecondCreationTimeTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state&startTs=17000";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "second-ps-type-update");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryNoTimestampTest() throws Exception {
+ String endpoint = "/aai/v14/dsl?format=state";
+ JsonArray results = getResultsForPserverLookupByHostname(endpoint);
+ assertEquals(1, results.size());
+ verifyEquipTypeValues(results, "second-ps-type-update");
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryNoTimestampWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+ }
+
+ @Test
+ public void stateQueryTimestampBeforeFirstCreateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=50";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAtFirstCreateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=100";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAfterFirstCreateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=200";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAtFirstUpdateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=500";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAfterFirstUpdateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=700";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAtFirstDeleteWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=1000";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAfterFirstDeleteWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=5000";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAtSecondCreateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=10000";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAfterSecondCreateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=12000";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ }
+
+ @Test
+ public void stateQueryTimestampAtSecondUpdateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=15000";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ }
+
+ @Test
+ public void stateQueryTimestampAfterSecondUpdateWithEquipTypeFilterTest() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=state&startTs=15000";
+ String equipType = "first-ps-type";
+ JsonArray results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "first-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 0, results.size());
+
+ equipType = "second-ps-type-update";
+ results = getResultsForPserverLookupByHostnameAndAnother(endpoint, "('equip-type','" + equipType + "')");
+ assertEquals("Filter equip-type on " + equipType, 1, results.size());
+
+ verifyEquipTypeValues(results, equipType);
+
+ verifyAllPropsTxIds(results);
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
index 6664465..46e4a35 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
@@ -19,7 +19,8 @@
*/
package org.onap.aai.rest.retired;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import org.junit.Test;
import org.onap.aai.rest.AbstractSpringRestTest;
@@ -34,7 +35,7 @@ import static org.junit.Assert.assertEquals;
public class RetiredConsumerSpringTest extends AbstractSpringRestTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(RetiredConsumerSpringTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(RetiredConsumerSpringTest.class);
private Map<String, HttpStatus> httpStatusMap;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ClosedLoopQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ClosedLoopQueryTest.java
new file mode 100644
index 0000000..821836a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ClosedLoopQueryTest.java
@@ -0,0 +1,103 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ClosedLoopQueryTest extends QueryTest {
+ public ClosedLoopQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver", "vserver-id", "vserver-id-1","vserver-name","vserver-name-1");
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1");
+
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1");
+ Vertex vfModule = graph.addVertex(T.label, "vf-module", T.id, "4", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1");
+
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "5", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "6", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1");
+
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserver-id-2","vserver-name","vserver-name-1");
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2");
+
+ Vertex serviceInstance1 = graph.addVertex(T.label, "service-instance", T.id, "9", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2");
+ Vertex vfModule1 = graph.addVertex(T.label, "vf-module", T.id, "10", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-2");
+
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "11", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName02");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "12", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, vserver, gnvf);
+ rules.addEdge(g, gnvf, serviceInstance);
+ rules.addTreeEdge(g, gnvf, vfModule);
+ rules.addTreeEdge(g, vserver,tenant);
+ rules.addTreeEdge(g, tenant,cloudregion);
+
+ //Not expected in result
+ rules.addEdge(g, vserver1, gnvf1);
+ rules.addEdge(g, gnvf1, serviceInstance1);
+ rules.addTreeEdge(g, gnvf1, vfModule1);
+ rules.addTreeEdge(g, vserver1,tenant1);
+ rules.addTreeEdge(g, tenant1,cloudregion1);
+ //Not expected in result
+
+ expectedResult.add(vserver);
+ expectedResult.add(gnvf);
+ expectedResult.add(serviceInstance);
+ expectedResult.add(vfModule);
+ expectedResult.add(tenant);
+ expectedResult.add(cloudregion);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "closed-loop";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vserver").has("vserver-id", "vserver-id-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceSummaryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceSummaryTest.java
new file mode 100644
index 0000000..1fba932
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceSummaryTest.java
@@ -0,0 +1,104 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetServiceInstanceSummaryTest extends QueryTest {
+
+ public GetServiceInstanceSummaryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "serviceinstanceid0");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "2", "aai-node-type", "l3-network", "network-id", "networkid0");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex servicesub = graph.addVertex(T.label, "service-subscription", T.id, "4", "aai-node-type", "service-subscription", "service-type", "servicetype0");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "5", "aai-node-type", "customer", "customer-id", "customerid0");
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "8", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "9", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "10", "aai-node-type", "service-instance", "service-instance-id", "serviceinstanceid1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "11", "aai-node-type", "l3-network", "network-id", "networkid0");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "12", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex servicesub1 = graph.addVertex(T.label, "service-subscription", T.id, "13", "aai-node-type", "service-subscription", "service-type", "servicetype0");
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "14", "aai-node-type", "customer", "customer-id", "customerid0");
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "15", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "16", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "17", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex cloudregion3 = graph.addVertex(T.label, "cloud-region", T.id, "18", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, serviceinstance, l3network);
+ rules.addEdge(g, l3network, cloudregion);
+ rules.addTreeEdge(g, serviceinstance, servicesub);
+ rules.addTreeEdge(g, servicesub, customer);
+ rules.addEdge(g, serviceinstance, genericvnf);
+ rules.addEdge(g, genericvnf, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion1);
+
+ rules.addEdge(g, serviceinstance1, l3network1);//false
+ rules.addEdge(g, l3network1, cloudregion2);//false
+ rules.addTreeEdge(g, serviceinstance1, servicesub1);//false
+ rules.addTreeEdge(g, servicesub1, customer1);//false
+ rules.addEdge(g, serviceinstance1, genericvnf1);//false
+ rules.addEdge(g, genericvnf1, vserver1);//false
+ rules.addTreeEdge(g, vserver1, tenant1);//false
+ rules.addTreeEdge(g, tenant1, cloudregion3);//false
+
+ expectedResult.add(serviceinstance);
+ expectedResult.add(cloudregion);
+ expectedResult.add(cloudregion1);
+ expectedResult.add(servicesub);
+ expectedResult.add(customer);
+ }
+ @Override
+ protected String getQueryName() {
+ return "getServiceInstanceSummary";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "serviceinstanceid0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceVnfVfModuleModelsTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceVnfVfModuleModelsTest.java
new file mode 100644
index 0000000..64abbae
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceInstanceVnfVfModuleModelsTest.java
@@ -0,0 +1,111 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class GetServiceInstanceVnfVfModuleModelsTest extends QueryTest {
+
+ public GetServiceInstanceVnfVfModuleModelsTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+
+
+
+ @Override
+ protected void createGraph() throws AAIException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex modelver = graph.addVertex(T.label, "model-ver", T.id, "2", "aai-node-type", "model-ver","model-ver-id", "model-ver-id-1");
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1");
+ Vertex modelver1 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver","model-ver-id", "model-ver-id-1");
+ Vertex model = graph.addVertex(T.label, "model", T.id, "5", "aai-node-type", "model","model-id", "model-id-1");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "6", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1");
+ Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "7", "aai-node-type", "model-ver","model-ver-id", "model-ver-id-2");
+ Vertex model1 = graph.addVertex(T.label, "model", T.id, "8", "aai-node-type", "model","model-id", "model-id-2");
+
+ Vertex serviceInstance1 = graph.addVertex(T.label, "service-instance", T.id, "9", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name", "service-instance-name-2");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "10", "aai-node-type", "l3-network","l3-network-id", "l3-network-id-1");
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "11", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "12", "aai-node-type", "complex","complex-id", "complex-1");
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "13", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-2");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "14", "aai-node-type", "l3-network","l3-network-id", "l3-network-id-2");
+
+ Vertex model2 = graph.addVertex(T.label, "model", T.id, "15", "aai-node-type", "model","model-id", "model-id-3");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addPrivateEdge(g, serviceInstance, modelver,null);
+ rules.addTreeEdge(g, modelver, model2);
+ rules.addEdge(g, serviceInstance, genericvnf);
+ rules.addPrivateEdge(g, genericvnf, modelver1,null);
+ rules.addTreeEdge(g, modelver1, model);
+ rules.addTreeEdge(g, genericvnf, vfmodule);
+ rules.addPrivateEdge(g, vfmodule, modelver2,null);
+ rules.addTreeEdge(g, modelver2, model1);
+
+ rules.addEdge(g, serviceInstance1, l3network);//not expected in result
+ rules.addEdge(g, serviceInstance1, genericvnf1);//not expected in result
+ rules.addEdge(g, genericvnf1, complex);//not expected in result
+ rules.addTreeEdge(g, genericvnf1, vfmodule1);//not expected in result
+ rules.addEdge(g, vfmodule1, l3network1);//not expected in result
+
+
+ expectedResult.add(serviceInstance);
+ expectedResult.add(modelver);
+ expectedResult.add(model2);
+ expectedResult.add(genericvnf);
+ expectedResult.add(modelver1);
+ expectedResult.add(model);
+ expectedResult.add(vfmodule);
+ expectedResult.add(modelver2);
+ expectedResult.add(model1);
+
+
+ }
+
+
+ @Override
+ protected String getQueryName() {
+ return "getServiceInstanceVnfVfModuleModels";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcInstanceQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcInstanceQueryTest.java
new file mode 100644
index 0000000..71e2f18
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcInstanceQueryTest.java
@@ -0,0 +1,101 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetTenantInfoAtSvcInstanceQueryTest extends QueryTest {
+ public GetTenantInfoAtSvcInstanceQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1");
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver-id-1","vserver-name","vserver-name-1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "4", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "complex-id", "complex-1");
+
+ Vertex serviceInstance1 = graph.addVertex(T.label, "service-instance", T.id, "7", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2");
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "9", "aai-node-type", "vserver", "vserver-id", "vserver-id-2","vserver-name","vserver-name-2");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "10", "aai-node-type", "tenant", "tenant-id", "tenantid02", "tenant-name", "tenantName02");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-2");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "12", "aai-node-type", "complex", "complex-id", "complex-2");
+
+
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceInstance, gnvf);
+ rules.addEdge(g, gnvf, vserver);
+ rules.addTreeEdge(g, vserver,tenant);
+ rules.addTreeEdge(g, tenant,cloudregion);
+ rules.addEdge(g, cloudregion, complex);
+
+ //Not expected in result
+ rules.addEdge(g, serviceInstance1, gnvf1);
+ rules.addEdge(g, gnvf1, vserver1);
+ rules.addTreeEdge(g, vserver1,tenant1);
+ rules.addTreeEdge(g, tenant1,cloudregion1);
+ rules.addEdge(g, cloudregion1, complex1);
+ //Not expected in result
+
+ expectedResult.add(serviceInstance);
+ expectedResult.add(gnvf);
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(cloudregion);
+ expectedResult.add(complex);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getTenantInfoAtSvcInstance";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcSubscriptionTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcSubscriptionTest.java
new file mode 100644
index 0000000..8ceab5e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetTenantInfoAtSvcSubscriptionTest.java
@@ -0,0 +1,89 @@
+package org.onap.aai.rest.search;
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+import java.util.Map;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+
+public class GetTenantInfoAtSvcSubscriptionTest extends QueryTest{
+
+ public GetTenantInfoAtSvcSubscriptionTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex servicesubscription = graph.addVertex(T.label, "service-subscription",T.id, "0", "aai-node-type", "service-subscription", "service-type", "service-type-0");
+ Vertex tenant = graph.addVertex(T.label, "tenant",T.id, "1", "aai-node-type", "tenant", "tenant-id", "tenant-id-0", "tenant-name", "tenant-name-0");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region",T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloud-owner-0", "cloud-region-id", "cloud-region-id-0");
+ Vertex complex = graph.addVertex(T.label, "complex",T.id, "3", "aai-node-type", "complex", "physical-location-id", "physical-location-id-0", "physical-location-type",
+ "physical-location-type-0", "street1", "street1-0", "city", "city-0", "postal-code", "postal-code-0", "country", "country-0", "region", "region-0");
+ Vertex servicesubscription1 = graph.addVertex(T.label, "service-subscription",T.id, "5", "aai-node-type", "service-subscription", "service-type", "service-type-1");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant",T.id, "6", "aai-node-type", "tenant", "tenant-id", "tenant-id-1", "tenant-name", "tenant-name-1");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region",T.id, "7", "aai-node-type", "cloud-region", "cloud-owner", "cloud-owner-1", "cloud-region-id", "cloud-region-id-1");
+ Vertex complex1 = graph.addVertex(T.label, "complex",T.id, "8", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1", "physical-location-type",
+ "physical-location-type-1", "street1", "street1-1", "city", "city-1", "postal-code", "postal-code-1", "country", "country-1", "region", "region-1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, servicesubscription, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, cloudregion, complex);
+
+ rules.addEdge(g, servicesubscription1, tenant1);
+ rules.addTreeEdge(g, tenant1, cloudregion1);
+ rules.addEdge(g, cloudregion1, complex1);
+
+
+ expectedResult.add(servicesubscription);
+ expectedResult.add(tenant);
+ expectedResult.add(cloudregion);
+ expectedResult.add(complex);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getTenantInfoAtSvcSubscription";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-subscription").has("service-type", "service-type-0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVnfVlanByCircuitIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVnfVlanByCircuitIdTest.java
new file mode 100644
index 0000000..74e4875
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVnfVlanByCircuitIdTest.java
@@ -0,0 +1,89 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetVnfVlanByCircuitIdTest extends QueryTest {
+ public GetVnfVlanByCircuitIdTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex logicallink1 = graph.addVertex(T.label, "logical-link", T.id, "1", "aai-node-type", "logical-link", "link-name", "linkName1", "link-type", "linkType1", "circuit-id", "circuitId1");
+ Vertex logicallink2 = graph.addVertex(T.label, "logical-link", T.id, "2", "aai-node-type", "logical-link", "link-name", "linkName2", "link-type", "linkType2", "circuit-id", "circuitId2");
+
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "3", "aai-node-type", "vlan", "vlan-interface", "vlanInterface1");
+ Vertex vlan2 = graph.addVertex(T.label, "vlan", T.id, "4", "aai-node-type", "vlan", "vlan-interface", "vlanInterface2");
+
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "interfaceName1");
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "6", "aai-node-type", "l-interface", "interface-name", "interfaceName2");
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnfId1", "vnf-type", "vnfType1");
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "8", "aai-node-type", "generic-vnf", "vnf-id", "vnfId2", "vnf-type", "vnfType2");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, logicallink1, vlan1);
+ rules.addTreeEdge(g, vlan1, linterface1);
+ rules.addTreeEdge(g, linterface1, genericvnf1);
+
+ rules.addEdge(g, logicallink2, vlan2);//false
+ rules.addTreeEdge(g, vlan2, linterface2);//false
+ rules.addTreeEdge(g, linterface2, genericvnf2);//false
+
+ expectedResult.add(logicallink1);
+ expectedResult.add(vlan1);
+ expectedResult.add(linterface1);
+ expectedResult.add(genericvnf1);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getVnfVlanByCircuitId";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("link-name","linkName1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("circuit-id","circuitId1");
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVserverDetailTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVserverDetailTest.java
new file mode 100644
index 0000000..094439b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetVserverDetailTest.java
@@ -0,0 +1,122 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetVserverDetailTest extends QueryTest {
+ public GetVserverDetailTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ //set up test graph
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "2", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "5", "aai-node-type", "vf-module", "vf-module-id", "vfmoduleid0");
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "6", "aai-node-type", "service-instance", "service-intsance-id", "serviceinstanceid0");
+ Vertex modelver0 = graph.addVertex(T.label, "model-ver", T.id, "7", "aai-node-type", "model-ver", "model-version-id", "modelversionid0");
+ Vertex modelver1 = graph.addVertex(T.label, "model-ver", T.id, "8", "aai-node-type", "model-ver", "model-version-id", "modelversionid1");
+ Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "9", "aai-node-type", "model-ver", "model-version-id", "modelversionid2");
+ Vertex model0 = graph.addVertex(T.label, "model", T.id, "10", "aai-node-type", "model", "model-invariant-id", "modelinvariantid0");
+ Vertex model1 = graph.addVertex(T.label, "model", T.id, "11", "aai-node-type", "model", "model-invariant-id", "modelinvariantid1");
+ Vertex model2 = graph.addVertex(T.label, "model", T.id, "12", "aai-node-type", "model", "model-invariant-id", "modelinvariantid2");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "13", "aai-node-type", "vserver", "vserver-id", "vserverid1");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "14", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "15", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "16", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0");
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "17", "aai-node-type", "vf-module", "vf-module-id", "vfmoduleid0");
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "18", "aai-node-type", "service-instance", "service-intsance-id", "serviceinstanceid0");
+ Vertex modelver3 = graph.addVertex(T.label, "model-ver", T.id, "19", "aai-node-type", "model-ver", "model-version-id", "modelversionid0");
+ Vertex modelver4 = graph.addVertex(T.label, "model-ver", T.id, "20", "aai-node-type", "model-ver", "model-version-id", "modelversionid1");
+ Vertex modelver5 = graph.addVertex(T.label, "model-ver", T.id, "21", "aai-node-type", "model-ver", "model-version-id", "modelversionid2");
+ Vertex model3 = graph.addVertex(T.label, "model", T.id, "22", "aai-node-type", "model", "model-invariant-id", "modelinvariantid0");
+ Vertex model4 = graph.addVertex(T.label, "model", T.id, "23", "aai-node-type", "model", "model-invariant-id", "modelinvariantid1");
+ Vertex model5 = graph.addVertex(T.label, "model", T.id, "24", "aai-node-type", "model", "model-invariant-id", "modelinvariantid2");
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, vserver, genericvnf);
+ rules.addPrivateEdge(g, genericvnf, modelver0, null);
+ rules.addTreeEdge(g, modelver0, model0);
+ rules.addTreeEdge(g, genericvnf, vfmodule);
+ rules.addPrivateEdge(g, vfmodule, modelver1, null);
+ rules.addTreeEdge(g, modelver1, model1);
+ rules.addEdge(g, genericvnf, serviceinstance);
+ rules.addPrivateEdge(g, serviceinstance, modelver2, null);
+ rules.addTreeEdge(g, modelver2, model2);
+
+ rules.addTreeEdge(g, vserver1, tenant1);//false
+ rules.addTreeEdge(g, tenant1, cloudregion1);//false
+ rules.addEdge(g, vserver1, genericvnf1);//false
+ rules.addPrivateEdge(g, genericvnf1, modelver3, null);//false
+ rules.addTreeEdge(g, modelver3, model3);//false
+ rules.addTreeEdge(g, genericvnf1, vfmodule1);//false
+ rules.addPrivateEdge(g, vfmodule1, modelver4, null);//false
+ rules.addTreeEdge(g, modelver4, model4);//false
+ rules.addEdge(g, genericvnf1, serviceinstance1);
+ rules.addPrivateEdge(g, serviceinstance1, modelver5, null);//false
+ rules.addTreeEdge(g, modelver5, model5);//false
+
+ expectedResult.add(vserver);
+ expectedResult.add(tenant);
+ expectedResult.add(cloudregion);
+ expectedResult.add(genericvnf);
+ expectedResult.add(modelver0);
+ expectedResult.add(model0);
+ expectedResult.add(vfmodule);
+ expectedResult.add(modelver1);
+ expectedResult.add(model1);
+ expectedResult.add(serviceinstance);
+ expectedResult.add(modelver2);
+ expectedResult.add(model2);
+ }
+ @Override
+ protected String getQueryName() {
+ return "getVserverDetail";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vserver").has("vserver-id", "vserverid0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetWlBundleIdQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetWlBundleIdQueryTest.java
new file mode 100644
index 0000000..2831315
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetWlBundleIdQueryTest.java
@@ -0,0 +1,100 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetWlBundleIdQueryTest extends QueryTest {
+ public GetWlBundleIdQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+
+ Vertex lagLink = graph.addVertex(T.label, "lag-link", T.id, "1", "aai-node-type", "lag-link", "lag-link-id", "lag-link-id-1","link-name", "link-name-1");
+ Vertex logicalLink = graph.addVertex(T.label, "logical-link", T.id, "2", "aai-node-type", "logical-link", "logical-link-id", "logical-link-id-1");
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1");
+ Vertex serviceSubcription = graph.addVertex(T.label, "service-subscription", T.id, "4", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "5", "aai-node-type", "customer", "customer-id", "customer-id-1");
+ Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "6", "aai-node-type", "logical-link", "logical-link-id", "logical-link-id-2");
+
+ Vertex lagLink1 = graph.addVertex(T.label, "lag-link", T.id, "7", "aai-node-type", "lag-link", "lag-link-id", "lag-link-id-2","link-name", "link-name-2");
+ Vertex logicalLink2 = graph.addVertex(T.label, "logical-link", T.id, "8", "aai-node-type", "logical-link", "logical-link-id", "logical-link-id-3");
+ Vertex serviceInstance1 = graph.addVertex(T.label, "service-instance", T.id, "9", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2");
+ Vertex serviceSubcription1 = graph.addVertex(T.label, "service-subscription", T.id, "10", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-2");
+ Vertex customer1 = graph.addVertex(T.label, "customer", T.id, "11", "aai-node-type", "customer", "customer-id", "customer-id-2");
+ Vertex logicalLink3 = graph.addVertex(T.label, "logical-link", T.id, "12", "aai-node-type", "logical-link", "logical-link-id", "logical-link-id-4");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, lagLink, logicalLink);
+ rules.addEdge(g, logicalLink, serviceInstance);
+ rules.addTreeEdge(g, serviceInstance,serviceSubcription);
+ rules.addTreeEdge(g, serviceSubcription,customer);
+ rules.addEdge(g, logicalLink, logicalLink1);
+
+ //Not expected in result
+ rules.addEdge(g, lagLink1, logicalLink2);
+ rules.addEdge(g, logicalLink2, serviceInstance1);
+ rules.addTreeEdge(g, serviceInstance1,serviceSubcription1);
+ rules.addTreeEdge(g, serviceSubcription1,customer1);
+ rules.addEdge(g, logicalLink2, logicalLink3);
+ //Not expected in result
+
+ expectedResult.add(lagLink);
+ expectedResult.add(logicalLink);
+ expectedResult.add(serviceInstance);
+ expectedResult.add(serviceSubcription);
+ expectedResult.add(customer);
+ expectedResult.add(logicalLink1);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getWlBundleId";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "lag-link").has("link-name", "link-name-1");
+
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
index 97045df..b489a83 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
@@ -26,7 +26,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
@@ -54,9 +53,7 @@ public class GroovyShellImplTest extends AAISetup{
private final static ModelType introspectorFactoryType = ModelType.MOXY;
private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
-
static {
VALID_HTTP_STATUS_CODES.add(200);
VALID_HTTP_STATUS_CODES.add(201);
@@ -117,7 +114,6 @@ public class GroovyShellImplTest extends AAISetup{
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new JanusGraphDBEngine(
queryStyle,
- type,
loader);
GenericQueryProcessor.Builder builder = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton);
builder.queryFrom(URI.create("te"));
@@ -134,7 +130,7 @@ public class GroovyShellImplTest extends AAISetup{
GraphTraversal<Vertex, Vertex> g = Mockito.mock(GraphTraversal.class);
g.has("cloud-region-id", "cloud-region-id-1");
Map<String, Object> params = new HashMap<>();
- groovyShellImpl.runQuery("vnfs-fromServiceInstance", params);
+ groovyShellImpl.runQuery("vnfs-fromServiceInstance", params, dbEngine.asAdmin().getTraversalSource());
}
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java
new file mode 100644
index 0000000..cab4ad0
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java
@@ -0,0 +1,200 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class IpsNetworksFromVnfTest extends QueryTest {
+
+ public IpsNetworksFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Ignore
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex genericVnf = graph.addVertex(T.label, "generic-vnf",T.id, "0", "aai-node-type", "generic-vnf", "generic-vnf-id", "serviceinstanceid0");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc",T.id, "1", "aai-node-type", "vnfc","vnfc-id", "vnfcId1");
+ Vertex cp = graph.addVertex(T.label, "cp",T.id, "30", "aai-node-type", "cp","cp-id", "cpId1");
+ Vertex vipIpv4AddressList = graph.addVertex(T.label, "vip-ipv4-address-list",T.id, "2", "aai-node-type", "vip-ipv4-address-list","vip-ipv4-address-list-id", "vip-ipv4-address-listId2");
+ Vertex vipIpv6AddressList = graph.addVertex(T.label, "vip-ipv6-address-list",T.id, "3", "aai-node-type", "vip-ipv6-address-list","vip-ipv6-address-list-id", "vip-ipv6-address-listId3");
+
+
+ Vertex subnetIpv4 = graph.addVertex(T.label, "subnet",T.id, "7", "aai-node-type", "subnet","subnet-id", "subnetId7");
+ Vertex l3Network1Ipv4 = graph.addVertex(T.label, "l3-network",T.id, "8", "aai-node-type", "l3-network","l3-network-id", "l3-networkId8");
+
+ Vertex subnetIpv6 = graph.addVertex(T.label, "subnet",T.id, "10", "aai-node-type", "subnet","subnet-id", "subnetId10");
+ Vertex l3Network1Ipv6 = graph.addVertex(T.label, "l3-network",T.id, "11", "aai-node-type", "l3-network","l3-network-id", "l3-networkId11");
+
+ Vertex vserver = graph.addVertex(T.label, "vserver",T.id, "18", "aai-node-type", "vserver","vserver-id", "vserverId18");
+ Vertex linterface = graph.addVertex(T.label, "l-interface",T.id, "19", "aai-node-type", "l-interface","l-interface-id", "l-interfaceId19");
+ Vertex pserver = graph.addVertex(T.label, "pserver",T.id, "20", "aai-node-type", "pserver","pserver-id", "pserverId20");
+
+
+ Vertex l3NetworklintIpv4 = graph.addVertex(T.label, "l3-network",T.id, "21", "aai-node-type", "l3-network","l3-network-id", "l3-networkId21");
+ Vertex subnetlintIpv4 = graph.addVertex(T.label, "subnet",T.id, "22", "aai-node-type", "subnet","subnet-id", "subnetId22");
+ Vertex l3Network1lintIpv4 = graph.addVertex(T.label, "l3-network",T.id, "23", "aai-node-type", "l3-network","l3-network-id", "l3-networkId23");
+
+ Vertex l3NetworklintIpv6 = graph.addVertex(T.label, "l3-network",T.id, "24", "aai-node-type", "l3-network","l3-network-id", "l3-networkId24");
+ Vertex subnetlintIpv6 = graph.addVertex(T.label, "subnet",T.id, "25", "aai-node-type", "subnet","subnet-id", "subnetId25");
+ Vertex l3Network1lintIpv6 = graph.addVertex(T.label, "l3-network",T.id, "26", "aai-node-type", "l3-network","l3-network-id", "l3-networkId26");
+
+
+ Vertex l3InterfaceIpv4AddressListLint = graph.addVertex(T.label, "l3-interface-ipv4-address-list",T.id, "27", "aai-node-type", "l3-interface-ipv4-address-list","l3-interface-ipv4-address-list-id", "l3-interface-ipv4-address-listId27");
+ Vertex l3InterfaceIpv6AddressListlInt = graph.addVertex(T.label, "l3-interface-ipv6-address-list",T.id, "28", "aai-node-type", "l3-interface-ipv6-address-list","l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-listId28");
+
+
+ Vertex complex = graph.addVertex(T.label, "complex",T.id, "29", "aai-node-type", "complex","complex-id", "complexId29");
+
+
+
+ Vertex genericVnf1 = graph.addVertex(T.label, "generic-vnf",T.id, "31", "aai-node-type", "generic-vnf", "generic-vnf-id", "serviceinstanceid1");
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc",T.id, "32", "aai-node-type", "vnfc","vnfc-id", "vnfcId2");
+ Vertex cp1 = graph.addVertex(T.label, "cp",T.id, "33", "aai-node-type", "cp","cp-id", "cpId3");
+ Vertex vipIpv4AddressList1 = graph.addVertex(T.label, "vip-ipv4-address-list",T.id, "34", "aai-node-type", "vip-ipv4-address-list","vip-ipv4-address-list-id", "vip-ipv4-address-listId4");
+ Vertex vipIpv6AddressList1 = graph.addVertex(T.label, "vip-ipv6-address-list",T.id, "35", "aai-node-type", "vip-ipv6-address-list","vip-ipv6-address-list-id", "vip-ipv6-address-listId5");
+ Vertex subnetIpv41 = graph.addVertex(T.label, "subnet",T.id, "36", "aai-node-type", "subnet","subnet-id", "subnetId6");
+ Vertex l3Network1Ipv41 = graph.addVertex(T.label, "l3-network",T.id, "37", "aai-node-type", "l3-network","l3-network-id", "l3-networkId7");
+ Vertex subnetIpv61 = graph.addVertex(T.label, "subnet",T.id, "38", "aai-node-type", "subnet","subnet-id", "subnetId8");
+ Vertex l3Network1Ipv61 = graph.addVertex(T.label, "l3-network",T.id, "39", "aai-node-type", "l3-network","l3-network-id", "l3-networkId9");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver",T.id, "40", "aai-node-type", "vserver","vserver-id", "vserverId10");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface",T.id, "41", "aai-node-type", "l-interface","l-interface-id", "l-interfaceId11");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver",T.id, "42", "aai-node-type", "pserver","pserver-id", "pserverId12");
+ Vertex l3NetworklintIpv41 = graph.addVertex(T.label, "l3-network",T.id, "43", "aai-node-type", "l3-network","l3-network-id", "l3-networkId13");
+ Vertex subnetlintIpv41 = graph.addVertex(T.label, "subnet",T.id, "44", "aai-node-type", "subnet","subnet-id", "subnetId14");
+ Vertex l3Network1lintIpv41 = graph.addVertex(T.label, "l3-network",T.id, "45", "aai-node-type", "l3-network","l3-network-id", "l3-networkId15");
+ Vertex l3NetworklintIpv61 = graph.addVertex(T.label, "l3-network",T.id, "46", "aai-node-type", "l3-network","l3-network-id", "l3-networkId16");
+ Vertex subnetlintIpv61 = graph.addVertex(T.label, "subnet",T.id, "47", "aai-node-type", "subnet","subnet-id", "subnetId17");
+ Vertex l3Network1lintIpv61 = graph.addVertex(T.label, "l3-network",T.id, "48", "aai-node-type", "l3-network","l3-network-id", "l3-networkId18");
+ Vertex l3InterfaceIpv4AddressListLint1 = graph.addVertex(T.label, "l3-interface-ipv4-address-list",T.id, "49", "aai-node-type", "l3-interface-ipv4-address-list","l3-interface-ipv4-address-list-id", "l3-interface-ipv4-address-listId19");
+ Vertex l3InterfaceIpv6AddressListlInt1 = graph.addVertex(T.label, "l3-interface-ipv6-address-list",T.id, "50", "aai-node-type", "l3-interface-ipv6-address-list","l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-listId20");
+ Vertex complex1 = graph.addVertex(T.label, "complex",T.id, "51", "aai-node-type", "complex","complex-id", "complexId21");
+
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, genericVnf,vnfc);
+ rules.addTreeEdge(g, vnfc,cp);
+ rules.addEdge(g, cp,vipIpv4AddressList);
+ rules.addEdge(g, cp,vipIpv6AddressList);
+
+ rules.addEdge(g, vipIpv4AddressList,subnetIpv4);
+ rules.addTreeEdge(g, subnetIpv4,l3Network1Ipv4);
+
+ rules.addEdge(g, vipIpv6AddressList,subnetIpv6);
+ rules.addTreeEdge(g, subnetIpv6,l3Network1Ipv6);
+
+ rules.addEdge(g, genericVnf,vserver);
+ rules.addEdge(g, vserver,pserver);
+
+ rules.addTreeEdge(g, cp,l3InterfaceIpv4AddressListLint);
+ rules.addTreeEdge(g, cp,l3InterfaceIpv6AddressListlInt);
+
+ rules.addEdge(g, l3InterfaceIpv4AddressListLint,l3NetworklintIpv4);
+ rules.addEdge(g, l3InterfaceIpv4AddressListLint,subnetlintIpv4);
+ rules.addTreeEdge(g, subnetlintIpv4,l3Network1lintIpv4);
+
+ rules.addEdge(g, l3InterfaceIpv6AddressListlInt,l3NetworklintIpv6);
+ rules.addEdge(g, l3InterfaceIpv6AddressListlInt,subnetlintIpv6);
+ rules.addTreeEdge(g, subnetlintIpv6,l3Network1lintIpv6);
+
+ rules.addEdge(g, pserver,complex);
+
+ //false
+ rules.addEdge(g, genericVnf1,vnfc1);
+ rules.addTreeEdge(g, vnfc1,cp1);
+ rules.addEdge(g, cp1,vipIpv4AddressList1);
+ rules.addEdge(g, cp1,vipIpv6AddressList1);
+ rules.addEdge(g, vipIpv4AddressList1,subnetIpv41);
+ rules.addTreeEdge(g, subnetIpv41,l3Network1Ipv41);
+ rules.addEdge(g, vipIpv6AddressList1,subnetIpv61);
+ rules.addTreeEdge(g, subnetIpv61,l3Network1Ipv61);
+ rules.addEdge(g, genericVnf1,vserver1);
+ rules.addEdge(g, vserver1,pserver1);
+ rules.addTreeEdge(g, cp1,l3InterfaceIpv4AddressListLint1);
+ rules.addTreeEdge(g, cp1,l3InterfaceIpv6AddressListlInt1);
+ rules.addEdge(g, l3InterfaceIpv4AddressListLint1,l3NetworklintIpv41);
+ rules.addEdge(g, l3InterfaceIpv4AddressListLint1,subnetlintIpv41);
+ rules.addTreeEdge(g, subnetlintIpv41,l3Network1lintIpv41);
+ rules.addEdge(g, l3InterfaceIpv6AddressListlInt1,l3NetworklintIpv61);
+ rules.addEdge(g, l3InterfaceIpv6AddressListlInt1,subnetlintIpv61);
+ rules.addTreeEdge(g, subnetlintIpv61,l3Network1lintIpv61);
+ rules.addEdge(g, pserver1,complex1);
+ //false
+
+ expectedResult.add(genericVnf);
+ expectedResult.add(vnfc);
+ expectedResult.add(vipIpv4AddressList);
+ expectedResult.add(vipIpv6AddressList);
+
+ expectedResult.add(subnetIpv4);
+ expectedResult.add(l3Network1Ipv4);
+
+ expectedResult.add(subnetIpv6);
+ expectedResult.add(l3Network1Ipv6);
+
+ expectedResult.add(l3InterfaceIpv4AddressListLint);
+ expectedResult.add(l3InterfaceIpv6AddressListlInt);
+
+ expectedResult.add(l3NetworklintIpv4);
+ expectedResult.add(subnetlintIpv4);
+ expectedResult.add(l3Network1lintIpv4);
+
+ expectedResult.add(l3NetworklintIpv6);
+ expectedResult.add(subnetlintIpv6);
+ expectedResult.add(l3Network1lintIpv6);
+
+ expectedResult.add(vserver);
+ expectedResult.add(pserver);
+ expectedResult.add(complex);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "ips-networks-fromVnf";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("generic-vnf-id", "serviceinstanceid0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
index 1fc8bbd..b4a3dcd 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
@@ -19,23 +19,16 @@
*/
package org.onap.aai.rest.search;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
-import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.JanusGraphDBEngine;
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.setup.SchemaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.*;
@@ -57,11 +50,6 @@ public class ModelAndNamedQueryRestProviderTest extends AAISetup{
private SchemaVersion version;
private static final ModelType introspectorFactoryType = ModelType.MOXY;
- private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private static final DBConnectionType type = DBConnectionType.REALTIME;
-
- private Loader loader;
- private TransactionalGraphEngine dbEngine;
static {
VALID_HTTP_STATUS_CODES.add(200);
@@ -82,7 +70,7 @@ public class ModelAndNamedQueryRestProviderTest extends AAISetup{
private List<MediaType> outputMediaTypes;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelAndNamedQueryRestProviderTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(ModelAndNamedQueryRestProviderTest.class.getName());
@Before
public void setup(){
@@ -112,8 +100,8 @@ public class ModelAndNamedQueryRestProviderTest extends AAISetup{
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Collections.singletonList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Collections.singletonList("JUNIT"));
when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
@@ -125,11 +113,6 @@ public class ModelAndNamedQueryRestProviderTest extends AAISetup{
Mockito.doReturn(null).when(queryParameters).remove(anyObject());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new JanusGraphDBEngine(
- queryStyle,
- type,
- loader);
}
@Test
@@ -224,7 +207,6 @@ public class ModelAndNamedQueryRestProviderTest extends AAISetup{
String message = String.format("Unable to find the %s in src/test/resources", filename);
assertNotNull(message, inputStream);
- String resource = IOUtils.toString(inputStream);
- return resource;
+ return IOUtils.toString(inputStream);
}
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java
index d92b902..138892c 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/OnapQueryTest.java
@@ -19,7 +19,8 @@
*/
package org.onap.aai.rest.search;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -93,7 +94,7 @@ public abstract class OnapQueryTest {
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
- protected EELFLogger logger;
+ protected Logger logger;
protected Graph graph;
protected GremlinGroovyShell shell;
@Mock protected TransactionalGraphEngine dbEngine;
@@ -144,7 +145,7 @@ public abstract class OnapQueryTest {
public void setUp() throws AAIException, NoEdgeRuleFoundException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
- logger = EELFManager.getInstance().getLogger(getClass());
+ logger = LoggerFactory.getLogger(getClass());
MockitoAnnotations.initMocks(this);
graph = TinkerGraph.open();
gts = graph.traversal();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
index 005b5e7..f96d4c5 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
@@ -19,7 +19,8 @@
*/
package org.onap.aai.rest.search;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -93,7 +94,7 @@ public abstract class QueryTest {
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
- protected EELFLogger logger;
+ protected Logger logger;
protected Graph graph;
protected GremlinGroovyShell shell;
@Mock protected TransactionalGraphEngine dbEngine;
@@ -144,7 +145,7 @@ public abstract class QueryTest {
public void setUp() throws AAIException, NoEdgeRuleFoundException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
- logger = EELFManager.getInstance().getLogger(getClass());
+ logger = LoggerFactory.getLogger(getClass());
MockitoAnnotations.initMocks(this);
graph = TinkerGraph.open();
gts = graph.traversal();
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
index b69f992..4332536 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
@@ -19,28 +19,23 @@
*/
package org.onap.aai.rest.search;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.JanusGraphDBEngine;
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.ws.rs.core.*;
import java.util.*;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -54,10 +49,8 @@ public class SearchProviderTest extends AAISetup{
private SchemaVersion version;
private static final ModelType introspectorFactoryType = ModelType.MOXY;
private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private static final DBConnectionType type = DBConnectionType.REALTIME;
private Loader loader;
- private TransactionalGraphEngine dbEngine;
static {
VALID_HTTP_STATUS_CODES.add(200);
@@ -78,7 +71,7 @@ public class SearchProviderTest extends AAISetup{
private List<MediaType> outputMediaTypes;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(SearchProviderTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(SearchProviderTest.class.getName());
@Before
public void setup(){
@@ -108,8 +101,8 @@ public class SearchProviderTest extends AAISetup{
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Collections.singletonList("JUNIT"));
+ when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Collections.singletonList("JUNIT"));
when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
@@ -122,10 +115,6 @@ public class SearchProviderTest extends AAISetup{
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new JanusGraphDBEngine(
- queryStyle,
- type,
- loader);
}
@Test
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
index d6ad59a..934d3fa 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
@@ -29,12 +29,10 @@ import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.db.DBSerializer;
-
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.QueryStyle;
@@ -96,7 +94,6 @@ public class SimpleFormatTest extends AAISetup{
Loader loader = loaderFactory.createLoaderForVersion(factoryType, schemaVersions.getRelatedLinkVersion());
dbEngine = spy(new JanusGraphDBEngine(
QueryStyle.TRAVERSAL,
- DBConnectionType.CACHED,
loader));
when(dbEngine.tx()).thenReturn(graph);
@@ -114,7 +111,7 @@ public class SimpleFormatTest extends AAISetup{
System.out.println(dbEngine.tx());
assertNotNull(graph.traversal());
JsonObject json = _simpleFormat.createPropertiesObject(vfmodule).get();
- json.entrySet().stream().forEach((System.out::println));
+ json.entrySet().forEach((System.out::println));
assertTrue(json.has("model-invariant-id"));
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
index 6cec307..7164dba 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyFromSubscriberNameAndServiceTypeTest.java
@@ -26,7 +26,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import com.google.common.base.CaseFormat;
import org.junit.Test;
@@ -35,7 +36,7 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
public class TopologyFromSubscriberNameAndServiceTypeTest extends QueryTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance()
+ private static final Logger LOGGER = LoggerFactory
.getLogger(TopologyFromSubscriberNameAndServiceTypeTest.class);
public TopologyFromSubscriberNameAndServiceTypeTest() throws AAIException, NoEdgeRuleFoundException {
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
index 9b10070..a07dfa6 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
@@ -19,7 +19,8 @@
*/
package org.onap.aai.rest.util;
-import com.att.eelf.configuration.EELFLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.eelf.configuration.EELFManager;
import org.junit.Before;
import org.junit.Test;
@@ -59,7 +60,7 @@ public class EchoResponseTest {
private List<MediaType> outputMediaTypes;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(EchoResponseTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(EchoResponseTest.class.getName());
@Before
public void setup(){
diff --git a/aai-traversal/src/test/resources/application-onap-test.properties b/aai-traversal/src/test/resources/application-onap-test.properties
index 48a0b60..c8e9f6a 100644
--- a/aai-traversal/src/test/resources/application-onap-test.properties
+++ b/aai-traversal/src/test/resources/application-onap-test.properties
@@ -57,7 +57,7 @@ schema.ingest.file=${server.local.startpath}/application-test.properties
# Schema Version Related Attributes
schema.uri.base.path=/aai
# Lists all of the versions in the schema
-schema.version.list=v10,v11,v12,v13,v14,v15,v16
+schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19
# Specifies from which version should the depth parameter to default to zero
schema.version.depth.start=v10
# Specifies from which version should the related link be displayed in response payload
@@ -70,5 +70,5 @@ schema.version.namespace.change.start=v12
# Specifies from which version should the client start seeing the edge label in payload
schema.version.edge.label.start=v12
# Specifies the version that the application should default to
-schema.version.api.default=v16
+schema.version.api.default=v19
schema.translator.list=config \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/application-test.properties b/aai-traversal/src/test/resources/application-test.properties
index 7e244bb..eae212b 100644
--- a/aai-traversal/src/test/resources/application-test.properties
+++ b/aai-traversal/src/test/resources/application-test.properties
@@ -48,7 +48,6 @@ dmaap.ribbon.listOfServers=localhost:3904
schema.configuration.location=N/A
# Choose if the oxm schema is onap or other system
schema.source.name=onap
->>>>>>> release/1902
# Location of where the oxm files are
schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/
# Location of where the dbedgerules files are
@@ -61,7 +60,7 @@ schema.ingest.file=${server.local.startpath}/application-test.properties
# Schema Version Related Attributes
schema.uri.base.path=/aai
# Lists all of the versions in the schema
-schema.version.list=v10,v11,v12,v13,v14,v15,v16
+schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19
# Specifies from which version should the depth parameter to default to zero
schema.version.depth.start=v10
# Specifies from which version should the related link be displayed in response payload
@@ -74,6 +73,6 @@ schema.version.namespace.change.start=v12
# Specifies from which version should the client start seeing the edge label in payload
schema.version.edge.label.start=v12
# Specifies the version that the application should default to
-schema.version.api.default=v16
+schema.version.api.default=v19
schema.translator.list=config
diff --git a/aai-traversal/src/test/resources/logback.xml b/aai-traversal/src/test/resources/logback.xml
index f8a5925..4b969b1 100644
--- a/aai-traversal/src/test/resources/logback.xml
+++ b/aai-traversal/src/test/resources/logback.xml
@@ -31,16 +31,32 @@
<property name="AJSC_HOME" value="${AJSC_HOME:-.}" />
<jmxConfigurator />
<property name="logDirectory" value="${AJSC_HOME}/logs" />
- <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
- <property name="eelfAuditLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
- <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
- <!-- <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> -->
- <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%ecompResponseCode|%ecompResponseDescription|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
- <property name="eelfTransLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{partnerName}:%m%n"/>
-
- <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
- <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
- <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
+ <!-- Old patterns
+ <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
+ <property name="eelfAuditLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
+ <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
+ <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%ecompServiceName|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%ecompResponseCode|%ecompResponseDescription|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
+ <property name="eelfTransLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{partnerName}:%m%n"/>
+ -->
+ <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
+ <property name="p_lvl" value="%level"/>
+ <property name="p_log" value="%logger"/>
+ <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/>
+ <property name="p_msg" value="%replace(%replace(%replace(%msg){'\t','\\\\t'}){'\n', '\\\\n'}){'\\|', '!'}"/>
+ <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_thr" value="%thread"/>
+ <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/>
+ <!-- Patterns from onap demo -->
+ <property name="errorPattern" value="%X{LogTimestamp}|%X{RequestID}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|${p_msg}%n" />
+ <property name="debugPattern" value="%X{LogTimestamp}|%X{RequestID}|${p_msg}\t${p_mdc}\t${p_exc}\t${p_mak}\t|^%n" />
+
+ <property name="auditPattern" value="%X{EntryTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||${p_mak}|${p_mdc}|||${p_msg}%n" />
+ <property name="metricPattern" value="%X{InvokeTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|${p_mak}|${p_mdc}|||${p_msg}%n" />
+ <property name="transLogPattern" value="%X{LogTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{RequestID}|%X{ServiceInstanceID}|%-10t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%replace(%replace(%X{ResponseDesc}){'\\|', '!'}){'\r|\n', '^'}|%X{InstanceUUID}|%level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{clientIpAddress}||%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{PartnerName}:%m%n"/>
+ <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
+ <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
+ <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
@@ -65,82 +81,74 @@
<includeCallerData>true</includeCallerData>
<appender-ref ref="SANE" />
</appender>
-
- <appender name="METRIC"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
+ <appender name="METRIC" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDirectory}/rest/metrics.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/metrics.log.%d{yyyy-MM-dd}
- </fileNamePattern>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/metrics.log.%d{yyyy-MM-dd}</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfMetricLogPattern}</pattern>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
</encoder>
</appender>
+
<appender name="asyncMETRIC" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1000</queueSize>
<includeCallerData>true</includeCallerData>
- <appender-ref ref="METRIC" />
+ <appender-ref ref="METRIC"/>
</appender>
<appender name="DEBUG"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>${logDirectory}/rest/debug.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}
- </fileNamePattern>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
</encoder>
</appender>
<appender name="asyncDEBUG" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1000</queueSize>
- <includeCallerData>true</includeCallerData>
<appender-ref ref="DEBUG" />
+ <includeCallerData>true</includeCallerData>
</appender>
-
<appender name="ERROR"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/rest/error.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
- <file>${logDirectory}/rest/error.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}
- </fileNamePattern>
- </rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfErrorLogPattern}</pattern>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
</encoder>
</appender>
<appender name="asyncERROR" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1000</queueSize>
- <includeCallerData>true</includeCallerData>
- <appender-ref ref="ERROR" />
+ <appender-ref ref="ERROR"/>
</appender>
<appender name="AUDIT"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDirectory}/rest/audit.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDirectory}/rest/audit.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfAuditLogPattern}</pattern>
+ <encoder>
+ <pattern>${auditPattern}</pattern>
</encoder>
</appender>
@@ -151,7 +159,7 @@
</appender>
<appender name="translog"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
@@ -162,11 +170,11 @@
<fileNamePattern>${logDirectory}/rest/translog.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfTransLogPattern}</pattern>
+ <encoder>
+ <pattern>${transLogPattern}</pattern>
</encoder>
</appender>
-
+
<appender name="asynctranslog" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1000</queueSize>
<includeCallerData>true</includeCallerData>
@@ -174,7 +182,7 @@
</appender>
<appender name="dmaapAAIEventConsumer"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
@@ -183,13 +191,14 @@
<fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/error.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
</encoder>
+
</appender>
<appender name="dmaapAAIEventConsumerDebug"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
@@ -200,12 +209,28 @@
<fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/debug.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+ <appender name="dmaapAAIEventConsumerInfo"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>INFO</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <File>${logDirectory}/dmaapAAIEventConsumer/dmaap-transaction.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/dmaap-transaction.log.%d{yyyy-MM-dd}
+ </fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${auditPattern}</pattern>
</encoder>
</appender>
<appender name="dmaapAAIEventConsumerMetric"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
@@ -216,12 +241,12 @@
<fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/metrics.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfMetricLogPattern}</pattern>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
</encoder>
</appender>
<appender name="external"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
@@ -230,151 +255,88 @@
<fileNamePattern>${logDirectory}/external/external.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
</encoder>
</appender>
- <logger name="org.onap.aai" level="DEBUG" additivity="true">
- <appender-ref ref="asyncDEBUG" />
- <appender-ref ref="asyncERROR" />
- <appender-ref ref="asyncMETRIC" />
- <appender-ref ref="asyncSANE" />
- </logger>
+ <appender name="auth"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>DEBUG</level>
+ </filter>
+ <file>${logDirectory}/auth/auth.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/auth/auth.log.%d{yyyy-MM-dd}
+ </fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}[%thread] %-5level %logger{1024} - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncAUTH" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>1000</queueSize>
+ <includeCallerData>true</includeCallerData>
+ <appender-ref ref="auth" />
+ </appender>
+ <!-- logback internals logging -->
+
+ <logger name="ch.qos.logback.classic" level="WARN" />
+ <logger name="ch.qos.logback.core" level="WARN" />
+ <logger name="com.att.aft.dme2" level="WARN" />
+ <logger name="com.jayway.jsonpath" level="WARN" />
+
+ <logger name="org.apache" level="OFF" />
+ <logger name="org.apache.commons" level="WARN" />
+ <logger name="org.apache.zookeeper" level="OFF" />
+ <logger name="org.codehaus.groovy" level="WARN" />
+ <logger name="org.eclipse.jetty" level="WARN" />
<!-- Spring related loggers -->
<logger name="org.springframework" level="WARN" />
<logger name="org.springframework.beans" level="WARN" />
<logger name="org.springframework.web" level="WARN" />
- <logger name="com.blog.spring.jms" level="WARN" />
- <logger name="com.jayway.jsonpath" level="WARN" />
-
- <!-- AJSC Services (bootstrap services) -->
- <logger name="ajsc" level="WARN" />
- <logger name="ajsc.RouteMgmtService" level="WARN" />
- <logger name="ajsc.ComputeService" level="WARN" />
- <logger name="ajsc.VandelayService" level="WARN" />
- <logger name="ajsc.FilePersistenceService" level="WARN" />
- <logger name="ajsc.UserDefinedJarService" level="WARN" />
- <logger name="ajsc.UserDefinedBeansDefService" level="WARN" />
- <logger name="ajsc.LoggingConfigurationService" level="WARN" />
-
- <!-- AJSC related loggers (DME2 Registration, csi logging, restlet, servlet
- logging) -->
- <logger name="org.codehaus.groovy" level="WARN" />
- <logger name="com.att.scamper" level="WARN" />
- <logger name="ajsc.utils" level="WARN" />
- <logger name="ajsc.utils.DME2Helper" level="WARN" />
- <logger name="ajsc.filters" level="WARN" />
- <logger name="ajsc.beans.interceptors" level="WARN" />
- <logger name="ajsc.restlet" level="WARN" />
- <logger name="ajsc.servlet" level="WARN" />
- <logger name="com.att.ajsc" level="WARN" />
- <logger name="com.att.ajsc.csi.logging" level="WARN" />
- <logger name="com.att.ajsc.filemonitor" level="WARN" />
- <logger name="com.netflix.loadbalancer" level="WARN" />
-
- <logger name="org.apache.zookeeper" level="WARN" />
-
- <!-- Other Loggers that may help troubleshoot -->
- <logger name="net.sf" level="WARN" />
- <logger name="org.apache.commons.httpclient" level="WARN" />
- <logger name="org.apache.commons" level="WARN" />
- <logger name="org.apache.coyote" level="WARN" />
- <logger name="org.apache.jasper" level="WARN" />
-
- <!-- Camel Related Loggers (including restlet/servlet/jaxrs/cxf logging.
- May aid in troubleshooting) -->
- <logger name="org.apache.camel" level="WARN" />
- <logger name="org.apache.cxf" level="WARN" />
- <logger name="org.apache.camel.processor.interceptor" level="WARN" />
- <logger name="org.apache.cxf.jaxrs.interceptor" level="WARN" />
- <logger name="org.apache.cxf.service" level="WARN" />
- <logger name="org.restlet" level="WARN" />
- <logger name="org.apache.camel.component.restlet" level="WARN" />
-
- <logger name="org.hibernate.validator" level="WARN" />
- <logger name="org.hibernate" level="WARN" />
- <logger name="org.hibernate.ejb" level="OFF" />
-
- <!-- logback internals logging -->
- <logger name="ch.qos.logback.classic" level="WARN" />
- <logger name="ch.qos.logback.core" level="WARN" />
+ <logger name="org.janusgraph" level="WARN" />
+ <logger name="org.zookeeper" level="OFF" />
- <logger name="org.eclipse.jetty" level="WARN" />
- <!-- logback jms appenders & loggers definition starts here -->
- <appender name="auditLogs"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter" />
- <file>${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.log
- </file>
- <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
- </encoder>
- </appender>
- <appender name="perfLogs"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter" />
- <file>${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.log
- </file>
- <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
- </encoder>
- </appender>
- <logger name="AuditRecord" level="INFO" additivity="false">
- <appender-ref ref="auditLogs" />
- </logger>
- <logger name="AuditRecord_DirectCall" level="INFO" additivity="false">
- <appender-ref ref="auditLogs" />
- </logger>
- <logger name="PerfTrackerRecord" level="INFO" additivity="false">
- <appender-ref ref="perfLogs" />
+ <logger name="org.onap.aai" level="DEBUG" additivity="false">
+ <appender-ref ref="asyncDEBUG" />
+ <appender-ref ref="asyncSANE" />
+ <appender-ref ref="STDOUT" />
</logger>
- <!-- logback jms appenders & loggers definition ends here -->
-
- <logger name="org.onap.aai.interceptors.post" level="DEBUG"
- additivity="false">
- <appender-ref ref="asynctranslog" />
+ <logger name="org.onap.aai.aaf.auth" level="DEBUG" additivity="false">
+ <appender-ref ref="asyncAUTH" />
</logger>
-
- <logger name="org.onap.aai.interceptors.pre.SetLoggingContext" level="DEBUG">
+ <logger name="org.onap.aai.aailog.logs.AaiScheduledTaskAuditLog" level="INFO">
<appender-ref ref="asyncAUDIT"/>
</logger>
-
- <logger name="org.onap.aai.interceptors.post.ResetLoggingContext" level="DEBUG">
+ <logger name="org.onap.logging.filter.base.AbstractAuditLogFilter" level="INFO">
<appender-ref ref="asyncAUDIT"/>
</logger>
+ <logger name="org.onap.aai.aailog.logs.AaiDBMetricLog" level="INFO">
+ <appender-ref ref="asyncMETRIC"/>
+ </logger>
+ <logger name="org.onap.logging.filter.base.AbstractMetricLogFilter" level="INFO">
+ <appender-ref ref="asyncMETRIC"/>
+ </logger>
+ <logger name="org.onap.aai.aailog.logs.AaiDmaapMetricLog" level="INFO">
+ <appender-ref ref="dmaapAAIEventConsumerMetric"/>
+ </logger>
+ <logger name="org.onap.aai.logging.ErrorLogHelper" level="WARN">
+ <appender-ref ref="asyncERROR"/>
+ </logger>
+ <logger name="org.onap.aai.interceptors.post" level="DEBUG" additivity="false">
+ <appender-ref ref="asynctranslog" />
+ </logger>
<logger name="org.onap.aai.dmaap" level="DEBUG" additivity="false">
<appender-ref ref="dmaapAAIEventConsumer" />
<appender-ref ref="dmaapAAIEventConsumerDebug" />
- <appender-ref ref="dmaapAAIEventConsumerMetric" />
</logger>
- <logger name="org.apache" level="WARN" />
- <logger name="org.zookeeper" level="WARN" />
- <logger name="org.janusgraph" level="WARN" />
- <logger name="com.att.aft.dme2" level="WARN" />
+ <logger name="com.att.nsa.mr" level="INFO" >
+ <appender-ref ref="dmaapAAIEventConsumerInfo" />
+ </logger>
<!-- ============================================================================ -->
<!-- General EELF logger -->
diff --git a/aai-traversal/src/test/resources/schema-ingest.properties b/aai-traversal/src/test/resources/schema-ingest.properties
index 9371645..363c5a1 100644
--- a/aai-traversal/src/test/resources/schema-ingest.properties
+++ b/aai-traversal/src/test/resources/schema-ingest.properties
@@ -2,9 +2,9 @@ schema.configuration.location=N/A
schema.nodes.location=src/main/resources/etc/oxm/
schema.edges.location=src/main/resources/etc/dbedgerules/
-schema.version.list=v10,v11,v12,v13,v14,v15,v16
+schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19
schema.version.depth.start=v10
schema.version.related.link.start=v10
schema.version.app.root.start=v11
schema.version.edge.label.start=v12
-schema.version.api.default=v16
+schema.version.api.default=v19