summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test/java
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-07 08:35:37 +0000
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-07 08:38:19 +0000
commitfbb02159b84435cf37221ae8ae5e0045167be15a (patch)
tree78196f6a3e5e4d0b1e5ca6ecadec0f9e9a623303 /aai-core/src/test/java
parent58f0fd2f6ef58de52e1f9a73540c1bb895c0d6e6 (diff)
Reduce the number of problems in aai-common by removing unused imports
- run mvn spotless:apply across aai-commmon to remove unused imports - run mvn formatter:format across aai-common Issue-ID: AAI-3583 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I2dfeb395eafa2824ce8369bba3a18db3e1845522
Diffstat (limited to 'aai-core/src/test/java')
-rw-r--r--aai-core/src/test/java/org/onap/aai/AAISetup.java30
-rw-r--r--aai-core/src/test/java/org/onap/aai/AbstractConfigTranslator.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/DataLinkSetup.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/HttpTestUtil.java74
-rw-r--r--aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java8
-rw-r--r--aai-core/src/test/java/org/onap/aai/concurrent/AaiCallableTest.java3
-rw-r--r--aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java28
-rw-r--r--aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java23
-rw-r--r--aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java8
-rw-r--r--aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java8
-rw-r--r--aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java8
-rw-r--r--aai-core/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java18
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java3
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java49
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java235
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java81
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java106
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java7
-rw-r--r--aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java6
-rw-r--r--aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java15
-rw-r--r--aai-core/src/test/java/org/onap/aai/parsers/uri/URIToDBKeyTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java84
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java81
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java19
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java27
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java4
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java38
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java319
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/PrivateEdgeIntegrationTest.java5
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/PserverTest.java38
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/VipAddressListTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/VnfcRelationshipIssueTest.java15
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java59
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/ueb/UEBNotificationTest.java53
-rw-r--r--aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java9
-rw-r--r--aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java23
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/AAICoreFakeEdgesConfigTranslator.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/AAICorePrivateEdgeTestConfigTranslator.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java33
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerDeltasTest.java510
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerNotificationEventsTest.java224
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java338
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java175
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/EdgerPairCanBeBothCousinAndParentChildTest.java108
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java100
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/OneToOneEdgeUpdateTest.java147
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/VersionedScenariosTest.java327
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngineTest.java3
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine_needsFakeEdgeRulesTest.java2
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/AggregateFormatTest.java17
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java17
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/GraphSONTest.java6
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java28
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java48
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java42
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java21
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java19
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java7
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java36
-rw-r--r--aai-core/src/test/java/org/onap/aai/stress/IndexStressTest.java35
-rw-r--r--aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforEdges.java1
-rw-r--r--aai-core/src/test/java/org/onap/aai/transforms/XmlFormatTransformerTest.java13
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java3
76 files changed, 1604 insertions, 2164 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/AAISetup.java b/aai-core/src/test/java/org/onap/aai/AAISetup.java
index ac9cba68..72d8273a 100644
--- a/aai-core/src/test/java/org/onap/aai/AAISetup.java
+++ b/aai-core/src/test/java/org/onap/aai/AAISetup.java
@@ -20,6 +20,8 @@
package org.onap.aai;
+import java.util.Map;
+
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -42,30 +44,14 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
-import java.util.Map;
-
@ContextConfiguration(
- classes = {
- ConfigConfiguration.class,
- AAIConfigTranslator.class,
- EdgeIngestor.class,
- EdgeSerializer.class,
- NodeIngestor.class,
- SpringContextAware.class,
- IntrospectionConfig.class,
- RestBeanConfig.class,
- XmlFormatTransformerConfiguration.class
- }
-)
+ classes = {ConfigConfiguration.class, AAIConfigTranslator.class, EdgeIngestor.class, EdgeSerializer.class,
+ NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class, RestBeanConfig.class,
+ XmlFormatTransformerConfiguration.class})
@TestPropertySource(
- properties = {
- "schema.uri.base.path = /aai",
- "schema.xsd.maxoccurs = 5000",
- "schema.translator.list=config",
- "schema.nodes.location=src/test/resources/onap/oxm",
- "schema.edges.location=src/test/resources/onap/dbedgerules"
- }
-)
+ properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000", "schema.translator.list=config",
+ "schema.nodes.location=src/test/resources/onap/oxm",
+ "schema.edges.location=src/test/resources/onap/dbedgerules"})
public abstract class AAISetup {
@ClassRule
diff --git a/aai-core/src/test/java/org/onap/aai/AbstractConfigTranslator.java b/aai-core/src/test/java/org/onap/aai/AbstractConfigTranslator.java
index 07183436..19b8220b 100644
--- a/aai-core/src/test/java/org/onap/aai/AbstractConfigTranslator.java
+++ b/aai-core/src/test/java/org/onap/aai/AbstractConfigTranslator.java
@@ -21,7 +21,6 @@
package org.onap.aai;
import java.io.File;
-import java.net.URL;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
diff --git a/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java
index 8a093669..b8782045 100644
--- a/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java
+++ b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java
@@ -33,8 +33,6 @@ import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.onap.aai.setup.AAIConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.testutils.TestUtilConfigTranslatorforDataLink;
diff --git a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
index 588cbc95..9d406eb2 100644
--- a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -20,8 +20,15 @@
package org.onap.aai;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.*;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.*;
+
+import javax.ws.rs.core.*;
+
import org.javatuples.Pair;
import org.mockito.Mockito;
import org.onap.aai.config.SpringContextAware;
@@ -40,14 +47,8 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
-
-import javax.ws.rs.core.*;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.*;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HttpTestUtil extends RESTAPI {
@@ -91,7 +92,6 @@ public class HttpTestUtil extends RESTAPI {
this.acceptType = acceptType;
}
-
public HttpTestUtil(QueryStyle qs, UEBNotification uebNotification, int notificationDepth) {
this(qs, uebNotification, notificationDepth, "application/json");
}
@@ -122,7 +122,7 @@ public class HttpTestUtil extends RESTAPI {
headersMultiMap.add("aai-request-context", "");
outputMediaTypes = new ArrayList<>();
- if(acceptType.equals("application/json")){
+ if (acceptType.equals("application/json")) {
outputMediaTypes.add(APPLICATION_JSON);
} else {
outputMediaTypes.add(APPLICATION_XML);
@@ -143,7 +143,7 @@ public class HttpTestUtil extends RESTAPI {
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
try {
- if(notification != null){
+ if (notification != null) {
doNothing().when(notification).triggerEvents();
}
} catch (AAIException e) {
@@ -167,7 +167,7 @@ public class HttpTestUtil extends RESTAPI {
try {
List<DBRequest> dbRequestList = new ArrayList<>();
- for(Map.Entry<String, String> entry : uriPayload.entrySet()){
+ for (Map.Entry<String, String> entry : uriPayload.entrySet()) {
String uri = entry.getKey();
String payload = entry.getValue();
@@ -193,7 +193,7 @@ public class HttpTestUtil extends RESTAPI {
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
- if(notification != null){
+ if (notification != null) {
traversalHttpEntry.setHttpEntryProperties(version, notification, notificationDepth);
} else {
traversalHttpEntry.setHttpEntryProperties(version);
@@ -213,23 +213,24 @@ public class HttpTestUtil extends RESTAPI {
HttpMethod httpMethod;
if (uri.contains("/relationship-list/relationship")) {
obj = loader.unmarshal("relationship", payload,
- org.onap.aai.restcore.MediaType.getEnum("application/json"));
+ org.onap.aai.restcore.MediaType.getEnum("application/json"));
httpMethod = HttpMethod.PUT_EDGE;
} else {
- obj = loader.unmarshal(objType, payload, org.onap.aai.restcore.MediaType.getEnum("application/json"));
+ obj = loader.unmarshal(objType, payload,
+ org.onap.aai.restcore.MediaType.getEnum("application/json"));
httpMethod = HttpMethod.PUT;
this.validateIntrospector(obj, loader, uriObject, httpMethod);
}
DBRequest dbRequest = new DBRequest.Builder(httpMethod, uriObject, uriQuery, obj, httpHeaders, uriInfo,
- "JUNIT-TRANSACTION").rawRequestContent(payload).build();
+ "JUNIT-TRANSACTION").rawRequestContent(payload).build();
dbRequestList.add(dbRequest);
}
Pair<Boolean, List<Pair<URI, Response>>> responsesTuple =
- traversalHttpEntry.process(dbRequestList, "JUNIT");
+ traversalHttpEntry.process(dbRequestList, "JUNIT");
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e) {
@@ -244,7 +245,7 @@ public class HttpTestUtil extends RESTAPI {
if (response != null) {
if ((response.getStatus() / 100) == 2) {
logger.info("Successfully completed the PUT request with status {} and committing it to DB",
- response.getStatus());
+ response.getStatus());
} else {
logFailure(HttpMethod.PUT, response);
}
@@ -292,7 +293,7 @@ public class HttpTestUtil extends RESTAPI {
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
- if(notification != null){
+ if (notification != null) {
traversalHttpEntry.setHttpEntryProperties(version, notification, notificationDepth);
} else {
traversalHttpEntry.setHttpEntryProperties(version);
@@ -315,13 +316,13 @@ public class HttpTestUtil extends RESTAPI {
this.validateIntrospector(obj, loader, uriObject, httpMethod);
DBRequest dbRequest = new DBRequest.Builder(httpMethod, uriObject, uriQuery, obj, httpHeaders, uriInfo,
- "JUNIT-TRANSACTION").rawRequestContent(payload).build();
+ "JUNIT-TRANSACTION").rawRequestContent(payload).build();
List<DBRequest> dbRequestList = new ArrayList<>();
dbRequestList.add(dbRequest);
Pair<Boolean, List<Pair<URI, Response>>> responsesTuple =
- traversalHttpEntry.process(dbRequestList, "JUNIT");
+ traversalHttpEntry.process(dbRequestList, "JUNIT");
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e) {
@@ -336,7 +337,7 @@ public class HttpTestUtil extends RESTAPI {
if (response != null) {
if ((response.getStatus() / 100) == 2) {
logger.info("Successfully completed the PUT request with status {} and committing it to DB",
- response.getStatus());
+ response.getStatus());
} else {
logFailure(HttpMethod.PUT, response);
}
@@ -353,8 +354,8 @@ public class HttpTestUtil extends RESTAPI {
return response;
}
- public Response doGet(String uri, String depth){
- return doGet(uri, depth, null);
+ public Response doGet(String uri, String depth) {
+ return doGet(uri, depth, null);
}
public Response doGet(String uri, String depth, String format) {
@@ -387,7 +388,7 @@ public class HttpTestUtil extends RESTAPI {
version = schemaVersions.getDefaultVersion();
}
- if(notification != null){
+ if (notification != null) {
traversalHttpEntry.setHttpEntryProperties(version, notification, notificationDepth);
} else {
traversalHttpEntry.setHttpEntryProperties(version);
@@ -401,7 +402,7 @@ public class HttpTestUtil extends RESTAPI {
queryParameters.add("depth", depth);
}
- if(format != null){
+ if (format != null) {
queryParameters.add("format", format);
}
@@ -461,7 +462,7 @@ public class HttpTestUtil extends RESTAPI {
return this.doGet(uri, "all");
}
- public Response doDelete(Map<String, Pair<String, String>> deletes){
+ public Response doDelete(Map<String, Pair<String, String>> deletes) {
this.init();
Response response = null;
@@ -476,7 +477,8 @@ public class HttpTestUtil extends RESTAPI {
String resourceVersion = delete.getValue().getValue0();
String content = delete.getValue().getValue1();
uri = uri.replaceAll("/aai/", "");
- logger.info("Starting the delete request for the uri {} with resource version {}", uri, resourceVersion);
+ logger.info("Starting the delete request for the uri {} with resource version {}", uri,
+ resourceVersion);
String[] arr = uri.split("/");
@@ -517,19 +519,20 @@ public class HttpTestUtil extends RESTAPI {
if (uri.contains("/relationship-list/relationship")) {
httpMethod = HttpMethod.DELETE_EDGE;
- obj = loader.unmarshal("relationship", content, org.onap.aai.restcore.MediaType.getEnum("application/json"));
+ obj = loader.unmarshal("relationship", content,
+ org.onap.aai.restcore.MediaType.getEnum("application/json"));
} else {
obj = loader.introspectorFromName(objType);
httpMethod = HttpMethod.DELETE;
}
- DBRequest dbRequest = new DBRequest.Builder(httpMethod, uriObject, uriQuery, obj, httpHeaders, uriInfo, "JUNIT-TRANSACTION").build();
-
+ DBRequest dbRequest = new DBRequest.Builder(httpMethod, uriObject, uriQuery, obj, httpHeaders, uriInfo,
+ "JUNIT-TRANSACTION").build();
dbRequestList.add(dbRequest);
}
Pair<Boolean, List<Pair<URI, Response>>> responsesTuple =
- traversalHttpEntry.process(dbRequestList, "JUNIT");
+ traversalHttpEntry.process(dbRequestList, "JUNIT");
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e) {
@@ -544,7 +547,7 @@ public class HttpTestUtil extends RESTAPI {
if (response != null) {
if ((response.getStatus() / 100) == 2) {
logger.info("Successfully completed the DELETE request with status {} and committing it to DB",
- response.getStatus());
+ response.getStatus());
} else {
logFailure(HttpMethod.DELETE, response);
}
@@ -562,6 +565,7 @@ public class HttpTestUtil extends RESTAPI {
public Response doDelete(String uri, String resourceVersion) {
return this.doDelete(uri, resourceVersion, null);
}
+
public Response doDelete(String uri, String resourceVersion, String content) {
Map<String, Pair<String, String>> deletes = new HashMap<>();
deletes.put(uri, new Pair<>(resourceVersion, content));
diff --git a/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java b/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
index 5d606733..f993ad28 100644
--- a/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
+++ b/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
@@ -20,6 +20,10 @@
package org.onap.aai.audit;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -27,10 +31,6 @@ import org.onap.aai.AAISetup;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.test.annotation.DirtiesContext;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class ListEndpointsTest extends AAISetup {
diff --git a/aai-core/src/test/java/org/onap/aai/concurrent/AaiCallableTest.java b/aai-core/src/test/java/org/onap/aai/concurrent/AaiCallableTest.java
index 0c3857ae..df5c144c 100644
--- a/aai-core/src/test/java/org/onap/aai/concurrent/AaiCallableTest.java
+++ b/aai-core/src/test/java/org/onap/aai/concurrent/AaiCallableTest.java
@@ -22,11 +22,8 @@ package org.onap.aai.concurrent;
import static org.junit.Assert.assertTrue;
-import java.lang.Object;
-
import org.junit.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.concurrent.AaiCallable;
import org.slf4j.MDC;
public class AaiCallableTest extends AAISetup {
diff --git a/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java b/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
index 6bea58f0..16faa5f1 100644
--- a/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
+++ b/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
@@ -108,8 +108,10 @@ public class DbMethHelperTest extends AAISetup {
dbser = new DBSerializer(version, dbEngine, introspectorFactoryType, "AAI-TEST");
dbMethHelper = new DbMethHelper(loader, spy);
- Vertex pserver1 = graph.addVertex("aai-node-type", "pserver", "hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
- Vertex pserver2 = graph.addVertex("aai-node-type", "pserver", "hostname", "testSearchVertexByIdentityMap-pserver-hostname-02");
+ Vertex pserver1 = graph.addVertex("aai-node-type", "pserver", "hostname",
+ "testSearchVertexByIdentityMap-pserver-hostname-01");
+ Vertex pserver2 = graph.addVertex("aai-node-type", "pserver", "hostname",
+ "testSearchVertexByIdentityMap-pserver-hostname-02");
Vertex genericVnf1 = graph.addVertex("aai-node-type", "generic-vnf", "vnf-id", "key1", "vnf-name", "vnfName1");
Vertex complex1 = graph.addVertex("aai-node-type", "complex", "physical-location-id", "id1");
GraphTraversalSource g = graph.traversal();
@@ -119,7 +121,7 @@ public class DbMethHelperTest extends AAISetup {
}
@Test
- public void testSearchVertexByIdentityMap() throws Exception{
+ public void testSearchVertexByIdentityMap() throws Exception {
String type = "pserver";
Map<String, Object> map = new HashMap<>();
map.put("pserver.hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
@@ -134,7 +136,8 @@ public class DbMethHelperTest extends AAISetup {
}
@Test(expected = AmbiguousMapAAIException.class)
- public void testSearchVertexByIdentityMap_throwAmbiguousMapAAIException() throws AmbiguousMapAAIException, Exception {
+ public void testSearchVertexByIdentityMap_throwAmbiguousMapAAIException()
+ throws AmbiguousMapAAIException, Exception {
String type = "pserver";
Map<String, Object> map = new HashMap<>();
map.put("pserver.hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
@@ -155,14 +158,16 @@ public class DbMethHelperTest extends AAISetup {
Vertex complex2 = graph.addVertex("aai-node-type", "complex", "physical-location-id", "id2");
map.put("physical-location-id", "id2");
Optional<Vertex> optionalVertex = dbMethHelper.locateUniqueVertex(type, map);
- Assert.assertEquals("vp[physical-location-id->id2]", optionalVertex.get().property("physical-location-id").toString());
+ Assert.assertEquals("vp[physical-location-id->id2]",
+ optionalVertex.get().property("physical-location-id").toString());
}
@Test(expected = AAIException.class)
public void testLocateUniqueVertex_throwsException() throws AAIException, Exception {
String type = "Pserver";
Map<String, Object> map = new HashMap<>();
- Introspector obj = loader.unmarshal("relationship", this.getJsonString("related-link-and-relationship-data.json"));
+ Introspector obj =
+ loader.unmarshal("relationship", this.getJsonString("related-link-and-relationship-data.json"));
map.put("hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
dbMethHelper.locateUniqueVertex(type, map);
}
@@ -178,8 +183,9 @@ public class DbMethHelperTest extends AAISetup {
@Test
public void testGetVertexProperties() throws Exception {
- Vertex pserver3 = graph.addVertex("aai-node-type", "pserver", "hostname", "testGetVertexProperties-pserver-hostname-01",
- "ptnii-equip-name", "testGetVertexProperties-pserver-ptnii-equip-name-01");
+ Vertex pserver3 =
+ graph.addVertex("aai-node-type", "pserver", "hostname", "testGetVertexProperties-pserver-hostname-01",
+ "ptnii-equip-name", "testGetVertexProperties-pserver-ptnii-equip-name-01");
String type = "pserver";
Map<String, Object> map = new HashMap<>();
map.put("pserver.hostname", "testGetVertexProperties-pserver-hostname-01");
@@ -194,8 +200,10 @@ public class DbMethHelperTest extends AAISetup {
Vertex v = optionalVertex.get();
List<String> vertexProperties = dbMethHelper.getVertexProperties(v);
Assert.assertTrue(vertexProperties.contains("Prop: [aai-node-type], val = [pserver] "));
- Assert.assertTrue(vertexProperties.contains("Prop: [hostname], val = [testGetVertexProperties-pserver-hostname-01] "));
- Assert.assertTrue(vertexProperties.contains("Prop: [ptnii-equip-name], val = [testGetVertexProperties-pserver-ptnii-equip-name-01] "));
+ Assert.assertTrue(
+ vertexProperties.contains("Prop: [hostname], val = [testGetVertexProperties-pserver-hostname-01] "));
+ Assert.assertTrue(vertexProperties
+ .contains("Prop: [ptnii-equip-name], val = [testGetVertexProperties-pserver-ptnii-equip-name-01] "));
}
@Test
diff --git a/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java b/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java
index cc420018..05cb3467 100644
--- a/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java
+++ b/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java
@@ -20,6 +20,17 @@
package org.onap.aai.dbmap;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.junit.Assert.*;
+
+import java.io.FileNotFoundException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.schema.JanusGraphIndex;
@@ -37,17 +48,6 @@ import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConstants;
-import java.io.FileNotFoundException;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.matchesPattern;
-import static org.junit.Assert.*;
-
public class AAIGraphTest extends AAISetup {
@Before
public void setup() {
@@ -67,7 +67,6 @@ public class AAIGraphTest extends AAISetup {
graphMgt.rollback();
}
-
@Test
public void janusGraphOpenNameTest() throws Exception {
JanusGraph graph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG)
diff --git a/aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java b/aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java
index 61e76071..3ef1befa 100644
--- a/aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java
+++ b/aai-core/src/test/java/org/onap/aai/domain/model/AAIResourceTest.java
@@ -22,15 +22,13 @@ package org.onap.aai.domain.model;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MultiHashtable;
+
+import java.util.*;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.audit.ListEndpoints;
-import org.onap.aai.setup.SchemaVersion;
-
-import java.util.*;
public class AAIResourceTest extends AAISetup {
private AAIResource aaiResource;
diff --git a/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java
index 79a9289a..20e3ab30 100644
--- a/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java
+++ b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntriesTest.java
@@ -20,18 +20,10 @@
package org.onap.aai.domain.translog;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.domain.model.AAIResource;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
public class TransactionLogEntriesTest extends AAISetup {
private TransactionLogEntries transactionLogEntries;
diff --git a/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java
index b692519c..3d4256b2 100644
--- a/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/domain/translog/TransactionLogEntryTest.java
@@ -20,18 +20,10 @@
package org.onap.aai.domain.translog;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.domain.model.AAIResource;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
public class TransactionLogEntryTest extends AAISetup {
private TransactionLogEntry transactionLogEntry;
diff --git a/aai-core/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java b/aai-core/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
index 47fad982..8437456d 100644
--- a/aai-core/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
+++ b/aai-core/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
@@ -21,7 +21,6 @@
package org.onap.aai.exceptions;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.onap.aai.AAISetup;
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java
index 7b15e8ca..4982f1d6 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/JSONStrategyTest.java
@@ -20,6 +20,9 @@
package org.onap.aai.introspection;
+import java.util.HashSet;
+import java.util.Set;
+
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Assert;
@@ -28,9 +31,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.onap.aai.AAISetup;
-import java.util.HashSet;
-import java.util.Set;
-
@Ignore("Not a used/flushed out feature")
public class JSONStrategyTest extends AAISetup {
private JSONStrategy jsonStrategy;
@@ -69,14 +69,16 @@ public class JSONStrategyTest extends AAISetup {
Assert.assertEquals(1024, jsonStrategy.getValue("ramInMegabytes"));
}
+
@Test
- public void testGetMethods(){
- Assert.assertEquals("pserver-type",jsonStrategy.getName());
- Assert.assertEquals("pserver-type",jsonStrategy.getDbName());
- Assert.assertEquals("",jsonStrategy.getGenericURI());
+ public void testGetMethods() {
+ Assert.assertEquals("pserver-type", jsonStrategy.getName());
+ Assert.assertEquals("pserver-type", jsonStrategy.getDbName());
+ Assert.assertEquals("", jsonStrategy.getGenericURI());
Assert.assertNull(jsonStrategy.getChildName());
- Assert.assertEquals("key",jsonStrategy.preProcessKey("key"));
+ Assert.assertEquals("key", jsonStrategy.preProcessKey("key"));
}
+
@Test
public void getPropertiesTest() {
Set<String> expected = new HashSet<>();
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java b/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java
index 887f191b..a83c41ae 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/MoxyEngineTest.java
@@ -20,9 +20,6 @@
package org.onap.aai.introspection;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java b/aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java
index f68e6af9..80037061 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/generator/CreateExampleTest.java
@@ -29,6 +29,7 @@ import java.util.List;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
@@ -37,7 +38,6 @@ import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.junit.Ignore;
@Ignore
public class CreateExampleTest extends AAISetup {
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java
index bda268c6..e83d3bd3 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java
@@ -95,35 +95,22 @@ public class DataCopyTest extends AAISetup {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- graph.traversal()
- .addV("model")
- .property("aai-node-type", "model")
- .property("model-invariant-id", "key1")
- .property(AAIProperties.AAI_URI,"/service-design-and-creation/models/model/key1")
- .as("v1")
- .addV("model-ver")
- .property("aai-node-type", "model-ver")
- .property("model-ver", "myValue")
- .property("model-version-id", "key2")
- .property("model-version", "testValue")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key1/model-vers/model-ver/key2")
- .as("v2")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v1").from("v2")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV("model")
- .property("aai-node-type", "model")
- .property("model-invariant-id", "key3")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3")
- .as("v3")
- .addV()
- .property("aai-node-type", "model-ver")
- .property("model-ver", "myValue")
- .property("model-version-id", "key4")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3/model-vers/model-ver/key4")
- .as("v4")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v3").from("v4")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .next();
+ graph.traversal().addV("model").property("aai-node-type", "model").property("model-invariant-id", "key1")
+ .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key1").as("v1")
+ .addV("model-ver").property("aai-node-type", "model-ver").property("model-ver", "myValue")
+ .property("model-version-id", "key2").property("model-version", "testValue")
+ .property(AAIProperties.AAI_URI,
+ "/service-design-and-creation/models/model/key1/model-vers/model-ver/key2")
+ .as("v2").addE("org.onap.relationships.inventory.BelongsTo").to("v1").from("v2")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV("model").property("aai-node-type", "model")
+ .property("model-invariant-id", "key3")
+ .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3").as("v3").addV()
+ .property("aai-node-type", "model-ver").property("model-ver", "myValue")
+ .property("model-version-id", "key4")
+ .property(AAIProperties.AAI_URI,
+ "/service-design-and-creation/models/model/key3/model-vers/model-ver/key4")
+ .as("v4").addE("org.onap.relationships.inventory.BelongsTo").to("v3").from("v4")
+ .property(EdgeProperty.CONTAINS.toString(), true).next();
graph.tx().commit();
}
@@ -141,8 +128,8 @@ public class DataCopyTest extends AAISetup {
}
@Test
- public void runPopulatePersonaModelVer() throws AAIException, UnsupportedEncodingException,
- IllegalArgumentException, SecurityException {
+ public void runPopulatePersonaModelVer()
+ throws AAIException, UnsupportedEncodingException, IllegalArgumentException, SecurityException {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("generic-vnf");
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java
index 62c366cb..440d2797 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java
@@ -20,6 +20,19 @@
package org.onap.aai.introspection.sideeffect;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -47,19 +60,6 @@ import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.UUID;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@RunWith(value = Parameterized.class)
public class DataLinkTest extends DataLinkSetup {
@@ -88,128 +88,74 @@ public class DataLinkTest extends DataLinkSetup {
public static void setup() {
graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
JanusGraphManagement graphMgt = graph.openManagement();
- graphMgt.makePropertyKey(AAIProperties.CREATED_TS).dataType(Long.class).cardinality(Cardinality.SINGLE)
- .make();
- graphMgt.makePropertyKey(AAIProperties.LAST_MOD_TS).dataType(Long.class).cardinality(Cardinality.SINGLE)
- .make();
+ graphMgt.makePropertyKey(AAIProperties.CREATED_TS).dataType(Long.class).cardinality(Cardinality.SINGLE).make();
+ graphMgt.makePropertyKey(AAIProperties.LAST_MOD_TS).dataType(Long.class).cardinality(Cardinality.SINGLE).make();
graphMgt.commit();
- graph.traversal()
- .addV()
- .property("aai-node-type", "vpn-binding")
- .property("vpn-id", "addKey")
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/addKey")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v1")
- .addV()
- .property("aai-node-type", "vpn-binding")
- .property("vpn-id", "modifyKey")
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/modifyKey")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v2")
- .addV()
- .property("aai-node-type", "route-target")
- .property("global-route-target", "modifyTargetKey")
- .property("route-target-role", "modifyRoleKey")
- .property("linked", true)
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/modifyKey/route-targets/route-target/modifyTargetKey/modifyRoleKey")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v3")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v2").from("v3")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV()
- .property("aai-node-type", "vpn-binding")
- .property("vpn-id", "deleteKey")
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/deleteKey")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v4")
- .addV()
- .property("aai-node-type", "route-target")
- .property("global-route-target", "deleteTargetKey")
- .property("route-target-role", "deleteRoleKey")
- .property("linked", true)
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/deleteKey/route-targets/route-target/deleteTargetKey/deleteRoleKey")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v5")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v4").from("v5")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV()
- .property("aai-node-type", "vpn-binding")
- .property("vpn-id", "getKey")
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKey")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v6")
- .addV()
- .property("aai-node-type", "route-target")
- .property("global-route-target", "getTargetKey")
- .property("route-target-role", "getRoleKey")
- .property("linked", true)
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKey/route-targets/route-target/getTargetKeyNoLink/getRoleKeyNoLink")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v7")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v6").from("v7")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV()
- .property("aai-node-type", "vpn-binding")
- .property("vpn-id", "getKeyNoLink")
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKeyNoLink")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v8")
- .addV()
- .property("aai-node-type", "route-target")
- .property("global-route-target", "getTargetKeyNoLink")
- .property("route-target-role", "getRoleKeyNoLink")
- .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKeyNoLink/route-targets/route-target/getTargetKeyNoLink/getRoleKeyNoLink")
- .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString())
- .property(AAIProperties.CREATED_TS, 123)
- .property(AAIProperties.SOURCE_OF_TRUTH, "sot")
- .property(AAIProperties.RESOURCE_VERSION, "123")
- .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot")
- .property(AAIProperties.LAST_MOD_TS, 333)
- .as("v9")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v8").from("v9")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .next();
+ graph.traversal().addV().property("aai-node-type", "vpn-binding").property("vpn-id", "addKey")
+ .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/addKey")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v1").addV().property("aai-node-type", "vpn-binding").property("vpn-id", "modifyKey")
+ .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/modifyKey")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v2").addV().property("aai-node-type", "route-target")
+ .property("global-route-target", "modifyTargetKey").property("route-target-role", "modifyRoleKey")
+ .property("linked", true)
+ .property(AAIProperties.AAI_URI,
+ "/network/vpn-bindings/vpn-binding/modifyKey/route-targets/route-target/modifyTargetKey/modifyRoleKey")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v3").addE("org.onap.relationships.inventory.BelongsTo").to("v2").from("v3")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV().property("aai-node-type", "vpn-binding")
+ .property("vpn-id", "deleteKey")
+ .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/deleteKey")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v4").addV().property("aai-node-type", "route-target")
+ .property("global-route-target", "deleteTargetKey").property("route-target-role", "deleteRoleKey")
+ .property("linked", true)
+ .property(AAIProperties.AAI_URI,
+ "/network/vpn-bindings/vpn-binding/deleteKey/route-targets/route-target/deleteTargetKey/deleteRoleKey")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v5").addE("org.onap.relationships.inventory.BelongsTo").to("v4").from("v5")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV().property("aai-node-type", "vpn-binding")
+ .property("vpn-id", "getKey")
+ .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKey")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v6").addV().property("aai-node-type", "route-target")
+ .property("global-route-target", "getTargetKey").property("route-target-role", "getRoleKey")
+ .property("linked", true)
+ .property(AAIProperties.AAI_URI,
+ "/network/vpn-bindings/vpn-binding/getKey/route-targets/route-target/getTargetKeyNoLink/getRoleKeyNoLink")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v7").addE("org.onap.relationships.inventory.BelongsTo").to("v6").from("v7")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV().property("aai-node-type", "vpn-binding")
+ .property("vpn-id", "getKeyNoLink")
+ .property(AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/getKeyNoLink")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v8").addV().property("aai-node-type", "route-target")
+ .property("global-route-target", "getTargetKeyNoLink").property("route-target-role", "getRoleKeyNoLink")
+ .property(AAIProperties.AAI_URI,
+ "/network/vpn-bindings/vpn-binding/getKeyNoLink/route-targets/route-target/getTargetKeyNoLink/getRoleKeyNoLink")
+ .property(AAIProperties.AAI_UUID, UUID.randomUUID().toString()).property(AAIProperties.CREATED_TS, 123)
+ .property(AAIProperties.SOURCE_OF_TRUTH, "sot").property(AAIProperties.RESOURCE_VERSION, "123")
+ .property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot").property(AAIProperties.LAST_MOD_TS, 333)
+ .as("v9").addE("org.onap.relationships.inventory.BelongsTo").to("v8").from("v9")
+ .property(EdgeProperty.CONTAINS.toString(), true).next();
graph.tx().commit();
}
@@ -228,8 +174,8 @@ public class DataLinkTest extends DataLinkSetup {
}
@Test
- public void verifyCreationOfVertex() throws AAIException, UnsupportedEncodingException,
- IllegalArgumentException, SecurityException {
+ public void verifyCreationOfVertex()
+ throws AAIException, UnsupportedEncodingException, IllegalArgumentException, SecurityException {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
final Introspector obj = loader.introspectorFromName("vpn-binding");
@@ -252,14 +198,15 @@ public class DataLinkTest extends DataLinkSetup {
runner.execute(obj, self);
- assertTrue("route-target vertex found", traversal.V().has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "key1").has("route-target-role", "key2").has("linked", true).hasNext());
+ assertTrue("route-target vertex found", traversal.V().has(AAIProperties.NODE_TYPE, "route-target")
+ .has("global-route-target", "key1").has("route-target-role", "key2").has("linked", true).hasNext());
g.tx().rollback();
}
@Test
- public void verifyModificationOfVertex() throws AAIException, UnsupportedEncodingException,
- IllegalArgumentException, SecurityException {
+ public void verifyModificationOfVertex()
+ throws AAIException, UnsupportedEncodingException, IllegalArgumentException, SecurityException {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDepthVersion());
final Introspector obj = loader.introspectorFromName("vpn-binding");
@@ -326,7 +273,9 @@ public class DataLinkTest extends DataLinkSetup {
runner.execute(obj, self);
- assertFalse("route-target vertex not found", traversal.V().has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "deleteTargetKey").has("route-target-role", "deleteRoleKey").has("linked", true).hasNext());
+ assertFalse("route-target vertex not found",
+ traversal.V().has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "deleteTargetKey")
+ .has("route-target-role", "deleteRoleKey").has("linked", true).hasNext());
g.tx().rollback();
@@ -354,14 +303,16 @@ public class DataLinkTest extends DataLinkSetup {
runner.execute(obj, self);
- assertTrue("both properties have been populated in target object", obj.getValue("global-route-target").equals("getTargetKey") && obj.getValue("route-target-role").equals("getRoleKey"));
+ assertTrue("both properties have been populated in target object",
+ obj.getValue("global-route-target").equals("getTargetKey")
+ && obj.getValue("route-target-role").equals("getRoleKey"));
g.tx().rollback();
}
@Test
- public void verifyPropertyPopulationWithV10OnlyPut() throws AAIException,
- UnsupportedEncodingException, IllegalArgumentException, SecurityException {
+ public void verifyPropertyPopulationWithV10OnlyPut()
+ throws AAIException, UnsupportedEncodingException, IllegalArgumentException, SecurityException {
final Introspector obj = loader.introspectorFromName("vpn-binding");
obj.setValue("vpn-id", "getKeyNoLink");
final Introspector routeTargets = loader.introspectorFromName("route-targets");
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java
index ee8ff77c..a349f85e 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -35,6 +36,7 @@ import org.janusgraph.core.JanusGraphFactory;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -52,7 +54,6 @@ import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.junit.Ignore;
@RunWith(value = Parameterized.class)
@Ignore
@@ -80,38 +81,22 @@ public class OwnerCheckTest extends AAISetup {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- graph.traversal()
- .addV("pnf")
- .property("aai-node-type", "pnf")
- .property("pnf-name", "my-pnf")
- .property("data-owner", "Operator")
- .property(AAIProperties.AAI_URI, "/network/pnfs/pnf/my-pnf")
- .property("model-invariant-id", "key1")
- .as("v1")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV("model-ver")
- .property("aai-node-type", "model-ver")
- .property("model-ver", "myValue")
- .property("model-version-id", "key2")
- .property("model-version", "testValue")
- .property(AAIProperties.AAI_URI, "/network/pnfs/pnf/my-pnf/model-vers/model-ver/key2")
- .as("v2")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v1").from("v2")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV("model")
- .property("aai-node-type", "model")
- .property("model-invariant-id", "key3")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3")
- .as("v3")
- .addV()
- .property("aai-node-type", "model-ver")
- .property("model-ver", "myValue")
- .property("model-version-id", "key4")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3/model-vers/model-ver/key4")
- .as("v4")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v3").from("v4")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .next();
+ graph.traversal().addV("pnf").property("aai-node-type", "pnf").property("pnf-name", "my-pnf")
+ .property("data-owner", "Operator").property(AAIProperties.AAI_URI, "/network/pnfs/pnf/my-pnf")
+ .property("model-invariant-id", "key1").as("v1").property(EdgeProperty.CONTAINS.toString(), true)
+ .addV("model-ver").property("aai-node-type", "model-ver").property("model-ver", "myValue")
+ .property("model-version-id", "key2").property("model-version", "testValue")
+ .property(AAIProperties.AAI_URI, "/network/pnfs/pnf/my-pnf/model-vers/model-ver/key2").as("v2")
+ .addE("org.onap.relationships.inventory.BelongsTo").to("v1").from("v2")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV("model").property("aai-node-type", "model")
+ .property("model-invariant-id", "key3")
+ .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3").as("v3").addV()
+ .property("aai-node-type", "model-ver").property("model-ver", "myValue")
+ .property("model-version-id", "key4")
+ .property(AAIProperties.AAI_URI,
+ "/service-design-and-creation/models/model/key3/model-vers/model-ver/key4")
+ .as("v4").addE("org.onap.relationships.inventory.BelongsTo").to("v3").from("v4")
+ .property(EdgeProperty.CONTAINS.toString(), true).next();
graph.tx().commit();
}
@@ -129,7 +114,7 @@ public class OwnerCheckTest extends AAISetup {
}
@Test
- public void shouldFailIfGroupsNotContainsDataOwner() throws Exception {
+ public void shouldFailIfGroupsNotContainsDataOwner() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
@@ -142,9 +127,7 @@ public class OwnerCheckTest extends AAISetup {
GraphTraversalSource traversal = g.traversal();
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
- DBSerializer serializer =
- new DBSerializer(schemaVersions.getDefaultVersion(),
- spy, introspectorFactoryType,
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType,
"AAI_TEST", new HashSet<>(Arrays.asList("OperatorI", "OperatorII")));
Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
@@ -159,7 +142,7 @@ public class OwnerCheckTest extends AAISetup {
}
@Test
- public void shouldPassIfGroupsContainsDataOwner() throws Exception {
+ public void shouldPassIfGroupsContainsDataOwner() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
@@ -176,9 +159,7 @@ public class OwnerCheckTest extends AAISetup {
Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
- DBSerializer serializer =
- new DBSerializer(schemaVersions.getDefaultVersion(),
- spy, introspectorFactoryType,
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType,
"AAI_TEST", new HashSet<>(Arrays.asList("OperatorIII", "Operator")));
OwnerCheck ownerCheck = new OwnerCheck(obj, selfV, spy, serializer);
@@ -189,7 +170,7 @@ public class OwnerCheckTest extends AAISetup {
}
@Test
- public void shouldPassIfGroupsIsEmpty() throws Exception {
+ public void shouldPassIfGroupsIsEmpty() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
@@ -203,9 +184,7 @@ public class OwnerCheckTest extends AAISetup {
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
DBSerializer serializer =
- new DBSerializer(schemaVersions.getDefaultVersion(),
- spy, introspectorFactoryType,
- "AAI_TEST");
+ new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
@@ -217,7 +196,7 @@ public class OwnerCheckTest extends AAISetup {
}
@Test
- public void shouldPassIfDataOwnerIsNull() throws Exception {
+ public void shouldPassIfDataOwnerIsNull() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
@@ -232,9 +211,7 @@ public class OwnerCheckTest extends AAISetup {
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
DBSerializer serializer =
- new DBSerializer(schemaVersions.getDefaultVersion(),
- spy, introspectorFactoryType,
- "AAI_TEST");
+ new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
@@ -246,7 +223,7 @@ public class OwnerCheckTest extends AAISetup {
}
@Test
- public void shouldPassIfDataOwnerIsEmpty() throws Exception {
+ public void shouldPassIfDataOwnerIsEmpty() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
@@ -261,9 +238,7 @@ public class OwnerCheckTest extends AAISetup {
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
DBSerializer serializer =
- new DBSerializer(schemaVersions.getDefaultVersion(),
- spy, introspectorFactoryType,
- "AAI_TEST");
+ new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java
index 6a7bfd33..edace19d 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/PrivateEdgeTest.java
@@ -20,6 +20,20 @@
package org.onap.aai.introspection.sideeffect;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -43,20 +57,6 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.springframework.test.annotation.DirtiesContext;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class PrivateEdgeTest extends AAISetup {
@@ -84,49 +84,30 @@ public class PrivateEdgeTest extends AAISetup {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- graph.traversal()
- .addV()
- .property("aai-node-type", "model")
- .property("model-invariant-id", "key1")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key1")
- .as("v1")
- .addV()
- .property("aai-node-type", "model-ver")
- .property("model-ver", "myValue")
- .property("model-version-id", "key2")
- .property("model-version", "testValue")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key1/model-vers/model-ver/key2")
- .as("v2")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v1").from("v2")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV()
- .property("aai-node-type", "model")
- .property("model-invariant-id", "key100")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key100")
- .as("v3")
- .addV()
- .property("aai-node-type", "model-ver")
- .property("model-ver", "myValue")
- .property("model-version-id", "key200")
- .property("model-version", "testValue")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key100/model-vers/model-ver/key200")
- .as("v4")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v3").from("v4")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .addV()
- .property("aai-node-type", "model")
- .property("model-invariant-id", "key3")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3")
- .as("v5")
- .addV()
- .property("aai-node-type", "model-ver")
- .property("model-ver", "myValue")
- .property("model-version-id", "key4")
- .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3/model-vers/model-ver/key4")
- .as("v6")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v5").from("v6")
- .property(EdgeProperty.CONTAINS.toString(), true)
- .next();
+ graph.traversal().addV().property("aai-node-type", "model").property("model-invariant-id", "key1")
+ .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key1").as("v1").addV()
+ .property("aai-node-type", "model-ver").property("model-ver", "myValue")
+ .property("model-version-id", "key2").property("model-version", "testValue")
+ .property(AAIProperties.AAI_URI,
+ "/service-design-and-creation/models/model/key1/model-vers/model-ver/key2")
+ .as("v2").addE("org.onap.relationships.inventory.BelongsTo").to("v1").from("v2")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "key100")
+ .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key100").as("v3").addV()
+ .property("aai-node-type", "model-ver").property("model-ver", "myValue")
+ .property("model-version-id", "key200").property("model-version", "testValue")
+ .property(AAIProperties.AAI_URI,
+ "/service-design-and-creation/models/model/key100/model-vers/model-ver/key200")
+ .as("v4").addE("org.onap.relationships.inventory.BelongsTo").to("v3").from("v4")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "key3")
+ .property(AAIProperties.AAI_URI, "/service-design-and-creation/models/model/key3").as("v5").addV()
+ .property("aai-node-type", "model-ver").property("model-ver", "myValue")
+ .property("model-version-id", "key4")
+ .property(AAIProperties.AAI_URI,
+ "/service-design-and-creation/models/model/key3/model-vers/model-ver/key4")
+ .as("v6").addE("org.onap.relationships.inventory.BelongsTo").to("v5").from("v6")
+ .property(EdgeProperty.CONTAINS.toString(), true).next();
graph.tx().commit();
}
@@ -138,7 +119,8 @@ public class PrivateEdgeTest extends AAISetup {
@Before
public void initMock() {
- Loader loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ Loader loader =
+ loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
MockitoAnnotations.initMocks(this);
dbEngine = new JanusGraphDBEngine(queryStyle, loader);
}
@@ -157,12 +139,8 @@ public class PrivateEdgeTest extends AAISetup {
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
- Vertex selfV = traversal.addV("generic-vnf")
- .property("aai-node-type", "generic-vnf")
- .property("vnf-id", "myId")
- .property("aai-uri", obj.getURI())
- .property("model-invariant-id", "key1")
- .next();
+ Vertex selfV = traversal.addV("generic-vnf").property("aai-node-type", "generic-vnf").property("vnf-id", "myId")
+ .property("aai-uri", obj.getURI()).property("model-invariant-id", "key1").next();
thrown.expectMessage(containsString("Cannot complete privateEdge uri"));
DBSerializer serializer =
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java b/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java
index 8b66d9a3..bc222ecc 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/tools/IntrospectorValidatorTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.List;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java b/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java
index 7bb38790..88e148f1 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/validation/IntrospectorValidationTest.java
@@ -33,8 +33,6 @@ import org.onap.aai.introspection.*;
import org.onap.aai.introspection.tools.IntrospectorValidator;
import org.onap.aai.introspection.tools.Issue;
import org.onap.aai.introspection.tools.IssueType;
-import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
-import org.onap.aai.util.AAIConstants;
import org.springframework.beans.factory.annotation.Autowired;
public class IntrospectorValidationTest extends AAISetup {
diff --git a/aai-core/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java b/aai-core/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
index 72b1150e..e6f498d3 100644
--- a/aai-core/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
+++ b/aai-core/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
@@ -20,13 +20,14 @@
package org.onap.aai.logging;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
+
import ch.qos.logback.access.spi.IAccessEvent;
+
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.*;
-
public class DME2RestFlagTest {
IAccessEvent mockAccEvent;
diff --git a/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java b/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
index cbe5bc6b..82522d50 100644
--- a/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
+++ b/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
@@ -20,12 +20,12 @@
package org.onap.aai.logging;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import javax.ws.rs.core.Response.Status;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
public class ErrorObjectTest {
diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java
index 1f347318..b038b72a 100644
--- a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java
+++ b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java
@@ -46,7 +46,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.onap.aai.AAISetup;
import org.onap.aai.DataLinkSetup;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java
index e8ccdddd..82ad2943 100644
--- a/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java
@@ -20,6 +20,14 @@
package org.onap.aai.parsers.query;
+import static org.junit.Assert.assertEquals;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+
import org.junit.Ignore;
import org.junit.Test;
import org.onap.aai.AAISetup;
@@ -30,13 +38,6 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.junit.Assert.assertEquals;
-
@Ignore
public class LegacyQueryTest extends AAISetup {
diff --git a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToDBKeyTest.java b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToDBKeyTest.java
index f19e2681..f9055b1d 100644
--- a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToDBKeyTest.java
+++ b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToDBKeyTest.java
@@ -35,7 +35,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.aai.AAISetup;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.*;
import org.onap.aai.parsers.exceptions.DoesNotStartWithValidNamespaceException;
diff --git a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java
index c28d5a7b..52aa470d 100644
--- a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java
+++ b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIToObjectTest.java
@@ -37,11 +37,9 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.aai.AAISetup;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.*;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.test.annotation.DirtiesContext;
diff --git a/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java b/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java
index 8ff021e0..7f6e5610 100644
--- a/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java
+++ b/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java
@@ -27,6 +27,8 @@ import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import com.google.gson.Gson;
+
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
@@ -44,8 +46,6 @@ import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import com.google.gson.Gson;
-
public class ValidationServiceTest {
private RestClient restClient;
@@ -77,62 +77,48 @@ public class ValidationServiceTest {
}
@Test
- public void testPreValidateWithSuccessRequestAndServiceIsDownAndShouldErrorWithConnectionRefused() throws IOException, AAIException {
+ public void testPreValidateWithSuccessRequestAndServiceIsDownAndShouldErrorWithConnectionRefused()
+ throws IOException, AAIException {
String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json");
- Mockito
- .when(
- restClient.execute(
- eq(ValidationService.VALIDATION_ENDPOINT),
- eq(HttpMethod.POST),
- any(),
- eq(pserverRequest)
- )
- ).thenThrow(new RuntimeException(new ConnectException("Connection refused")));
+ Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(),
+ eq(pserverRequest))).thenThrow(new RuntimeException(new ConnectException("Connection refused")));
validationService.preValidate(pserverRequest);
- assertThat(capture.toString(), containsString("Connection refused to the validation microservice due to service unreachable"));
+ assertThat(capture.toString(),
+ containsString("Connection refused to the validation microservice due to service unreachable"));
}
@Test
- public void testPreValidateWithSuccessRequestAndServiceIsUnreachableAndShouldErrorWithConnectionTimeout() throws IOException, AAIException {
+ public void testPreValidateWithSuccessRequestAndServiceIsUnreachableAndShouldErrorWithConnectionTimeout()
+ throws IOException, AAIException {
String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json");
- Mockito
- .when(
- restClient.execute(
- eq(ValidationService.VALIDATION_ENDPOINT),
- eq(HttpMethod.POST),
- any(),
- eq(pserverRequest)
- )
- ).thenThrow(new RuntimeException(new ConnectTimeoutException("Connection timed out")));
+ Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(),
+ eq(pserverRequest)))
+ .thenThrow(new RuntimeException(new ConnectTimeoutException("Connection timed out")));
validationService.preValidate(pserverRequest);
- assertThat(capture.toString(), containsString("Connection timeout to the validation microservice as this could indicate the server is unable to reach port"));
+ assertThat(capture.toString(), containsString(
+ "Connection timeout to the validation microservice as this could indicate the server is unable to reach port"));
}
@Test
- public void testPreValidateWithSuccessRequestAndRespondSuccessfullyWithinAllowedTime() throws IOException, AAIException {
+ public void testPreValidateWithSuccessRequestAndRespondSuccessfullyWithinAllowedTime()
+ throws IOException, AAIException {
String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json");
- String validationResponse = PayloadUtil.getResourcePayload("prevalidation/success-response-with-empty-violations.json");
+ String validationResponse =
+ PayloadUtil.getResourcePayload("prevalidation/success-response-with-empty-violations.json");
ResponseEntity responseEntity = Mockito.mock(ResponseEntity.class, Mockito.RETURNS_DEEP_STUBS);
- Mockito
- .when(
- restClient.execute(
- eq(ValidationService.VALIDATION_ENDPOINT),
- eq(HttpMethod.POST),
- any(),
- eq(pserverRequest)
- )
- ).thenReturn(responseEntity);
+ Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(),
+ eq(pserverRequest))).thenReturn(responseEntity);
Mockito.when(responseEntity.getStatusCodeValue()).thenReturn(200);
Mockito.when(responseEntity.getBody()).thenReturn(validationResponse);
@@ -145,23 +131,20 @@ public class ValidationServiceTest {
}
@Test
- public void testPreValidateWithSuccessRequestAndServiceIsAvailableAndRequestIsTakingTooLongAndClientShouldTimeout() throws IOException, AAIException {
+ public void testPreValidateWithSuccessRequestAndServiceIsAvailableAndRequestIsTakingTooLongAndClientShouldTimeout()
+ throws IOException, AAIException {
String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json");
- Mockito
- .when(
- restClient.execute(
- eq(ValidationService.VALIDATION_ENDPOINT),
- eq(HttpMethod.POST),
- any(),
- eq(pserverRequest)
- )
- ).thenThrow(new RuntimeException(new SocketTimeoutException("Request timed out due to taking longer than client expected")));
+ Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(),
+ eq(pserverRequest)))
+ .thenThrow(new RuntimeException(
+ new SocketTimeoutException("Request timed out due to taking longer than client expected")));
validationService.preValidate(pserverRequest);
- assertThat(capture.toString(), containsString("Request to validation service took longer than the currently set timeout"));
+ assertThat(capture.toString(),
+ containsString("Request to validation service took longer than the currently set timeout"));
}
@Test
@@ -173,13 +156,15 @@ public class ValidationServiceTest {
List<String> errorMessages = validationService.extractViolations(validation);
assertNotNull("Expected the error messages to be not null", errorMessages);
assertThat(errorMessages.size(), is(1));
- assertThat(errorMessages.get(0), is("Invalid nf values, check nf-type, nf-role, nf-function, and nf-naming-code"));
+ assertThat(errorMessages.get(0),
+ is("Invalid nf values, check nf-type, nf-role, nf-function, and nf-naming-code"));
}
@Test
public void testErrorMessagesAreEmptyListWhenViolationsReturnEmptyList() throws IOException {
- String genericVnfRequest = PayloadUtil.getResourcePayload("prevalidation/success-response-with-empty-violations.json");
+ String genericVnfRequest =
+ PayloadUtil.getResourcePayload("prevalidation/success-response-with-empty-violations.json");
Validation validation = gson.fromJson(genericVnfRequest, Validation.class);
List<String> errorMessages = validationService.extractViolations(validation);
@@ -190,7 +175,8 @@ public class ValidationServiceTest {
@Test
public void testErrorMessagesAreEmptyListWhenViolationsIsNotFoundInJson() throws IOException {
- String genericVnfRequest = PayloadUtil.getResourcePayload("prevalidation/success-response-with-exclude-violations.json");
+ String genericVnfRequest =
+ PayloadUtil.getResourcePayload("prevalidation/success-response-with-exclude-violations.json");
Validation validation = gson.fromJson(genericVnfRequest, Validation.class);
List<String> errorMessages = validationService.extractViolations(validation);
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
index 2d6e2291..c09c7b5c 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/ExcludeQueryTest.java
@@ -33,7 +33,6 @@ import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
index 6be9dc05..3803554f 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/GremlinTraversalTest.java
@@ -24,7 +24,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.introspection.ModelType;
public class GremlinTraversalTest extends QueryBuilderTestAbstraction {
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
index 44d812c3..6d10115a 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java
@@ -20,6 +20,15 @@
package org.onap.aai.query.builder;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -54,19 +63,11 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
-import static org.junit.Assert.*;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {ConfigConfiguration.class, QueryTestsConfigTranslator.class, NodeIngestor.class, EdgeIngestor.class,
- EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class, XmlFormatTransformerConfiguration.class})
+ EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class,
+ XmlFormatTransformerConfiguration.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@TestPropertySource(
properties = {"schema.translator.list = config", "schema.nodes.location=src/test/resources/onap/oxm",
@@ -121,12 +122,12 @@ public abstract class QueryBuilderTestAbstraction {
protected GraphTraversal<Vertex, Vertex> addVHelper(GraphTraversalSource gts, String label, Object... props) {
for (int i = 0; i < props.length; i++) {
if (props[i].equals(AAIProperties.NODE_TYPE)) {
- label = props[i+1].toString();
+ label = props[i + 1].toString();
}
}
GraphTraversal<Vertex, Vertex> v = gts.addV(label);
- for (int i = 0; i < props.length; i+=2) {
- v.property(props[i], props[i+1]);
+ for (int i = 0; i < props.length; i += 2) {
+ v.property(props[i], props[i + 1]);
}
return v;
}
@@ -148,8 +149,10 @@ public abstract class QueryBuilderTestAbstraction {
@Test
public void createEdgeLinterfaceToLogicalLinkTraversal() throws AAIException {
- Vertex lInterface = this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
- Vertex logicalLink = this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
+ Vertex lInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
+ Vertex logicalLink =
+ this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
@@ -164,8 +167,10 @@ public abstract class QueryBuilderTestAbstraction {
@SuppressWarnings("rawtypes")
@Test
public void createEdgeLinterfaceToLogicalLinkTraversal_tree() throws AAIException {
- Vertex lInterface = this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
- Vertex logicalLink = this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
+ Vertex lInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
+ Vertex logicalLink =
+ this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
QueryBuilder<Tree> tQ = getNewTreeTraversalWithTestEdgeRules(lInterface).createEdgeTraversal(EdgeType.COUSIN,
@@ -183,9 +188,12 @@ public abstract class QueryBuilderTestAbstraction {
@SuppressWarnings("rawtypes")
@Test
public void createEdgeLinterfaceToLogicalLinkTraversal_Path() throws AAIException {
- Vertex pInterface = this.addVHelper(g, "vertex", "aai-node-type", "p-interface", "interface-name", "p-interface-a").next();
- Vertex lInterface = this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
- Vertex logicalLink = this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
+ Vertex pInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "p-interface", "interface-name", "p-interface-a").next();
+ Vertex lInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
+ Vertex logicalLink =
+ this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
testEdgeSer.addEdge(g, lInterface, logicalLink);
testEdgeSer.addTreeEdge(g, pInterface, lInterface);
@@ -203,8 +211,10 @@ public abstract class QueryBuilderTestAbstraction {
@SuppressWarnings("rawtypes")
@Test
public void parentVertexTest() throws AAIException {
- Vertex pInterface = this.addVHelper(g, "vertex", "aai-node-type", "p-interface", "interface-name", "p-interface-a").next();
- Vertex lInterface = this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
+ Vertex pInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "p-interface", "interface-name", "p-interface-a").next();
+ Vertex lInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
testEdgeSer.addTreeEdge(g, pInterface, lInterface);
@@ -217,8 +227,10 @@ public abstract class QueryBuilderTestAbstraction {
@Test
public void createEdgeLinterfaceToLogicalLinkIntrospectorTraversal() throws AAIException {
- Vertex lInterface = this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
- Vertex logicalLink = this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
+ Vertex lInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
+ Vertex logicalLink =
+ this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
@@ -234,8 +246,10 @@ public abstract class QueryBuilderTestAbstraction {
@Test
public void createEdgeLinterfaceToLogicalLinkVertexToIntrospectorTraversal() throws AAIException {
- Vertex lInterface = this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
- Vertex logicalLink = this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
+ Vertex lInterface =
+ this.addVHelper(g, "vertex", "aai-node-type", "l-interface", "interface-name", "l-interface-a").next();
+ Vertex logicalLink =
+ this.addVHelper(g, "vertex", "aai-node-type", "logical-link", "link-name", "logical-link-a").next();
testEdgeSer.addEdge(g, lInterface, logicalLink, "sourceLInterface");
QueryBuilder<Vertex> tQ = getNewVertexTraversalWithTestEdgeRules(lInterface);
@@ -385,7 +399,7 @@ public abstract class QueryBuilderTestAbstraction {
this.addVHelper(g, "vertex", "aai-node-type", "vnfc", "vnfc-name", "b-name").next();
QueryBuilder<Vertex> tQ = new GremlinTraversal<>(loader, g);
- tQ.getVerticesByCommaSeperatedValue("vnfc-name","a-name, b-name");
+ tQ.getVerticesByCommaSeperatedValue("vnfc-name", "a-name, b-name");
List<Vertex> list = tQ.toList();
@@ -506,7 +520,8 @@ public abstract class QueryBuilderTestAbstraction {
public void edgeToVertexMultiRuleInTraversalTest() throws AAIException {
Vertex gvnf = this.addVHelper(g, "vertex", "aai-node-type", "generic-vnf", "vnf-id", "gvnf").next();
- Vertex complex = this.addVHelper(g, "vertex", "aai-node-type", "complex", "physical-location-id", "a-name").next();
+ Vertex complex =
+ this.addVHelper(g, "vertex", "aai-node-type", "complex", "physical-location-id", "a-name").next();
testEdgeSer.addEdge(g, gvnf, complex);
testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
@@ -581,7 +596,8 @@ public abstract class QueryBuilderTestAbstraction {
public void edgeTraversalMultiRuleInTraversalTest() throws AAIException {
Vertex gvnf = this.addVHelper(g, "vertex", "aai-node-type", "generic-vnf", "vnf-id", "gvnf").next();
- Vertex complex = this.addVHelper(g, "vertex", "aai-node-type", "complex", "physical-location-id", "a-name").next();
+ Vertex complex =
+ this.addVHelper(g, "vertex", "aai-node-type", "complex", "physical-location-id", "a-name").next();
Edge e1 = testEdgeSer.addEdge(g, gvnf, complex);
Edge e2 = testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
@@ -754,7 +770,8 @@ public abstract class QueryBuilderTestAbstraction {
QueryBuilder<Edge> tQ = getNewEdgeTraversalWithTestEdgeRules(gvnf);
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver");
- List<Vertex> list = tQ.createEdgeTraversalIfParameterIsPresent(EdgeType.COUSIN, "pserver", "vce", "optional").toList();
+ List<Vertex> list =
+ tQ.createEdgeTraversalIfParameterIsPresent(EdgeType.COUSIN, "pserver", "vce", "optional").toList();
assertEquals("Has 1 vertex ", 1, list.size());
assertTrue("result has optional-vce vertex ", list.contains(optionalVce));
}
@@ -775,14 +792,14 @@ public abstract class QueryBuilderTestAbstraction {
tQ.createEdgeTraversal(EdgeType.COUSIN, "generic-vnf", "pserver");
MissingOptionalParameter missingParameter = MissingOptionalParameter.getInstance();
- List<Vertex> list = tQ.createEdgeTraversalIfParameterIsPresent(EdgeType.COUSIN, "pserver", "vce", missingParameter).toList();
+ List<Vertex> list = tQ
+ .createEdgeTraversalIfParameterIsPresent(EdgeType.COUSIN, "pserver", "vce", missingParameter).toList();
assertEquals("Has 2 vertices ", 2, list.size());
assertTrue("result has pserver-1 vertex ", list.contains(pserver1));
assertTrue("result has pserver-2 vertex ", list.contains(pserver2));
assertTrue("result does not have optional-vce vertex ", !list.contains(optionalVce));
}
-
protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules(Vertex v);
protected abstract QueryBuilder<Edge> getNewEdgeTraversalWithTestEdgeRules();
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java
index 3661f3de..2a213f2e 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryTestsConfigTranslator.java
@@ -26,7 +26,6 @@ import org.onap.aai.AbstractConfigTranslator;
import org.onap.aai.setup.SchemaConfigVersions;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
/**
* So the query tests can access their edge rule file
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
index 4eac35eb..eca5c54e 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/TraversalQueryTest.java
@@ -20,6 +20,14 @@
package org.onap.aai.query.builder;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -32,14 +40,6 @@ import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class TraversalQueryTest extends QueryBuilderTestAbstraction {
@Override
@@ -242,7 +242,8 @@ public class TraversalQueryTest extends QueryBuilderTestAbstraction {
public void abstractEdgeToVertexMultiRuleInTraversalTest() throws AAIException {
Vertex gvnf = this.addVHelper(g, "vertex", "aai-node-type", "generic-vnf", "vnf-id", "gvnf").next();
- Vertex complex = this.addVHelper(g, "vertex", "aai-node-type", "complex", "physical-location-id", "a-name").next();
+ Vertex complex =
+ this.addVHelper(g, "vertex", "aai-node-type", "complex", "physical-location-id", "a-name").next();
testEdgeSer.addEdge(g, gvnf, complex);
testEdgeSer.addEdge(g, gvnf, complex, "complex-generic-vnf-B");
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java
index dcf11ba2..f0486e45 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/UntilTest.java
@@ -33,7 +33,6 @@ import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java
index b517ced2..f90bb5f2 100644
--- a/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/query/builder/optimization/AbstractGraphTraversalBuilderOptmizationTest.java
@@ -20,7 +20,16 @@
package org.onap.aai.query.builder.optimization;
+import static org.junit.Assert.assertEquals;
+
import com.google.common.base.CaseFormat;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -40,14 +49,6 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.springframework.beans.factory.annotation.Autowired;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-import static org.junit.Assert.assertEquals;
-
public abstract class AbstractGraphTraversalBuilderOptmizationTest extends AAISetup {
protected static final List<String> RANDOM_VALUES = Arrays.asList("A", "B", "C", "D", "E");
@@ -104,12 +105,10 @@ public abstract class AbstractGraphTraversalBuilderOptmizationTest extends AAISe
for (int crCtr = 0; crCtr < 3; crCtr++) {
crUri = String.format(crUriPattern, prefix + "cloud-owner-" + crCtr, prefix + "cloud-region-id-" + crCtr);
// System.out.println(crUri);
- cr = g.addV(CLOUD_REGION)
- .property(AAIProperties.NODE_TYPE, CLOUD_REGION)
- .property(CLOUD_REGION_ID, prefix + "cloud-region-id-" + crCtr)
- .property(CLOUD_OWNER, prefix + "cloud-owner-" + crCtr)
- .property(AAIProperties.AAI_URI, crUri)
- .next();
+ cr = g.addV(CLOUD_REGION).property(AAIProperties.NODE_TYPE, CLOUD_REGION)
+ .property(CLOUD_REGION_ID, prefix + "cloud-region-id-" + crCtr)
+ .property(CLOUD_OWNER, prefix + "cloud-owner-" + crCtr).property(AAIProperties.AAI_URI, crUri)
+ .next();
for (int i = 0; i < tenantNum; i++) {
Introspector intro = loader.introspectorFromName(TENANT);
tenant = dbser.createNewVertex(intro);
diff --git a/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java b/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java
index 34477206..8cf112ab 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/HPACapabilityTest.java
@@ -22,8 +22,6 @@ package org.onap.aai.rest;
import static org.junit.Assert.assertEquals;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.jayway.jsonpath.JsonPath;
import java.util.*;
@@ -40,6 +38,8 @@ import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Ignore
@RunWith(AAIJunitRunner.class)
diff --git a/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java
index 2b7a5818..e6664e1a 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java
@@ -20,8 +20,18 @@
package org.onap.aai.rest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.ws.rs.core.Response;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraphTransaction;
import org.json.JSONObject;
@@ -40,19 +50,10 @@ import org.onap.aai.rest.ueb.NotificationEvent;
import org.onap.aai.rest.ueb.UEBNotification;
import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.test.annotation.DirtiesContext;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.*;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class ImpliedDeleteIntegrationTest extends AAISetup {
@@ -64,10 +65,7 @@ public class ImpliedDeleteIntegrationTest extends AAISetup {
@Parameterized.Parameters(name = "QueryStyle.{0}")
public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {
- { QueryStyle.TRAVERSAL },
- { QueryStyle.TRAVERSAL_URI }
- });
+ return Arrays.asList(new Object[][] {{QueryStyle.TRAVERSAL}, {QueryStyle.TRAVERSAL_URI}});
}
@Test
@@ -102,10 +100,8 @@ public class ImpliedDeleteIntegrationTest extends AAISetup {
List<NotificationEvent> notificationEvents = notification.getEvents();
assertThat(notificationEvents.size(), is(5));
- List<String> notificationEventHeaders = notification.getEvents()
- .stream()
- .map(event -> event.getEventHeader().marshal(false))
- .collect(Collectors.toList());
+ List<String> notificationEventHeaders = notification.getEvents().stream()
+ .map(event -> event.getEventHeader().marshal(false)).collect(Collectors.toList());
Long deletedEventsCount = notificationEventHeaders.stream().filter(e -> e.contains("\"DELETE\"")).count();
diff --git a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
index 16783180..cafca63f 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
@@ -17,10 +17,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.rest;
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.junit.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+
+import javax.ws.rs.core.Response;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
@@ -45,15 +57,6 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.test.annotation.DirtiesContext;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.*;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.junit.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class NotificationDmaapEventTest extends AAISetup {
@@ -63,14 +66,12 @@ public class NotificationDmaapEventTest extends AAISetup {
@Parameterized.Parameters(name = "QueryStyle.{0}")
public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {
- { QueryStyle.TRAVERSAL },
- { QueryStyle.TRAVERSAL_URI }
- });
+ return Arrays.asList(new Object[][] {{QueryStyle.TRAVERSAL}, {QueryStyle.TRAVERSAL_URI}});
}
@Test
- public void testCreateWithPserverWithAllChildrenAndVerifyMultipleNotificationsWhenNotificationDepthIsZero() throws IOException, AAIException {
+ public void testCreateWithPserverWithAllChildrenAndVerifyMultipleNotificationsWhenNotificationDepthIsZero()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -93,15 +94,9 @@ public class NotificationDmaapEventTest extends AAISetup {
String header = event.getEventHeader().marshal(false);
- assertThat(
- event.getEventHeader().marshal(false),
- containsString("\"CREATE\"")
- );
+ assertThat(event.getEventHeader().marshal(false), containsString("\"CREATE\""));
- assertThat(
- header,
- containsString("\"top-entity-type\":\"pserver\"")
- );
+ assertThat(header, containsString("\"top-entity-type\":\"pserver\""));
});
@@ -111,7 +106,8 @@ public class NotificationDmaapEventTest extends AAISetup {
// Test existing pserver create new pinterface check dmaap event for pinterface is CREATE
@Test
- public void testExistingPserverCreateNewChildPInterfaceAndCheckDmaapEventForPInterfaceIsCreateWhenNotificationDepthIsZero() throws IOException, AAIException {
+ public void testExistingPserverCreateNewChildPInterfaceAndCheckDmaapEventForPInterfaceIsCreateWhenNotificationDepthIsZero()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -126,8 +122,7 @@ public class NotificationDmaapEventTest extends AAISetup {
assertEquals("Expecting the pserver to be created", 201, response.getStatus());
notification.clearEvents();
-
- response = httpTestUtil.doGet(uri , "all");
+ response = httpTestUtil.doGet(uri, "all");
assertEquals("Expecting the pserver to be found", 200, response.getStatus());
JSONObject pserverJson = new JSONObject(response.getEntity().toString());
@@ -153,15 +148,18 @@ public class NotificationDmaapEventTest extends AAISetup {
assertThat(notificationEventHeader, containsString("\"entity-type\":\"p-interface\""));
assertThat(notificationEventHeader, containsString("\"top-entity-type\":\"pserver\""));
- String expectedNotificationHeader = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-zero/expected-notification-header-create-child-on-existing-obj.json");
- String expectedNotificationBody = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-zero/expected-notification-body-create-child-on-existing-obj.json");
+ String expectedNotificationHeader = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-zero/expected-notification-header-create-child-on-existing-obj.json");
+ String expectedNotificationBody = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-zero/expected-notification-body-create-child-on-existing-obj.json");
JSONAssert.assertEquals(expectedNotificationHeader, notificationEventHeader, false);
JSONAssert.assertEquals(expectedNotificationBody, notificationEventBody, false);
}
@Test
- public void testExistingPserverCreateNewChildPInterfaceAndCheckDmaapEventForPserverIsSentWithNewPInterfaceWhenNotificationDepthIsAll() throws IOException, AAIException {
+ public void testExistingPserverCreateNewChildPInterfaceAndCheckDmaapEventForPserverIsSentWithNewPInterfaceWhenNotificationDepthIsAll()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -175,7 +173,7 @@ public class NotificationDmaapEventTest extends AAISetup {
response = httpTestUtil.doPut(uri, pserverResource);
assertEquals("Expecting the pserver to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(uri , "all");
+ response = httpTestUtil.doGet(uri, "all");
assertEquals("Expecting the pserver to be found", 200, response.getStatus());
JSONObject pserverJson = new JSONObject(response.getEntity().toString());
@@ -203,8 +201,10 @@ public class NotificationDmaapEventTest extends AAISetup {
assertThat(notificationEventHeader, containsString("\"entity-type\":\"pserver\""));
assertThat(notificationEventHeader, containsString("\"top-entity-type\":\"pserver\""));
- String expectedNotificationHeader = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-all/expected-notification-header-create-child-on-existing-obj.json");
- String expectedNotificationBody = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-all/expected-notification-body-create-child-on-existing-obj.json");
+ String expectedNotificationHeader = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-all/expected-notification-header-create-child-on-existing-obj.json");
+ String expectedNotificationBody = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-all/expected-notification-body-create-child-on-existing-obj.json");
JSONAssert.assertEquals(expectedNotificationHeader, notificationEventHeader, false);
JSONAssert.assertEquals(expectedNotificationBody, notificationEventBody, false);
@@ -215,20 +215,19 @@ public class NotificationDmaapEventTest extends AAISetup {
// After an pserver's p-interface is updated on the pserver, even though
// the pserver nothing changed, expecting the pserver resource version to be changed
- assertThat(
- "Expecting the new pserver resource version and old resource version to be not same",
- newPserverResourceVersion,
- is(not(pserverResourceVersion))
- );
+ assertThat("Expecting the new pserver resource version and old resource version to be not same",
+ newPserverResourceVersion, is(not(pserverResourceVersion)));
assertEquals("Expecting the p-interface to be found", 200, response.getStatus());
}
// Test Bulk Scenario
@Test
- public void testBulkScenarioWhereMultipleCreatesAndEnsureNoDuplicationInDmaapEventsWhenNotificationDepthIsZero() throws UnsupportedEncodingException, AAIException {
+ public void testBulkScenarioWhereMultipleCreatesAndEnsureNoDuplicationInDmaapEventsWhenNotificationDepthIsZero()
+ throws UnsupportedEncodingException, AAIException {
String pserverUri = "/aai/v14/cloud-infrastructure/pservers/pserver/random-pserver";
- String cloudRegionUri = "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/random-cloud-region-owner/random-cloud-region-id";
+ String cloudRegionUri =
+ "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/random-cloud-region-owner/random-cloud-region-id";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MINIMUM_DEPTH);
@@ -252,12 +251,13 @@ public class NotificationDmaapEventTest extends AAISetup {
});
}
-
@Test
- public void testBulkScenarioWhereMultipleCreatesAndEnsureNoDuplicationInDmaapEventsWhenNotificationDepthIsAll() throws UnsupportedEncodingException, AAIException {
+ public void testBulkScenarioWhereMultipleCreatesAndEnsureNoDuplicationInDmaapEventsWhenNotificationDepthIsAll()
+ throws UnsupportedEncodingException, AAIException {
String pserverUri = "/aai/v14/cloud-infrastructure/pservers/pserver/random-pserver";
- String cloudRegionUri = "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/random-cloud-region-owner/random-cloud-region-id";
+ String cloudRegionUri =
+ "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/random-cloud-region-owner/random-cloud-region-id";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH);
@@ -282,7 +282,8 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testDeleteOnExistingPserverAndCheckIfNotificationDepthIsZeroThatAllEventsHaveDeleteAndThatDepthIsZeroOnEachNotificationEvent() throws IOException, AAIException {
+ public void testDeleteOnExistingPserverAndCheckIfNotificationDepthIsZeroThatAllEventsHaveDeleteAndThatDepthIsZeroOnEachNotificationEvent()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle);
@@ -295,7 +296,7 @@ public class NotificationDmaapEventTest extends AAISetup {
response = httpTestUtil.doPut(uri, pserverResource);
assertEquals("Expecting the pserver to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(uri , "all");
+ response = httpTestUtil.doGet(uri, "all");
assertEquals("Expecting the pserver to be found", 200, response.getStatus());
JSONObject pserverObject = new JSONObject(response.getEntity().toString());
@@ -312,19 +313,12 @@ public class NotificationDmaapEventTest extends AAISetup {
String header = event.getEventHeader().marshal(false);
- assertThat(
- event.getEventHeader().marshal(false),
- containsString("\"DELETE\"")
- );
+ assertThat(event.getEventHeader().marshal(false), containsString("\"DELETE\""));
- assertThat(
- header,
- containsString("\"top-entity-type\":\"pserver\"")
- );
+ assertThat(header, containsString("\"top-entity-type\":\"pserver\""));
});
}
-
@Test
public void testDeleteOnExistingResourceVersionMismatchNoEventGenerated() throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
@@ -339,27 +333,27 @@ public class NotificationDmaapEventTest extends AAISetup {
response = httpTestUtil.doPut(uri, pserverResource);
assertEquals("Expecting the pserver to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(uri , "all");
+ response = httpTestUtil.doGet(uri, "all");
assertEquals("Expecting the pserver to be found", 200, response.getStatus());
JSONObject pserverObject = new JSONObject(response.getEntity().toString());
String resourceVersion = pserverObject.getString("resource-version");
httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MINIMUM_DEPTH);
- response = httpTestUtil.doDelete(uri, resourceVersion+"123");
+ response = httpTestUtil.doDelete(uri, resourceVersion + "123");
assertEquals("Resource version mismatch exception", 412, response.getStatus());
List<NotificationEvent> notificationEvents = notification.getEvents();
assertThat(notificationEvents.size(), is(0));
}
-
// Test notification depth set to all
// Scenario for testing the creation of pserver with children, grandchildren
// Default behaviour is for one event to be sent out
// which includes all the children and grandchildren, etc
@Test
- public void testCreateWithPserverWithAllChildrenAndVerifyOneNotificationWhenNotificationDepthIsAll() throws IOException, AAIException {
+ public void testCreateWithPserverWithAllChildrenAndVerifyOneNotificationWhenNotificationDepthIsAll()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -380,25 +374,13 @@ public class NotificationDmaapEventTest extends AAISetup {
// Verify all the events are create since its a new PUT
String header = notificationEvent.getEventHeader().marshal(false);
- assertThat(
- header,
- containsString("\"CREATE\"")
- );
+ assertThat(header, containsString("\"CREATE\""));
- assertThat(
- header,
- containsString("\"entity-type\":\"pserver\"")
- );
+ assertThat(header, containsString("\"entity-type\":\"pserver\""));
- assertThat(
- header,
- containsString("\"top-entity-type\":\"pserver\"")
- );
+ assertThat(header, containsString("\"top-entity-type\":\"pserver\""));
- assertThat(
- header,
- containsString("\"entity-link\":\"" + uri + "\"")
- );
+ assertThat(header, containsString("\"entity-link\":\"" + uri + "\""));
response = httpTestUtil.doGet(uri);
assertEquals("Expecting the pserver to be found", 200, response.getStatus());
@@ -407,7 +389,8 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testPatchExistingPserverWithChildrenAndModifyOnlyOneObjectAndVerifyThatOnlyOneNotificationEventNoChildrenWhenNotificationDepthIsZero() throws IOException, AAIException {
+ public void testPatchExistingPserverWithChildrenAndModifyOnlyOneObjectAndVerifyThatOnlyOneNotificationEventNoChildrenWhenNotificationDepthIsZero()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -443,7 +426,8 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testPatchExistingPserverWithChildrenAndModifyOnlyOneObjectAndVerifyThatOnlyOneNotificationEventIncludeChildrenWhenNotificationDepthIsAll() throws IOException, AAIException {
+ public void testPatchExistingPserverWithChildrenAndModifyOnlyOneObjectAndVerifyThatOnlyOneNotificationEventIncludeChildrenWhenNotificationDepthIsAll()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -482,7 +466,8 @@ public class NotificationDmaapEventTest extends AAISetup {
// Scenario where we are only updating one field in p-interface
// Make sure the parent and children are included
@Test
- public void testUpdateExistingPserverWithChildrenAndModifyOnlyOneObjectAndVerifyThatOnlyOneNotificationEventIncludingChildrenWhenNotificationDepthIsAll() throws IOException, AAIException {
+ public void testUpdateExistingPserverWithChildrenAndModifyOnlyOneObjectAndVerifyThatOnlyOneNotificationEventIncludingChildrenWhenNotificationDepthIsAll()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -506,7 +491,8 @@ public class NotificationDmaapEventTest extends AAISetup {
pInterfaceObject.put("equipment-identifier", "new-equipment-identifier");
httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH);
- response = httpTestUtil.doPut(uri + "/p-interfaces/p-interface/example-interface-name-val-46147", pInterfaceObject.toString());
+ response = httpTestUtil.doPut(uri + "/p-interfaces/p-interface/example-interface-name-val-46147",
+ pInterfaceObject.toString());
assertThat(response.getStatus(), is(200));
// Get the parent uri as the notification event json has parent structure it makes it easy to compare
@@ -524,7 +510,8 @@ public class NotificationDmaapEventTest extends AAISetup {
// Test notification depth set to 0
// Scenario where we are only updating one field in p-interface
@Test
- public void testUpdateExistingPserverWithChildrenAndModifyOnlyPInterfaceAndVerifyThatOnlyOneNotificationForPInterfaceIsCreatedWhenNotificationDepthIsZero() throws IOException, AAIException {
+ public void testUpdateExistingPserverWithChildrenAndModifyOnlyPInterfaceAndVerifyThatOnlyOneNotificationForPInterfaceIsCreatedWhenNotificationDepthIsZero()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
@@ -548,7 +535,8 @@ public class NotificationDmaapEventTest extends AAISetup {
pInterfaceObject.put("equipment-identifier", "new-equipment-identifier");
httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MINIMUM_DEPTH);
- response = httpTestUtil.doPut(uri + "/p-interfaces/p-interface/example-interface-name-val-46147", pInterfaceObject.toString());
+ response = httpTestUtil.doPut(uri + "/p-interfaces/p-interface/example-interface-name-val-46147",
+ pInterfaceObject.toString());
assertThat(response.getStatus(), is(200));
response = httpTestUtil.doGet(uri);
@@ -562,7 +550,8 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testExistingPserverWithChildAndGenericVnfAndCreateEdgeBetweenThemAndCheckNoChildWhenNotificationDepthIsZero() throws IOException, AAIException {
+ public void testExistingPserverWithChildAndGenericVnfAndCreateEdgeBetweenThemAndCheckNoChildWhenNotificationDepthIsZero()
+ throws IOException, AAIException {
String hostname = "example-hostname-val-85598";
@@ -604,11 +593,14 @@ public class NotificationDmaapEventTest extends AAISetup {
List<NotificationEvent> notificationEvents = notification.getEvents();
assertThat(notificationEvents.size(), is(2));
- String expectedNotificationHeader = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-zero/expected-notification-header-create-edge-between-pserver-and-generic-vnf.json");
- String expectedNotificationBody = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-zero/expected-notification-body-create-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationHeader = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-zero/expected-notification-header-create-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationBody = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-zero/expected-notification-body-create-edge-between-pserver-and-generic-vnf.json");
- JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), false);
- JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
+ JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false),
+ false);
+ JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
response = httpTestUtil.doGet(genericVnfUri);
@@ -617,7 +609,8 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testExistingPserverWithChildAndGenericVnfAndCreateEdgeBetweenThemAndCheckChildrenIncludedWhenNotificationDepthIsAll() throws IOException, AAIException {
+ public void testExistingPserverWithChildAndGenericVnfAndCreateEdgeBetweenThemAndCheckChildrenIncludedWhenNotificationDepthIsAll()
+ throws IOException, AAIException {
String hostname = "example-hostname-val-85598";
@@ -659,12 +652,15 @@ public class NotificationDmaapEventTest extends AAISetup {
List<NotificationEvent> notificationEvents = notification.getEvents();
assertThat(notificationEvents.size(), is(2));
- String expectedNotificationHeader = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-all/expected-notification-header-create-edge-between-pserver-and-generic-vnf.json");
- String expectedNotificationBody = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-all/expected-notification-body-create-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationHeader = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-all/expected-notification-header-create-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationBody = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-all/expected-notification-body-create-edge-between-pserver-and-generic-vnf.json");
System.out.println("Notification Body: " + notificationEvents.get(0).getObj().marshal(false));
- JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), false);
- JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
+ JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false),
+ false);
+ JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
response = httpTestUtil.doGet(genericVnfUri);
@@ -673,7 +669,8 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testExistingPserverWithChildAndGenericVnfAndExistingEdgeBetweenThemAndDeleteEdgeAndCheckNoChildWhenNotificationDepthIsZero() throws IOException, AAIException {
+ public void testExistingPserverWithChildAndGenericVnfAndExistingEdgeBetweenThemAndDeleteEdgeAndCheckNoChildWhenNotificationDepthIsZero()
+ throws IOException, AAIException {
String hostname = "example-hostname-val-85598";
@@ -707,7 +704,6 @@ public class NotificationDmaapEventTest extends AAISetup {
assertEquals("Expecting the generic-vnf to be found", 200, response.getStatus());
assertThat(response.getEntity().toString(), not(containsString(hostname)));
-
response = httpTestUtil.doPut(pserverUri + "/relationship-list/relationship", relationship);
assertEquals("Expecting the pserver to generic-vnf relationship to be created", 200, response.getStatus());
@@ -734,16 +730,20 @@ public class NotificationDmaapEventTest extends AAISetup {
assertThat(notificationEvents.size(), is(2));
- String expectedNotificationHeader = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-zero/expected-notification-header-delete-edge-between-pserver-and-generic-vnf.json");
- String expectedNotificationBody = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-zero/expected-notification-body-delete-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationHeader = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-zero/expected-notification-header-delete-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationBody = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-zero/expected-notification-body-delete-edge-between-pserver-and-generic-vnf.json");
- JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), false);
- JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
+ JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false),
+ false);
+ JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
}
@Test
- public void testExistingPserverWithChildAndGenericVnfAndExistingEdgeBetweenThemAndDeleteEdgeAndCheckChildrenWhenNotificationDepthIsAll() throws IOException, AAIException {
+ public void testExistingPserverWithChildAndGenericVnfAndExistingEdgeBetweenThemAndDeleteEdgeAndCheckChildrenWhenNotificationDepthIsAll()
+ throws IOException, AAIException {
String hostname = "example-hostname-val-85598";
@@ -777,7 +777,6 @@ public class NotificationDmaapEventTest extends AAISetup {
assertEquals("Expecting the generic-vnf to be found", 200, response.getStatus());
assertThat(response.getEntity().toString(), not(containsString(hostname)));
-
response = httpTestUtil.doPut(pserverUri + "/relationship-list/relationship", relationship);
assertEquals("Expecting the pserver to generic-vnf relationship to be created", 200, response.getStatus());
@@ -803,16 +802,20 @@ public class NotificationDmaapEventTest extends AAISetup {
List<NotificationEvent> notificationEvents = notification.getEvents();
assertThat(notificationEvents.size(), is(2));
- String expectedNotificationHeader = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-all/expected-notification-header-delete-edge-between-pserver-and-generic-vnf.json");
- String expectedNotificationBody = PayloadUtil.getResourcePayload("notification-dmaap-events/depth-all/expected-notification-body-delete-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationHeader = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-all/expected-notification-header-delete-edge-between-pserver-and-generic-vnf.json");
+ String expectedNotificationBody = PayloadUtil.getResourcePayload(
+ "notification-dmaap-events/depth-all/expected-notification-body-delete-edge-between-pserver-and-generic-vnf.json");
- JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), false);
- JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
+ JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false),
+ false);
+ JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false);
}
@Test
- public void testDeleteOnExistingResourceVersionMismatchNoEventGeneratedFullDepth() throws IOException, AAIException {
+ public void testDeleteOnExistingResourceVersionMismatchNoEventGeneratedFullDepth()
+ throws IOException, AAIException {
String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598";
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle);
@@ -825,14 +828,14 @@ public class NotificationDmaapEventTest extends AAISetup {
response = httpTestUtil.doPut(uri, pserverResource);
assertEquals("Expecting the pserver to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(uri , "all");
+ response = httpTestUtil.doGet(uri, "all");
assertEquals("Expecting the pserver to be found", 200, response.getStatus());
JSONObject pserverObject = new JSONObject(response.getEntity().toString());
String resourceVersion = pserverObject.getString("resource-version");
httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH);
- response = httpTestUtil.doDelete(uri, resourceVersion+"123");
+ response = httpTestUtil.doDelete(uri, resourceVersion + "123");
assertEquals("Resource version mismatch exception", 412, response.getStatus());
List<NotificationEvent> notificationEvents = notification.getEvents();
@@ -840,70 +843,74 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testCreateVnfWithChildrenCreateCustomerWithChildrenAndCousinBetweenVlanAndServiceInstanceThenDeleteCustomerVerifyingVlanRV() throws IOException, AAIException {
+ public void testCreateVnfWithChildrenCreateCustomerWithChildrenAndCousinBetweenVlanAndServiceInstanceThenDeleteCustomerVerifyingVlanRV()
+ throws IOException, AAIException {
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle);
- JsonObject paylaods = new JsonParser().parse(
- PayloadUtil.getResourcePayload("customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json"))
- .getAsJsonObject();
+ JsonObject paylaods = new JsonParser().parse(PayloadUtil.getResourcePayload(
+ "customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json"))
+ .getAsJsonObject();
String gvnfPaylaod = paylaods.get("generic-vnf").toString();
String custPaylaod = paylaods.get("customer").toString();
String gvnfUri = "/aai/v14/network/generic-vnfs/generic-vnf/gvnf";
String custUri = "/aai/v14/business/customers/customer/cust";
String vlanUri = "/aai/v14/network/generic-vnfs/generic-vnf/gvnf/l-interfaces/l-interface/lint/vlans/vlan/vlan";
- //Setup generic vnf
+ // Setup generic vnf
Response response = httpTestUtil.doGet(gvnfUri);
assertEquals("Expecting the generic-vnf to be not found", 404, response.getStatus());
response = httpTestUtil.doPut(gvnfUri, gvnfPaylaod);
assertEquals("Expecting the generic-vnf to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(gvnfUri , "all");
+ response = httpTestUtil.doGet(gvnfUri, "all");
assertEquals("Expecting the generic-vnf to be found", 200, response.getStatus());
- response = httpTestUtil.doGet(vlanUri , "all");
+ response = httpTestUtil.doGet(vlanUri, "all");
assertEquals("Expecting the vlan to be found", 200, response.getStatus());
String vlanResourceVersion = new JSONObject(response.getEntity().toString()).getString("resource-version");
- //Setup customer with service instance relation to vlan
+ // Setup customer with service instance relation to vlan
response = httpTestUtil.doGet(custUri);
assertEquals("Expecting the customer to be not found", 404, response.getStatus());
response = httpTestUtil.doPut(custUri, custPaylaod);
assertEquals("Expecting the customer to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(custUri , "all");
+ response = httpTestUtil.doGet(custUri, "all");
assertEquals("Expecting the customer to be found", 200, response.getStatus());
String custResourceVersion = new JSONObject(response.getEntity().toString()).getString("resource-version");
- //Verify vlan rv was updated
- response = httpTestUtil.doGet(vlanUri , "all");
+ // Verify vlan rv was updated
+ response = httpTestUtil.doGet(vlanUri, "all");
assertEquals("Expecting the vlan to be found", 200, response.getStatus());
- String vlanResourceVersionAfterCustPut = new JSONObject(response.getEntity().toString()).getString("resource-version");
- assertThat("Expecting the vlan resource version to be updated", vlanResourceVersionAfterCustPut, not(is(vlanResourceVersion)));
+ String vlanResourceVersionAfterCustPut =
+ new JSONObject(response.getEntity().toString()).getString("resource-version");
+ assertThat("Expecting the vlan resource version to be updated", vlanResourceVersionAfterCustPut,
+ not(is(vlanResourceVersion)));
- //Delete customer
+ // Delete customer
notification.clearEvents();
httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH);
response = httpTestUtil.doDelete(custUri, custResourceVersion);
assertEquals("Expecting customer to be deleted", 204, response.getStatus());
- //Verify vlan rv was updated
- response = httpTestUtil.doGet(vlanUri , "all");
+ // Verify vlan rv was updated
+ response = httpTestUtil.doGet(vlanUri, "all");
assertEquals("Expecting the vlan to be found", 200, response.getStatus());
- String vlanResourceVersionAfterDelete = new JSONObject(response.getEntity().toString()).getString("resource-version");
- assertThat("Expecting the vlan resource version to be updated", vlanResourceVersionAfterDelete, not(is(vlanResourceVersionAfterCustPut)));
+ String vlanResourceVersionAfterDelete =
+ new JSONObject(response.getEntity().toString()).getString("resource-version");
+ assertThat("Expecting the vlan resource version to be updated", vlanResourceVersionAfterDelete,
+ not(is(vlanResourceVersionAfterCustPut)));
List<NotificationEvent> notificationEvents = notification.getEvents();
- assertThat("Expect the delete to generate 4 events customer, its children and vlan", notificationEvents.size(), is(4));
+ assertThat("Expect the delete to generate 4 events customer, its children and vlan", notificationEvents.size(),
+ is(4));
}
-
@Test
public void testBulkCreateOfComplexAndPserverWithRelationshipThenBulkDeleteBoth() throws IOException, AAIException {
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH);
- JsonObject paylaods = new JsonParser().parse(
- PayloadUtil.getResourcePayload("complex_pserver_with_relation.json"))
- .getAsJsonObject();
+ JsonObject paylaods = new JsonParser()
+ .parse(PayloadUtil.getResourcePayload("complex_pserver_with_relation.json")).getAsJsonObject();
String complexPaylaod = paylaods.get("complex").toString();
String pserverPaylaod = paylaods.get("pserver").toString();
String complexUri = "/aai/v14/cloud-infrastructure/complexes/complex/complex-1";
@@ -914,17 +921,17 @@ public class NotificationDmaapEventTest extends AAISetup {
response = httpTestUtil.doGet(pserverUri);
assertEquals("Expecting the pserver to be not found", 404, response.getStatus());
- Map<String,String> puts = new LinkedHashMap<>();
+ Map<String, String> puts = new LinkedHashMap<>();
puts.put(complexUri, complexPaylaod);
puts.put(pserverUri, pserverPaylaod);
response = httpTestUtil.doPut(puts);
assertEquals("Expecting the puts request to succeed", 201, response.getStatus());
assertEquals("Expect 2 messages to be created", 2, notification.getEvents().size());
- response = httpTestUtil.doGet(complexUri , "all");
+ response = httpTestUtil.doGet(complexUri, "all");
assertEquals("Expecting the complex to be found", 200, response.getStatus());
String complexRV = new JSONObject(response.getEntity().toString()).getString("resource-version");
- response = httpTestUtil.doGet(pserverUri , "all");
+ response = httpTestUtil.doGet(pserverUri, "all");
assertEquals("Expecting the pserver to be found", 200, response.getStatus());
String pserverRv = new JSONObject(response.getEntity().toString()).getString("resource-version");
assertThat("Resource versions match", complexRV, is(pserverRv));
@@ -943,13 +950,14 @@ public class NotificationDmaapEventTest extends AAISetup {
}
@Test
- public void testCreateVnfWithChildrenCreateCustomerWithChildrenAndCousinBetweenVlanAndServiceInstanceThenImplicitDeleteVlanVerifyingServiceInstanceRV() throws IOException, AAIException {
+ public void testCreateVnfWithChildrenCreateCustomerWithChildrenAndCousinBetweenVlanAndServiceInstanceThenImplicitDeleteVlanVerifyingServiceInstanceRV()
+ throws IOException, AAIException {
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle);
- JsonObject paylaods = new JsonParser().parse(
- PayloadUtil.getResourcePayload("customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json"))
- .getAsJsonObject();
+ JsonObject paylaods = new JsonParser().parse(PayloadUtil.getResourcePayload(
+ "customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json"))
+ .getAsJsonObject();
String gvnfPaylaod = paylaods.get("generic-vnf").toString();
String custPaylaod = paylaods.get("customer").toString();
String custUri = "/aai/v14/business/customers/customer/cust";
@@ -959,36 +967,39 @@ public class NotificationDmaapEventTest extends AAISetup {
String lintUri = gvnfUri + "/l-interfaces/l-interface/lint";
String vlanUri = lintUri + "/vlans/vlan/vlan";
- //Setup generic vnf
+ // Setup generic vnf
Response response = httpTestUtil.doGet(gvnfUri);
assertEquals("Expecting the generic-vnf to be not found", 404, response.getStatus());
response = httpTestUtil.doPut(gvnfUri, gvnfPaylaod);
assertEquals("Expecting the generic-vnf to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(gvnfUri , "all");
+ response = httpTestUtil.doGet(gvnfUri, "all");
assertEquals("Expecting the generic-vnf to be found", 200, response.getStatus());
- response = httpTestUtil.doGet(vlanUri , "all");
+ response = httpTestUtil.doGet(vlanUri, "all");
assertEquals("Expecting the vlan to be found", 200, response.getStatus());
String vlanResourceVersion = new JSONObject(response.getEntity().toString()).getString("resource-version");
- //Setup customer with service instance relation to vlan
+ // Setup customer with service instance relation to vlan
response = httpTestUtil.doGet(custUri);
assertEquals("Expecting the customer to be not found", 404, response.getStatus());
response = httpTestUtil.doPut(custUri, custPaylaod);
assertEquals("Expecting the customer to be created", 201, response.getStatus());
- response = httpTestUtil.doGet(custUri , "all");
+ response = httpTestUtil.doGet(custUri, "all");
assertEquals("Expecting the customer to be found", 200, response.getStatus());
- response = httpTestUtil.doGet(siUri , "all");
+ response = httpTestUtil.doGet(siUri, "all");
assertEquals("Expecting the service-instance to be found", 200, response.getStatus());
- String serviceInstanceResourceVersion = new JSONObject(response.getEntity().toString()).getString("resource-version");
+ String serviceInstanceResourceVersion =
+ new JSONObject(response.getEntity().toString()).getString("resource-version");
- //Verify vlan rv was updated
- response = httpTestUtil.doGet(vlanUri , "all");
+ // Verify vlan rv was updated
+ response = httpTestUtil.doGet(vlanUri, "all");
assertEquals("Expecting the vlan to be found", 200, response.getStatus());
- String vlanResourceVersionAfterCustPut = new JSONObject(response.getEntity().toString()).getString("resource-version");
- assertThat("Expecting the vlan resource version to be updated", vlanResourceVersionAfterCustPut, not(is(vlanResourceVersion)));
+ String vlanResourceVersionAfterCustPut =
+ new JSONObject(response.getEntity().toString()).getString("resource-version");
+ assertThat("Expecting the vlan resource version to be updated", vlanResourceVersionAfterCustPut,
+ not(is(vlanResourceVersion)));
- //Get linterface, replace vlans with empty json (implicit delete) and put triggering implicit delete
- response = httpTestUtil.doGet(lintUri , "all");
+ // Get linterface, replace vlans with empty json (implicit delete) and put triggering implicit delete
+ response = httpTestUtil.doGet(lintUri, "all");
assertEquals("Expecting the l-interface to be found", 200, response.getStatus());
JSONObject lintJson = new JSONObject(response.getEntity().toString());
lintJson.put("vlans", new JsonObject());
@@ -1000,15 +1011,15 @@ public class NotificationDmaapEventTest extends AAISetup {
List<NotificationEvent> notificationEvents = notification.getEvents();
assertThat("Expect the implied delete to generate 2", notificationEvents.size(), is(2));
- //Verify vlan is no longer there anf get service-instance and compare rv
- response = httpTestUtil.doGet(vlanUri , "all");
+ // Verify vlan is no longer there anf get service-instance and compare rv
+ response = httpTestUtil.doGet(vlanUri, "all");
assertEquals("Expecting the vlan not to be found", 404, response.getStatus());
- response = httpTestUtil.doGet(siUri , "all");
+ response = httpTestUtil.doGet(siUri, "all");
assertEquals("Expecting the service-instance to be found", 200, response.getStatus());
- String serviceInstanceResourceVersionAfterImplicitDelete = new JSONObject(response.getEntity().toString()).getString("resource-version");
+ String serviceInstanceResourceVersionAfterImplicitDelete =
+ new JSONObject(response.getEntity().toString()).getString("resource-version");
assertThat("Expecting the service-instance resource version to be updated after implicit delete of vlan",
- serviceInstanceResourceVersionAfterImplicitDelete,
- not(is(serviceInstanceResourceVersion)));
+ serviceInstanceResourceVersionAfterImplicitDelete, not(is(serviceInstanceResourceVersion)));
}
@After
@@ -1019,9 +1030,7 @@ public class NotificationDmaapEventTest extends AAISetup {
GraphTraversalSource g = transaction.traversal();
- g.V()
- .has(AAIProperties.SOURCE_OF_TRUTH, "JUNIT")
- .forEachRemaining(Vertex::remove);
+ g.V().has(AAIProperties.SOURCE_OF_TRUTH, "JUNIT").forEachRemaining(Vertex::remove);
transaction.commit();
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/PrivateEdgeIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/rest/PrivateEdgeIntegrationTest.java
index 8753b1b8..13611aba 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/PrivateEdgeIntegrationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/PrivateEdgeIntegrationTest.java
@@ -21,7 +21,6 @@
package org.onap.aai.rest;
import static junit.framework.TestCase.fail;
-
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -30,8 +29,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.jayway.jsonpath.JsonPath;
import java.util.*;
@@ -52,6 +49,8 @@ import org.onap.aai.PayloadUtil;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.setup.SchemaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.test.annotation.DirtiesContext;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
diff --git a/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java b/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java
index 5f23a278..2afa6036 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/PserverDuplicateTest.java
@@ -32,7 +32,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
+
import javax.ws.rs.core.Response;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
diff --git a/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java b/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java
index 80ced5ea..6e2c2ab2 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/PserverTest.java
@@ -20,9 +20,21 @@
package org.onap.aai.rest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static junit.framework.TestCase.fail;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import com.jayway.jsonpath.JsonPath;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.After;
@@ -39,20 +51,10 @@ import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.engines.QueryStyle;
import org.skyscreamer.jsonassert.JSONAssert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.test.annotation.DirtiesContext;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import static junit.framework.TestCase.fail;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class PserverTest extends AAISetup {
@@ -79,7 +81,8 @@ public class PserverTest extends AAISetup {
public void testPutPserverCreateGetInXmlForFormats() throws Exception {
httpTestUtil = new HttpTestUtil(queryStyle, "application/xml");
String pserverUri = "/aai/v12/cloud-infrastructure/pservers/pserver/test-pserver-xml";
- String cloudRegionUri = "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/cloud-region-random1/cloud-region-random1-region";
+ String cloudRegionUri =
+ "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/cloud-region-random1/cloud-region-random1-region";
Response response = httpTestUtil.doGet(pserverUri);
assertNotNull("Expected the response to be not null", response);
@@ -102,10 +105,11 @@ public class PserverTest extends AAISetup {
assertNotNull("Expected the response to be not null", response);
assertEquals("Expecting the cloud-region to pserver relationship to be created", 200, response.getStatus());
- response = httpTestUtil.doGet(pserverUri , "0", "raw");
+ response = httpTestUtil.doGet(pserverUri, "0", "raw");
assertNotNull("Expected the response to be not null", response);
assertEquals("Expecting the pserver to be created", 200, response.getStatus());
- assertThat(response.getEntity().toString(), containsString("<related-to><node><relationship-label>org.onap.relationships.inventory.LocatedIn</relationship-label><node-type>cloud-region</node-type>"));
+ assertThat(response.getEntity().toString(), containsString(
+ "<related-to><node><relationship-label>org.onap.relationships.inventory.LocatedIn</relationship-label><node-type>cloud-region</node-type>"));
}
@Test
diff --git a/aai-core/src/test/java/org/onap/aai/rest/VipAddressListTest.java b/aai-core/src/test/java/org/onap/aai/rest/VipAddressListTest.java
index 354b030b..a88e7b6d 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/VipAddressListTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/VipAddressListTest.java
@@ -31,7 +31,6 @@ import java.util.Collection;
import javax.ws.rs.core.Response;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
diff --git a/aai-core/src/test/java/org/onap/aai/rest/VnfcRelationshipIssueTest.java b/aai-core/src/test/java/org/onap/aai/rest/VnfcRelationshipIssueTest.java
index ae611717..1bfc8b74 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/VnfcRelationshipIssueTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/VnfcRelationshipIssueTest.java
@@ -20,6 +20,14 @@
package org.onap.aai.rest;
+import static junit.framework.TestCase.fail;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.ws.rs.core.Response;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.*;
@@ -35,13 +43,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.Collection;
-
-import static junit.framework.TestCase.fail;
-import static org.junit.Assert.assertEquals;
-
@RunWith(value = Parameterized.class)
public class VnfcRelationshipIssueTest extends AAISetup {
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
index 0adcbfe0..1462485d 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
@@ -20,8 +20,23 @@
package org.onap.aai.rest.db;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.when;
+
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.*;
+
+import javax.ws.rs.core.*;
+
import org.javatuples.Pair;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -46,19 +61,6 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.util.AAIConfig;
-import javax.ws.rs.core.*;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.*;
-
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.when;
-
@RunWith(value = Parameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class HttpEntryTest extends AAISetup {
@@ -376,7 +378,6 @@ public class HttpEntryTest extends AAISetup {
doNothing().when(uebNotification).triggerEvents();
Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
-
assertEquals("Expected the pserver relationship to be deleted", 200, response.getStatus());
assertEquals("Two notifications", 2, uebNotification.getEvents().size());
assertEquals("Notification generated for PUT edge", "UPDATE",
@@ -620,17 +621,15 @@ public class HttpEntryTest extends AAISetup {
// Put complex
uri = "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01";
content =
- "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
+ "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
// Put Relationship
uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01/relationship-list/relationship";
content = "{\"related-to\":\"complex\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}" +
- "\"relationship-daasSta\":[{" +
- "\"relationship-key\":\"complex.physical-location-id\"," +
- "\"relationship-value\":\"httpEntryTest-complex-01\"" +
- "}]";
+ + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}"
+ + "\"relationship-daasSta\":[{" + "\"relationship-key\":\"complex.physical-location-id\","
+ + "\"relationship-value\":\"httpEntryTest-complex-01\"" + "}]";
Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
@@ -638,7 +637,8 @@ public class HttpEntryTest extends AAISetup {
uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01";
content = "";
response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET_RELATIONSHIP, uri, content);
- String expected = "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-data\":[{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"httpEntryTest-complex-01\"}]}]}";
+ String expected =
+ "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-data\":[{\"relationship-key\":\"complex.physical-location-id\",\"relationship-value\":\"httpEntryTest-complex-01\"}]}]}";
Assert.assertEquals(expected, response.getEntity().toString());
dbEngine.rollback();
@@ -657,17 +657,15 @@ public class HttpEntryTest extends AAISetup {
// Put complex
uri = "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01";
content =
- "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
+ "{\"physical-location-id\":\"httpEntryTest-complex-01\",\"physical-location-type\":\"AAIDefault\",\"street1\":\"AAIDefault\",\"city\":\"AAIDefault\",\"state\":\"NJ\",\"postal-code\":\"07748\",\"country\":\"USA\",\"region\":\"US\"}";
doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT, uri, content);
// Put Relationship
uri = "/cloud-infrastructure/pservers/pserver/httpEntryTest-pserver-01/relationship-list/relationship";
content = "{\"related-to\":\"complex\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString()
- + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}" +
- "\"relationship-daasSta\":[{" +
- "\"relationship-key\":\"complex.physical-location-id\"," +
- "\"relationship-value\":\"httpEntryTest-complex-01\"" +
- "}]";
+ + "/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}"
+ + "\"relationship-daasSta\":[{" + "\"relationship-key\":\"complex.physical-location-id\","
+ + "\"relationship-value\":\"httpEntryTest-complex-01\"" + "}]";
Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content);
assertEquals("Expected the pserver relationship to be created", 200, response.getStatus());
@@ -690,14 +688,13 @@ public class HttpEntryTest extends AAISetup {
JSONObject pserverResponseFields = new JSONObject(pserverResponse);
String pserverResponseRelationshipList = pserverResponseFields.get("relationship-list").toString();
- String expected = "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-data\":[{\"relationship-value\":\"httpEntryTest-complex-01\",\"relationship-key\":\"complex.physical-location-id\"}],\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}]}";
+ String expected =
+ "{\"relationship\":[{\"related-to\":\"complex\",\"relationship-data\":[{\"relationship-value\":\"httpEntryTest-complex-01\",\"relationship-key\":\"complex.physical-location-id\"}],\"related-link\":\"/aai/v14/cloud-infrastructure/complexes/complex/httpEntryTest-complex-01\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}]}";
assertEquals(expected, pserverResponseRelationshipList);
-// Assert.assertEquals(expected, response.getEntity().toString());
+ // Assert.assertEquals(expected, response.getEntity().toString());
queryParameters.remove("format");
dbEngine.rollback();
}
-
-
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/ueb/UEBNotificationTest.java b/aai-core/src/test/java/org/onap/aai/rest/ueb/UEBNotificationTest.java
index 58b96e49..efa43250 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/ueb/UEBNotificationTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/ueb/UEBNotificationTest.java
@@ -20,6 +20,16 @@
package org.onap.aai.rest.ueb;
+import static org.junit.Assert.assertEquals;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.UUID;
+
+import javax.ws.rs.core.Response;
+
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.AAISetup;
@@ -34,15 +44,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import javax.ws.rs.core.Response;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.UUID;
-
-import static org.junit.Assert.assertEquals;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class UEBNotificationTest extends AAISetup {
@@ -58,7 +59,6 @@ public class UEBNotificationTest extends AAISetup {
public QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI;
-
@Before
public void setup() throws Exception {
version = schemaVersions.getDefaultVersion();
@@ -72,20 +72,13 @@ public class UEBNotificationTest extends AAISetup {
pserver.setValue("hostname", "hn");
URI uri = new URI("/cloud-infrastructure/pservers/pserver/hn");
UEBNotification uebNotification = new UEBNotification(loader, loaderFactory, schemaVersions);
- uebNotification.createNotificationEvent(
- UUID.randomUUID().toString(),
- "JUNIT-SOT",
- Response.Status.CREATED,
- uri,
- pserver,
- new HashMap<>(),
- BASE_PATH);
+ uebNotification.createNotificationEvent(UUID.randomUUID().toString(), "JUNIT-SOT", Response.Status.CREATED, uri,
+ pserver, new HashMap<>(), BASE_PATH);
assertEquals("One event created", 1, uebNotification.getEvents().size());
- assertEquals(
- "Uri is correct",
- BASE_PATH + "/" + schemaVersions.getDefaultVersion() + "/cloud-infrastructure/pservers/pserver/hn",
- uebNotification.getEvents().get(0).getEventHeader().getValue("entity-link").toString());
+ assertEquals("Uri is correct",
+ BASE_PATH + "/" + schemaVersions.getDefaultVersion() + "/cloud-infrastructure/pservers/pserver/hn",
+ uebNotification.getEvents().get(0).getEventHeader().getValue("entity-link").toString());
}
@Test
@@ -95,18 +88,12 @@ public class UEBNotificationTest extends AAISetup {
pserver.setValue("hostname", "hn");
URI uri = new URI(BASE_PATH + "/v12/cloud-infrastructure/pservers/pserver/hn");
UEBNotification uebNotification = new UEBNotification(loader, loaderFactory, schemaVersions);
- uebNotification.createNotificationEvent(
- UUID.randomUUID().toString(),
- "JUNIT-SOT",
- Response.Status.CREATED,
- uri,
- pserver,
- new HashMap<>(), BASE_PATH);
+ uebNotification.createNotificationEvent(UUID.randomUUID().toString(), "JUNIT-SOT", Response.Status.CREATED, uri,
+ pserver, new HashMap<>(), BASE_PATH);
assertEquals("One event created", 1, uebNotification.getEvents().size());
- assertEquals(
- "Uri is correct",
- BASE_PATH + "/" + schemaVersions.getDefaultVersion() + "/cloud-infrastructure/pservers/pserver/hn",
- uebNotification.getEvents().get(0).getEventHeader().getValue("entity-link").toString());
+ assertEquals("Uri is correct",
+ BASE_PATH + "/" + schemaVersions.getDefaultVersion() + "/cloud-infrastructure/pservers/pserver/hn",
+ uebNotification.getEvents().get(0).getEventHeader().getValue("entity-link").toString());
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java b/aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java
index 5adf5b26..e6b1a7e6 100644
--- a/aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java
+++ b/aai-core/src/test/java/org/onap/aai/restcore/JettyObfuscationConversionCommandLineUtilTest.java
@@ -31,20 +31,21 @@ public class JettyObfuscationConversionCommandLineUtilTest extends AAISetup {
public void testMainObfuscation() {
String[] args = {"-e", "[thisStringToObfuscate]"};
jettyObfuscationConversionCommandLineUtil.main(args);
- Assert.assertTrue(true); // No exception was encountered
+ Assert.assertTrue(true); // No exception was encountered
}
@Test
public void testMainDeobfuscation() {
- String[] args = {"-d", "OBF:1pj11w261wmr1t3b1vgv1s9r1z7i1vuz1tae1qji1vg71mdb1vgn1qhs1ta01vub1z7k1sbj1vfz1t2v1wnf1w1c1pj5"};
+ String[] args = {"-d",
+ "OBF:1pj11w261wmr1t3b1vgv1s9r1z7i1vuz1tae1qji1vg71mdb1vgn1qhs1ta01vub1z7k1sbj1vfz1t2v1wnf1w1c1pj5"};
jettyObfuscationConversionCommandLineUtil.main(args);
- Assert.assertTrue(true); // No exception was encountered
+ Assert.assertTrue(true); // No exception was encountered
}
@Test
public void testMain_failedParseInput() {
String[] args = {"-e [thisStringToObfuscate]"};
jettyObfuscationConversionCommandLineUtil.main(args);
- Assert.assertTrue(true); // No exception was encountered
+ Assert.assertTrue(true); // No exception was encountered
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java b/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java
index 6be45ff5..3c099c75 100644
--- a/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java
+++ b/aai-core/src/test/java/org/onap/aai/restcore/RESTAPITest.java
@@ -20,25 +20,21 @@
package org.onap.aai.restcore;
-import com.google.common.collect.HashMultimap;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.aai.AAISetup;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException;
-
-import javax.ws.rs.core.*;
-
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.Callable;
+import javax.ws.rs.core.*;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.exceptions.AAIException;
+
public class RESTAPITest extends AAISetup {
private static RESTAPI restapi;
private static HttpHeaders httpHeaders;
@@ -99,7 +95,8 @@ public class RESTAPITest extends AAISetup {
when(httpHeaders.getRequestHeaders()).thenReturn(requestHeaders);
when(callable.call()).thenReturn(response);
- Response resp = restapi.runner(AAI_TIMEOUT_ENABLED, AAI_TIMEOUT_BY_APP, AAI_TIMEOUT_DEFAULT_LIMIT, httpHeaders, info, HttpMethod.GET, callable);
+ Response resp = restapi.runner(AAI_TIMEOUT_ENABLED, AAI_TIMEOUT_BY_APP, AAI_TIMEOUT_DEFAULT_LIMIT, httpHeaders,
+ info, HttpMethod.GET, callable);
Assert.assertNotNull(resp);
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/AAICoreFakeEdgesConfigTranslator.java b/aai-core/src/test/java/org/onap/aai/serialization/db/AAICoreFakeEdgesConfigTranslator.java
index a49394f1..3753b7f8 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/AAICoreFakeEdgesConfigTranslator.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/AAICoreFakeEdgesConfigTranslator.java
@@ -26,7 +26,6 @@ import org.onap.aai.AbstractConfigTranslator;
import org.onap.aai.setup.SchemaConfigVersions;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
/**
* Quick and dirty access to test schema files
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/AAICorePrivateEdgeTestConfigTranslator.java b/aai-core/src/test/java/org/onap/aai/serialization/db/AAICorePrivateEdgeTestConfigTranslator.java
index 24762d57..78cef07f 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/AAICorePrivateEdgeTestConfigTranslator.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/AAICorePrivateEdgeTestConfigTranslator.java
@@ -26,7 +26,6 @@ import org.onap.aai.AbstractConfigTranslator;
import org.onap.aai.setup.SchemaConfigVersions;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
/**
* Quick and dirty access to the real schema files for updating core tests
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java
index 454aa218..bbbe6aac 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java
@@ -20,6 +20,18 @@
package org.onap.aai.serialization.db;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -44,18 +56,6 @@ import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.test.annotation.DirtiesContext;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class DbAliasTest extends DataLinkSetup {
@@ -90,7 +90,8 @@ public class DbAliasTest extends DataLinkSetup {
}
@Test
- public void checkOnWrite() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException, IllegalArgumentException {
+ public void checkOnWrite() throws AAIException, UnsupportedEncodingException, URISyntaxException, SecurityException,
+ IllegalArgumentException {
final String property = "persona-model-customization-id";
String dbPropertyName = property;
TransactionalGraphEngine spy = spy(this.dbEngine);
@@ -129,12 +130,14 @@ public class DbAliasTest extends DataLinkSetup {
}
@Test
- public void checkOnRead() throws AAIException, UnsupportedEncodingException, SecurityException, IllegalArgumentException {
+ public void checkOnRead()
+ throws AAIException, UnsupportedEncodingException, SecurityException, IllegalArgumentException {
final String property = "persona-model-customization-id";
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
- Vertex v = graph.traversal().addV().property("vnf-id", "key1").property("model-customization-id", "hello").next();
+ Vertex v =
+ graph.traversal().addV().property("vnf-id", "key1").property("model-customization-id", "hello").next();
graph.tx().commit();
Graph g = graph.newTransaction();
GraphTraversalSource traversal = g.traversal();
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerDeltasTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerDeltasTest.java
index de8f2224..b8d3f750 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerDeltasTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerDeltasTest.java
@@ -20,9 +20,18 @@
package org.onap.aai.serialization.db;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.*;
+
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphFactory;
@@ -50,19 +59,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.*;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-@TestPropertySource(properties = {
- "delta.events.enabled=true",
- })
+@TestPropertySource(properties = {"delta.events.enabled=true",})
public class DbSerializerDeltasTest extends AAISetup {
// to use, set thrown.expect to whatever your test needs
@@ -110,27 +109,27 @@ public class DbSerializerDeltasTest extends AAISetup {
public void createTopLevelThenUpdateTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
engine.startTransaction();
- DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ DBSerializer dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
Introspector gvnf = loader.introspectorFromName("generic-vnf");
Vertex gvnfVert = dbserLocal.createNewVertex(gvnf);
QueryParser uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI("/network/generic-vnfs/generic-vnf/myvnf"));
+ dbEngine.getQueryBuilder().createQueryFromURI(new URI("/network/generic-vnfs/generic-vnf/myvnf"));
gvnf.setValue("vnf-id", "myvnf");
gvnf.setValue("vnf-type", "typo");
dbserLocal.serializeToDb(gvnf, gvnfVert, uriQuery, "generic-vnf", gvnf.marshal(false));
- assertTrue("Original created vertex exists", engine.tx().traversal().V()
- .has("aai-node-type", "generic-vnf")
- .has("vnf-id", "myvnf")
- .has("vnf-type", "typo")
- .hasNext());
-
-
- assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(5L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertTrue("Original created vertex exists", engine.tx().traversal().V().has("aai-node-type", "generic-vnf")
+ .has("vnf-id", "myvnf").has("vnf-type", "typo").hasNext());
+
+ assertEquals(DeltaAction.CREATE,
+ dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getAction());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas()
+ .values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(5L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas()
+ .values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -141,20 +140,20 @@ public class DbSerializerDeltasTest extends AAISetup {
gvnf = dbserLocal.getLatestVersionView(gvnfVert);
gvnf.setValue("vnf-type", "new-typo");
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
dbserLocal.serializeToDb(gvnf, gvnfVert, uriQuery, "generic-vnf", gvnf.marshal(false));
- assertTrue("Vertex is updated", engine.tx().traversal().V()
- .has("aai-node-type", "generic-vnf")
- .has("vnf-id", "myvnf")
- .has("vnf-type", "new-typo")
- .hasNext());
-
-
- assertEquals(DeltaAction.UPDATE, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
+ assertTrue("Vertex is updated", engine.tx().traversal().V().has("aai-node-type", "generic-vnf")
+ .has("vnf-id", "myvnf").has("vnf-type", "new-typo").hasNext());
+
+ assertEquals(DeltaAction.UPDATE,
+ dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getAction());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas()
+ .values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get("/network/generic-vnfs/generic-vnf/myvnf").getPropertyDeltas()
+ .values().stream().filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -165,31 +164,30 @@ public class DbSerializerDeltasTest extends AAISetup {
}
@Test
- public void createTopLevelThenCreateChildTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ public void createTopLevelThenCreateChildTest()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
engine.startTransaction();
- DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ DBSerializer dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
Introspector gvnf = loader.introspectorFromName("generic-vnf");
Vertex gvnfVert = dbserLocal.createNewVertex(gvnf);
final String vnfUri = "/network/generic-vnfs/generic-vnf/myvnf";
- QueryParser uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI(vnfUri));
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI(vnfUri));
gvnf.setValue("vnf-id", "myvnf");
gvnf.setValue("vnf-type", "typo");
dbserLocal.serializeToDb(gvnf, gvnfVert, uriQuery, "generic-vnf", gvnf.marshal(false));
- assertTrue("Original created vertex exists", engine.tx().traversal().V()
- .has("aai-node-type", "generic-vnf")
- .has("vnf-id", "myvnf")
- .has("vnf-type", "typo")
- .hasNext());
-
+ assertTrue("Original created vertex exists", engine.tx().traversal().V().has("aai-node-type", "generic-vnf")
+ .has("vnf-id", "myvnf").has("vnf-type", "typo").hasNext());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(vnfUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(5L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(5L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -198,7 +196,8 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
Introspector vf = loader.introspectorFromName("vf-module");
Vertex vfVertex = dbserLocal.createNewVertex(vf);
final String vfUri = "/network/generic-vnfs/generic-vnf/myvnf/vf-modules/vf-module/myvf";
@@ -206,24 +205,19 @@ public class DbSerializerDeltasTest extends AAISetup {
vf.setValue("vf-module-id", "myvf");
dbserLocal.serializeToDb(vf, vfVertex, uriQuery, "vf-module", vf.marshal(false));
- assertTrue("Vertex is creted", engine.tx().traversal().V()
- .has("aai-node-type", "vf-module")
- .has("vf-module-id", "myvf")
- .hasNext());
- assertTrue("Vf module has edge to gvnf", engine.tx().traversal().V()
- .has("aai-node-type", "vf-module")
- .has("vf-module-id", "myvf")
- .both()
- .has("aai-node-type", "generic-vnf")
- .has("vnf-id", "myvnf")
- .hasNext());
-
+ assertTrue("Vertex is creted",
+ engine.tx().traversal().V().has("aai-node-type", "vf-module").has("vf-module-id", "myvf").hasNext());
+ assertTrue("Vf module has edge to gvnf",
+ engine.tx().traversal().V().has("aai-node-type", "vf-module").has("vf-module-id", "myvf").both()
+ .has("aai-node-type", "generic-vnf").has("vnf-id", "myvnf").hasNext());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(vfUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -234,15 +228,16 @@ public class DbSerializerDeltasTest extends AAISetup {
}
@Test
- public void createTopWithChildThenDeleteTopTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ public void createTopWithChildThenDeleteTopTest()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
engine.startTransaction();
- DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ DBSerializer dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
Introspector gvnf = loader.introspectorFromName("generic-vnf");
Vertex gvnfVert = dbserLocal.createNewVertex(gvnf);
final String vnfUri = "/network/generic-vnfs/generic-vnf/myvnf";
- QueryParser uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI(vnfUri));
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI(vnfUri));
gvnf.setValue("vnf-id", "myvnf");
gvnf.setValue("vnf-type", "typo");
@@ -260,32 +255,28 @@ public class DbSerializerDeltasTest extends AAISetup {
Gson gson = new GsonBuilder().create();
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
- assertTrue("Original created vertex exists", engine.tx().traversal().V()
- .has("aai-node-type", "generic-vnf")
- .has("vnf-id", "myvnf")
- .has("vnf-type", "typo")
- .hasNext());
- assertTrue("Vertex is creted", engine.tx().traversal().V()
- .has("aai-node-type", "vf-module")
- .has("vf-module-id", "myvf")
- .hasNext());
- assertTrue("Vf module has edge to gvnf", engine.tx().traversal().V()
- .has("aai-node-type", "vf-module")
- .has("vf-module-id", "myvf")
- .both()
- .has("aai-node-type", "generic-vnf")
- .has("vnf-id", "myvnf")
- .hasNext());
+ assertTrue("Original created vertex exists", engine.tx().traversal().V().has("aai-node-type", "generic-vnf")
+ .has("vnf-id", "myvnf").has("vnf-type", "typo").hasNext());
+ assertTrue("Vertex is creted",
+ engine.tx().traversal().V().has("aai-node-type", "vf-module").has("vf-module-id", "myvf").hasNext());
+ assertTrue("Vf module has edge to gvnf",
+ engine.tx().traversal().V().has("aai-node-type", "vf-module").has("vf-module-id", "myvf").both()
+ .has("aai-node-type", "generic-vnf").has("vnf-id", "myvnf").hasNext());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(vnfUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(5L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(5L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(vfUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
- assertEquals(1L, dbserLocal.getObjectDeltas().get(vfUri).getRelationshipDeltas().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(1L, dbserLocal.getObjectDeltas().get(vfUri).getRelationshipDeltas().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -294,36 +285,37 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
gvnf = dbserLocal.getLatestVersionView(gvnfVert);
String rv = gvnf.getValue(AAIProperties.RESOURCE_VERSION);
dbserLocal.delete(engine.tx().traversal().V(gvnfVert).next(), rv, true);
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
- assertFalse("generic-vnf no longer exists", engine.tx().traversal().V()
- .has("aai-node-type", "generic-vnf")
- .hasNext());
- assertFalse("vf-module no longer exists", engine.tx().traversal().V()
- .has("aai-node-type", "vf-module")
- .hasNext());
+ assertFalse("generic-vnf no longer exists",
+ engine.tx().traversal().V().has("aai-node-type", "generic-vnf").hasNext());
+ assertFalse("vf-module no longer exists",
+ engine.tx().traversal().V().has("aai-node-type", "vf-module").hasNext());
assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(vnfUri).getAction());
- assertEquals(12L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(vfUri).getAction());
- assertEquals(11L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
+ assertEquals(12L, dbserLocal.getObjectDeltas().get(vnfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
+ assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(vfUri).getAction());
+ assertEquals(11L, dbserLocal.getObjectDeltas().get(vfUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
}
-
-
@Test
- public void createComplexPserverWithRelDeleteRel() throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ public void createComplexPserverWithRelDeleteRel()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
engine.startTransaction();
- DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ DBSerializer dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
Introspector complex = loader.introspectorFromName("complex");
Vertex complexV = dbserLocal.createNewVertex(complex);
final String complexUri = "/cloud-infrastructure/complexes/complex/c-id";
- QueryParser uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI(complexUri));
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI(complexUri));
complex.setValue("physical-location-id", "c-id");
complex.setValue("physical-location-type", "type");
@@ -333,17 +325,16 @@ public class DbSerializerDeltasTest extends AAISetup {
complex.setValue("country", "abc");
complex.setValue("region", "ef");
dbserLocal.serializeToDb(complex, complexV, uriQuery, "complex", complex.marshal(false));
- assertTrue("Complex created", engine.tx().traversal().V()
- .has("aai-node-type", "complex")
- .has("physical-location-id", "c-id")
- .hasNext());
-
+ assertTrue("Complex created", engine.tx().traversal().V().has("aai-node-type", "complex")
+ .has("physical-location-id", "c-id").hasNext());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(complexUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(10L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(10L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -352,13 +343,12 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
-
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
Introspector pserver = loader.introspectorFromName("pserver");
Vertex pserverV = dbserLocal.createNewVertex(pserver);
final String pserverUri = "/cloud-infrastructure/pservers/pserver/ps";
- uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI(pserverUri));
+ uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI(pserverUri));
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "complex");
@@ -372,25 +362,20 @@ public class DbSerializerDeltasTest extends AAISetup {
System.out.println(pserver.marshal(true));
dbserLocal.serializeToDb(pserver, pserverV, uriQuery, "pserver", pserver.marshal(false));
- assertTrue("Pserver created", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps")
- .hasNext());
- assertTrue("Pserver has edge to complex", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps")
- .bothE()
- .otherV()
- .has("aai-node-type", "complex")
- .hasNext());
-
+ assertTrue("Pserver created",
+ engine.tx().traversal().V().has("aai-node-type", "pserver").has("hostname", "ps").hasNext());
+ assertTrue("Pserver has edge to complex", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps").bothE().otherV().has("aai-node-type", "complex").hasNext());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(pserverUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
- assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -399,25 +384,22 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
-
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST", AAIProperties.MINIMUM_DEPTH);
dbserLocal.touchStandardVertexProperties(pserverV, false);
dbserLocal.deleteEdge(relationship, pserverV);
- assertFalse("Pserver no longer has edge to complex", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps")
- .bothE()
- .otherV()
- .has("aai-node-type", "complex")
- .hasNext());
-
+ assertFalse("Pserver no longer has edge to complex", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps").bothE().otherV().has("aai-node-type", "complex").hasNext());
assertEquals(DeltaAction.UPDATE, dbserLocal.getObjectDeltas().get(pserverUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(3L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
- assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE_REL)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(3L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
+ assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE_REL)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -428,19 +410,18 @@ public class DbSerializerDeltasTest extends AAISetup {
}
@Test
- public void createComplexPserverWithRelUpdatePserverToDeleteRelAddPinterfaceThenDeleteComplex() throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ public void createComplexPserverWithRelUpdatePserverToDeleteRelAddPinterfaceThenDeleteComplex()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
engine.startTransaction();
- Gson gson = new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES)
- .create();
+ Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create();
- DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-complex", AAIProperties.MINIMUM_DEPTH);
+ DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-complex",
+ AAIProperties.MINIMUM_DEPTH);
Introspector complex = loader.introspectorFromName("complex");
Vertex complexV = dbserLocal.createNewVertex(complex);
final String complexUri = "/cloud-infrastructure/complexes/complex/c-id-b";
- QueryParser uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI(complexUri));
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI(complexUri));
complex.setValue("physical-location-id", "c-id-b");
complex.setValue("physical-location-type", "type");
@@ -454,15 +435,15 @@ public class DbSerializerDeltasTest extends AAISetup {
System.out.println("Create Complex");
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
- assertTrue("Complex created", engine.tx().traversal().V()
- .has("aai-node-type", "complex")
- .has("physical-location-id", "c-id-b")
- .hasNext());
+ assertTrue("Complex created", engine.tx().traversal().V().has("aai-node-type", "complex")
+ .has("physical-location-id", "c-id-b").hasNext());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(complexUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(10L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(10L, dbserLocal.getObjectDeltas().get(complexUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -471,13 +452,12 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
-
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-pserver",
+ AAIProperties.MINIMUM_DEPTH);
Introspector pserver = loader.introspectorFromName("pserver");
Vertex pserverV = dbserLocal.createNewVertex(pserver);
final String pserverUri = "/cloud-infrastructure/pservers/pserver/ps-b";
- uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI(pserverUri));
+ uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI(pserverUri));
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "complex");
@@ -502,35 +482,29 @@ public class DbSerializerDeltasTest extends AAISetup {
System.out.println("Create Pserver with pinterface and relationship to complex ");
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
- assertTrue("Pserver created", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .hasNext());
- assertTrue("Pserver has edge to complex", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .bothE()
- .otherV()
- .has("aai-node-type", "complex")
- .hasNext());
- assertTrue("Pserver has edge to pinterface", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .bothE()
- .otherV()
- .has("aai-node-type", "p-interface")
- .hasNext());
+ assertTrue("Pserver created",
+ engine.tx().traversal().V().has("aai-node-type", "pserver").has("hostname", "ps-b").hasNext());
+ assertTrue("Pserver has edge to complex", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps-b").bothE().otherV().has("aai-node-type", "complex").hasNext());
+ assertTrue("Pserver has edge to pinterface", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps-b").bothE().otherV().has("aai-node-type", "p-interface").hasNext());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(pserverUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(5L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
- assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(5L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(pintUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pintUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pintUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
- assertEquals(1L, dbserLocal.getObjectDeltas().get(pintUri).getRelationshipDeltas().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pintUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pintUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(1L, dbserLocal.getObjectDeltas().get(pintUri).getRelationshipDeltas().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE_REL)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -539,7 +513,8 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-pserver",
+ AAIProperties.MINIMUM_DEPTH);
pserver = dbserLocal.getLatestVersionView(pserverV);
relationshipList = loader.introspectorFromName("relationship-list");
relationshipList.setValue("relationship", Collections.emptyList());
@@ -552,21 +527,19 @@ public class DbSerializerDeltasTest extends AAISetup {
System.out.println("Update pserver removing relationship to complex");
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
- assertFalse("Pserver no longer has edge to complex", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .bothE()
- .otherV()
- .has("aai-node-type", "complex")
- .hasNext());
+ assertFalse("Pserver no longer has edge to complex", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps-b").bothE().otherV().has("aai-node-type", "complex").hasNext());
assertEquals(DeltaAction.UPDATE, dbserLocal.getObjectDeltas().get(pserverUri).getAction());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
- assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE_REL)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
+ assertEquals(1L, dbserLocal.getObjectDeltas().get(pserverUri).getRelationshipDeltas().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE_REL)).count());
assertFalse(dbserLocal.getObjectDeltas().containsKey(pintUri));
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -575,7 +548,8 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "delete-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "delete-pserver",
+ AAIProperties.MINIMUM_DEPTH);
pserver = dbserLocal.getLatestVersionView(pserverV);
String rv = pserver.getValue(AAIProperties.RESOURCE_VERSION);
dbserLocal.delete(engine.tx().traversal().V(pserverV).next(), rv, true);
@@ -583,16 +557,16 @@ public class DbSerializerDeltasTest extends AAISetup {
System.out.println("Delete pserver");
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
- assertFalse("pserver no longer exists", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .hasNext());
+ assertFalse("pserver no longer exists", engine.tx().traversal().V().has("aai-node-type", "pserver").hasNext());
assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(pserverUri).getAction());
- assertEquals(12L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
+ assertEquals(12L, dbserLocal.getObjectDeltas().get(pserverUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(pintUri).getAction());
- assertEquals(10L, dbserLocal.getObjectDeltas().get(pintUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
+ assertEquals(10L, dbserLocal.getObjectDeltas().get(pintUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -602,42 +576,37 @@ public class DbSerializerDeltasTest extends AAISetup {
});
}
-
// /network/ipsec-configurations/ipsec-configuration/{ipsec-configuration-id}/vig-servers/vig-server/{vig-address-type}
// ipaddress-v4-vig
@Test
public void createNodeWithListTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
- Gson gson = new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES)
- .create();
+ Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create();
engine.startTransaction();
/*
* Create the parent ipsec-configuration
*/
- DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-ipsec", AAIProperties.MINIMUM_DEPTH);
+ DBSerializer dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "create-ipsec", AAIProperties.MINIMUM_DEPTH);
Introspector ipsec = loader.introspectorFromName("ipsec-configuration");
Vertex ipsecVert = dbserLocal.createNewVertex(ipsec);
final String ipsecUri = "/network/ipsec-configurations/ipsec-configuration/ipsec";
- QueryParser uriQuery =
- dbEngine.getQueryBuilder().createQueryFromURI(new URI(ipsecUri));
+ QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(new URI(ipsecUri));
ipsec.setValue("ipsec-configuration-id", "ipsec");
dbserLocal.serializeToDb(ipsec, ipsecVert, uriQuery, "generic-vnf", ipsec.marshal(false));
assertTrue("Original created vertex exists", engine.tx().traversal().V()
- .has("aai-node-type", "ipsec-configuration")
- .has("ipsec-configuration-id", "ipsec")
- .hasNext());
+ .has("aai-node-type", "ipsec-configuration").has("ipsec-configuration-id", "ipsec").hasNext());
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(ipsecUri).getAction());
- assertEquals(4L,
- dbserLocal.getObjectDeltas().get(ipsecUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L,
- dbserLocal.getObjectDeltas().get(ipsecUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(ipsecUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(ipsecUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -649,7 +618,8 @@ public class DbSerializerDeltasTest extends AAISetup {
/*
* Create child vig-server with list property vig-address-type
*/
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-child-vig-server", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-child-vig-server",
+ AAIProperties.MINIMUM_DEPTH);
Introspector vig = loader.introspectorFromName("vig-server");
Vertex vigVertex = dbserLocal.createNewVertex(vig);
final String vigUri = "/network/ipsec-configurations/ipsec-configuration/ipsec/vig-servers/vig-server/vig";
@@ -661,27 +631,22 @@ public class DbSerializerDeltasTest extends AAISetup {
list.add("address-2");
vig.setValue("ipaddress-v4-vig", list);
dbserLocal.serializeToDb(vig, vigVertex, uriQuery, "vf-module", vig.marshal(false));
- assertTrue("Vertex is creted", engine.tx().traversal().V()
- .has("aai-node-type", "vig-server")
- .has("vig-address-type", "vig")
- .hasNext());
- assertTrue("Vf module has edge to gvnf", engine.tx().traversal().V()
- .has("aai-node-type", "vig-server")
- .has("vig-address-type", "vig")
- .both()
- .has("aai-node-type", "ipsec-configuration")
- .has("ipsec-configuration-id", "ipsec")
- .hasNext());
+ assertTrue("Vertex is creted", engine.tx().traversal().V().has("aai-node-type", "vig-server")
+ .has("vig-address-type", "vig").hasNext());
+ assertTrue("Vf module has edge to gvnf",
+ engine.tx().traversal().V().has("aai-node-type", "vig-server").has("vig-address-type", "vig").both()
+ .has("aai-node-type", "ipsec-configuration").has("ipsec-configuration-id", "ipsec").hasNext());
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
assertEquals(DeltaAction.CREATE, dbserLocal.getObjectDeltas().get(vigUri).getAction());
- assertEquals(4L,
- dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(5L,
- dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
- assertThat(dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().get("ipaddress-v4-vig").getValue(), instanceOf(List.class));
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(5L, dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.CREATE)).count());
+ assertThat(dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().get("ipaddress-v4-vig").getValue(),
+ instanceOf(List.class));
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -693,7 +658,8 @@ public class DbSerializerDeltasTest extends AAISetup {
/*
* Update child vig-server with new list for vig-address-type
*/
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-child-vig-server", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-child-vig-server",
+ AAIProperties.MINIMUM_DEPTH);
vig = dbserLocal.getLatestVersionView(vigVertex);
uriQuery = engine.getQueryBuilder(ipsecVert).createQueryFromURI(new URI(vigUri));
@@ -702,28 +668,24 @@ public class DbSerializerDeltasTest extends AAISetup {
list.add("address-4");
vig.setValue("ipaddress-v4-vig", list);
dbserLocal.serializeToDb(vig, vigVertex, uriQuery, "vf-module", vig.marshal(false));
- assertTrue("Vertex is still there", engine.tx().traversal().V()
- .has("aai-node-type", "vig-server")
- .has("vig-address-type", "vig")
- .hasNext());
- assertTrue("Vf module has edge to gvnf", engine.tx().traversal().V()
- .has("aai-node-type", "vig-server")
- .has("vig-address-type", "vig")
- .both()
- .has("aai-node-type", "ipsec-configuration")
- .has("ipsec-configuration-id", "ipsec")
- .hasNext());
+ assertTrue("Vertex is still there", engine.tx().traversal().V().has("aai-node-type", "vig-server")
+ .has("vig-address-type", "vig").hasNext());
+ assertTrue("Vf module has edge to gvnf",
+ engine.tx().traversal().V().has("aai-node-type", "vig-server").has("vig-address-type", "vig").both()
+ .has("aai-node-type", "ipsec-configuration").has("ipsec-configuration-id", "ipsec").hasNext());
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
assertEquals(DeltaAction.UPDATE, dbserLocal.getObjectDeltas().get(vigUri).getAction());
- assertEquals(4L,
- dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
- assertEquals(4L,
- dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
- assertThat(dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().get("ipaddress-v4-vig").getValue(), instanceOf(List.class));
- assertThat(dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().get("ipaddress-v4-vig").getOldValue(), instanceOf(List.class));
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.STATIC)).count());
+ assertEquals(4L, dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.UPDATE)).count());
+ assertThat(dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().get("ipaddress-v4-vig").getValue(),
+ instanceOf(List.class));
+ assertThat(dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().get("ipaddress-v4-vig").getOldValue(),
+ instanceOf(List.class));
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
@@ -732,26 +694,28 @@ public class DbSerializerDeltasTest extends AAISetup {
}
});
/*
- * Delete top level
+ * Delete top level
*/
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "delete-ipsec", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal =
+ new DBSerializer(version, engine, introspectorFactoryType, "delete-ipsec", AAIProperties.MINIMUM_DEPTH);
ipsec = dbserLocal.getLatestVersionView(ipsecVert);
String rv = ipsec.getValue(AAIProperties.RESOURCE_VERSION);
dbserLocal.delete(engine.tx().traversal().V(ipsecVert).next(), rv, true);
System.out.println(gson.toJsonTree(dbserLocal.getObjectDeltas().values()));
- assertFalse("ipsec-configuration no longer exists", engine.tx().traversal().V()
- .has("aai-node-type", "ipsec-configuration")
- .hasNext());
- assertFalse("vig-server no longer exists", engine.tx().traversal().V()
- .has("aai-node-type", "vig-server")
- .hasNext());
+ assertFalse("ipsec-configuration no longer exists",
+ engine.tx().traversal().V().has("aai-node-type", "ipsec-configuration").hasNext());
+ assertFalse("vig-server no longer exists",
+ engine.tx().traversal().V().has("aai-node-type", "vig-server").hasNext());
assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(ipsecUri).getAction());
- assertEquals(9L, dbserLocal.getObjectDeltas().get(ipsecUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(vigUri).getAction());
- assertEquals(10L, dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream().filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
+ assertEquals(9L, dbserLocal.getObjectDeltas().get(ipsecUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
+ assertEquals(DeltaAction.DELETE, dbserLocal.getObjectDeltas().get(vigUri).getAction());
+ assertEquals(10L, dbserLocal.getObjectDeltas().get(vigUri).getPropertyDeltas().values().stream()
+ .filter(d -> d.getAction().equals(DeltaAction.DELETE)).count());
dbserLocal.getObjectDeltas().values().forEach(od -> {
- if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID) ) {
+ if (!od.getPropertyDeltas().containsKey(AAIProperties.AAI_UUID)) {
fail(od.getUri() + " is missing " + AAIProperties.AAI_UUID);
} else if (od.getPropertyDeltas().get(AAIProperties.AAI_UUID) == null) {
fail(od.getUri() + " " + AAIProperties.AAI_UUID + " is null");
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerNotificationEventsTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerNotificationEventsTest.java
index cc1fc03d..4c4fc061 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerNotificationEventsTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerNotificationEventsTest.java
@@ -20,6 +20,15 @@
package org.onap.aai.serialization.db;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+import java.util.stream.Collectors;
+
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphFactory;
@@ -45,15 +54,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class DbSerializerNotificationEventsTest extends AAISetup {
@@ -98,24 +98,25 @@ public class DbSerializerNotificationEventsTest extends AAISetup {
}
/*
- Create Complex
- Create Pserver with pinterface and relationship to complex
- Update pserver removing relationship to complex
- Update pserver adding a second p-interface
- Add l-interface directly to the 2nd p-interface
- Delete pserver
+ * Create Complex
+ * Create Pserver with pinterface and relationship to complex
+ * Update pserver removing relationship to complex
+ * Update pserver adding a second p-interface
+ * Add l-interface directly to the 2nd p-interface
+ * Delete pserver
*/
@Test
- public void createComplexPserverWithRelUpdatePserverToDeleteRelAddPinterfaceThenDeleteComplexCheckingUpdatedListTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ public void createComplexPserverWithRelUpdatePserverToDeleteRelAddPinterfaceThenDeleteComplexCheckingUpdatedListTest()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
engine.startTransaction();
System.out.println("Create Complex");
- DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-complex", AAIProperties.MINIMUM_DEPTH);
+ DBSerializer dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-complex",
+ AAIProperties.MINIMUM_DEPTH);
Introspector complex = loader.introspectorFromName("complex");
Vertex complexV = dbserLocal.createNewVertex(complex);
final String complexUri = "/cloud-infrastructure/complexes/complex/c-id-b";
- QueryParser uriQuery =
- engine.getQueryBuilder().createQueryFromURI(new URI(complexUri));
+ QueryParser uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(complexUri));
complex.setValue("physical-location-id", "c-id-b");
complex.setValue("physical-location-type", "type");
@@ -126,30 +127,25 @@ public class DbSerializerNotificationEventsTest extends AAISetup {
complex.setValue("region", "ef");
dbserLocal.serializeToDb(complex, complexV, uriQuery, "complex", complex.marshal(false));
- assertTrue("Complex created", engine.tx().traversal().V()
- .has("aai-node-type", "complex")
- .has("physical-location-id", "c-id-b")
- .hasNext());
+ assertTrue("Complex created", engine.tx().traversal().V().has("aai-node-type", "complex")
+ .has("physical-location-id", "c-id-b").hasNext());
Map<Vertex, Boolean> updated = getUpdatedVertexes(dbserLocal);
assertEquals("Number of updated vertexes", 1, updated.size());
assertThat("Only modified vertexes are in the updated set",
- updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
- is(Collections.singleton(complexUri)));
- List<String> didNotUpdateStandardVertexProps = updated.entrySet().stream()
- .filter(e -> !e.getValue())
- .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
- assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps, is(Collections.emptyList()));
-
-
-
+ updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
+ is(Collections.singleton(complexUri)));
+ List<String> didNotUpdateStandardVertexProps = updated.entrySet().stream().filter(e -> !e.getValue())
+ .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
+ assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps,
+ is(Collections.emptyList()));
System.out.println("Create Pserver with pinterface and relationship to complex ");
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-pserver",
+ AAIProperties.MINIMUM_DEPTH);
Introspector pserver = loader.introspectorFromName("pserver");
Vertex pserverV = dbserLocal.createNewVertex(pserver);
final String pserverUri = "/cloud-infrastructure/pservers/pserver/ps-b";
- uriQuery =
- engine.getQueryBuilder().createQueryFromURI(new URI(pserverUri));
+ uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(pserverUri));
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "complex");
@@ -170,37 +166,25 @@ public class DbSerializerNotificationEventsTest extends AAISetup {
pserver.setValue("p-interfaces", pints.getUnderlyingObject());
dbserLocal.serializeToDb(pserver, pserverV, uriQuery, "pserver", pserver.marshal(false));
- assertTrue("Pserver created", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .hasNext());
- assertTrue("Pserver has edge to complex", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .bothE()
- .otherV()
- .has("aai-node-type", "complex")
- .hasNext());
- assertTrue("Pserver has edge to pinterface", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .bothE()
- .otherV()
- .has("aai-node-type", "p-interface")
- .hasNext());
+ assertTrue("Pserver created",
+ engine.tx().traversal().V().has("aai-node-type", "pserver").has("hostname", "ps-b").hasNext());
+ assertTrue("Pserver has edge to complex", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps-b").bothE().otherV().has("aai-node-type", "complex").hasNext());
+ assertTrue("Pserver has edge to pinterface", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps-b").bothE().otherV().has("aai-node-type", "p-interface").hasNext());
updated = getUpdatedVertexes(dbserLocal);
assertEquals("Number of updated vertexes", 3, updated.size());
assertThat("Only modified vertexes are in the updated set",
- updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
- is(new HashSet<>(Arrays.asList(pserverUri, pintUri, complexUri))));
- didNotUpdateStandardVertexProps = updated.entrySet().stream()
- .filter(e -> !e.getValue())
- .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
- assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps, is(Collections.emptyList()));
-
+ updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
+ is(new HashSet<>(Arrays.asList(pserverUri, pintUri, complexUri))));
+ didNotUpdateStandardVertexProps = updated.entrySet().stream().filter(e -> !e.getValue())
+ .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
+ assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps,
+ is(Collections.emptyList()));
System.out.println("Update pserver removing relationship to complex");
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-pserver",
+ AAIProperties.MINIMUM_DEPTH);
pserver = dbserLocal.getLatestVersionView(pserverV);
relationshipList = loader.introspectorFromName("relationship-list");
relationshipList.setValue("relationship", Collections.emptyList());
@@ -209,114 +193,89 @@ public class DbSerializerNotificationEventsTest extends AAISetup {
pserver.setValue("number-of-cpus", 99);
dbserLocal.serializeToDb(pserver, pserverV, uriQuery, "pserver", pserver.marshal(false));
- assertFalse("Pserver no longer has edge to complex", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .bothE()
- .otherV()
- .has("aai-node-type", "complex")
- .hasNext());
+ assertFalse("Pserver no longer has edge to complex", engine.tx().traversal().V().has("aai-node-type", "pserver")
+ .has("hostname", "ps-b").bothE().otherV().has("aai-node-type", "complex").hasNext());
updated = getUpdatedVertexes(dbserLocal);
assertEquals("Number of updated vertexes", 2, updated.size());
assertThat("Only modified vertexes are in the updated set",
- updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
- is(new HashSet<>(Arrays.asList(pserverUri, complexUri))));
- didNotUpdateStandardVertexProps = updated.entrySet().stream()
- .filter(e -> !e.getValue())
- .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
- assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps, is(Collections.emptyList()));
-
-
+ updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
+ is(new HashSet<>(Arrays.asList(pserverUri, complexUri))));
+ didNotUpdateStandardVertexProps = updated.entrySet().stream().filter(e -> !e.getValue())
+ .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
+ assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps,
+ is(Collections.emptyList()));
System.out.println("Update pserver adding a second p-interface");
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "update-pserver",
+ AAIProperties.MINIMUM_DEPTH);
pserver = dbserLocal.getLatestVersionView(pserverV);
Introspector pint2 = loader.introspectorFromName("p-interface");
pint2.setValue("interface-name", "pint-2");
pints = pserver.getWrappedValue("p-interfaces");
- List<Object> pintList = pserver.getWrappedValue("p-interfaces").getWrappedListValue("p-interface")
- .stream().map(Introspector::getUnderlyingObject).collect(Collectors.toList());
+ List<Object> pintList = pserver.getWrappedValue("p-interfaces").getWrappedListValue("p-interface").stream()
+ .map(Introspector::getUnderlyingObject).collect(Collectors.toList());
pintList.add(pint2.getUnderlyingObject());
pints.setValue("p-interface", pintList);
pserver.setValue("p-interfaces", pints.getUnderlyingObject());
final String pint2Uri = pserverUri + "/p-interfaces/p-interface/pint-2";
dbserLocal.serializeToDb(pserver, pserverV, uriQuery, "pserver", pserver.marshal(false));
- assertTrue("Pserver has edge to pinterface 2", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .in()
- .has("aai-node-type", "p-interface")
- .has("interface-name","pint-2")
- .hasNext());
- assertTrue("p-interface 2 created", engine.tx().traversal().V()
- .has("aai-node-type", "p-interface")
- .has("interface-name", "pint-2")
- .has(AAIProperties.AAI_URI, pint2Uri)
- .hasNext());
+ assertTrue("Pserver has edge to pinterface 2",
+ engine.tx().traversal().V().has("aai-node-type", "pserver").has("hostname", "ps-b").in()
+ .has("aai-node-type", "p-interface").has("interface-name", "pint-2").hasNext());
+ assertTrue("p-interface 2 created", engine.tx().traversal().V().has("aai-node-type", "p-interface")
+ .has("interface-name", "pint-2").has(AAIProperties.AAI_URI, pint2Uri).hasNext());
updated = getUpdatedVertexes(dbserLocal);
assertEquals("Number of updated vertexes", 1, updated.size());
assertThat("Only modified vertexes are in the updated set",
- updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
- is(Collections.singleton(pint2Uri)));
- didNotUpdateStandardVertexProps = updated.entrySet().stream()
- .filter(e -> !e.getValue())
- .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
- assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps, is(Collections.emptyList()));
-
+ updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
+ is(Collections.singleton(pint2Uri)));
+ didNotUpdateStandardVertexProps = updated.entrySet().stream().filter(e -> !e.getValue())
+ .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
+ assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps,
+ is(Collections.emptyList()));
System.out.println("Add l-interface directly to the 2nd p-interface");
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "create-pserver",
+ AAIProperties.MINIMUM_DEPTH);
Introspector lInt = loader.introspectorFromName("l-interface");
Vertex lIntV = dbserLocal.createNewVertex(lInt);
final String lIntUri = pint2Uri + "/l-interfaces/l-interface/lint-1";
- uriQuery =
- engine.getQueryBuilder().createQueryFromURI(new URI(lIntUri));
+ uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(lIntUri));
lInt.setValue("interface-name", "lint-1");
dbserLocal.serializeToDb(lInt, lIntV, uriQuery, "l-interface", lInt.marshal(false));
- assertTrue("l-interface created", engine.tx().traversal().V()
- .has("aai-node-type", "l-interface")
- .has("interface-name", "lint-1")
- .hasNext());
-
- assertTrue("Pserver has edge to pinterface to l-interface", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .has("hostname", "ps-b")
- .bothE()
- .otherV()
- .has("aai-node-type", "p-interface")
- .bothE()
- .otherV()
- .has("aai-node-type", "l-interface")
- .hasNext());
+ assertTrue("l-interface created", engine.tx().traversal().V().has("aai-node-type", "l-interface")
+ .has("interface-name", "lint-1").hasNext());
+
+ assertTrue("Pserver has edge to pinterface to l-interface",
+ engine.tx().traversal().V().has("aai-node-type", "pserver").has("hostname", "ps-b").bothE().otherV()
+ .has("aai-node-type", "p-interface").bothE().otherV().has("aai-node-type", "l-interface")
+ .hasNext());
updated = getUpdatedVertexes(dbserLocal);
assertEquals("Number of updated vertexes", 1, updated.size());
assertThat("Only modified vertexes are in the updated set",
- updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
- is(new HashSet<>(Collections.singletonList(lIntUri))));
- didNotUpdateStandardVertexProps = updated.entrySet().stream()
- .filter(e -> !e.getValue())
- .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
- assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps, is(Collections.emptyList()));
-
+ updated.keySet().stream().map(v -> v.<String>value(AAIProperties.AAI_URI)).collect(Collectors.toSet()),
+ is(new HashSet<>(Collections.singletonList(lIntUri))));
+ didNotUpdateStandardVertexProps = updated.entrySet().stream().filter(e -> !e.getValue())
+ .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
+ assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps,
+ is(Collections.emptyList()));
System.out.println("Delete pserver");
- dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "delete-pserver", AAIProperties.MINIMUM_DEPTH);
+ dbserLocal = new DBSerializer(version, engine, introspectorFactoryType, "delete-pserver",
+ AAIProperties.MINIMUM_DEPTH);
pserver = dbserLocal.getLatestVersionView(pserverV);
String rv = pserver.getValue(AAIProperties.RESOURCE_VERSION);
dbserLocal.delete(engine.tx().traversal().V(pserverV).next(), rv, true);
- assertFalse("pserver no longer exists", engine.tx().traversal().V()
- .has("aai-node-type", "pserver")
- .hasNext());
+ assertFalse("pserver no longer exists", engine.tx().traversal().V().has("aai-node-type", "pserver").hasNext());
updated = getUpdatedVertexes(dbserLocal);
assertEquals("Number of updated vertexes", 0, updated.size());
- didNotUpdateStandardVertexProps = updated.entrySet().stream()
- .filter(e -> !e.getValue())
- .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
- assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps, is(Collections.emptyList()));
-
+ didNotUpdateStandardVertexProps = updated.entrySet().stream().filter(e -> !e.getValue())
+ .map(e -> e.getKey().<String>value(AAIProperties.AAI_URI)).collect(Collectors.toList());
+ assertThat("Vertexes should all have their standard props updated", didNotUpdateStandardVertexProps,
+ is(Collections.emptyList()));
}
@@ -326,5 +285,4 @@ public class DbSerializerNotificationEventsTest extends AAISetup {
return updated;
}
-
}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java
index 27d77315..282f6457 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java
@@ -20,6 +20,16 @@
package org.onap.aai.serialization.db;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -48,16 +58,6 @@ import org.onap.aai.util.AAIConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class DbSerializerTest extends AAISetup {
@@ -165,58 +165,42 @@ public class DbSerializerTest extends AAISetup {
*/
Vertex l3interipv4addresslist_1 = graph.addVertex("aai-node-type", "l3-interface-ipv4-address-list",
- "l3-interface-ipv4-address", "l3-interface-ipv4-address-1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
- Vertex subnet_2 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-2",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "l3-interface-ipv4-address", "l3-interface-ipv4-address-1", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
+ Vertex subnet_2 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-2", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
Vertex l3interipv6addresslist_3 = graph.addVertex("aai-node-type", "l3-interface-ipv6-address-list",
- "l3-interface-ipv6-address", "l3-interface-ipv6-address-3",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
- Vertex subnet_4 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-4",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
- Vertex subnet_5 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-5",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
- Vertex l3network_6 = graph.addVertex("aai-node-type", "l3-network", "network-id", "network-id-6", "network-name", "network-name-6",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "l3-interface-ipv6-address", "l3-interface-ipv6-address-3", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
+ Vertex subnet_4 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-4", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
+ Vertex subnet_5 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-5", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
+ Vertex l3network_6 = graph.addVertex("aai-node-type", "l3-network", "network-id", "network-id-6",
+ "network-name", "network-name-6", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
GraphTraversalSource g = graph.traversal();
edgeSer.addEdge(g, l3interipv4addresslist_1, subnet_2);
edgeSer.addEdge(g, l3interipv6addresslist_3, subnet_4);
edgeSer.addTreeEdge(g, subnet_5, l3network_6);
- l3interipv4addresslist_1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3interipv4addresslist_1).toString());
+ l3interipv4addresslist_1.property(AAIProperties.AAI_URI,
+ dbser.getURIForVertex(l3interipv4addresslist_1).toString());
subnet_2.property(AAIProperties.AAI_URI, dbser.getURIForVertex(subnet_2).toString());
- l3interipv6addresslist_3.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3interipv6addresslist_3).toString());
+ l3interipv6addresslist_3.property(AAIProperties.AAI_URI,
+ dbser.getURIForVertex(l3interipv6addresslist_3).toString());
subnet_4.property(AAIProperties.AAI_URI, dbser.getURIForVertex(subnet_4).toString());
subnet_5.property(AAIProperties.AAI_URI, dbser.getURIForVertex(subnet_5).toString());
l3network_6.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3network_6).toString());
@@ -230,52 +214,31 @@ public class DbSerializerTest extends AAISetup {
*/
Vertex l3network1 = graph.addVertex("aai-node-type", "l3-network", "network-id", "network-id-v1",
- "network-name", "network-name-v1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "network-name", "network-name-v1", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex l3network2 = graph.addVertex("aai-node-type", "l3-network", "network-id", "network-id-v2",
- "network-name", "network-name-v2",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
- Vertex subnet1 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-v1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
- Vertex subnet2 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-v2",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "network-name", "network-name-v2", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
+ Vertex subnet1 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-v1", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
+ Vertex subnet2 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-v2", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
Vertex l3interipv4addresslist_1 = graph.addVertex("aai-node-type", "l3-interface-ipv4-address-list",
- "l3-interface-ipv4-address", "l3-intr-v1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "l3-interface-ipv4-address", "l3-intr-v1", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex l3interipv6addresslist_1 = graph.addVertex("aai-node-type", "l3-interface-ipv6-address-list",
- "l3-interface-ipv6-address", "l3-interface-ipv6-v1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "l3-interface-ipv6-address", "l3-interface-ipv6-v1", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
GraphTraversalSource g = graph.traversal();
edgeSer.addTreeEdge(g, subnet1, l3network1);
@@ -285,13 +248,12 @@ public class DbSerializerTest extends AAISetup {
edgeSer.addTreeEdge(g, subnet2, l3network2);
subnet1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(subnet1).toString());
- l3interipv4addresslist_1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3interipv4addresslist_1).toString());
+ l3interipv4addresslist_1.property(AAIProperties.AAI_URI,
+ dbser.getURIForVertex(l3interipv4addresslist_1).toString());
l3network1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3network1).toString());
subnet2.property(AAIProperties.AAI_URI, dbser.getURIForVertex(subnet2).toString());
l3network2.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3network2).toString());
-
-
}
private void vserverSetup() throws AAIException, UnsupportedEncodingException {
@@ -300,61 +262,40 @@ public class DbSerializerTest extends AAISetup {
* and edges
*/
- Vertex vserver1 = graph.addVertex("aai-node-type", "vserver", "vserver-id", "vss1",
- AAIProperties.AAI_URI, "/cloud-infrastructure/cloud-regions/cloud-region/me/123/tenants/tenant/453/vservers/vserver/vss1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ Vertex vserver1 = graph.addVertex("aai-node-type", "vserver", "vserver-id", "vss1", AAIProperties.AAI_URI,
+ "/cloud-infrastructure/cloud-regions/cloud-region/me/123/tenants/tenant/453/vservers/vserver/vss1",
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex lInterface1 = graph.addVertex("aai-node-type", "l-interface", "interface-name", "lIntr1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex lInterface2 = graph.addVertex("aai-node-type", "l-interface", "interface-name", "lIntr2",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex logicalLink1 = graph.addVertex("aai-node-type", "logical-link", "link-name", "logLink1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex logicalLink2 = graph.addVertex("aai-node-type", "logical-link", "link-name", "logLink2",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex l3interipv4addresslist_1 = graph.addVertex("aai-node-type", "l3-interface-ipv4-address-list",
- "l3-interface-ipv4-address", "l3-intr-ipv4-address-1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "l3-interface-ipv4-address", "l3-intr-ipv4-address-1", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
Vertex l3interipv6addresslist_2 = graph.addVertex("aai-node-type", "l3-interface-ipv6-address-list",
- "l3-interface-ipv4-address", "l3-intr-ipv6-address-1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "l3-interface-ipv4-address", "l3-intr-ipv6-address-1", AAIProperties.AAI_UUID,
+ UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333L);
GraphTraversalSource g = graph.traversal();
@@ -369,8 +310,10 @@ public class DbSerializerTest extends AAISetup {
vserver1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(vserver1).toString());
lInterface1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(lInterface1).toString());
lInterface2.property(AAIProperties.AAI_URI, dbser.getURIForVertex(lInterface2).toString());
- l3interipv4addresslist_1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3interipv4addresslist_1).toString());
- l3interipv6addresslist_2.property(AAIProperties.AAI_URI, dbser.getURIForVertex(l3interipv6addresslist_2).toString());
+ l3interipv4addresslist_1.property(AAIProperties.AAI_URI,
+ dbser.getURIForVertex(l3interipv4addresslist_1).toString());
+ l3interipv6addresslist_2.property(AAIProperties.AAI_URI,
+ dbser.getURIForVertex(l3interipv6addresslist_2).toString());
logicalLink1.property(AAIProperties.AAI_URI, dbser.getURIForVertex(logicalLink1).toString());
logicalLink2.property(AAIProperties.AAI_URI, dbser.getURIForVertex(logicalLink2).toString());
}
@@ -617,21 +560,13 @@ public class DbSerializerTest extends AAISetup {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "/network/generic-vnfs/generic-vnf/myvnf", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex vnfc = engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri",
- "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "/network/vnfcs/vnfc/a-name", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
edgeSer.addEdge(engine.tx().traversal(), gvnf, vnfc);
@@ -663,21 +598,13 @@ public class DbSerializerTest extends AAISetup {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "/network/generic-vnfs/generic-vnf/myvnf", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex vnfc = engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri",
- "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "/network/vnfcs/vnfc/a-name", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
edgeSer.addEdge(engine.tx().traversal(), gvnf, vnfc);
@@ -850,19 +777,21 @@ public class DbSerializerTest extends AAISetup {
Introspector obj = loader.introspectorFromName("generic-vnf");
obj = dbser.dbToObject(Collections.singletonList(gvnf), obj, AAIProperties.MAXIMUM_DEPTH, false, "false");
- assertFalse("Relationship does not contain edge-property", obj.getWrappedValue("relationship-list").getWrappedListValue("relationship").get(0).hasProperty("relationship-label"));
+ assertFalse("Relationship does not contain edge-property", obj.getWrappedValue("relationship-list")
+ .getWrappedListValue("relationship").get(0).hasProperty("relationship-label"));
}
@Test
- public void createEdgeWithInvalidLabelTest() throws AAIException, UnsupportedEncodingException,
- SecurityException, IllegalArgumentException {
+ public void createEdgeWithInvalidLabelTest()
+ throws AAIException, UnsupportedEncodingException, SecurityException, IllegalArgumentException {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
"/network/generic-vnfs/generic-vnf/myvnf", "aai-uuid", "a");
- engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name", "aai-uuid", "b");
+ engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name",
+ "aai-uuid", "b");
Introspector relData = loader.introspectorFromName("relationship-data");
relData.setValue("relationship-key", "vnfc.vnfc-name");
@@ -881,13 +810,15 @@ public class DbSerializerTest extends AAISetup {
}
@Test
- public void createEdgeUsingIntrospectorTest() throws AAIException, UnsupportedEncodingException, SecurityException, IllegalArgumentException {
+ public void createEdgeUsingIntrospectorTest()
+ throws AAIException, UnsupportedEncodingException, SecurityException, IllegalArgumentException {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf", "aai-uuid", "a");
- engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name", "aai-uuid", "b");
+ "/network/generic-vnfs/generic-vnf/myvnf", "aai-uuid", "a");
+ engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name",
+ "aai-uuid", "b");
Introspector relData = loader.introspectorFromName("relationship-data");
relData.setValue("relationship-key", "vnfc.vnfc-name");
@@ -979,22 +910,15 @@ public class DbSerializerTest extends AAISetup {
public void deleteItemsWithTraversal() throws AAIException {
DBSerializer dbser = new DBSerializer(version, engine, ModelType.MOXY, "AAI-TEST");
engine.startTransaction();
- Vertex gv = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "id1",
- AAIProperties.AAI_URI, "/network/generic-vnfs/generic-vnf/id1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ Vertex gv = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "id1", AAIProperties.AAI_URI,
+ "/network/generic-vnfs/generic-vnf/id1", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
Vertex lint = engine.tx().addVertex("aai-node-type", "l-interface", "interface-name", "name1",
- AAIProperties.AAI_URI, "/network/generic-vnfs/generic-vnf/id1/l-interfaces/l-interface/name1",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ AAIProperties.AAI_URI, "/network/generic-vnfs/generic-vnf/id1/l-interfaces/l-interface/name1",
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123L,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
assertTrue(engine.tx().traversal().V().has("vnf-id", "id1").hasNext());
assertTrue(engine.tx().traversal().V().has("interface-name", "name1").hasNext());
@@ -1012,20 +936,12 @@ public class DbSerializerTest extends AAISetup {
DBSerializer dbser = new DBSerializer(version, engine, ModelType.MOXY, "AAI-TEST");
engine.startTransaction();
Vertex gv = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "id1", "aai-uri",
- "/network/generic-vnfs/generic-vnf/id1", "aai-uuid", "a",
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
- Vertex lint = engine.tx().addVertex("aai-node-type", "l-interface",
- "aai-uri", "abc",
- "aai-uuid", "b",
- AAIProperties.CREATED_TS, 123L,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333L);
+ "/network/generic-vnfs/generic-vnf/id1", "aai-uuid", "a", AAIProperties.CREATED_TS, 123L,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
+ Vertex lint = engine.tx().addVertex("aai-node-type", "l-interface", "aai-uri", "abc", "aai-uuid", "b",
+ AAIProperties.CREATED_TS, 123L, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333L);
edgeSer.addTreeEdge(engine.tx().traversal(), gv, lint);
Introspector lintIntro = loader.introspectorFromName("l-interface");
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java
index 9a78a433..ead83917 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java
@@ -20,6 +20,18 @@
package org.onap.aai.serialization.db;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -53,23 +65,12 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
//@RunWith(value = Parameterized.class) TODO replace this functionality
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {ConfigConfiguration.class, AAICoreFakeEdgesConfigTranslator.class, NodeIngestor.class,
- EdgeIngestor.class, EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class, XmlFormatTransformerConfiguration.class})
+ EdgeIngestor.class, EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class,
+ XmlFormatTransformerConfiguration.class})
@TestPropertySource(
properties = {"schema.translator.list = config", "schema.nodes.location=src/test/resources/onap/oxm",
"schema.edges.location=src/test/resources/onap/dbedgerules"})
@@ -146,7 +147,8 @@ public class DbSerializer_needsFakeRulesTest {
"l3-interface-ipv6-address", "l3-interface-ipv6-address-3");
Vertex subnet_4 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-4");
Vertex subnet_5 = graph.addVertex("aai-node-type", "subnet", "subnet-id", "subnet-id-5");
- Vertex l3network_6 = graph.addVertex("aai-node-type", "l3-network", "network-id", "network-id-6", "network-name", "network-name-6");
+ Vertex l3network_6 = graph.addVertex("aai-node-type", "l3-network", "network-id", "network-id-6",
+ "network-name", "network-name-6");
GraphTraversalSource g = graph.traversal();
edgeSer.addEdge(g, l3interipv4addresslist_1, subnet_2);
@@ -182,13 +184,9 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "vnfc-" + testName, AAIProperties.AAI_URI,
- "/network/vnfcs/vnfc/vnfc-" + testName,
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/vnfcs/vnfc/vnfc-" + testName, AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "vnfc");
@@ -220,19 +218,13 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf", "aai-uuid", "a",
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/generic-vnfs/generic-vnf/myvnf", "aai-uuid", "a", AAIProperties.CREATED_TS, 123,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Vertex vnfc = engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri",
- "/network/vnfcs/vnfc/a-name", "aai-uuid", "b",
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/vnfcs/vnfc/a-name", "aai-uuid", "b", AAIProperties.CREATED_TS, 123,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
// sunny day case
Introspector relData = loader.introspectorFromName("relationship-data");
@@ -288,21 +280,13 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/generic-vnfs/generic-vnf/myvnf", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Vertex vnfc = engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri",
- "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/vnfcs/vnfc/a-name", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
edgeSer.addEdge(graph.traversal(), gvnf, vnfc, "uses");
Introspector relData = loader.introspectorFromName("relationship-data");
@@ -337,21 +321,13 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/generic-vnfs/generic-vnf/myvnf", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Vertex vnfc = engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri",
- "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/vnfcs/vnfc/a-name", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Introspector relData = loader.introspectorFromName("relationship-data");
relData.setValue("relationship-key", "vnfc.vnfc-name");
@@ -380,21 +356,13 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/generic-vnfs/generic-vnf/myvnf", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Vertex vnfc = engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri",
- "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/vnfcs/vnfc/a-name", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
edgeSer.addEdge(graph.traversal(), gvnf, vnfc, "uses");
edgeSer.addEdge(graph.traversal(), gvnf, vnfc, "re-uses");
edgeSer.addEdge(graph.traversal(), gvnf, vnfc, "over-uses");
@@ -430,21 +398,13 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
Vertex gvnf = engine.tx().addVertex("aai-node-type", "generic-vnf", "vnf-id", "myvnf", "aai-uri",
- "/network/generic-vnfs/generic-vnf/myvnf",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/generic-vnfs/generic-vnf/myvnf", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Vertex vnfc = engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri",
- "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ "/network/vnfcs/vnfc/a-name", AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
+ AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION,
+ "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
edgeSer.addEdge(graph.traversal(), gvnf, vnfc, "uses");
edgeSer.addEdge(graph.traversal(), gvnf, vnfc, "re-uses");
edgeSer.addEdge(graph.traversal(), gvnf, vnfc, "over-uses");
@@ -512,12 +472,10 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
- engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name", "aai-uuid", "b",
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name",
+ "aai-uuid", "b", AAIProperties.CREATED_TS, 123, AAIProperties.SOURCE_OF_TRUTH, "sot",
+ AAIProperties.RESOURCE_VERSION, "123", AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
+ AAIProperties.LAST_MOD_TS, 333);
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "vnfc");
@@ -567,12 +525,9 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", "vnfc");
@@ -653,12 +608,9 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Introspector relationship;
Introspector relationshipList;
@@ -726,12 +678,9 @@ public class DbSerializer_needsFakeRulesTest {
engine.startTransaction();
engine.tx().addVertex("aai-node-type", "vnfc", "vnfc-name", "a-name", "aai-uri", "/network/vnfcs/vnfc/a-name",
- AAIProperties.AAI_UUID, UUID.randomUUID().toString(),
- AAIProperties.CREATED_TS, 123,
- AAIProperties.SOURCE_OF_TRUTH, "sot",
- AAIProperties.RESOURCE_VERSION, "123",
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot",
- AAIProperties.LAST_MOD_TS, 333);
+ AAIProperties.AAI_UUID, UUID.randomUUID().toString(), AAIProperties.CREATED_TS, 123,
+ AAIProperties.SOURCE_OF_TRUTH, "sot", AAIProperties.RESOURCE_VERSION, "123",
+ AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, "lmsot", AAIProperties.LAST_MOD_TS, 333);
Introspector relationship;
Introspector relationshipList;
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java
index 69206a40..5dfa12b7 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/EdgeRulesTest.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.assertEquals;
import com.google.common.collect.Multimap;
import java.util.*;
-import java.util.stream.Collectors;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.junit.Rule;
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/EdgerPairCanBeBothCousinAndParentChildTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/EdgerPairCanBeBothCousinAndParentChildTest.java
index d00408e8..cc0eb889 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/EdgerPairCanBeBothCousinAndParentChildTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/EdgerPairCanBeBothCousinAndParentChildTest.java
@@ -20,6 +20,16 @@
package org.onap.aai.serialization.db;
+import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphFactory;
@@ -40,16 +50,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collections;
-
-import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class EdgerPairCanBeBothCousinAndParentChildTest extends AAISetup {
@@ -106,8 +106,8 @@ public class EdgerPairCanBeBothCousinAndParentChildTest extends AAISetup {
*/
private void initData() throws UnsupportedEncodingException, AAIException, URISyntaxException {
engine.startTransaction();
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
-
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
Introspector gvnf = loader.introspectorFromName("generic-vnf");
gvnf.setValue("vnf-id", "gvnf-a" + SOURCE_OF_TRUTH);
@@ -127,23 +127,13 @@ public class EdgerPairCanBeBothCousinAndParentChildTest extends AAISetup {
lagints.setValue("lag-interface", Collections.singletonList(lagInt.getUnderlyingObject()));
gvnf.setValue("lag-interfaces", lagints.getUnderlyingObject());
-
-
Vertex gvnfV = serializer.createNewVertex(gvnf);
QueryParser uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(gvnfAUri));
serializer.serializeToDb(gvnf, gvnfV, uriQuery, "generic-vnf", gvnf.marshal(false));
- assertTrue("generic-vnf-a created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, gvnfAUri)
- .hasNext());
- assertTrue("lag-int-a created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lagIntAUri)
- .hasNext());
- assertTrue("l-int created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lintUri)
- .hasNext());
-
-
+ assertTrue("generic-vnf-a created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfAUri).hasNext());
+ assertTrue("lag-int-a created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, lagIntAUri).hasNext());
+ assertTrue("l-int created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, lintUri).hasNext());
gvnf = loader.introspectorFromName("generic-vnf");
gvnf.setValue("vnf-id", "gvnf-b" + SOURCE_OF_TRUTH);
@@ -166,69 +156,43 @@ public class EdgerPairCanBeBothCousinAndParentChildTest extends AAISetup {
serializer.serializeToDb(gvnf, gvnfV, uriQuery, "generic-vnf", gvnf.marshal(false));
engine.tx().traversal().V().forEachRemaining(v -> System.out.println(v.<String>value(AAIProperties.AAI_URI)));
- assertTrue("generic-vnf-b created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, gvnfBUri)
- .hasNext());
- assertTrue("lag-int-b created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lagIntBUri)
- .hasNext());
+ assertTrue("generic-vnf-b created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfBUri).hasNext());
+ assertTrue("lag-int-b created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, lagIntBUri).hasNext());
assertTrue("lag-interface relationship l-interface created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lagIntBUri)
- .both()
- .has(AAIProperties.AAI_URI, lintUri)
- .hasNext());
+ .has(AAIProperties.AAI_URI, lagIntBUri).both().has(AAIProperties.AAI_URI, lintUri).hasNext());
}
-
@Test
public void verifyReadOfGenericVnfATest() throws AAIException, UnsupportedEncodingException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
- String gvnfALatestView = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfAUri).next()).marshal(false);
+ String gvnfALatestView =
+ serializer.getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfAUri).next())
+ .marshal(false);
+ assertThat(gvnfALatestView, hasJsonPath("$.lag-interfaces.lag-interface[*]", hasSize(1)));
assertThat(gvnfALatestView,
- hasJsonPath(
- "$.lag-interfaces.lag-interface[*]",
- hasSize(1)
- ));
- assertThat(gvnfALatestView,
- hasJsonPath(
- "$.lag-interfaces.lag-interface[*].l-interfaces.l-interface[*]",
- hasSize(1)
- ));
- assertThat(gvnfALatestView,
- hasJsonPath(
+ hasJsonPath("$.lag-interfaces.lag-interface[*].l-interfaces.l-interface[*]", hasSize(1)));
+ assertThat(gvnfALatestView, hasJsonPath(
"$.lag-interfaces.lag-interface[*].l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + lagIntBUri
- )
- ));
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + lagIntBUri)));
}
@Test
public void verifyReadOfGenericVnfBTest() throws AAIException, UnsupportedEncodingException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
- String gvnfBLatestView = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfBUri).next()).marshal(false);
+ String gvnfBLatestView =
+ serializer.getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfBUri).next())
+ .marshal(false);
+ assertThat(gvnfBLatestView, hasJsonPath("$.lag-interfaces.lag-interface[*]", hasSize(1)));
+ assertThat(gvnfBLatestView, not(hasJsonPath("$.lag-interfaces.lag-interface[*].l-interfaces.l-interface[*]")));
assertThat(gvnfBLatestView,
- hasJsonPath(
- "$.lag-interfaces.lag-interface[*]",
- hasSize(1)
- ));
- assertThat(gvnfBLatestView,
- not(hasJsonPath(
- "$.lag-interfaces.lag-interface[*].l-interfaces.l-interface[*]"
- )));
- assertThat(gvnfBLatestView,
- hasJsonPath(
- "$.lag-interfaces.lag-interface[*].relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + lintUri
- )
- ));
+ hasJsonPath("$.lag-interfaces.lag-interface[*].relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + lintUri)));
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java
index 20e300a1..44f89746 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java
@@ -17,15 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.serialization.db;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.mockito.Matchers;
import org.mockito.Mockito;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
@@ -34,12 +38,6 @@ import org.onap.aai.serialization.engines.query.QueryEngine;
import org.onap.aai.util.AAIConstants;
import org.springframework.boot.test.rule.OutputCapture;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.mockito.Matchers.eq;
-
public class ImpliedDeleteUnitTest {
private TransactionalGraphEngine mockEngine;
@@ -51,10 +49,10 @@ public class ImpliedDeleteUnitTest {
public final OutputCapture outputCapture = new OutputCapture();
@Before
- public void setup(){
- mockEngine = Mockito.mock(TransactionalGraphEngine.class);
+ public void setup() {
+ mockEngine = Mockito.mock(TransactionalGraphEngine.class);
mockSerializer = Mockito.mock(DBSerializer.class);
- impliedDelete = Mockito.spy(new ImpliedDelete(mockEngine, mockSerializer));
+ impliedDelete = Mockito.spy(new ImpliedDelete(mockEngine, mockSerializer));
}
// aai.implied.delete.whitelist.sdnc=*
@@ -63,10 +61,7 @@ public class ImpliedDeleteUnitTest {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
- Mockito
- .doReturn("*")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
+ Mockito.doReturn("*").when(impliedDelete).get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Mockito.when(mockEngine.getQueryEngine()).thenReturn(mockQueryEngine);
@@ -91,10 +86,7 @@ public class ImpliedDeleteUnitTest {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
- Mockito
- .doReturn("'vserver'")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
+ Mockito.doReturn("'vserver'").when(impliedDelete).get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Mockito.when(mockEngine.getQueryEngine()).thenReturn(mockQueryEngine);
@@ -118,10 +110,7 @@ public class ImpliedDeleteUnitTest {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
- Mockito
- .doReturn("'vserver'")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
+ Mockito.doReturn("'vserver'").when(impliedDelete).get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Mockito.when(mockEngine.getQueryEngine()).thenReturn(mockQueryEngine);
@@ -149,10 +138,8 @@ public class ImpliedDeleteUnitTest {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
- Mockito
- .doReturn("'vce','pserver','vserver','cloud-region'")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
+ Mockito.doReturn("'vce','pserver','vserver','cloud-region'").when(impliedDelete)
+ .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Mockito.when(mockEngine.getQueryEngine()).thenReturn(mockQueryEngine);
@@ -173,17 +160,13 @@ public class ImpliedDeleteUnitTest {
// aai.implied.delete.whitelist.sdnc='vserver','vce','pserver'
@Test
public void testImpliedDeleteWhenUserIsAllowedToInvokeMultipleMethodsAndDeletableReturnsMultipleVertexes()
- throws AAIException, UnsupportedEncodingException {
+ throws AAIException, UnsupportedEncodingException {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
// On a spy the syntax should be doReturn => when => method to spy
// On a mock the syntax should be when => thenReturn|thenAnswer
- Mockito
- .doReturn("'vserver'")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
-
+ Mockito.doReturn("'vserver'").when(impliedDelete).get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Introspector mockIntrospector = Mockito.mock(Introspector.class);
@@ -213,20 +196,13 @@ public class ImpliedDeleteUnitTest {
vertices.add(volume3);
vertices.add(volume4);
- Mockito
- .when(mockQueryEngine.findDeletable(Mockito.anyList()))
- .thenReturn(vertices);
+ Mockito.when(mockQueryEngine.findDeletable(Mockito.anyList())).thenReturn(vertices);
- Mockito
- .when(mockSerializer.getLatestVersionView(Mockito.anyObject()))
- .thenReturn(mockIntrospector);
+ Mockito.when(mockSerializer.getLatestVersionView(Mockito.anyObject())).thenReturn(mockIntrospector);
- Mockito
- .when(mockIntrospector.marshal(false))
- .thenReturn("{\"volume-id\":\"volume-1\"}")
- .thenReturn("{\"volume-id\":\"volume-2\"}")
- .thenReturn("{\"volume-id\":\"volume-3\"}")
- .thenReturn("{\"volume-id\":\"volume-4\"}");
+ Mockito.when(mockIntrospector.marshal(false)).thenReturn("{\"volume-id\":\"volume-1\"}")
+ .thenReturn("{\"volume-id\":\"volume-2\"}").thenReturn("{\"volume-id\":\"volume-3\"}")
+ .thenReturn("{\"volume-id\":\"volume-4\"}");
impliedDelete.execute(vserver.id(), "SDNC", "vserver", vertices);
}
@@ -237,10 +213,7 @@ public class ImpliedDeleteUnitTest {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
- Mockito
- .doReturn("")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
+ Mockito.doReturn("").when(impliedDelete).get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Mockito.when(mockEngine.getQueryEngine()).thenReturn(mockQueryEngine);
@@ -260,14 +233,12 @@ public class ImpliedDeleteUnitTest {
// aai.implied.delete.whitelist.sdnc='vce'
@Test(expected = AAIException.class)
- public void testImpliedDeleteWhenUserIsAllowedToDeleteVceChildrenButRequestedToDeleteVserverChildren() throws AAIException {
+ public void testImpliedDeleteWhenUserIsAllowedToDeleteVceChildrenButRequestedToDeleteVserverChildren()
+ throws AAIException {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
- Mockito
- .doReturn("'vce'")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
+ Mockito.doReturn("'vce'").when(impliedDelete).get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Mockito.when(mockEngine.getQueryEngine()).thenReturn(mockQueryEngine);
@@ -286,17 +257,14 @@ public class ImpliedDeleteUnitTest {
}
@Test
- public void testImpliedDeleteWhenUserIsAllowedToDeleteAndPrintingDeletingVertexItThrowsExceptionVerifyLog() throws AAIException, UnsupportedEncodingException {
+ public void testImpliedDeleteWhenUserIsAllowedToDeleteAndPrintingDeletingVertexItThrowsExceptionVerifyLog()
+ throws AAIException, UnsupportedEncodingException {
QueryEngine mockQueryEngine = Mockito.mock(QueryEngine.class);
// On a spy the syntax should be doReturn => when => method to spy
// On a mock the syntax should be when => thenReturn|thenAnswer
- Mockito
- .doReturn("'vserver'")
- .when(impliedDelete)
- .get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc","");
-
+ Mockito.doReturn("'vserver'").when(impliedDelete).get(AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + "sdnc", "");
Introspector mockIntrospector = Mockito.mock(Introspector.class);
@@ -314,18 +282,14 @@ public class ImpliedDeleteUnitTest {
vertices.add(volume1);
- Mockito
- .when(mockQueryEngine.findDeletable(Mockito.anyList()))
- .thenReturn(vertices);
+ Mockito.when(mockQueryEngine.findDeletable(Mockito.anyList())).thenReturn(vertices);
- Mockito
- .when(mockSerializer.getLatestVersionView(Mockito.anyObject()))
- .thenThrow(new RuntimeException("Unable to find node"));
+ Mockito.when(mockSerializer.getLatestVersionView(Mockito.anyObject()))
+ .thenThrow(new RuntimeException("Unable to find node"));
impliedDelete.execute(vserver.id(), "SDNC", "vserver", vertices);
- outputCapture.expect(
- CoreMatchers.containsString("Encountered an exception during retrieval of vertex properties with vertex-id " + vserver.id())
- );
+ outputCapture.expect(CoreMatchers.containsString(
+ "Encountered an exception during retrieval of vertex properties with vertex-id " + vserver.id()));
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/OneToOneEdgeUpdateTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/OneToOneEdgeUpdateTest.java
index 0c90c735..16820d6a 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/OneToOneEdgeUpdateTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/OneToOneEdgeUpdateTest.java
@@ -20,6 +20,16 @@
package org.onap.aai.serialization.db;
+import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collections;
+
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphFactory;
@@ -40,16 +50,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Collections;
-
-import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class OneToOneEdgeUpdateTest extends AAISetup {
@@ -108,8 +108,8 @@ public class OneToOneEdgeUpdateTest extends AAISetup {
*/
private void initData() throws UnsupportedEncodingException, AAIException, URISyntaxException {
engine.startTransaction();
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
-
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
Introspector gvnf = loader.introspectorFromName("generic-vnf");
gvnf.setValue("vnf-id", "gvnf-a" + SOURCE_OF_TRUTH);
@@ -139,28 +139,16 @@ public class OneToOneEdgeUpdateTest extends AAISetup {
lints.setValue("l-interface", Arrays.asList(lint.getUnderlyingObject(), lintA.getUnderlyingObject()));
gvnf.setValue("l-interfaces", lints.getUnderlyingObject());
-
System.out.println(gvnf.marshal(true));
Vertex gvnfV = serializer.createNewVertex(gvnf);
QueryParser uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(gvnfAUri));
serializer.serializeToDb(gvnf, gvnfV, uriQuery, "generic-vnf", gvnf.marshal(false));
- assertTrue("generic-vnf-a created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, gvnfAUri)
- .hasNext());
- assertTrue("l-int created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lintUri)
- .hasNext());
- assertTrue("l-int-a created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lintAUri)
- .hasNext());
- assertTrue("sriov-vf created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, sriovVfUri)
- .hasNext());
- assertTrue("sriov-vf-a created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, sriovVfAUri)
- .hasNext());
-
+ assertTrue("generic-vnf-a created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfAUri).hasNext());
+ assertTrue("l-int created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, lintUri).hasNext());
+ assertTrue("l-int-a created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, lintAUri).hasNext());
+ assertTrue("sriov-vf created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, sriovVfUri).hasNext());
+ assertTrue("sriov-vf-a created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, sriovVfAUri).hasNext());
gvnf = loader.introspectorFromName("generic-vnf");
gvnf.setValue("vnf-id", "gvnf-b" + SOURCE_OF_TRUTH);
@@ -183,87 +171,57 @@ public class OneToOneEdgeUpdateTest extends AAISetup {
serializer.serializeToDb(gvnf, gvnfV, uriQuery, "generic-vnf", gvnf.marshal(false));
engine.tx().traversal().V().forEachRemaining(v -> System.out.println(v.<String>value(AAIProperties.AAI_URI)));
- assertTrue("generic-vnf-b created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, gvnfBUri)
- .hasNext());
- assertTrue("l-int-b created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lIntBUri)
- .hasNext());
+ assertTrue("generic-vnf-b created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfBUri).hasNext());
+ assertTrue("l-int-b created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, lIntBUri).hasNext());
assertTrue("l-interface relationship sriov-vf created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lIntBUri)
- .both()
- .has(AAIProperties.AAI_URI, sriovVfUri)
- .hasNext());
+ .has(AAIProperties.AAI_URI, lIntBUri).both().has(AAIProperties.AAI_URI, sriovVfUri).hasNext());
}
-
@Test
public void verifyReadOfGenericVnfATest() throws AAIException, UnsupportedEncodingException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
-
- String gvnfALatestView = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfAUri).next()).marshal(false);
-
- assertThat(gvnfALatestView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*]",
- hasSize(2)
- ));
- assertThat(gvnfALatestView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].sriov-vfs.sriov-vf[*]",
- hasSize(2)
- ));
- assertThat(gvnfALatestView,
- hasJsonPath(
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
+
+ String gvnfALatestView =
+ serializer.getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfAUri).next())
+ .marshal(false);
+
+ assertThat(gvnfALatestView, hasJsonPath("$.l-interfaces.l-interface[*]", hasSize(2)));
+ assertThat(gvnfALatestView, hasJsonPath("$.l-interfaces.l-interface[*].sriov-vfs.sriov-vf[*]", hasSize(2)));
+ assertThat(gvnfALatestView, hasJsonPath(
"$.l-interfaces.l-interface[*].sriov-vfs.sriov-vf[*].relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + lIntBUri
- )
- ));
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + lIntBUri)));
}
@Test
public void verifyReadOfGenericVnfBTest() throws AAIException, UnsupportedEncodingException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
- String gvnfBLatestView = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfBUri).next()).marshal(false);
+ String gvnfBLatestView =
+ serializer.getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfBUri).next())
+ .marshal(false);
+ assertThat(gvnfBLatestView, hasJsonPath("$.l-interfaces.l-interface[*]", hasSize(1)));
+ assertThat(gvnfBLatestView, not(hasJsonPath("$.l-interfaces.l-interface[*].sriov-vfs.sriov-vf[*]")));
assertThat(gvnfBLatestView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*]",
- hasSize(1)
- ));
- assertThat(gvnfBLatestView,
- not(hasJsonPath(
- "$.l-interfaces.l-interface[*].sriov-vfs.sriov-vf[*]"
- )));
- assertThat(gvnfBLatestView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + sriovVfUri
- )
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + sriovVfUri)));
}
@Test
- public void replaceRelationshipToSriovVfTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ public void replaceRelationshipToSriovVfTest()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
- Introspector lint = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, lIntBUri).next());
+ Introspector lint = serializer
+ .getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, lIntBUri).next());
String lintView = lint.marshal(false);
- assertThat(lintView,
- hasJsonPath(
- "$.relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + sriovVfUri
- )
- ));
+ assertThat(lintView, hasJsonPath("$.relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + sriovVfUri)));
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-link", sriovVfAUri);
@@ -273,13 +231,14 @@ public class OneToOneEdgeUpdateTest extends AAISetup {
QueryParser uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(lIntBUri));
serializer.serializeToDb(lint, engine.tx().traversal().V().has(AAIProperties.AAI_URI, lIntBUri).next(),
- uriQuery, "generic-vnf", lint.marshal(false));
+ uriQuery, "generic-vnf", lint.marshal(false));
}
-
@Test
- public void createRelationshipForNonExistentRuleTest() throws AAIException, UnsupportedEncodingException, URISyntaxException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ public void createRelationshipForNonExistentRuleTest()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
Vertex gvnfAV = engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfAUri).next();
Introspector gvnfA = serializer.getLatestVersionView(gvnfAV);
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/VersionedScenariosTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/VersionedScenariosTest.java
index 8e77c549..1dcdccbf 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/VersionedScenariosTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/VersionedScenariosTest.java
@@ -20,6 +20,18 @@
package org.onap.aai.serialization.db;
+import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphFactory;
@@ -40,18 +52,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class VersionedScenariosTest extends AAISetup {
@@ -108,8 +108,8 @@ public class VersionedScenariosTest extends AAISetup {
*/
private void initData() throws UnsupportedEncodingException, AAIException, URISyntaxException {
engine.startTransaction();
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
-
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
Introspector gvnf = loader.introspectorFromName("generic-vnf");
gvnf.setValue("vnf-id", "gvnf" + SOURCE_OF_TRUTH);
@@ -132,27 +132,20 @@ public class VersionedScenariosTest extends AAISetup {
QueryParser uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(gvnfUri));
serializer.serializeToDb(gvnf, gvnfV, uriQuery, "generic-vnf", gvnf.marshal(false));
- assertTrue("generic-vnf created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, gvnfUri)
- .hasNext());
- assertTrue("source created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lintSourceUri)
- .hasNext());
- assertTrue("destination created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, lintDestinationUri)
- .hasNext());
-
-
+ assertTrue("generic-vnf created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfUri).hasNext());
+ assertTrue("source created", engine.tx().traversal().V().has(AAIProperties.AAI_URI, lintSourceUri).hasNext());
+ assertTrue("destination created",
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, lintDestinationUri).hasNext());
Introspector llDefault = loader.introspectorFromName("logical-link");
llDefault.setValue("link-name", "llDefault");
List<Object> relList = new ArrayList<>();
Introspector relationship = loader.introspectorFromName("relationship");
- //relationship.setValue("related-to", "l-interface");
+ // relationship.setValue("related-to", "l-interface");
relationship.setValue("related-link", lintSourceUri);
relList.add(relationship.getUnderlyingObject());
relationship = loader.introspectorFromName("relationship");
- //relationship.setValue("related-to", "l-interface");
+ // relationship.setValue("related-to", "l-interface");
relationship.setValue("related-link", lintDestinationUri);
relList.add(relationship.getUnderlyingObject());
Introspector relationshipList = loader.introspectorFromName("relationship-list");
@@ -163,20 +156,13 @@ public class VersionedScenariosTest extends AAISetup {
uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(llDefaultUri));
serializer.serializeToDb(llDefault, llDefaultV, uriQuery, "logical-link", llDefault.marshal(false));
- assertTrue("logical-link created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, llDefaultUri)
- .hasNext());
- assertTrue("default source relationship created",engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, llDefaultUri)
- .both()
- .has(AAIProperties.AAI_URI, lintSourceUri)
- .hasNext());
- assertTrue("default destination relationship created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, llDefaultUri)
- .both()
- .has(AAIProperties.AAI_URI, lintDestinationUri)
- .hasNext());
-
+ assertTrue("logical-link created",
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, llDefaultUri).hasNext());
+ assertTrue("default source relationship created", engine.tx().traversal().V()
+ .has(AAIProperties.AAI_URI, llDefaultUri).both().has(AAIProperties.AAI_URI, lintSourceUri).hasNext());
+ assertTrue("default destination relationship created",
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, llDefaultUri).both()
+ .has(AAIProperties.AAI_URI, lintDestinationUri).hasNext());
Introspector llLabeled = loader.introspectorFromName("logical-link");
llLabeled.setValue("link-name", "llLabeled");
@@ -199,179 +185,122 @@ public class VersionedScenariosTest extends AAISetup {
uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(llLabeledUri));
serializer.serializeToDb(llLabeled, llLabeledV, uriQuery, "logical-link", llLabeled.marshal(false));
- assertTrue("logical-link created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, llLabeledUri)
- .hasNext());
- assertTrue("labeled source relationship created",engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, llLabeledUri)
- .both("org.onap.relationships.inventory.Source")
- .has(AAIProperties.AAI_URI, lintSourceUri)
- .hasNext());
- assertTrue("labeled destination relationship created", engine.tx().traversal().V()
- .has(AAIProperties.AAI_URI, llLabeledUri)
- .both("org.onap.relationships.inventory.Destination")
- .has(AAIProperties.AAI_URI, lintDestinationUri)
- .hasNext());
+ assertTrue("logical-link created",
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, llLabeledUri).hasNext());
+ assertTrue("labeled source relationship created",
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, llLabeledUri)
+ .both("org.onap.relationships.inventory.Source").has(AAIProperties.AAI_URI, lintSourceUri)
+ .hasNext());
+ assertTrue("labeled destination relationship created",
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, llLabeledUri)
+ .both("org.onap.relationships.inventory.Destination")
+ .has(AAIProperties.AAI_URI, lintDestinationUri).hasNext());
}
-
@Test
public void verifyRelsOfLatestViewOfGenericVnf() throws AAIException, UnsupportedEncodingException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
- String gvnfLatestView = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfUri).next()).marshal(false);
+ String gvnfLatestView =
+ serializer.getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfUri).next())
+ .marshal(false);
assertThat(gvnfLatestView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*]",
- hasSize(4)
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*]", hasSize(4)));
assertThat(gvnfLatestView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + llDefaultUri,
- "/aai/" + schemaVersions.getDefaultVersion() + llDefaultUri,
- "/aai/" + schemaVersions.getDefaultVersion() + llLabeledUri,
- "/aai/" + schemaVersions.getDefaultVersion() + llLabeledUri
- )
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + llDefaultUri,
+ "/aai/" + schemaVersions.getDefaultVersion() + llDefaultUri,
+ "/aai/" + schemaVersions.getDefaultVersion() + llLabeledUri,
+ "/aai/" + schemaVersions.getDefaultVersion() + llLabeledUri)));
assertThat(gvnfLatestView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*].relationship-label",
- containsInAnyOrder(
- "tosca.relationships.network.LinksTo",
- "tosca.relationships.network.LinksTo",
- "org.onap.relationships.inventory.Source",
- "org.onap.relationships.inventory.Destination")
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*].relationship-label",
+ containsInAnyOrder("tosca.relationships.network.LinksTo", "tosca.relationships.network.LinksTo",
+ "org.onap.relationships.inventory.Source",
+ "org.onap.relationships.inventory.Destination")));
}
@Test
public void verifyRelsOfLatestViewOfLLDefault() throws AAIException, UnsupportedEncodingException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
- String llDefaultLatestView = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, llDefaultUri).next()).marshal(false);
- assertThat(llDefaultLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*]",
- hasSize(2)
- ));
- assertThat(llDefaultLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + lintSourceUri,
- "/aai/" + schemaVersions.getDefaultVersion() + lintDestinationUri
- )
- ));
+ String llDefaultLatestView = serializer
+ .getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, llDefaultUri).next())
+ .marshal(false);
+ assertThat(llDefaultLatestView, hasJsonPath("$.relationship-list.relationship[*]", hasSize(2)));
assertThat(llDefaultLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*].relationship-label",
- containsInAnyOrder("tosca.relationships.network.LinksTo","tosca.relationships.network.LinksTo")
- ));
- assertThat(llDefaultLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*].relationship-label",
- not(contains("org.onap.relationships.inventory.Source", "org.onap.relationships.inventory.Destination"))
- ));
+ hasJsonPath("$.relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + lintSourceUri,
+ "/aai/" + schemaVersions.getDefaultVersion() + lintDestinationUri)));
+ assertThat(llDefaultLatestView, hasJsonPath("$.relationship-list.relationship[*].relationship-label",
+ containsInAnyOrder("tosca.relationships.network.LinksTo", "tosca.relationships.network.LinksTo")));
+ assertThat(llDefaultLatestView, hasJsonPath("$.relationship-list.relationship[*].relationship-label", not(
+ contains("org.onap.relationships.inventory.Source", "org.onap.relationships.inventory.Destination"))));
}
@Test
public void verifyRelsOfLatestViewOfLLLabeled() throws AAIException, UnsupportedEncodingException {
- DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ DBSerializer serializer = new DBSerializer(version, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
- String llLabeledLatestView = serializer.getLatestVersionView(
- engine.tx().traversal().V().has(AAIProperties.AAI_URI, llLabeledUri).next()).marshal(false);
- assertThat(llLabeledLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*]",
- hasSize(2)
- ));
+ String llLabeledLatestView = serializer
+ .getLatestVersionView(engine.tx().traversal().V().has(AAIProperties.AAI_URI, llLabeledUri).next())
+ .marshal(false);
+ assertThat(llLabeledLatestView, hasJsonPath("$.relationship-list.relationship[*]", hasSize(2)));
assertThat(llLabeledLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + schemaVersions.getDefaultVersion() + lintSourceUri,
- "/aai/" + schemaVersions.getDefaultVersion() + lintDestinationUri
- )
- ));
- assertThat(llLabeledLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*].relationship-label",
- not(containsInAnyOrder("tosca.relationships.network.LinksTo","tosca.relationships.network.LinksTo"))
- ));
- assertThat(llLabeledLatestView,
- hasJsonPath(
- "$.relationship-list.relationship[*].relationship-label",
- contains("org.onap.relationships.inventory.Source", "org.onap.relationships.inventory.Destination")
- ));
+ hasJsonPath("$.relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + schemaVersions.getDefaultVersion() + lintSourceUri,
+ "/aai/" + schemaVersions.getDefaultVersion() + lintDestinationUri)));
+ assertThat(llLabeledLatestView, hasJsonPath("$.relationship-list.relationship[*].relationship-label",
+ not(containsInAnyOrder("tosca.relationships.network.LinksTo", "tosca.relationships.network.LinksTo"))));
+ assertThat(llLabeledLatestView, hasJsonPath("$.relationship-list.relationship[*].relationship-label",
+ contains("org.onap.relationships.inventory.Source", "org.onap.relationships.inventory.Destination")));
}
-
@Test
public void verifyRelsOfOldViewOfGenericVnf() throws AAIException, UnsupportedEncodingException {
SchemaVersion oldVersion = new SchemaVersion("v11");
Loader oldLoader = loaderFactory.getLoaderStrategy(introspectorFactoryType, oldVersion);
- DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
-
- String gvnfOldView = oldSerializer.dbToObject(
- Collections.singletonList(engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfUri).next()),
- oldLoader.introspectorFromName("generic-vnf"),
- AAIProperties.MAXIMUM_DEPTH, false, "false")
- .marshal(false);
+ DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
+
+ String gvnfOldView = oldSerializer
+ .dbToObject(
+ Collections
+ .singletonList(engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfUri).next()),
+ oldLoader.introspectorFromName("generic-vnf"), AAIProperties.MAXIMUM_DEPTH, false, "false")
+ .marshal(false);
assertThat(gvnfOldView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*]",
- hasSize(2)
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*]", hasSize(2)));
assertThat(gvnfOldView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*].relationship-label",
- emptyCollectionOf(String.class)
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*].relationship-label",
+ emptyCollectionOf(String.class)));
assertThat(gvnfOldView,
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + oldVersion + llDefaultUri,
- "/aai/" + oldVersion + llDefaultUri
- )
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + oldVersion + llDefaultUri, "/aai/" + oldVersion + llDefaultUri)));
}
@Test
public void verifyRelsOfOldViewOfLLDefault() throws AAIException, UnsupportedEncodingException {
SchemaVersion oldVersion = new SchemaVersion("v11");
Loader oldLoader = loaderFactory.getLoaderStrategy(introspectorFactoryType, oldVersion);
- DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
-
- String llDefaultOldView = oldSerializer.dbToObject(
- Collections.singletonList(engine.tx().traversal().V().has(AAIProperties.AAI_URI, llDefaultUri).next()),
- oldLoader.introspectorFromName("logical-link"),
- AAIProperties.MAXIMUM_DEPTH, false, "false")
- .marshal(false);
- assertThat(llDefaultOldView,
- hasJsonPath(
- "$.relationship-list.relationship[*]",
- hasSize(2)
- ));
+ DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
+
+ String llDefaultOldView = oldSerializer
+ .dbToObject(
+ Collections.singletonList(
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, llDefaultUri).next()),
+ oldLoader.introspectorFromName("logical-link"), AAIProperties.MAXIMUM_DEPTH, false, "false")
+ .marshal(false);
+ assertThat(llDefaultOldView, hasJsonPath("$.relationship-list.relationship[*]", hasSize(2)));
assertThat(llDefaultOldView,
- hasJsonPath(
- "$.relationship-list.relationship[*].relationship-label",
- emptyCollectionOf(String.class)
- ));
- assertThat(llDefaultOldView,
- hasJsonPath(
- "$.relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + oldVersion + lintSourceUri,
- "/aai/" + oldVersion + lintDestinationUri
- )
- ));
+ hasJsonPath("$.relationship-list.relationship[*].relationship-label", emptyCollectionOf(String.class)));
+ assertThat(llDefaultOldView, hasJsonPath("$.relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + oldVersion + lintSourceUri, "/aai/" + oldVersion + lintDestinationUri)));
}
@@ -379,39 +308,32 @@ public class VersionedScenariosTest extends AAISetup {
public void verifyRelsOfOldViewOfLLLabeled() throws AAIException, UnsupportedEncodingException {
SchemaVersion oldVersion = new SchemaVersion("v11");
Loader oldLoader = loaderFactory.getLoaderStrategy(introspectorFactoryType, oldVersion);
- DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
-
- String llLabeledtOldView = oldSerializer.dbToObject(
- Collections.singletonList(engine.tx().traversal().V().has(AAIProperties.AAI_URI, llLabeledUri).next()),
- oldLoader.introspectorFromName("logical-link"),
- AAIProperties.MAXIMUM_DEPTH, false, "false")
- .marshal(false);
- assertThat(llLabeledtOldView,
- not(hasJsonPath(
- "$.relationship-list.relationship[*]"
- )));
+ DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
+
+ String llLabeledtOldView = oldSerializer
+ .dbToObject(
+ Collections.singletonList(
+ engine.tx().traversal().V().has(AAIProperties.AAI_URI, llLabeledUri).next()),
+ oldLoader.introspectorFromName("logical-link"), AAIProperties.MAXIMUM_DEPTH, false, "false")
+ .marshal(false);
+ assertThat(llLabeledtOldView, not(hasJsonPath("$.relationship-list.relationship[*]")));
}
-
@Test
- public void useOldVersionToUpdatedGenericVnfAndVerifyLatestVersionRels() throws AAIException, UnsupportedEncodingException, URISyntaxException {
+ public void useOldVersionToUpdatedGenericVnfAndVerifyLatestVersionRels()
+ throws AAIException, UnsupportedEncodingException, URISyntaxException {
SchemaVersion oldVersion = new SchemaVersion("v11");
Loader oldLoader = loaderFactory.getLoaderStrategy(introspectorFactoryType, oldVersion);
- DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH, AAIProperties.MINIMUM_DEPTH);
+ DBSerializer oldSerializer = new DBSerializer(oldVersion, engine, introspectorFactoryType, SOURCE_OF_TRUTH,
+ AAIProperties.MINIMUM_DEPTH);
Vertex oldGvnfV = engine.tx().traversal().V().has(AAIProperties.AAI_URI, gvnfUri).next();
- Introspector oldGvnf = oldSerializer.dbToObject(
- Collections.singletonList(oldGvnfV),
- oldLoader.introspectorFromName("generic-vnf"),
- AAIProperties.MAXIMUM_DEPTH, false, "false");
+ Introspector oldGvnf = oldSerializer.dbToObject(Collections.singletonList(oldGvnfV),
+ oldLoader.introspectorFromName("generic-vnf"), AAIProperties.MAXIMUM_DEPTH, false, "false");
assertThat(oldGvnf.marshal(false),
- hasJsonPath(
- "$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
- containsInAnyOrder(
- "/aai/" + oldVersion + llDefaultUri,
- "/aai/" + oldVersion + llDefaultUri
- )
- ));
+ hasJsonPath("$.l-interfaces.l-interface[*].relationship-list.relationship[*].related-link",
+ containsInAnyOrder("/aai/" + oldVersion + llDefaultUri, "/aai/" + oldVersion + llDefaultUri)));
oldGvnf.setValue("in-maint", true);
QueryParser uriQuery = engine.getQueryBuilder().createQueryFromURI(new URI(gvnfUri));
oldSerializer.serializeToDb(oldGvnf, oldGvnfV, uriQuery, "generic-vnf", oldGvnf.marshal(false));
@@ -420,7 +342,4 @@ public class VersionedScenariosTest extends AAISetup {
verifyRelsOfOldViewOfGenericVnf();
}
-
-
-
}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngineTest.java b/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngineTest.java
index 5201cc5e..738953d5 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngineTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngineTest.java
@@ -26,9 +26,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.onap.aai.edges.enums.EdgeField.CONTAINS;
-import com.jayway.jsonpath.JsonPath;
-
-import java.io.InputStream;
import java.util.*;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine_needsFakeEdgeRulesTest.java b/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine_needsFakeEdgeRulesTest.java
index 8c603558..6ae32f39 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine_needsFakeEdgeRulesTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine_needsFakeEdgeRulesTest.java
@@ -38,8 +38,6 @@ import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.serialization.db.AAICoreFakeEdgesConfigTranslator;
import org.onap.aai.serialization.db.EdgeSerializer;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/AggregateFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/AggregateFormatTest.java
index 0b6ffd9e..2b80fb14 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/AggregateFormatTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/AggregateFormatTest.java
@@ -20,7 +20,14 @@
package org.onap.aai.serialization.queryformats;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import com.google.gson.JsonObject;
+
+import java.util.*;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -46,12 +53,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class AggregateFormatTest extends AAISetup {
@@ -126,8 +127,8 @@ public class AggregateFormatTest extends AAISetup {
assertTrue(json.has("hostname"));
assertFalse(json.has("node-type"));
Map<String, List<String>> propMap = new HashMap<>();
- List<String> selectedProps = new ArrayList<String>( Arrays.asList("'physical-location-id'"));
- propMap.put("complex",selectedProps);
+ List<String> selectedProps = new ArrayList<String>(Arrays.asList("'physical-location-id'"));
+ propMap.put("complex", selectedProps);
JsonObject json1 = aggregate.createSelectedPropertiesObject(complex, propMap).get();
json1.entrySet().forEach((System.out::println));
assertFalse(json1.has("country"));
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java
index 33b2dab6..daf7d474 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java
@@ -20,7 +20,15 @@
package org.onap.aai.serialization.queryformats;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import com.google.gson.JsonObject;
+
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -46,15 +54,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class CountQuerySupportTest extends AAISetup {
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/GraphSONTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/GraphSONTest.java
index 22b500f8..04026b4a 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/GraphSONTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/GraphSONTest.java
@@ -26,8 +26,6 @@ import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@@ -49,8 +47,8 @@ import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.serialization.db.AAICorePrivateEdgeTestConfigTranslator;
import org.onap.aai.serialization.db.EdgeSerializer;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java
index 0904ceb3..1bfdf9c4 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java
@@ -20,8 +20,17 @@
package org.onap.aai.serialization.queryformats;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.*;
+
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.io.UnsupportedEncodingException;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
@@ -50,13 +59,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import javax.ws.rs.core.MultivaluedHashMap;
-import java.io.UnsupportedEncodingException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.*;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class MultiFormatTest extends AAISetup {
@@ -80,11 +82,12 @@ public class MultiFormatTest extends AAISetup {
"{\"path\":[{\"resource-type\":\"generic-vnf\"},{\"resource-type\":\"vserver\"},{\"resource-type\":\"pserver\"},{\"resource-type\":\"complex\"}]}")
.getAsJsonObject();
private JsonObject expectedAsTreeWithResourceFormat = new JsonParser().parse(
- "{\"results\":[{\"generic-vnf\":{\"vnf-id\":\"vnf-id-1\",\"vnf-name\":\"vnf-name-1\",\"related-nodes\":[{\"vserver\":{\"vserver-id\":\"vserver-id-1\",\"vserver-name\":\"vserver-name-1\",\"related-nodes\":[{\"pserver\":{\"hostname\":\"hostname-1\"}}]}},{\"pserver\":{\"hostname\":\"hostname-2\",\"related-nodes\":[{\"complex\":{\"physical-location-id\":\"physical-location-id-2\",\"country\":\"US\"}}]}}]}}]}")
+ "{\"results\":[{\"generic-vnf\":{\"vnf-id\":\"vnf-id-1\",\"vnf-name\":\"vnf-name-1\",\"related-nodes\":[{\"vserver\":{\"vserver-id\":\"vserver-id-1\",\"vserver-name\":\"vserver-name-1\",\"related-nodes\":[{\"pserver\":{\"hostname\":\"hostname-1\"}}]}},{\"pserver\":{\"hostname\":\"hostname-2\",\"related-nodes\":[{\"complex\":{\"physical-location-id\":\"physical-location-id-2\",\"country\":\"US\"}}]}}]}}]}")
.getAsJsonObject();
private JsonObject expectedAsTreeWithSimpleFormat = new JsonParser().parse(
- "{\"results\":[{\"id\":\"0\",\"node-type\":\"generic-vnf\",\"url\":null,\"properties\":{\"vnf-id\":\"vnf-id-1\",\"vnf-name\":\"vnf-name-1\"},\"related-to\":[{\"id\":\"1\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"vserver\",\"url\":null},{\"id\":\"5\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"pserver\",\"url\":null}],\"related-nodes\":[{\"id\":\"1\",\"node-type\":\"vserver\",\"url\":null,\"properties\":{\"vserver-id\":\"vserver-id-1\",\"vserver-name\":\"vserver-name-1\"},\"related-to\":[{\"id\":\"0\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"generic-vnf\",\"url\":null},{\"id\":\"2\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"pserver\",\"url\":null}],\"related-nodes\":[{\"id\":\"2\",\"node-type\":\"pserver\",\"url\":null,\"properties\":{\"hostname\":\"hostname-1\"},\"related-to\":[{\"id\":\"1\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"vserver\",\"url\":null},{\"id\":\"3\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"complex\",\"url\":null}]}]},{\"id\":\"5\",\"node-type\":\"pserver\",\"url\":null,\"properties\":{\"hostname\":\"hostname-2\"},\"related-to\":[{\"id\":\"0\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"generic-vnf\",\"url\":null},{\"id\":\"6\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"complex\",\"url\":null}],\"related-nodes\":[{\"id\":\"6\",\"node-type\":\"complex\",\"url\":null,\"properties\":{\"physical-location-id\":\"physical-location-id-2\",\"country\":\"US\"},\"related-to\":[{\"id\":\"5\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"pserver\",\"url\":null}]}]}]}]}")
- .getAsJsonObject();
+ "{\"results\":[{\"id\":\"0\",\"node-type\":\"generic-vnf\",\"url\":null,\"properties\":{\"vnf-id\":\"vnf-id-1\",\"vnf-name\":\"vnf-name-1\"},\"related-to\":[{\"id\":\"1\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"vserver\",\"url\":null},{\"id\":\"5\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"pserver\",\"url\":null}],\"related-nodes\":[{\"id\":\"1\",\"node-type\":\"vserver\",\"url\":null,\"properties\":{\"vserver-id\":\"vserver-id-1\",\"vserver-name\":\"vserver-name-1\"},\"related-to\":[{\"id\":\"0\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"generic-vnf\",\"url\":null},{\"id\":\"2\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"pserver\",\"url\":null}],\"related-nodes\":[{\"id\":\"2\",\"node-type\":\"pserver\",\"url\":null,\"properties\":{\"hostname\":\"hostname-1\"},\"related-to\":[{\"id\":\"1\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"vserver\",\"url\":null},{\"id\":\"3\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"complex\",\"url\":null}]}]},{\"id\":\"5\",\"node-type\":\"pserver\",\"url\":null,\"properties\":{\"hostname\":\"hostname-2\"},\"related-to\":[{\"id\":\"0\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"generic-vnf\",\"url\":null},{\"id\":\"6\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"complex\",\"url\":null}],\"related-nodes\":[{\"id\":\"6\",\"node-type\":\"complex\",\"url\":null,\"properties\":{\"physical-location-id\":\"physical-location-id-2\",\"country\":\"US\"},\"related-to\":[{\"id\":\"5\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"pserver\",\"url\":null}]}]}]}]}")
+ .getAsJsonObject();
+
@Before
public void setUp() throws Exception {
@@ -136,7 +139,7 @@ public class MultiFormatTest extends AAISetup {
@Test
public void testAsTreeParamAndSimpleFormat()
- throws AAIFormatVertexException, AAIException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIException, AAIFormatQueryResultFormatNotSupported {
createLoaderEngineSetup();
DBSerializer serializer = new DBSerializer(version, dbEngine, factoryType, "Junit");
@@ -154,7 +157,7 @@ public class MultiFormatTest extends AAISetup {
@Test
public void testAsTreeParamAndResourceFormat()
- throws AAIFormatVertexException, AAIException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIException, AAIFormatQueryResultFormatNotSupported {
createLoaderEngineSetup();
DBSerializer serializer = new DBSerializer(version, dbEngine, factoryType, "Junit");
@@ -169,7 +172,6 @@ public class MultiFormatTest extends AAISetup {
assertEquals(this.expectedAsTreeWithResourceFormat, json);
}
-
@Test
public void testPathResultQueryIdFormat()
throws AAIFormatVertexException, AAIException, AAIFormatQueryResultFormatNotSupported {
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java
index 199939ed..b38b20a8 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java
@@ -20,7 +20,15 @@
package org.onap.aai.serialization.queryformats;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import com.google.gson.JsonObject;
+
+import java.util.Optional;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -47,13 +55,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.util.Optional;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class PathedURLTest extends AAISetup {
@@ -83,17 +84,11 @@ public class PathedURLTest extends AAISetup {
graph = TinkerGraph.open();
- Vertex pserver1 =
- graph.addVertex(
- T.label, "pserver",
- T.id, "2",
- "aai-node-type", "pserver",
- "hostname", "hostname-1",
- "resource-version", System.currentTimeMillis()
- );
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname",
+ "hostname-1", "resource-version", System.currentTimeMillis());
Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex",
- "physical-location-id", "physical-location-id-1", "country", "US");
+ "physical-location-id", "physical-location-id-1", "country", "US");
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, pserver1, complex1);
@@ -120,7 +115,7 @@ public class PathedURLTest extends AAISetup {
when(dbEngine.asAdmin()).thenReturn(spyAdmin);
when(spyAdmin.getReadOnlyTraversalSource())
- .thenReturn(graph.traversal().withStrategies(ReadOnlyStrategy.instance()));
+ .thenReturn(graph.traversal().withStrategies(ReadOnlyStrategy.instance()));
when(spyAdmin.getTraversalSource()).thenReturn(graph.traversal());
}
}
@@ -132,7 +127,7 @@ public class PathedURLTest extends AAISetup {
when(urlBuilder.pathed(pserver)).thenReturn("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1");
Optional<JsonObject> jsonObjectOptional = pathedURL.getJsonFromVertex(pserver);
- if(!jsonObjectOptional.isPresent()){
+ if (!jsonObjectOptional.isPresent()) {
fail("Expecting an json object returned from pathed url but returned none");
}
@@ -141,18 +136,21 @@ public class PathedURLTest extends AAISetup {
assertNotNull("Expecting the pserver object to contain resource type", pserverObject.get("resource-type"));
assertThat(pserverObject.get("resource-type").getAsString(), CoreMatchers.is("pserver"));
assertNotNull("Expecting the pserver object to contain resource link", pserverObject.get("resource-link"));
- assertThat(pserverObject.get("resource-link").getAsString(), CoreMatchers.is("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1"));
- assertNotNull("Expecting the pserver object to contain resource version", pserverObject.get("resource-version"));
+ assertThat(pserverObject.get("resource-link").getAsString(),
+ CoreMatchers.is("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1"));
+ assertNotNull("Expecting the pserver object to contain resource version",
+ pserverObject.get("resource-version"));
}
@Test
- public void testPathedUrlReturnsResourceVersionWhenIncludeUrlIsNotSet() throws AAIFormatVertexException, AAIException {
+ public void testPathedUrlReturnsResourceVersionWhenIncludeUrlIsNotSet()
+ throws AAIFormatVertexException, AAIException {
pathedURL = new PathedURL.Builder(loader, serializer, urlBuilder).build();
when(urlBuilder.pathed(pserver)).thenReturn("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1");
Optional<JsonObject> jsonObjectOptional = pathedURL.getJsonFromVertex(pserver);
- if(!jsonObjectOptional.isPresent()){
+ if (!jsonObjectOptional.isPresent()) {
fail("Expecting an json object returned from pathed url but returned none");
}
@@ -161,7 +159,9 @@ public class PathedURLTest extends AAISetup {
assertNotNull("Expecting the pserver object to contain resource type", pserverObject.get("resource-type"));
assertThat(pserverObject.get("resource-type").getAsString(), CoreMatchers.is("pserver"));
assertNotNull("Expecting the pserver object to contain resource link", pserverObject.get("resource-link"));
- assertThat(pserverObject.get("resource-link").getAsString(), CoreMatchers.is("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1"));
- assertNull("Expecting the pserver object to not contain resource version", pserverObject.get("resource-version"));
+ assertThat(pserverObject.get("resource-link").getAsString(),
+ CoreMatchers.is("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1"));
+ assertNull("Expecting the pserver object to not contain resource version",
+ pserverObject.get("resource-version"));
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java
index f88de4fb..232e80b3 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java
@@ -20,7 +20,14 @@
package org.onap.aai.serialization.queryformats;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import com.google.gson.JsonObject;
+
+import java.util.*;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -46,12 +53,6 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class RawFormatTest extends AAISetup {
@@ -98,27 +99,27 @@ public class RawFormatTest extends AAISetup {
}
@Test
- public void verifyPserverRelatedToHasEdgeLabel()
- throws AAIFormatVertexException {
- assertEquals("org.onap.relationships.inventory.LocatedIn", rawFormat.createRelationshipObject(pserver).get(0).getAsJsonObject().get("relationship-label").getAsString());
+ public void verifyPserverRelatedToHasEdgeLabel() throws AAIFormatVertexException {
+ assertEquals("org.onap.relationships.inventory.LocatedIn", rawFormat.createRelationshipObject(pserver).get(0)
+ .getAsJsonObject().get("relationship-label").getAsString());
}
@Test
- public void verifyPserverRelatedToComplexLabel()
- throws AAIFormatVertexException {
- assertEquals("complex", rawFormat.createRelationshipObject(pserver).get(0).getAsJsonObject().get("node-type").getAsString());
+ public void verifyPserverRelatedToComplexLabel() throws AAIFormatVertexException {
+ assertEquals("complex",
+ rawFormat.createRelationshipObject(pserver).get(0).getAsJsonObject().get("node-type").getAsString());
}
@Test
- public void verifyComplexRelatedToHasEdgeLabel()
- throws AAIFormatVertexException {
- assertEquals("org.onap.relationships.inventory.LocatedIn", rawFormat.createRelationshipObject(complex).get(0).getAsJsonObject().get("relationship-label").getAsString());
+ public void verifyComplexRelatedToHasEdgeLabel() throws AAIFormatVertexException {
+ assertEquals("org.onap.relationships.inventory.LocatedIn", rawFormat.createRelationshipObject(complex).get(0)
+ .getAsJsonObject().get("relationship-label").getAsString());
}
@Test
- public void verifyComplexRelatedToPserverLabel()
- throws AAIFormatVertexException {
- assertEquals("pserver", rawFormat.createRelationshipObject(complex).get(0).getAsJsonObject().get("node-type").getAsString());
+ public void verifyComplexRelatedToPserverLabel() throws AAIFormatVertexException {
+ assertEquals("pserver",
+ rawFormat.createRelationshipObject(complex).get(0).getAsJsonObject().get("node-type").getAsString());
}
private void createLoaderEngineSetup() throws AAIException {
@@ -149,13 +150,12 @@ public class RawFormatTest extends AAISetup {
json.entrySet().forEach((System.out::println));
assertTrue(json.has("hostname"));
Map<String, List<String>> propMap = new HashMap<>();
- List<String> selectedProps = new ArrayList<String>( Arrays.asList("'physical-location-id'"));
- propMap.put("complex",selectedProps);
+ List<String> selectedProps = new ArrayList<String>(Arrays.asList("'physical-location-id'"));
+ propMap.put("complex", selectedProps);
JsonObject json1 = rawFormat.createSelectedPropertiesObject(complex, propMap).get();
json1.entrySet().forEach((System.out::println));
assertFalse(json1.has("aai-node-type"));
assertTrue(json1.has("physical-location-id"));
}
-
}
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java
index 781656e1..10178931 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java
@@ -20,7 +20,17 @@
package org.onap.aai.serialization.queryformats;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import com.google.gson.JsonObject;
+
+import java.util.Arrays;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
@@ -42,14 +52,6 @@ import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexExcepti
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.springframework.test.annotation.DirtiesContext;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import java.util.Arrays;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class ResourceFormatTest extends AAISetup {
@@ -126,7 +128,8 @@ public class ResourceFormatTest extends AAISetup {
createLoaderEngineSetup();
serializer = new DBSerializer(schemaVersions.getAppRootVersion(), dbEngine, factoryType, "Junit");
- FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath, "https://localhost:8447/aai/");
+ FormatFactory ff =
+ new FormatFactory(loader, serializer, schemaVersions, basePath, "https://localhost:8447/aai/");
MultivaluedMap mvm = new MultivaluedHashMap();
mvm.add("depth", "0");
Formatter formatter = ff.get(Format.resource, mvm);
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java
index 57a23115..2bb3971d 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/ResourceWithSoTTest.java
@@ -20,8 +20,14 @@
package org.onap.aai.serialization.queryformats;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import com.google.gson.JsonObject;
+
import java.util.Optional;
+
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -42,10 +48,6 @@ import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexExcepti
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.setup.SchemaVersion;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
public class ResourceWithSoTTest extends AAISetup {
@Mock
private UrlBuilder urlBuilder;
@@ -115,7 +117,8 @@ public class ResourceWithSoTTest extends AAISetup {
// This test is to simulate a PUT request
@Test
public void testGetJsonFromVertexWithCreateVertex() throws AAIFormatVertexException, AAIException {
- if (putVertex == null) fail("The vertex used for this test is null. Fail immediately.");
+ if (putVertex == null)
+ fail("The vertex used for this test is null. Fail immediately.");
JsonObject json = resourceWithSoT.getJsonFromVertex(putVertex).get();
assertEquals(jsonPutObj, json);
@@ -124,8 +127,10 @@ public class ResourceWithSoTTest extends AAISetup {
// This test is to simulate PATCH requests
@Test
public void testGetJsonFromVertexWithModifyVertex() throws AAIFormatVertexException, AAIException {
- if (patchVertex1 == null) fail("The vertex 1 used for this test is null. Fail immediately.");
- if (patchVertex2 == null) fail("The vertex 2 used for this test is null. Fail immediately.");
+ if (patchVertex1 == null)
+ fail("The vertex 1 used for this test is null. Fail immediately.");
+ if (patchVertex2 == null)
+ fail("The vertex 2 used for this test is null. Fail immediately.");
// Differing Source of Truths will indicate that the action performed modified the vertex
JsonObject json1 = resourceWithSoT.getJsonFromVertex(patchVertex1).get();
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java
index bf8a1c9e..279c3e83 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java
@@ -31,6 +31,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import com.google.gson.JsonObject;
+
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
@@ -60,8 +62,6 @@ import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexExcepti
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.springframework.test.annotation.DirtiesContext;
-import com.google.gson.JsonObject;
-
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class SimpleFormatTest extends AAISetup {
@@ -140,7 +140,8 @@ public class SimpleFormatTest extends AAISetup {
createLoaderEngineSetup();
serializer = new DBSerializer(schemaVersions.getRelatedLinkVersion(), dbEngine, factoryType, "Junit");
- FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath, "https://localhost:8447/aai/");
+ FormatFactory ff =
+ new FormatFactory(loader, serializer, schemaVersions, basePath, "https://localhost:8447/aai/");
MultivaluedMap mvm = new MultivaluedHashMap();
mvm.add("depth", "0");
Formatter formatter = ff.get(Format.simple, mvm);
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java b/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java
index c509ab43..b8c3ea95 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/tinkerpop/TreeBackedVertexTest.java
@@ -48,27 +48,21 @@ public class TreeBackedVertexTest {
public void configure() {
GraphTraversalSource g = graph.traversal();
- startKey = g.addV("vserver").as("v1").property("test", "hello")
- .addV("vserver").as("v2")
- .addV("interface").property("name", "interface 1").as("v10")
- .addE("hasChild").from("v2").property(EdgeProperty.CONTAINS.toString(), true)
- .addV("pserver").property("name", "pserver 1").as("v4")
- .addE("runsOn").to("v1").property(EdgeProperty.CONTAINS.toString(), false)
- .addV("interface").property("name", "interface 2").as("v3")
- .addE("hasChild").from("v1").property(EdgeProperty.CONTAINS.toString(), true)
- .addV("address").property("name", "address 1")
- .addE("hasChild").from("v3").property(EdgeProperty.CONTAINS.toString(), true)
- .addV("address").property("name", "address 2")
- .addE("hasChild").from("v3").property(EdgeProperty.CONTAINS.toString(), true)
- .addV("complex").property("name", "complex 1")
- .addE("locatedIn").from("v4").property(EdgeProperty.CONTAINS.toString(), false)
- .addV("interface").property("name", "interface 3")
- .addE("hasChild").from("v4").property(EdgeProperty.CONTAINS.toString(), true)
- .addV("subnet").property("name", "subnet 1").as("v5")
- .addE("in").from("v3").property(EdgeProperty.CONTAINS.toString(), false)
- .addV("address").property("name", "address 3").as("v6")
- .addE("hasChild").from("v5").property(EdgeProperty.CONTAINS.toString(), true)
- .select("v1").next();
+ startKey = g.addV("vserver").as("v1").property("test", "hello").addV("vserver").as("v2").addV("interface")
+ .property("name", "interface 1").as("v10").addE("hasChild").from("v2")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV("pserver").property("name", "pserver 1").as("v4")
+ .addE("runsOn").to("v1").property(EdgeProperty.CONTAINS.toString(), false).addV("interface")
+ .property("name", "interface 2").as("v3").addE("hasChild").from("v1")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV("address").property("name", "address 1")
+ .addE("hasChild").from("v3").property(EdgeProperty.CONTAINS.toString(), true).addV("address")
+ .property("name", "address 2").addE("hasChild").from("v3")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV("complex").property("name", "complex 1")
+ .addE("locatedIn").from("v4").property(EdgeProperty.CONTAINS.toString(), false).addV("interface")
+ .property("name", "interface 3").addE("hasChild").from("v4")
+ .property(EdgeProperty.CONTAINS.toString(), true).addV("subnet").property("name", "subnet 1").as("v5")
+ .addE("in").from("v3").property(EdgeProperty.CONTAINS.toString(), false).addV("address")
+ .property("name", "address 3").as("v6").addE("hasChild").from("v5")
+ .property(EdgeProperty.CONTAINS.toString(), true).select("v1").next();
tree = new GraphTraversalQueryEngine(g).findSubGraph((Vertex) startKey);
treeDepth1 = new GraphTraversalQueryEngine(g).findSubGraph((Vertex) startKey, 1, false);
diff --git a/aai-core/src/test/java/org/onap/aai/stress/IndexStressTest.java b/aai-core/src/test/java/org/onap/aai/stress/IndexStressTest.java
index 90cda070..fb7ba400 100644
--- a/aai-core/src/test/java/org/onap/aai/stress/IndexStressTest.java
+++ b/aai-core/src/test/java/org/onap/aai/stress/IndexStressTest.java
@@ -43,12 +43,12 @@ public class IndexStressTest extends AAISetup {
private static final Logger LOGGER = LoggerFactory.getLogger(IndexStressTest.class);
@Before
- public void setup(){
+ public void setup() {
AAIGraph.getInstance().getGraph();
}
@Test
- public void testIndexStress(){
+ public void testIndexStress() {
JanusGraphTransaction tx = AAIGraph.getInstance().getGraph().newTransaction();
GraphTraversalSource g = tx.traversal();
@@ -58,18 +58,15 @@ public class IndexStressTest extends AAISetup {
int TOTAL_LINKS = 101000;
- for(int i = 0; i <TOTAL_LINKS; i++){
+ for (int i = 0; i < TOTAL_LINKS; i++) {
String linkName = generateName(linkNameSet);
aaiUriSet.add("/network/logical-links/logical-link/" + linkName);
- Vertex v = g.addV()
- .property("aai-node-type", "logical-link")
- .property("link-name", linkName)
- .property("aai-uri", "/network/logical-links/logical-link/" + linkName)
- .next();
+ Vertex v = g.addV().property("aai-node-type", "logical-link").property("link-name", linkName)
+ .property("aai-uri", "/network/logical-links/logical-link/" + linkName).next();
- if(i % 1000 == 0){
+ if (i % 1000 == 0) {
LOGGER.debug("Committing up to index {}", i);
tx.commit();
tx = AAIGraph.getInstance().getGraph().newTransaction();
@@ -82,29 +79,29 @@ public class IndexStressTest extends AAISetup {
tx = AAIGraph.getInstance().getGraph().newTransaction();
g = tx.traversal();
- int totalLinks= 0;
+ int totalLinks = 0;
int totalLinksWithNodeType = 0;
int totalLinksUsingUri = 0;
int index = 0;
for (String linkName : linkNameSet) {
- if(g.V().has("aai-node-type", "logical-link").has("link-name", linkName).hasNext()){
- totalLinksWithNodeType++;
+ if (g.V().has("aai-node-type", "logical-link").has("link-name", linkName).hasNext()) {
+ totalLinksWithNodeType++;
}
- if(g.V().has("link-name", linkName).hasNext()){
+ if (g.V().has("link-name", linkName).hasNext()) {
totalLinks++;
}
- if(g.V().has("aai-uri", "/network/logical-links/logical-link/" + linkName).hasNext()){
+ if (g.V().has("aai-uri", "/network/logical-links/logical-link/" + linkName).hasNext()) {
totalLinksUsingUri++;
}
index++;
- if(index%1000 == 0){
- LOGGER.debug("Processed {} many queries and has {} many to go", index, (TOTAL_LINKS-index));
+ if (index % 1000 == 0) {
+ LOGGER.debug("Processed {} many queries and has {} many to go", index, (TOTAL_LINKS - index));
LOGGER.debug("Total links using linkname found: {}", totalLinks);
LOGGER.debug("Total links using nodetype and linkname found: {}", totalLinksWithNodeType);
LOGGER.debug("Total links using uri found: {}", totalLinksUsingUri);
@@ -118,11 +115,11 @@ public class IndexStressTest extends AAISetup {
LOGGER.debug("Total links using uri found: {}", totalLinksUsingUri);
}
- String generateName(Set<String> uniqueKeys){
+ String generateName(Set<String> uniqueKeys) {
- while(true) {
+ while (true) {
String data = RandomStringUtils.randomAlphabetic(20);
- if (!uniqueKeys.contains(data)){
+ if (!uniqueKeys.contains(data)) {
uniqueKeys.add(data);
return data;
}
diff --git a/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java b/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java
index 279e0967..bfa5573c 100644
--- a/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java
+++ b/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java
@@ -21,7 +21,6 @@
package org.onap.aai.testutils;
import java.util.ArrayList;
-import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
diff --git a/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforEdges.java b/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforEdges.java
index d47a775c..b00fd423 100644
--- a/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforEdges.java
+++ b/aai-core/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforEdges.java
@@ -21,7 +21,6 @@
package org.onap.aai.testutils;
import java.util.ArrayList;
-import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
diff --git a/aai-core/src/test/java/org/onap/aai/transforms/XmlFormatTransformerTest.java b/aai-core/src/test/java/org/onap/aai/transforms/XmlFormatTransformerTest.java
index 6d6ae194..01699393 100644
--- a/aai-core/src/test/java/org/onap/aai/transforms/XmlFormatTransformerTest.java
+++ b/aai-core/src/test/java/org/onap/aai/transforms/XmlFormatTransformerTest.java
@@ -17,19 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.transforms;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+import java.io.IOException;
+
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.PayloadUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
public class XmlFormatTransformerTest {
private static final Logger LOGGER = LoggerFactory.getLogger(XmlFormatTransformerTest.class);
@@ -37,7 +38,7 @@ public class XmlFormatTransformerTest {
private XmlFormatTransformer xmlFormatTransformer;
@Before
- public void setup(){
+ public void setup() {
this.xmlFormatTransformer = new XmlFormatTransformer();
}
diff --git a/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java b/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java
index e11ff262..68f01962 100644
--- a/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java
+++ b/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.Month;
@@ -35,7 +36,9 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
+
import javax.xml.bind.JAXBException;
+
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.JAXBContext;
import org.eclipse.persistence.jaxb.JAXBMarshaller;