aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core
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
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')
-rw-r--r--aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java49
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java60
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java12
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java24
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/Introspector.java9
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java23
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java9
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java22
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java13
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java102
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java11
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java10
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java21
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java47
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java55
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java24
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java40
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java209
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java382
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java56
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java26
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java67
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java45
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java54
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java43
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java26
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java18
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java116
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java102
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java18
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java17
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java37
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java9
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java37
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java50
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java20
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java12
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/Entity.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/EntityList.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java30
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/KeyValueList.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/PojoUtils.java98
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/Request.java10
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/RestController.java29
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java12
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java7
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java24
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java16
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java13
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java19
-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
179 files changed, 2798 insertions, 3349 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
index 0a027d64..ae493ef1 100644
--- a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
+++ b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
@@ -22,6 +22,8 @@
package org.onap.aai.audit;
+import com.google.common.base.CaseFormat;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -46,8 +48,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import com.google.common.base.CaseFormat;
-
/**
* The Class ListEndpoints.
*/
diff --git a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java
index 69560ec1..2703bdc4 100644
--- a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java
+++ b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java
@@ -44,7 +44,7 @@ public abstract class AaiCallable<T> implements Callable<T> {
* The call method
*/
public T call() throws Exception {
- if ( mdcCopy != null ) {
+ if (mdcCopy != null) {
MDC.setContextMap(mdcCopy);
}
return process();
diff --git a/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java b/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java
index 0c83c2b3..b945d855 100644
--- a/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java
+++ b/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.transforms.XmlFormatTransformer;
@@ -27,7 +28,7 @@ import org.springframework.context.annotation.Configuration;
public class XmlFormatTransformerConfiguration {
@Bean
- public XmlFormatTransformer xmlFormatTransformer(){
+ public XmlFormatTransformer xmlFormatTransformer() {
return new XmlFormatTransformer();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
index 1b3a3287..7ed8da4f 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
@@ -20,9 +20,6 @@
package org.onap.aai.dbgen;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -60,6 +57,8 @@ import org.apache.tinkerpop.shaded.jackson.core.type.TypeReference;
import org.apache.tinkerpop.shaded.jackson.databind.JsonNode;
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
import org.apache.tinkerpop.shaded.jackson.databind.node.JsonNodeType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This is a Wrapper around the GraphsonReader class
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
index 9f3e7475..250c1263 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
@@ -19,15 +19,24 @@
*/
package org.onap.aai.dbgen;
-import org.onap.aai.util.AAIConstants;
+
import com.google.common.collect.Multimap;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.Cardinality;
import org.janusgraph.core.Multiplicity;
import org.janusgraph.core.PropertyKey;
-import org.janusgraph.core.schema.JanusGraphManagement;
-import org.janusgraph.core.schema.JanusGraphIndex;
import org.janusgraph.core.schema.ConsistencyModifier;
+import org.janusgraph.core.schema.JanusGraphIndex;
+import org.janusgraph.core.schema.JanusGraphManagement;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
@@ -37,17 +46,10 @@ import org.onap.aai.introspection.LoaderUtil;
import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
public class SchemaGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaGenerator.class);
@@ -85,7 +87,6 @@ public class SchemaGenerator {
makeEdgeLabels(graphMgmt);
-
Map<String, Introspector> objs = LoaderUtil.getLatestVersion().getAllObjects();
Map<String, PropertyKey> seenProps = new HashMap<>();
@@ -112,8 +113,8 @@ public class SchemaGenerator {
if (process) {
- LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]",
- dbPropName, type.getSimpleName(), cardinality);
+ LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]", dbPropName, type.getSimpleName(),
+ cardinality);
PropertyKey propK;
if (!seenProps.containsKey(dbPropName)) {
propK = graphMgmt.makePropertyKey(dbPropName).dataType(type).cardinality(cardinality)
@@ -125,8 +126,7 @@ public class SchemaGenerator {
LOGGER.info(" Lock is being set for aai-uri Property.");
graphMgmt.setConsistency(propK, ConsistencyModifier.LOCK);
}
- }
- else if (dbPropName.equals("resource-version")) {
+ } else if (dbPropName.equals("resource-version")) {
String aai_rv_lock_enabled = AAIConfig.get(AAIConstants.AAI_LOCK_RV_ENABLED, "false");
LOGGER.info(" Info: aai_rv_lock_enabled:" + aai_rv_lock_enabled);
if ("true".equals(aai_rv_lock_enabled)) {
@@ -146,21 +146,23 @@ public class SchemaGenerator {
if (obj.getUniqueProperties().contains(propName)) {
LOGGER.info("Add Unique index for PropertyKey: [{}]", dbPropName);
indexG = graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK).unique()
- .buildCompositeIndex();
+ .buildCompositeIndex();
} else {
LOGGER.info("Add index for PropertyKey: [{}]", dbPropName);
- indexG = graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK).buildCompositeIndex();
+ indexG = graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK)
+ .buildCompositeIndex();
}
if (indexG != null && dbPropName.equals("aai-uri")) {
- String aai_uri_lock_enabled = AAIConfig.get(AAIConstants.AAI_LOCK_URI_ENABLED, "false");
+ String aai_uri_lock_enabled =
+ AAIConfig.get(AAIConstants.AAI_LOCK_URI_ENABLED, "false");
LOGGER.info(" Info:: aai_uri_lock_enabled:" + aai_uri_lock_enabled);
if ("true".equals(aai_uri_lock_enabled)) {
LOGGER.info("Lock is being set for aai-uri Index.");
graphMgmt.setConsistency(indexG, ConsistencyModifier.LOCK);
}
- }
- else if (indexG != null && dbPropName.equals("resource-version")) {
- String aai_rv_lock_enabled = AAIConfig.get(AAIConstants.AAI_LOCK_RV_ENABLED, "false");
+ } else if (indexG != null && dbPropName.equals("resource-version")) {
+ String aai_rv_lock_enabled =
+ AAIConfig.get(AAIConstants.AAI_LOCK_RV_ENABLED, "false");
LOGGER.info(" Info:: aai_rv_lock_enabled:" + aai_rv_lock_enabled);
if ("true".equals(aai_rv_lock_enabled)) {
LOGGER.info("Lock is being set for resource-version Index.");
@@ -189,8 +191,7 @@ public class SchemaGenerator {
EdgeIngestor edgeIngestor = SpringContextAware.getBean(EdgeIngestor.class);
Set<String> labels = Optional.ofNullable(edgeIngestor.getAllCurrentRules())
- .map(collectValues(EdgeRule::getLabel))
- .orElseGet(HashSet::new);
+ .map(collectValues(EdgeRule::getLabel)).orElseGet(HashSet::new);
labels.forEach(label -> {
if (graphMgmt.containsRelationType(label)) {
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java
index a35625f6..95825685 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java
@@ -20,7 +20,16 @@
package org.onap.aai.dbgen;
+import static org.onap.aai.db.props.AAIProperties.*;
+
import com.google.common.collect.Multimap;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.Cardinality;
import org.janusgraph.core.Multiplicity;
@@ -39,21 +48,14 @@ import org.onap.aai.util.AAIConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.onap.aai.db.props.AAIProperties.*;
-
public class SchemaGenerator4Hist {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaGenerator4Hist.class);
- private SchemaGenerator4Hist(){
+ private SchemaGenerator4Hist() {
}
+
/**
* Load schema into JanusGraph.
*
@@ -125,12 +127,12 @@ public class SchemaGenerator4Hist {
Cardinality cardinality = Cardinality.LIST;
boolean process = false;
if (obj.isListType(propName) && obj.isSimpleGenericType(propName)) {
- // NOTE - For history - All properties have cardinality = LIST
- // It is assumed that there is special processing in the Resources MS
- // for History to turn what used to be SET (referred to as isListType
- // above) will be stored in our db as a single String. And that
- // single string will have Cardinality = LIST so we can track its
- // history.
+ // NOTE - For history - All properties have cardinality = LIST
+ // It is assumed that there is special processing in the Resources MS
+ // for History to turn what used to be SET (referred to as isListType
+ // above) will be stored in our db as a single String. And that
+ // single string will have Cardinality = LIST so we can track its
+ // history.
type = obj.getGenericTypeClass(propName);
process = true;
} else if (obj.isSimpleType(propName)) {
@@ -139,8 +141,8 @@ public class SchemaGenerator4Hist {
if (process) {
- LOGGER.info(" Creating PropertyKey: [{}], [{}], [{}]",
- dbPropName, type.getSimpleName(), cardinality);
+ LOGGER.info(" Creating PropertyKey: [{}], [{}], [{}]", dbPropName, type.getSimpleName(),
+ cardinality);
PropertyKey propK;
if (!seenProps.containsKey(dbPropName)) {
propK = graphMgmt.makePropertyKey(dbPropName).dataType(type).cardinality(cardinality)
@@ -153,7 +155,7 @@ public class SchemaGenerator4Hist {
LOGGER.debug(" Index [{}] already existed in the DB. ", dbPropName);
} else {
if (obj.getIndexedProperties().contains(propName)) {
- // NOTE - for History we never add a unique index - just a regular index
+ // NOTE - for History we never add a unique index - just a regular index
LOGGER.info("Add index for PropertyKey: [{}]", dbPropName);
graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK).buildCompositeIndex();
} else {
@@ -163,20 +165,19 @@ public class SchemaGenerator4Hist {
}
}
}
- }// Done processing all properties defined in the OXM
+ } // Done processing all properties defined in the OXM
// Add the 3 new History properties are in the DB
// They are all Cardinality=Single since instance of a Node, Edge or Property can
- // only have one of them. That is, a Property can show up many times in a
- // node, but each instance of that property will only have a single start-ts,
- // end-ts, end-source-of-truth. Same goes for a node or edge itself.
+ // only have one of them. That is, a Property can show up many times in a
+ // node, but each instance of that property will only have a single start-ts,
+ // end-ts, end-source-of-truth. Same goes for a node or edge itself.
makeNewProperty(graphMgmt, seenProps, String.class, END_SOT);
makeNewProperty(graphMgmt, seenProps, Long.class, START_TS);
makeNewProperty(graphMgmt, seenProps, Long.class, END_TS);
makeNewProperty(graphMgmt, seenProps, String.class, START_TX_ID);
makeNewProperty(graphMgmt, seenProps, String.class, END_TX_ID);
-
String imsg = "-- About to call graphMgmt commit";
LOGGER.info(imsg);
graphMgmt.commit();
@@ -186,17 +187,14 @@ public class SchemaGenerator4Hist {
}
- private static <T> void makeNewProperty(JanusGraphManagement graphMgmt,
- Map<String, PropertyKey> seenProps,
- Class<T> type,
- String propertyName) {
+ private static <T> void makeNewProperty(JanusGraphManagement graphMgmt, Map<String, PropertyKey> seenProps,
+ Class<T> type, String propertyName) {
if (graphMgmt.containsRelationType(propertyName)) {
LOGGER.debug("PropertyKey [{}] already existed in the DB.", propertyName);
} else if (!seenProps.containsKey(propertyName)) {
- LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]",
- propertyName, type.getSimpleName(), Cardinality.SINGLE);
- graphMgmt.makePropertyKey(propertyName).dataType(type).cardinality(Cardinality.SINGLE)
- .make();
+ LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]", propertyName, type.getSimpleName(),
+ Cardinality.SINGLE);
+ graphMgmt.makePropertyKey(propertyName).dataType(type).cardinality(Cardinality.SINGLE).make();
}
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
index 62ac4f06..cb388ccc 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
@@ -58,8 +58,6 @@ public class AAIGraph {
protected JanusGraph graph;
private static boolean isInit = false;
-
-
/**
* Instantiates a new AAI graph.
*/
@@ -139,7 +137,8 @@ public class AAIGraph {
transaction.tx().commit();
logger.info("Snapshot loaded to inmemory graph.");
} catch (Exception e) {
- logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", ExceptionUtils.getStackTrace(e)));
+ logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s",
+ ExceptionUtils.getStackTrace(e)));
throw new RuntimeException(e);
}
}
@@ -151,7 +150,8 @@ public class AAIGraph {
JanusGraphManagement graphMgt = graph.openManagement();
logger.info("-- loading schema into JanusGraph");
- if ("true".equals(SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
+ if ("true".equals(
+ SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
} else {
SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
index 4dbc1224..b6afe626 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
@@ -35,7 +35,6 @@ import org.janusgraph.diskstorage.configuration.ConfigElement;
*/
public class AAIGraphConfig {
-
private AAIGraphConfig() {
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
index ac9407e3..51a2c221 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
@@ -20,9 +20,6 @@
package org.onap.aai.dbmap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -36,6 +33,8 @@ import org.janusgraph.core.schema.JanusGraphManagement;
import org.onap.aai.dbgen.GraphSONPartialIO;
import org.onap.aai.dbgen.SchemaGenerator;
import org.onap.aai.logging.LogFormatTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class InMemoryGraph {
@@ -46,7 +45,7 @@ public class InMemoryGraph {
/*
* Create a In-memory graph
*/
- try(InputStream is = new FileInputStream(builder.propertyFile)){
+ try (InputStream is = new FileInputStream(builder.propertyFile)) {
graph = JanusGraphFactory.open(builder.propertyFile);
Properties graphProps = new Properties();
@@ -63,7 +62,7 @@ public class InMemoryGraph {
transaction.io(GraphSONPartialIO.build()).readGraph(builder.graphsonLocation);
} else {
transaction.io(GraphSONPartialIO.build()).reader().create().readGraph(builder.seqInputStream,
- graph);
+ graph);
}
} else {
if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
@@ -76,7 +75,8 @@ public class InMemoryGraph {
}
} catch (Exception e) {
- LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", LogFormatTools.getStackTop(e)));
+ LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s",
+ LogFormatTools.getStackTop(e)));
throw new IllegalStateException("Could not load datasnapshot to in memory graph");
}
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
index 3c030466..2858ece3 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
@@ -22,6 +22,14 @@
package org.onap.aai.dmaap;
+import java.util.Map;
+import java.util.Objects;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.aailog.logs.AaiDmaapMetricLog;
@@ -37,13 +45,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-import java.util.Map;
-import java.util.Objects;
-
public class AAIDmaapEventJMSConsumer implements MessageListener {
private static final String EVENT_TOPIC = "event-topic";
@@ -57,7 +58,6 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
private Environment environment;
private Map<String, String> mdcCopy;
-
public AAIDmaapEventJMSConsumer(Environment environment, RestTemplate restTemplate, HttpHeaders httpHeaders) {
super();
mdcCopy = MDC.getCopyOfContextMap();
@@ -86,7 +86,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
String aaiElsErrorCode = AaiElsErrorCode.SUCCESS;
String errorDescription = "";
- if ( mdcCopy != null ) {
+ if (mdcCopy != null) {
MDC.setContextMap(mdcCopy);
}
@@ -113,8 +113,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
if (aaiEventHeader.has("entity-link")) {
serviceName = aaiEventHeader.get("entity-link").toString();
}
- }
- catch (JSONException jexc) {
+ } catch (JSONException jexc) {
// ignore, this is just used for logging
}
}
@@ -139,8 +138,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
aaiElsErrorCode = AaiElsErrorCode.AVAILABILITY_TIMEOUT_ERROR;
errorDescription = e.getMessage();
ErrorLogHelper.logException(new AAIException("AAI_7304", jsmMessageTxt));
- }
- finally {
+ } finally {
metricLog.post(aaiElsErrorCode, errorDescription);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java b/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java
index 1df64b69..da70d505 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java
@@ -25,5 +25,6 @@ import org.json.JSONObject;
public interface MessageProducer {
void sendMessageToDefaultDestination(JSONObject finalJson);
+
void sendMessageToDefaultDestination(String msg);
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
index ac13ab07..7b5b2da7 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
@@ -20,11 +20,11 @@
package org.onap.aai.domain.model;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+
public class AAIResources {
private DynamicJAXBContext jaxbContext;
diff --git a/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java b/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java
index 1e6307cc..dad35669 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java
@@ -26,10 +26,10 @@
package org.onap.aai.domain.notificationEvent;
-import org.w3c.dom.Element;
-
import javax.xml.bind.annotation.*;
+import org.w3c.dom.Element;
+
/**
* <p>
* Java class for anonymous complex type.
diff --git a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java
index c48f1ed8..f7fe13b5 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java
@@ -29,10 +29,11 @@ package org.onap.aai.domain.responseMessage;
//Generated on: 2015.09.11 at 11:53:27 AM EDT
//
-import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.bind.annotation.*;
+
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"aaiResponseMessageDatum", "any"})
@XmlRootElement(name = "aai-response-message-data", namespace = "http://org.onap.aai.inventory")
diff --git a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java
index 8263e58d..f5068742 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java
@@ -27,10 +27,11 @@ package org.onap.aai.domain.responseMessage;
//Generated on: 2015.09.11 at 11:53:27 AM EDT
//
-import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.bind.annotation.*;
+
/**
* <p>
* Java class for anonymous complex type.
diff --git a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
index cde4f4b9..d1caf511 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
@@ -26,12 +26,13 @@
package org.onap.aai.domain.translog;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import java.util.ArrayList;
-import java.util.List;
/**
* <p>
diff --git a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java
index 16c773ae..37a1eeff 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java
@@ -20,10 +20,10 @@
package org.onap.aai.domain.translog;
-import org.eclipse.persistence.oxm.annotations.XmlCDATA;
-
import javax.xml.bind.annotation.*;
+import org.eclipse.persistence.oxm.annotations.XmlCDATA;
+
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = "",
diff --git a/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java b/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
index ec28858e..612273d4 100644
--- a/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
+++ b/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
@@ -20,13 +20,12 @@
package org.onap.aai.extensions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.lang.reflect.Method;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ExtensionController {
diff --git a/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java b/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java
index 094e7cee..5f7a9a1c 100644
--- a/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java
+++ b/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java
@@ -31,7 +31,6 @@ import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.rest.db.DBRequest;
diff --git a/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java b/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java
index 62cadab3..1d66a8a5 100644
--- a/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java
+++ b/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java
@@ -30,7 +30,6 @@ import java.util.UUID;
import javax.xml.transform.stream.StreamSource;
-import org.onap.aai.config.SpringContextAware;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
index 117610ff..c9e1f455 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
@@ -20,6 +20,8 @@
package org.onap.aai.introspection;
+import com.google.common.base.CaseFormat;
+
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -48,8 +50,6 @@ import org.onap.aai.workarounds.NamingExceptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.CaseFormat;
-
public abstract class Introspector implements Cloneable {
private static final Logger LOGGER = LoggerFactory.getLogger(Introspector.class);
@@ -185,7 +185,7 @@ public abstract class Introspector implements Cloneable {
if (obj != null) {
try {
- if (! (obj.getClass().getCanonicalName().equals(nameClass.getCanonicalName()))) {
+ if (!(obj.getClass().getCanonicalName().equals(nameClass.getCanonicalName()))) {
if (nameClass.isPrimitive()) {
nameClass = ClassUtils.primitiveToWrapper(nameClass);
result = nameClass.getConstructor(String.class).newInstance(obj.toString());
@@ -317,8 +317,7 @@ public abstract class Introspector implements Cloneable {
String indexedKeys = this.getMetadata(ObjectMetadata.INDEXED_PROPS);
if (dslKeys != null) {
Arrays.stream(dslKeys.split(",")).forEach(result::add);
- }
- else if(indexedKeys != null){
+ } else if (indexedKeys != null) {
Arrays.stream(indexedKeys.split(",")).forEach(result::add);
}
this.dslStartNodeProperties = Collections.unmodifiableSet(result);
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java b/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java
index 93a48290..e6ecef0f 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java
@@ -20,9 +20,6 @@
package org.onap.aai.introspection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
@@ -31,6 +28,8 @@ import java.util.Set;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.logging.LogFormatTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IntrospectorWalker {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
index 484e5612..40352360 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.onap.aai.schema.enums.ObjectMetadata;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java b/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java
index 7471c745..6099e1b4 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java
@@ -20,8 +20,6 @@
package org.onap.aai.introspection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableMap;
@@ -49,6 +47,8 @@ import org.onap.aai.restcore.MediaType;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.workarounds.NamingExceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class MoxyLoader extends Loader {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java b/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java
index 57e41081..df8e9238 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java
@@ -20,8 +20,6 @@
package org.onap.aai.introspection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.CaseFormat;
import com.google.common.base.Joiner;
@@ -44,12 +42,12 @@ import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping;
import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.nodes.CaseFormatStore;
-import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.restcore.MediaType;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.setup.SchemaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.web.util.UriUtils;
public class MoxyStrategy extends Introspector {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java b/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java
index 1aca431f..822b0464 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java
@@ -22,6 +22,7 @@ package org.onap.aai.introspection;
import java.util.Map;
import java.util.Set;
+
import org.onap.aai.schema.enums.PropertyMetadata;
public final class PropertyPredicates {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java b/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java
index 6ce42e4e..0cf19962 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java
@@ -26,7 +26,8 @@ public class AAIUnmarshallingException extends AAIException {
private static final long serialVersionUID = -5615651557821878103L;
- private static final String AAI_MSG="AAI_3000";
+ private static final String AAI_MSG = "AAI_3000";
+
public AAIUnmarshallingException() {
}
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java b/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java
index 8288fd68..c5a14ce0 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java
@@ -20,13 +20,13 @@
package org.onap.aai.introspection.generator;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.*;
-
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.*;
+
public class CreateExample implements Wanderer {
private SecureRandom rand = new SecureRandom();
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java
index 0994f023..d7780928 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java
@@ -20,6 +20,17 @@
package org.onap.aai.introspection.sideeffect;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
@@ -31,16 +42,6 @@ import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-
public class DataCopy extends SideEffect {
public DataCopy(Introspector obj, Vertex self, TransactionalGraphEngine dbEngine, DBSerializer serializer) {
@@ -73,7 +74,7 @@ public class DataCopy extends SideEffect {
"multiple values of " + entry.getKey() + " found when searching " + uri);
}
}
- } //else skip processing because no required properties were specified
+ } // else skip processing because no required properties were specified
}
@Override
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java
index 4d75f38a..d9976455 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java
@@ -42,14 +42,13 @@ public class OwnerCheck extends SideEffect {
}
@Override
- protected void processURI(Optional<String> completeUri, Entry<String, String> entry)
- throws AAIException {
+ protected void processURI(Optional<String> completeUri, Entry<String, String> entry) throws AAIException {
if (!isAuthorized(serializer.getGroups(), self)) {
throw new AAIException("AAI_3304",
- "Group(s) :" + serializer.getGroups() + " not authorized to perform function");
+ "Group(s) :" + serializer.getGroups() + " not authorized to perform function");
- } //else skip processing because no required properties were specified
+ } // else skip processing because no required properties were specified
}
@@ -60,7 +59,7 @@ public class OwnerCheck extends SideEffect {
String dataOwner = dataOwnerProperty.toString();
String dataOwnerWithReadAccess = dataOwner + READ_ONLY_SUFFIX;
return groups.stream()
- .anyMatch(group -> group.equals(dataOwner) || group.equals(dataOwnerWithReadAccess));
+ .anyMatch(group -> group.equals(dataOwner) || group.equals(dataOwnerWithReadAccess));
}
}
return true;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java
index 06586317..9e32ef40 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java
@@ -21,6 +21,15 @@
package org.onap.aai.introspection.sideeffect;
import com.google.common.collect.Multimap;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+import java.util.Map.Entry;
+
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -46,13 +55,6 @@ import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.db.exceptions.EdgeMultiplicityException;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.Map.Entry;
-
public class PrivateEdge extends SideEffect {
public PrivateEdge(Introspector obj, Vertex self, TransactionalGraphEngine dbEngine, DBSerializer serializer) {
@@ -134,8 +136,8 @@ public class PrivateEdge extends SideEffect {
break;
}
} else {
- edgeSerializer.addPrivateEdge(this.dbEngine.asAdmin().getTraversalSource(), self,
- otherVertex, edgeRule.getLabel());
+ edgeSerializer.addPrivateEdge(this.dbEngine.asAdmin().getTraversalSource(), self, otherVertex,
+ edgeRule.getLabel());
}
}
} else {
@@ -143,7 +145,7 @@ public class PrivateEdge extends SideEffect {
throw new AAIException("AAI_6114", "object located at " + uri + " not found");
} else {
throw new AAIMultiplePropertiesException(
- "multiple values of " + entry.getKey() + " found when searching " + uri);
+ "multiple values of " + entry.getKey() + " found when searching " + uri);
}
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java
index 9ca396ad..bec46520 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java
@@ -31,6 +31,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java
index 8bc83156..5862767c 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java
@@ -20,9 +20,6 @@
package org.onap.aai.introspection.sideeffect;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java b/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java
index ca735357..dfa7c95a 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java
@@ -20,9 +20,6 @@
package org.onap.aai.parsers.query;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -43,6 +40,8 @@ import org.onap.aai.parsers.uri.URIToObject;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.restcore.util.URITools;
import org.onap.aai.schema.enums.PropertyMetadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class LegacyQueryParser.
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java b/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java
index e1319802..7df49b2e 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java
@@ -20,9 +20,6 @@
package org.onap.aai.parsers.query;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import org.onap.aai.config.SpringContextAware;
@@ -34,6 +31,8 @@ import org.onap.aai.introspection.ModelType;
import org.onap.aai.parsers.relationship.RelationshipToURI;
import org.onap.aai.parsers.uri.URIParser;
import org.onap.aai.query.builder.QueryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
/**
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java b/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java
index 0ee22f50..8ed0fcb6 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java
@@ -20,9 +20,6 @@
package org.onap.aai.parsers.relationship;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -50,6 +47,8 @@ import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException;
import org.onap.aai.parsers.uri.URIParser;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.setup.SchemaVersions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
/**
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java b/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java
index 80643429..3ca20c5e 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java
@@ -52,7 +52,7 @@ public class URIParser {
private URI originalURI = null;
private MultivaluedMap<String, String> queryParams = null;
-
+
private static String aaiExceptionCode = "AAI_3001";
/**
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java b/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java
index d420c558..db1e36b5 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.prevalidation;
import com.google.gson.annotations.SerializedName;
@@ -70,9 +71,8 @@ public class Validation {
return false;
}
Validation that = (Validation) o;
- return Objects.equals(validationId, that.validationId) &&
- Objects.equals(action, that.action) &&
- Objects.equals(violations, that.violations);
+ return Objects.equals(validationId, that.validationId) && Objects.equals(action, that.action)
+ && Objects.equals(violations, that.violations);
}
@Override
@@ -82,11 +82,8 @@ public class Validation {
@Override
public String toString() {
- return "Validation{" +
- "validationId='" + validationId + '\'' +
- ", action='" + action + '\'' +
- ", violations=" + violations +
- '}';
+ return "Validation{" + "validationId='" + validationId + '\'' + ", action='" + action + '\'' + ", violations="
+ + violations + '}';
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java
index 36569dd0..7030cf7d 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.prevalidation;
import org.onap.aai.restclient.RestClient;
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java
index 29b31081..c66511f0 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java
@@ -19,10 +19,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.prevalidation;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
+
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
@@ -34,7 +36,9 @@ import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+
import javax.annotation.PostConstruct;
+
import org.apache.http.conn.ConnectTimeoutException;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
@@ -63,25 +67,24 @@ public class ValidationService {
* Error indicating that the service trying to connect is down
*/
static final String CONNECTION_REFUSED_STRING =
- "Connection refused to the validation microservice due to service unreachable";
+ "Connection refused to the validation microservice due to service unreachable";
/**
* Error indicating that the server is unable to reach the port
* Could be server related connectivity issue
*/
- static final String CONNECTION_TIMEOUT_STRING =
- "Connection timeout to the validation microservice as this could " +
- "indicate the server is unable to reach port, " +
- "please check on server by running: nc -w10 -z -v ${VALIDATION_HOST} ${VALIDATION_PORT}";
+ static final String CONNECTION_TIMEOUT_STRING = "Connection timeout to the validation microservice as this could "
+ + "indicate the server is unable to reach port, "
+ + "please check on server by running: nc -w10 -z -v ${VALIDATION_HOST} ${VALIDATION_PORT}";
/**
* Error indicating that the request exceeded the allowed time
*
* Note: This means that the service could be active its
- * just taking some time to process our request
+ * just taking some time to process our request
*/
static final String REQUEST_TIMEOUT_STRING =
- "Request to validation service took longer than the currently set timeout";
+ "Request to validation service took longer than the currently set timeout";
static final String VALIDATION_ENDPOINT = "/v1/validate";
static final String VALIDATION_HEALTH_ENDPOINT = "/v1/info";
@@ -105,26 +108,20 @@ public class ValidationService {
private final Gson gson;
@Autowired
- public ValidationService(
- @Qualifier("validationRestClient") RestClient validationRestClient,
- @Value("${spring.application.name}") String appName,
- @Value("${validation.service.node-types}") String validationNodes,
- @Value("${validation.service.exclusion-regexes}") String exclusionRegexes
- ){
+ public ValidationService(@Qualifier("validationRestClient") RestClient validationRestClient,
+ @Value("${spring.application.name}") String appName,
+ @Value("${validation.service.node-types}") String validationNodes,
+ @Value("${validation.service.exclusion-regexes}") String exclusionRegexes) {
this.validationRestClient = validationRestClient;
this.appName = appName;
- this.validationNodeTypes = Arrays
- .stream(validationNodes.split(","))
- .collect(Collectors.toSet());
+ this.validationNodeTypes = Arrays.stream(validationNodes.split(",")).collect(Collectors.toSet());
- if(exclusionRegexes == null || exclusionRegexes.isEmpty()){
+ if (exclusionRegexes == null || exclusionRegexes.isEmpty()) {
this.exclusionList = new ArrayList<>();
} else {
- this.exclusionList = Arrays
- .stream(exclusionRegexes.split(","))
- .map(Pattern::compile)
- .collect(Collectors.toList());
+ this.exclusionList =
+ Arrays.stream(exclusionRegexes.split(",")).map(Pattern::compile).collect(Collectors.toList());
}
this.gson = new Gson();
LOGGER.info("Successfully initialized the pre validation service");
@@ -143,32 +140,28 @@ public class ValidationService {
try {
- healthCheckResponse = validationRestClient.execute(
- VALIDATION_HEALTH_ENDPOINT,
- HttpMethod.GET,
- httpHeaders,
- null
- );
+ healthCheckResponse =
+ validationRestClient.execute(VALIDATION_HEALTH_ENDPOINT, HttpMethod.GET, httpHeaders, null);
- } catch(Exception ex){
+ } catch (Exception ex) {
AAIException validationException = new AAIException("AAI_4021", ex);
throw validationException;
}
- if(!isSuccess(healthCheckResponse)){
+ if (!isSuccess(healthCheckResponse)) {
throw new AAIException("AAI_4021");
}
LOGGER.info("Successfully connected to the validation service endpoint");
}
- public boolean shouldValidate(String nodeType){
+ public boolean shouldValidate(String nodeType) {
return this.validationNodeTypes.contains(nodeType);
}
public void validate(List<NotificationEvent> notificationEvents) throws AAIException {
- if(notificationEvents == null || notificationEvents.isEmpty()){
+ if (notificationEvents == null || notificationEvents.isEmpty()) {
return;
}
@@ -177,10 +170,10 @@ public class ValidationService {
// is in one of the regexes then we skip sending it to validation
NotificationEvent notification = notificationEvents.get(0);
Introspector eventHeader = notification.getEventHeader();
- if(eventHeader != null){
+ if (eventHeader != null) {
String source = eventHeader.getValue(SOURCE_NAME);
- for(Pattern pattern: exclusionList){
- if(pattern.matcher(source).matches()){
+ for (Pattern pattern : exclusionList) {
+ if (pattern.matcher(source).matches()) {
return;
}
}
@@ -192,7 +185,7 @@ public class ValidationService {
Introspector eventHeader = event.getEventHeader();
- if(eventHeader == null){
+ if (eventHeader == null) {
// Should I skip processing the request and let it continue
// or fail the request and cause client impact
continue;
@@ -205,13 +198,13 @@ public class ValidationService {
* Skipping the delete events for now
* Note: Might revisit this later when validation supports DELETE events
*/
- if(DELETE.equalsIgnoreCase(action)){
+ if (DELETE.equalsIgnoreCase(action)) {
continue;
}
if (this.shouldValidate(entityType)) {
List<String> violations = this.preValidate(event.getNotificationEvent());
- if(!violations.isEmpty()){
+ if (!violations.isEmpty()) {
AAIException aaiException = new AAIException("AAI_4019");
aaiException.getTemplateVars().addAll(violations);
throw aaiException;
@@ -232,47 +225,40 @@ public class ValidationService {
ResponseEntity responseEntity;
try {
- responseEntity = validationRestClient.execute(
- VALIDATION_ENDPOINT,
- HttpMethod.POST,
- httpHeaders,
- body
- );
+ responseEntity = validationRestClient.execute(VALIDATION_ENDPOINT, HttpMethod.POST, httpHeaders, body);
Object responseBody = responseEntity.getBody();
- if(isSuccess(responseEntity)){
- LOGGER.debug("Validation Service returned following response status code {} and body {}", responseEntity.getStatusCodeValue(), responseEntity.getBody());
+ if (isSuccess(responseEntity)) {
+ LOGGER.debug("Validation Service returned following response status code {} and body {}",
+ responseEntity.getStatusCodeValue(), responseEntity.getBody());
} else if (responseBody != null) {
Validation validation = null;
try {
validation = gson.fromJson(responseBody.toString(), Validation.class);
- } catch(JsonSyntaxException jsonException){
+ } catch (JsonSyntaxException jsonException) {
LOGGER.warn("Unable to convert the response body {}", jsonException.getMessage());
}
- if(validation == null){
- LOGGER.debug(
- "Validation Service following status code {} with body {}",
- responseEntity.getStatusCodeValue(),
- responseEntity.getBody()
- );
+ if (validation == null) {
+ LOGGER.debug("Validation Service following status code {} with body {}",
+ responseEntity.getStatusCodeValue(), responseEntity.getBody());
} else {
violations.addAll(extractViolations(validation));
}
} else {
LOGGER.warn("Unable to convert the response body null");
}
- } catch(Exception e){
+ } catch (Exception e) {
// If the exception cause is client side timeout
// then proceed as if it passed validation
// resources microservice shouldn't be blocked because of validation service
// is taking too long or if the validation service is down
// Any other exception it should block the request from passing?
- if(e.getCause() instanceof SocketTimeoutException){
+ if (e.getCause() instanceof SocketTimeoutException) {
LOGGER.error(REQUEST_TIMEOUT_STRING, e.getCause());
- } else if(e.getCause() instanceof ConnectException){
+ } else if (e.getCause() instanceof ConnectException) {
LOGGER.error(CONNECTION_REFUSED_STRING, e.getCause());
- } else if(e.getCause() instanceof ConnectTimeoutException){
+ } else if (e.getCause() instanceof ConnectTimeoutException) {
LOGGER.error(CONNECTION_TIMEOUT_STRING, e.getCause());
} else {
LOGGER.error("Unknown exception thrown please investigate", e.getCause());
@@ -281,7 +267,7 @@ public class ValidationService {
return violations;
}
- boolean isSuccess(ResponseEntity responseEntity){
+ boolean isSuccess(ResponseEntity responseEntity) {
return responseEntity != null && responseEntity.getStatusCode().is2xxSuccessful();
}
@@ -289,7 +275,7 @@ public class ValidationService {
List<String> errorMessages = new ArrayList<>();
- if(validation == null){
+ if (validation == null) {
return errorMessages;
}
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java
index 6173e4bd..f899e9fe 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java
@@ -20,20 +20,19 @@
package org.onap.aai.prevalidation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import org.onap.aai.restclient.NoAuthRestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.onap.aai.restclient.NoAuthRestClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
-import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class ValidationServiceNoAuthClient extends NoAuthRestClient {
private static Logger logger = LoggerFactory.getLogger(ValidationServiceNoAuthClient.class);
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java
index 40efd469..f72f6bcf 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java
@@ -20,6 +20,10 @@
package org.onap.aai.prevalidation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.onap.aai.restclient.OneWaySSLRestClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
@@ -27,10 +31,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class ValidationServiceOneWayClient extends OneWaySSLRestClient {
@Value("${validation.service.base.url}")
@@ -75,7 +75,7 @@ public class ValidationServiceOneWayClient extends OneWaySSLRestClient {
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
String defaultContentType =
- headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java
index 8674272e..af283063 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java
@@ -22,6 +22,10 @@
package org.onap.aai.prevalidation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.onap.aai.restclient.TwoWaySSLRestClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
@@ -29,10 +33,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class ValidationServiceRestClient extends TwoWaySSLRestClient {
@Value("${validation.service.base.url}")
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java b/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java
index e5472a7c..59b9f41f 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java
@@ -94,14 +94,9 @@ public class Violation {
@Override
public String toString() {
- return "Violation{" +
- "violationId='" + violationId + '\'' +
- ", modelName='" + modelName + '\'' +
- ", category='" + category + '\'' +
- ", severity='" + severity + '\'' +
- ", violationType='" + violationType + '\'' +
- ", errorMessage='" + errorMessage + '\'' +
- '}';
+ return "Violation{" + "violationId='" + violationId + '\'' + ", modelName='" + modelName + '\'' + ", category='"
+ + category + '\'' + ", severity='" + severity + '\'' + ", violationType='" + violationType + '\''
+ + ", errorMessage='" + errorMessage + '\'' + '}';
}
@Override
@@ -113,12 +108,10 @@ public class Violation {
return false;
}
Violation violation = (Violation) o;
- return Objects.equals(violationId, violation.violationId) &&
- Objects.equals(modelName, violation.modelName) &&
- Objects.equals(category, violation.category) &&
- Objects.equals(severity, violation.severity) &&
- Objects.equals(violationType, violation.violationType) &&
- Objects.equals(errorMessage, violation.errorMessage);
+ return Objects.equals(violationId, violation.violationId) && Objects.equals(modelName, violation.modelName)
+ && Objects.equals(category, violation.category) && Objects.equals(severity, violation.severity)
+ && Objects.equals(violationType, violation.violationType)
+ && Objects.equals(errorMessage, violation.errorMessage);
}
@Override
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
index 1dc3f1d6..2517e2c0 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
@@ -72,7 +72,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
* Instantiates a new graph traversal builder.
*
* @param loader the loader
- * @param start the start
+ * @param start the start
*/
public GraphTraversalBuilder(Loader loader, GraphTraversalSource source, Vertex start) {
super(loader, source, start);
@@ -108,12 +108,14 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
traversal.has(key);
}
- //TODO: Remove this once we test this - at this point i dont thib this is required
- //because predicare is an object
- /*@Override
- protected void vertexHas(final String key, final P<?> predicate) {
- traversal.has(key, predicate);
- }*/
+ // TODO: Remove this once we test this - at this point i dont thib this is required
+ // because predicare is an object
+ /*
+ * @Override
+ * protected void vertexHas(final String key, final P<?> predicate) {
+ * traversal.has(key, predicate);
+ * }
+ */
/**
* @{inheritDoc}
@@ -154,7 +156,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
public QueryBuilder<Vertex> getVerticesStartsWithProperty(String key, Object value) {
// correct value call because the index is registered as an Integer
- //TODO Check if this needs to be in QB and add these as internal
+ // TODO Check if this needs to be in QB and add these as internal
this.vertexHas(key, org.janusgraph.core.attribute.Text.textPrefix(value));
stepIndex++;
@@ -355,7 +357,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
*/
@Override
public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Introspector parent, Introspector child)
- throws AAIException {
+ throws AAIException {
createTraversal(type, parent, child, false);
return (QueryBuilder<Vertex>) this;
@@ -363,13 +365,13 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
@Override
public QueryBuilder<Vertex> createPrivateEdgeTraversal(EdgeType type, Introspector parent, Introspector child)
- throws AAIException {
+ throws AAIException {
this.createTraversal(type, parent, child, true);
return (QueryBuilder<Vertex>) this;
}
private void createTraversal(EdgeType type, Introspector parent, Introspector child, boolean isPrivateEdge)
- throws AAIException {
+ throws AAIException {
String isAbstractType = parent.getMetadata(ObjectMetadata.ABSTRACT);
if ("true".equals(isAbstractType)) {
markParentBoundary();
@@ -385,13 +387,13 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
*/
@Override
public QueryBuilder<Vertex> createEdgeTraversalWithLabels(EdgeType type, Introspector out, Introspector in,
- List<String> labels) throws AAIException {
+ List<String> labels) throws AAIException {
this.edgeQueryToVertex(type, out, in, labels);
return (QueryBuilder<Vertex>) this;
}
private Traversal<Vertex, Vertex>[] handleAbstractEdge(EdgeType type, Introspector abstractParent,
- Introspector child, boolean isPrivateEdge) throws AAIException {
+ Introspector child, boolean isPrivateEdge) throws AAIException {
String childName = child.getDbName();
String inheritorMetadata = abstractParent.getMetadata(ObjectMetadata.INHERITORS);
String[] inheritors = inheritorMetadata.split(",");
@@ -427,7 +429,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
innerTraversal.in(inLabels.toArray(new String[inLabels.size()]));
} else {
innerTraversal.union(__.out(outLabels.toArray(new String[outLabels.size()])),
- __.in(inLabels.toArray(new String[inLabels.size()])));
+ __.in(inLabels.toArray(new String[inLabels.size()])));
}
innerTraversal.has(AAIProperties.NODE_TYPE, childName);
@@ -439,7 +441,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
}
public QueryBuilder<Edge> getEdgesBetweenWithLabels(EdgeType type, String outNodeType, String inNodeType,
- List<String> labels) throws AAIException {
+ List<String> labels) throws AAIException {
Introspector outObj = loader.introspectorFromName(outNodeType);
Introspector inObj = loader.introspectorFromName(inNodeType);
this.edgeQuery(type, outObj, inObj, labels);
@@ -600,7 +602,6 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
return this;
}
-
/**
* {@inheritDoc}
*/
@@ -694,12 +695,12 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
* Edge query.
*
* @param outObj the out type
- * @param inObj the in type
+ * @param inObj the in type
* @throws NoEdgeRuleFoundException
* @throws AAIException
*/
private void edgeQueryToVertex(EdgeType type, Introspector outObj, Introspector inObj, List<String> labels)
- throws AAIException {
+ throws AAIException {
String outType = outObj.getDbName();
String inType = inObj.getDbName();
@@ -731,7 +732,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
}
if (rules.isEmpty()) {
throw new NoEdgeRuleFoundException(
- "No edge rules found for " + outType + " and " + inType + " of type " + type.toString());
+ "No edge rules found for " + outType + " and " + inType + " of type " + type.toString());
}
}
@@ -756,7 +757,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
traversal.in(inLabels.toArray(new String[inLabels.size()]));
} else {
traversal.union(__.out(outLabels.toArray(new String[outLabels.size()])),
- __.in(inLabels.toArray(new String[inLabels.size()])));
+ __.in(inLabels.toArray(new String[inLabels.size()])));
}
stepIndex++;
@@ -769,12 +770,12 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
* Edge query.
*
* @param outObj the out type
- * @param inObj the in type
+ * @param inObj the in type
* @throws NoEdgeRuleFoundException
* @throws AAIException
*/
private void edgeQuery(EdgeType type, Introspector outObj, Introspector inObj, List<String> labels)
- throws AAIException {
+ throws AAIException {
String outType = outObj.getDbName();
String inType = inObj.getDbName();
@@ -822,7 +823,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
traversal.inE(inLabels.toArray(new String[inLabels.size()]));
} else {
traversal.union(__.outE(outLabels.toArray(new String[outLabels.size()])),
- __.inE(inLabels.toArray(new String[inLabels.size()])));
+ __.inE(inLabels.toArray(new String[inLabels.size()])));
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java
index 712a1ddb..4500a47e 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java
@@ -22,8 +22,6 @@
package org.onap.aai.query.builder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@@ -48,6 +46,8 @@ import org.onap.aai.introspection.Loader;
import org.onap.aai.restcore.search.GremlinGroovyShell;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class GremlinQueryBuilder.
@@ -85,7 +85,6 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
list = new ArrayList<>();
}
-
@Override
public QueryBuilder<Vertex> exactMatchQuery(Introspector obj) {
// TODO not implemented because this is implementation is no longer used
@@ -121,7 +120,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
String valueString = value.toString();
if (valueString.indexOf('\'') != -1) {
- value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
+ value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
}
LOGGER.trace("Inside getVerticesByProperty(): key = {}, value = {}", key, value);
term = value.toString();
@@ -129,7 +128,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
String valueString = value.toString();
if (valueString.indexOf('\'') != -1) {
- value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
+ value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
}
LOGGER.trace("Inside getVerticesByProperty(): key = {}, value = {}", key, value);
term = "'" + value + "'";
@@ -189,22 +188,20 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
stepIndex++;
return (QueryBuilder<Vertex>) this;
}
-
+
/**
* @{inheritDoc}
*/
@Override
public QueryBuilder<Vertex> getVerticesByCommaSeperatedValue(String key, String value) {
ArrayList<String> arguments = new ArrayList<>(Arrays.asList(value.split(",")));
- //add the single quotes
+ // add the single quotes
for (int i = 0; i < arguments.size(); i++) {
- if(arguments.get(i) != null && !arguments.get(i).startsWith("'")
- && !arguments.get(i).endsWith("'")) {
- arguments.set(i,"'" + arguments.get(i).trim() + "'");
- }
- else {
- arguments.set(i, arguments.get(i).trim());
- }
+ if (arguments.get(i) != null && !arguments.get(i).startsWith("'") && !arguments.get(i).endsWith("'")) {
+ arguments.set(i, "'" + arguments.get(i).trim() + "'");
+ } else {
+ arguments.set(i, arguments.get(i).trim());
+ }
}
String predicate = "P.within(#!#argument#!#)";
String argument = Joiner.on(",").join(arguments);
@@ -339,7 +336,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
public QueryBuilder<Vertex> getTypedVerticesByMap(String type, Map<String, String> map) {
for (Map.Entry<String, String> es : map.entrySet()) {
- //TODO what is this and where is it used - need to check
+ // TODO what is this and where is it used - need to check
list.add(HAS + es.getKey() + "', '" + es.getValue() + "')");
stepIndex++;
}
@@ -729,7 +726,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
return this;
}
-
+
@Override
public QueryBuilder<E> valueMap() {
this.list.add(".valueMap()");
@@ -737,23 +734,22 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
return this;
}
-
+
@Override
public QueryBuilder<E> valueMap(String... names) {
- String stepString = ".valueMap('";
- for (int i = 0; i < names.length; i++) {
- stepString = stepString + names[i] + "'";
- if (i != (names.length - 1)) {
- stepString = stepString + ",'";
- }
- }
- stepString = stepString + ")";
- this.list.add(stepString);
- stepIndex++;
+ String stepString = ".valueMap('";
+ for (int i = 0; i < names.length; i++) {
+ stepString = stepString + names[i] + "'";
+ if (i != (names.length - 1)) {
+ stepString = stepString + ",'";
+ }
+ }
+ stepString = stepString + ")";
+ this.list.add(stepString);
+ stepIndex++;
- return this;
+ return this;
}
-
/**
* {@inheritDoc}
@@ -955,5 +951,4 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
* This is required for the subgraphstrategies to work
*/
-
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java
index 9cd35ab9..710db480 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java
@@ -61,7 +61,6 @@ public class GremlinTraversal<E> extends GremlinQueryBuilder<E> {
this.factory = new TraversalStrategy(this.loader, this);
}
-
protected GremlinTraversal(List<String> traversal, Loader loader, GraphTraversalSource source,
GremlinQueryBuilder<E> gtb) {
super(loader, source);
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java
index 5b14995c..49772b08 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java
@@ -20,21 +20,20 @@
package org.onap.aai.query.builder;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.parsers.query.QueryParser;
-import org.onap.aai.parsers.query.TraversalStrategy;
-
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
/**
* The Class GremlinTraversal.
@@ -60,9 +59,8 @@ public class HistoryGremlinTraversal<E> extends GremlinTraversal<E> {
super(loader, source, start);
}
-
protected HistoryGremlinTraversal(List<String> traversal, Loader loader, GraphTraversalSource source,
- GremlinQueryBuilder<E> gtb) {
+ GremlinQueryBuilder<E> gtb) {
super(traversal, loader, source, gtb);
}
@@ -155,15 +153,15 @@ public class HistoryGremlinTraversal<E> extends GremlinTraversal<E> {
/*
* This is required for the subgraphstrategies to work
*/
- private void touchHistoryProperties(String key){
- if(key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
+ private void touchHistoryProperties(String key) {
+ if (key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
list.add(".where(__.properties('" + key + "'))");
}
}
private void touchHistoryProperties(String key, Object value) {
- if(key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
+ if (key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
list.add(".where(__.properties('" + key + "').hasValue(" + value + "))");
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java
index 119f8522..c30850ce 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java
@@ -21,6 +21,7 @@
package org.onap.aai.query.builder;
import java.util.Map;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -39,12 +40,12 @@ public class HistoryTraversalURIOptimizedQuery<E> extends TraversalURIOptimizedQ
}
protected HistoryTraversalURIOptimizedQuery(GraphTraversal traversal, Loader loader, GraphTraversalSource source,
- GraphTraversalBuilder gtb) {
+ GraphTraversalBuilder gtb) {
super(traversal, loader, source, gtb);
}
protected HistoryTraversalURIOptimizedQuery(GraphTraversal traversal, Loader loader, GraphTraversalSource source,
- GraphTraversalBuilder gtb, Map<Integer, String> stepToAaiUri) {
+ GraphTraversalBuilder gtb, Map<Integer, String> stepToAaiUri) {
super(traversal, loader, source, gtb, stepToAaiUri);
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
index 007f9798..423583f4 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
@@ -20,6 +20,14 @@
package org.onap.aai.query.builder;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.MultivaluedMap;
+
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;
@@ -38,13 +46,6 @@ import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.parsers.query.QueryParserStrategy;
import org.springframework.context.ApplicationContext;
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
/**
* The Class QueryBuilder.
*/
@@ -111,7 +112,6 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
*/
public abstract QueryBuilder<Vertex> getVerticesByProperty(String key, Object value);
-
/**
* Gets the edges by property.
*
@@ -374,7 +374,7 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* @throws AAIException
*/
public QueryBuilder<Vertex> createEdgeTraversalWithLabels(MissingOptionalParameter edgeType, String outNodeType,
- String inNodeType, List<String> labels) throws AAIException {
+ String inNodeType, List<String> labels) throws AAIException {
/*
* When no optional parameter edgetype is sent get all edges between the 2 nodetypes
*/
@@ -413,7 +413,8 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
return queryBuilder;
}
- public QueryBuilder<Vertex> createEdgeTraversalWithLabels(String outNodeType, String inNodeType, List<String> labels) throws AAIException {
+ public QueryBuilder<Vertex> createEdgeTraversalWithLabels(String outNodeType, String inNodeType,
+ List<String> labels) throws AAIException {
Introspector out = loader.introspectorFromName(outNodeType);
Introspector in = loader.introspectorFromName(inNodeType);
@@ -480,13 +481,13 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
public abstract QueryBuilder<Vertex> createEdgeTraversalWithLabels(EdgeType type, Introspector out, Introspector in,
List<String> labels) throws AAIException;
-
/**
* This method and it's overloaded counterpart are conditional statements.
* This method creates an edge traversal step if an optional property is present
* This is necessary in cases such as "if the Optional Property 1 is sent,
* find all Nodes of type A with edges to Nodes of type B with property 1,
* otherwise, simply find all nodes of type A".
+ *
* @param type
* @param outNodeType
* @param inNodeType
@@ -494,9 +495,9 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* @return
* @throws AAIException
*/
- public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType, String inNodeType,
- Object value) throws AAIException {
- return this.createEdgeTraversal(type, outNodeType, inNodeType);
+ public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType,
+ String inNodeType, Object value) throws AAIException {
+ return this.createEdgeTraversal(type, outNodeType, inNodeType);
}
/**
@@ -505,6 +506,7 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* This is necessary in cases such as "if the Optional Property 1 is sent,
* find all Nodes of type A with edges to Nodes of type B with property 1,
* otherwise, simply find all nodes of type A".
+ *
* @param type
* @param outNodeType
* @param inNodeType
@@ -512,9 +514,9 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* @return
* @throws AAIException
*/
- public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType, String inNodeType,
- MissingOptionalParameter value) throws AAIException {
- return (QueryBuilder<Vertex>) this;
+ public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType,
+ String inNodeType, MissingOptionalParameter value) throws AAIException {
+ return (QueryBuilder<Vertex>) this;
}
/**
@@ -783,12 +785,12 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
return getVerticesByProperty(key, value);
}
- protected abstract void vertexHas(String key, Object value) ;
+ protected abstract void vertexHas(String key, Object value);
protected abstract void vertexHasNot(String key);
protected abstract void vertexHas(String key);
- //TODO: This probably is not required but need to test
+ // TODO: This probably is not required but need to test
// protected abstract void vertexHas(final String key, final P<?> predicate);
}
diff --git a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
index 554ecb36..28d66dd0 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
@@ -20,13 +20,23 @@
package org.onap.aai.rest.db;
-import org.onap.aai.introspection.sideeffect.OwnerCheck;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.fge.jsonpatch.JsonPatchException;
import com.github.fge.jsonpatch.mergepatch.JsonMergePatch;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import javax.ws.rs.core.*;
+import javax.ws.rs.core.Response.Status;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphException;
import org.javatuples.Pair;
@@ -35,6 +45,7 @@ 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.introspection.sideeffect.OwnerCheck;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.parsers.query.QueryParser;
@@ -56,20 +67,10 @@ import org.onap.aai.transforms.XmlFormatTransformer;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
import org.onap.aai.util.delta.DeltaEvents;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.ResponseEntity;
-
-import javax.ws.rs.core.*;
-import javax.ws.rs.core.Response.Status;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.stream.Collectors;
/**
* The Class HttpEntry.
@@ -187,7 +188,8 @@ public class HttpEntry {
return this;
}
- public HttpEntry setHttpEntryProperties(SchemaVersion version, UEBNotification notification, int notificationDepth) {
+ public HttpEntry setHttpEntryProperties(SchemaVersion version, UEBNotification notification,
+ int notificationDepth) {
this.version = version;
this.loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
this.dbEngine = new JanusGraphDBEngine(queryStyle, loader);
@@ -244,10 +246,8 @@ public class HttpEntry {
return dbEngine;
}
- public Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests,
- String sourceOfTruth,
- Set<String> groups)
- throws AAIException {
+ public Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests, String sourceOfTruth,
+ Set<String> groups) throws AAIException {
return this.process(requests, sourceOfTruth, groups, true);
}
@@ -347,21 +347,21 @@ public class HttpEntry {
* @throws AAIException the AAI exception
*/
public Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests, String sourceOfTruth,
- boolean enableResourceVersion) throws AAIException {
+ boolean enableResourceVersion) throws AAIException {
return this.process(requests, sourceOfTruth, Collections.EMPTY_SET, enableResourceVersion);
}
- private Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests,
- String sourceOfTruth,
- Set<String> groups,
- boolean enableResourceVersion) throws AAIException {
+ private Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests, String sourceOfTruth,
+ Set<String> groups, boolean enableResourceVersion) throws AAIException {
DBSerializer serializer = null;
- if(serverBase != null){
- serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups, notificationDepth, serverBase);
+ if (serverBase != null) {
+ serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups,
+ notificationDepth, serverBase);
} else {
- serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups, notificationDepth);
+ serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups,
+ notificationDepth);
}
Response response;
@@ -383,7 +383,7 @@ public class HttpEntry {
String outputMediaType = null;
- if(requests != null && !requests.isEmpty()){
+ if (requests != null && !requests.isEmpty()) {
HttpHeaders headers = requests.get(0).getHeaders();
outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
}
@@ -451,8 +451,8 @@ public class HttpEntry {
String resourceVersion = obj.getValue(AAIProperties.RESOURCE_VERSION);
if (vertices.isEmpty()) {
if (enableResourceVersion) {
- serializer.verifyResourceVersion("create", query.getResultType(), "",
- resourceVersion, obj.getURI());
+ serializer.verifyResourceVersion("create", query.getResultType(), "", resourceVersion,
+ obj.getURI());
}
isNewVertex = true;
} else {
@@ -477,10 +477,13 @@ public class HttpEntry {
}
/*
- * This skip-related-to query parameter is used to determine if the relationships object will omit the related-to-property
- * If a GET is sent to resources without a format, if format=resource, or if format=resource_and_url with this param set to false
+ * This skip-related-to query parameter is used to determine if the relationships object will omit
+ * the related-to-property
+ * If a GET is sent to resources without a format, if format=resource, or if format=resource_and_url
+ * with this param set to false
* then behavior will be keep the related-to properties. By default, set to true.
- * Otherwise, for any other case, when the skip-related-to parameter exists, has value=true, or some unfamiliar input (e.g. skip-related-to=bogusvalue), the value is true.
+ * Otherwise, for any other case, when the skip-related-to parameter exists, has value=true, or some
+ * unfamiliar input (e.g. skip-related-to=bogusvalue), the value is true.
*/
boolean isSkipRelatedTo = true;
if (params.containsKey("skip-related-to")) {
@@ -498,27 +501,29 @@ public class HttpEntry {
case GET:
if (format == null) {
- obj = this.getObjectFromDb(vertices, serializer, query, obj, request.getUri(),
- depth, isNodeOnly, cleanUp, isSkipRelatedTo);
+ obj = this.getObjectFromDb(vertices, serializer, query, obj, request.getUri(), depth,
+ isNodeOnly, cleanUp, isSkipRelatedTo);
if (obj != null) {
status = Status.OK;
MarshallerProperties properties;
- Optional<MarshallerProperties> marshallerPropOpt = request.getMarshallerProperties();
+ Optional<MarshallerProperties> marshallerPropOpt =
+ request.getMarshallerProperties();
if (marshallerPropOpt.isPresent()) {
properties = marshallerPropOpt.get();
} else {
properties = new MarshallerProperties.Builder(
- org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build();
+ org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build();
}
result = obj.marshal(properties);
}
} else {
- FormatFactory ff =
- new FormatFactory(loader, serializer, schemaVersions, basePath + "/", serverBase);
+ FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath + "/",
+ serverBase);
Formatter formatter = ff.get(format, params);
- result = formatter.output(vertices.stream().map(vertex -> (Object) vertex)
- .collect(Collectors.toList())).toString();
+ result = formatter.output(
+ vertices.stream().map(vertex -> (Object) vertex).collect(Collectors.toList()))
+ .toString();
if (outputMediaType == null) {
outputMediaType = MediaType.APPLICATION_JSON;
@@ -547,16 +552,17 @@ public class HttpEntry {
}
result = obj.marshal(properties);
} else {
- String msg = createRelationshipNotFoundMessage(query.getResultType(),
- request.getUri());
+ String msg =
+ createRelationshipNotFoundMessage(query.getResultType(), request.getUri());
throw new AAIException("AAI_6149", msg);
}
} else {
- FormatFactory ff =
- new FormatFactory(loader, serializer, schemaVersions, basePath + "/", serverBase);
+ FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath + "/",
+ serverBase);
Formatter formatter = ff.get(format, params);
- result = formatter.output(vertices.stream().map(vertex -> (Object) vertex)
- .collect(Collectors.toList())).toString();
+ result = formatter.output(
+ vertices.stream().map(vertex -> (Object) vertex).collect(Collectors.toList()))
+ .toString();
if (outputMediaType == null) {
outputMediaType = MediaType.APPLICATION_JSON;
@@ -580,16 +586,19 @@ public class HttpEntry {
mainVertexesToNotifyOn.add(v);
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
- Map<String, Pair<Introspector, LinkedHashMap<String,Introspector>>> allImpliedDeleteObjs = serializer.getImpliedDeleteUriObjectPair();
+ Map<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> allImpliedDeleteObjs =
+ serializer.getImpliedDeleteUriObjectPair();
- for (Map.Entry<String, Pair<Introspector, LinkedHashMap<String,Introspector>>> entry: allImpliedDeleteObjs.entrySet()) {
+ for (Map.Entry<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> entry : allImpliedDeleteObjs
+ .entrySet()) {
// The format is purposefully %s/%s%s due to the fact
// that every aai-uri will have a slash at the beginning
// If that assumption isn't true, then its best to change this code
- String curUri = String.format("%s/%s%s", basePath , version , entry.getKey());
+ String curUri = String.format("%s/%s%s", basePath, version, entry.getKey());
Introspector curObj = entry.getValue().getValue0();
HashMap<String, Introspector> curObjRelated = entry.getValue().getValue1();
- notification.createNotificationEvent(transactionId, sourceOfTruth, Status.NO_CONTENT, URI.create(curUri), curObj, curObjRelated, basePath);
+ notification.createNotificationEvent(transactionId, sourceOfTruth,
+ Status.NO_CONTENT, URI.create(curUri), curObj, curObjRelated, basePath);
}
}
@@ -638,8 +647,7 @@ public class HttpEntry {
String resourceVersion = params.getFirst(AAIProperties.RESOURCE_VERSION);
obj = serializer.getLatestVersionView(v, notificationDepth);
if (query.isDependent()) {
- relatedObjects =
- serializer.getRelatedObjects(queryEngine, v, obj, this.loader);
+ relatedObjects = serializer.getRelatedObjects(queryEngine, v, obj, this.loader);
}
/*
* Find all Delete-other-vertex vertices and create structure for notify
@@ -664,8 +672,7 @@ public class HttpEntry {
deleteObjects = this.buildIntrospectorObjects(serializer, deletableVertices);
uriMap = this.buildURIMap(serializer, deleteObjects);
- deleteRelatedObjects =
- this.buildRelatedObjects(serializer, queryEngine, deleteObjects);
+ deleteRelatedObjects = this.buildRelatedObjects(serializer, queryEngine, deleteObjects);
}
serializer.delete(v, deletableVertices, resourceVersion, enableResourceVersion);
@@ -701,10 +708,8 @@ public class HttpEntry {
* to be able to use for testing the vertex id endpoint functionality
* since we presently have no other way of generating those id urls
*/
- if (response == null && v != null
- && (method.equals(HttpMethod.PUT) || method.equals(HttpMethod.GET)
- || method.equals(HttpMethod.MERGE_PATCH)
- || method.equals(HttpMethod.GET_RELATIONSHIP))
+ if (response == null && v != null && (method.equals(HttpMethod.PUT) || method.equals(HttpMethod.GET)
+ || method.equals(HttpMethod.MERGE_PATCH) || method.equals(HttpMethod.GET_RELATIONSHIP))
) {
String myvertid = v.id().toString();
@@ -734,10 +739,11 @@ public class HttpEntry {
templateVars.add(request.getUri().getPath());
templateVars.addAll(e.getTemplateVars());
ErrorLogHelper.logException(e);
- response = Response.status(e.getErrorObject().getHTTPResponseCode()).entity(ErrorLogHelper
- .getRESTAPIErrorResponse(request.getHeaders().getAcceptableMediaTypes(), e, templateVars))
- .type(outputMediaType)
- .build();
+ response =
+ Response.status(e.getErrorObject().getHTTPResponseCode())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponse(
+ request.getHeaders().getAcceptableMediaTypes(), e, templateVars))
+ .type(outputMediaType).build();
Pair<URI, Response> pairedResp = Pair.with(request.getUri(), response);
responses.add(pairedResp);
} catch (Exception e) {
@@ -747,23 +753,23 @@ public class HttpEntry {
templateVars.add(request.getMethod().toString()); // GET, PUT, etc
templateVars.add(request.getUri().getPath());
ErrorLogHelper.logException(ex);
- response = Response.status(ex.getErrorObject().getHTTPResponseCode()).entity(ErrorLogHelper
- .getRESTAPIErrorResponse(request.getHeaders().getAcceptableMediaTypes(), ex, templateVars))
- .type(outputMediaType)
- .build();
+ response =
+ Response.status(ex.getErrorObject().getHTTPResponseCode())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponse(
+ request.getHeaders().getAcceptableMediaTypes(), ex, templateVars))
+ .type(outputMediaType).build();
Pair<URI, Response> pairedResp = Pair.with(request.getUri(), response);
responses.add(pairedResp);
- }
- finally {
+ } finally {
if (response != null) {
metricLog.post(request, response);
}
}
}
- if (success) {
- generateEvents(sourceOfTruth, serializer, transactionId, queryEngine, mainVertexesToNotifyOn);
- } else {
+ if (success) {
+ generateEvents(sourceOfTruth, serializer, transactionId, queryEngine, mainVertexesToNotifyOn);
+ } else {
notification.clearEvents();
}
@@ -774,18 +780,19 @@ public class HttpEntry {
* Generate notification events for the resulting db requests.
*/
private void generateEvents(String sourceOfTruth, DBSerializer serializer, String transactionId,
- QueryEngine queryEngine, Set<Vertex> mainVertexesToNotifyOn)
- throws AAIException {
+ QueryEngine queryEngine, Set<Vertex> mainVertexesToNotifyOn) throws AAIException {
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
- serializer.getUpdatedVertexes().entrySet().stream().filter(Map.Entry::getValue)
- .map(Map.Entry::getKey).forEach(mainVertexesToNotifyOn::add);
+ serializer.getUpdatedVertexes().entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey)
+ .forEach(mainVertexesToNotifyOn::add);
}
Set<Vertex> edgeVertexes = serializer.touchStandardVertexPropertiesForEdges().stream()
- .filter(v -> !mainVertexesToNotifyOn.contains(v)).collect(Collectors.toSet());
+ .filter(v -> !mainVertexesToNotifyOn.contains(v)).collect(Collectors.toSet());
try {
- createNotificationEvents(mainVertexesToNotifyOn, sourceOfTruth, serializer, transactionId, queryEngine, notificationDepth);
- if("true".equals(AAIConfig.get("aai.notification.both.sides.enabled", "true"))){
- createNotificationEvents(edgeVertexes, sourceOfTruth, serializer, transactionId, queryEngine, AAIProperties.MINIMUM_DEPTH);
+ createNotificationEvents(mainVertexesToNotifyOn, sourceOfTruth, serializer, transactionId, queryEngine,
+ notificationDepth);
+ if ("true".equals(AAIConfig.get("aai.notification.both.sides.enabled", "true"))) {
+ createNotificationEvents(edgeVertexes, sourceOfTruth, serializer, transactionId, queryEngine,
+ AAIProperties.MINIMUM_DEPTH);
}
} catch (UnsupportedEncodingException e) {
LOGGER.warn("Encountered exception generating events", e);
@@ -793,15 +800,14 @@ public class HttpEntry {
// Since @Autowired required is set to false, we need to do a null check
// for the existence of the validationService since its only enabled if profile is enabled
- if (validationService != null){
+ if (validationService != null) {
validationService.validate(notification.getEvents());
}
notification.triggerEvents();
if (isDeltaEventsEnabled) {
try {
DeltaEvents deltaEvents =
- new DeltaEvents(transactionId, sourceOfTruth, version.toString(),
- serializer.getObjectDeltas());
+ new DeltaEvents(transactionId, sourceOfTruth, version.toString(), serializer.getObjectDeltas());
deltaEvents.triggerEvents();
} catch (Exception e) {
LOGGER.error("Error sending Delta Events", e);
@@ -813,10 +819,12 @@ public class HttpEntry {
* Generate notification events for provided set of vertexes at the specified depth
*/
private void createNotificationEvents(Set<Vertex> vertexesToNotifyOn, String sourceOfTruth, DBSerializer serializer,
- String transactionId, QueryEngine queryEngine, int eventDepth) throws AAIException, UnsupportedEncodingException {
+ String transactionId, QueryEngine queryEngine, int eventDepth)
+ throws AAIException, UnsupportedEncodingException {
for (Vertex vertex : vertexesToNotifyOn) {
if (canGenerateEvent(vertex)) {
- boolean isCurVertexNew = vertex.value(AAIProperties.CREATED_TS).equals(vertex.value(AAIProperties.LAST_MOD_TS));
+ boolean isCurVertexNew =
+ vertex.value(AAIProperties.CREATED_TS).equals(vertex.value(AAIProperties.LAST_MOD_TS));
Status curObjStatus = (isCurVertexNew) ? Status.CREATED : Status.OK;
Introspector curObj = serializer.getLatestVersionView(vertex, eventDepth);
@@ -826,14 +834,15 @@ public class HttpEntry {
if (!curObj.isTopLevel()) {
curRelatedObjs = serializer.getRelatedObjects(queryEngine, vertex, curObj, this.loader);
}
- notification.createNotificationEvent(transactionId, sourceOfTruth, curObjStatus,
- URI.create(uri), curObj, curRelatedObjs, basePath);
+ notification.createNotificationEvent(transactionId, sourceOfTruth, curObjStatus, URI.create(uri),
+ curObj, curRelatedObjs, basePath);
}
}
}
/**
* Verifies that vertex has needed properties to generate on
+ *
* @param vertex Vertex to be verified
* @return <code>true</code> if vertex has necessary properties and exists
*/
@@ -843,8 +852,8 @@ public class HttpEntry {
if (!vertex.property(AAIProperties.AAI_URI).isPresent()) {
LOGGER.debug("Encountered an vertex {} with missing aai-uri", vertex.id());
canGenerate = false;
- } else if (!vertex.property(AAIProperties.CREATED_TS).isPresent() ||
- !vertex.property(AAIProperties.LAST_MOD_TS).isPresent()) {
+ } else if (!vertex.property(AAIProperties.CREATED_TS).isPresent()
+ || !vertex.property(AAIProperties.LAST_MOD_TS).isPresent()) {
LOGGER.debug("Encountered an vertex {} with missing timestamp", vertex.id());
canGenerate = false;
}
@@ -912,6 +921,7 @@ public class HttpEntry {
return serializer.dbToObject(results, obj, depth, nodeOnly, cleanUp);
}
+
/**
* Gets the object from db.
*
@@ -971,8 +981,8 @@ public class HttpEntry {
* @throws URISyntaxException
*/
private Introspector getRelationshipObjectFromDb(List<Vertex> results, DBSerializer serializer, QueryParser query,
- URI uri, boolean isSkipRelatedTo) throws AAIException, IllegalArgumentException, SecurityException, UnsupportedEncodingException,
- AAIUnknownObjectException {
+ URI uri, boolean isSkipRelatedTo) throws AAIException, IllegalArgumentException, SecurityException,
+ UnsupportedEncodingException, AAIUnknownObjectException {
// nothing found
if (results.isEmpty()) {
@@ -996,7 +1006,7 @@ public class HttpEntry {
* @return the string
*/
private String createNotFoundMessage(String resultType, URI uri) {
- return "No Node of type " + resultType + " found at: " + uri.getPath();
+ return "No Node of type " + resultType + " found at: " + uri.getPath();
}
/**
@@ -1007,7 +1017,7 @@ public class HttpEntry {
* @return the string
*/
private String createRelationshipNotFoundMessage(String resultType, URI uri) {
- return "No relationship found of type " + resultType + " at the given URI: " + uri.getPath()
+ return "No relationship found of type " + resultType + " at the given URI: " + uri.getPath()
+ "/relationship-list";
}
@@ -1105,8 +1115,7 @@ public class HttpEntry {
if (null != entry.getValue()) {
relatedObjectsMap.put(entry.getValue().getObjectId(), relatedObjects);
}
- } catch (IllegalArgumentException | SecurityException
- | UnsupportedEncodingException | AAIException e) {
+ } catch (IllegalArgumentException | SecurityException | UnsupportedEncodingException | AAIException e) {
LOGGER.warn("Unable to get realted Objects, Just continue");
}
@@ -1153,14 +1162,16 @@ public class HttpEntry {
List<Object> vertexList = (List<Object>) aggregateVertexList.get(0);
this.setTotalsForPaging(vertexList.size(), this.getPaginationBucket());
int startIndex = (this.getPaginationIndex() - 1) * this.getPaginationBucket();
- int endIndex = Math.min((this.getPaginationBucket() * this.getPaginationIndex()), vertexList.size());
+ int endIndex =
+ Math.min((this.getPaginationBucket() * this.getPaginationIndex()), vertexList.size());
if (startIndex > endIndex) {
throw new AAIException("AAI_6150",
- " ResultIndex is not appropriate for the result set, Needs to be <= " + endIndex);
+ " ResultIndex is not appropriate for the result set, Needs to be <= " + endIndex);
}
finalList.add(new ArrayList<Object>());
for (int i = startIndex; i < endIndex; i++) {
- ((ArrayList<Object>) finalList.get(0)).add(((ArrayList<Object>) aggregateVertexList.get(0)).get(i));
+ ((ArrayList<Object>) finalList.get(0))
+ .add(((ArrayList<Object>) aggregateVertexList.get(0)).get(i));
}
return finalList;
}
diff --git a/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java b/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java
index 14e554cd..b8e93c5b 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java
@@ -70,6 +70,7 @@ public class NotificationEvent {
public String getNotificationEvent() throws AAIException {
return new StoreNotificationEvent(transactionId, sourceOfTruth).storeEventOnly(loader, eventHeader, obj);
}
+
/**
* Gets the notification version.
*
diff --git a/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java b/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
index d9516315..be30c468 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
@@ -27,7 +27,9 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+
import javax.ws.rs.core.Response.Status;
+
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
@@ -204,6 +206,7 @@ public class UEBNotification {
public List<NotificationEvent> getEvents() {
return new ArrayList<>(this.events.values());
}
+
public Map<String, NotificationEvent> getEventsMap() {
return this.events;
}
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java b/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java
index 7c5d43c1..3666eb67 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java
@@ -32,10 +32,12 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java b/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java
index 13f3f05e..4a8760ec 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java
@@ -92,11 +92,11 @@ public abstract class AAIAbstractGroovyShell {
* @return result of graph traversal
*/
public abstract String executeTraversal(TransactionalGraphEngine engine, String traversal,
- Map<String, Object> params, QueryStyle style, GraphTraversalSource source);
+ Map<String, Object> params, QueryStyle style, GraphTraversalSource source);
- protected Loader getLoader(){
+ protected Loader getLoader() {
SchemaVersions schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
return SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(ModelType.MOXY,
- schemaVersions.getDefaultVersion());
+ schemaVersions.getDefaultVersion());
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java b/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java
index 85e47223..cc7a601b 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java
@@ -61,7 +61,8 @@ public class GremlinGroovyShell extends AAIAbstractGroovyShell {
}
@Override
- public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params, QueryStyle style, GraphTraversalSource source) {
+ public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params,
+ QueryStyle style, GraphTraversalSource source) {
throw new UnsupportedOperationException();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java b/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java
index fbaa7465..7a948761 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java
@@ -28,14 +28,9 @@ import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.introspection.ModelType;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.onap.aai.setup.SchemaVersions;
/**
* Creates and returns a groovy shell with the
@@ -74,7 +69,8 @@ public class GroovyQueryBuilder extends AAIAbstractGroovyShell {
}
@Override
- public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params, QueryStyle style, GraphTraversalSource traversalSource) {
+ public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params,
+ QueryStyle style, GraphTraversalSource traversalSource) {
QueryBuilder<Vertex> builder = engine.getQueryBuilder(style, traversalSource);
builder.changeLoader(getLoader());
Binding binding = new Binding(params);
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java b/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java
index fc32f859..962d2e99 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java
@@ -20,7 +20,6 @@
package org.onap.aai.restcore.util;
-import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.HashMap;
import java.util.LinkedHashSet;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
index db92babc..dc478337 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
@@ -17,8 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.serialization.db;
+import com.google.common.base.CaseFormat;
+
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
@@ -111,8 +114,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
-import com.google.common.base.CaseFormat;
-
public class DBSerializer {
private static final Logger LOGGER = LoggerFactory.getLogger(DBSerializer.class);
@@ -140,7 +141,8 @@ public class DBSerializer {
private Map<String, ObjectDelta> objectDeltas = new LinkedHashMap<>();
private Map<Vertex, Boolean> updatedVertexes = new LinkedHashMap<>();
private Set<Vertex> edgeVertexes = new LinkedHashSet<>();
- private Map<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> impliedDeleteUriObjectPair = new LinkedHashMap<>();
+ private Map<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> impliedDeleteUriObjectPair =
+ new LinkedHashMap<>();
private int notificationDepth;
private boolean isDeltaEventsEnabled;
private boolean isMultiTenancyEnabled;
@@ -162,8 +164,8 @@ public class DBSerializer {
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
@@ -176,18 +178,18 @@ public class DBSerializer {
}
public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
- String sourceOfTruth, Set<String> groups) throws AAIException {
+ String sourceOfTruth, Set<String> groups) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = groups;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE);
this.currentTimeMillis = System.currentTimeMillis();
@@ -196,22 +198,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- int notificationDepth) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, int notificationDepth) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = Collections.EMPTY_SET;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE);
this.currentTimeMillis = System.currentTimeMillis();
@@ -219,23 +218,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- Set<String> groups,
- int notificationDepth) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, Set<String> groups, int notificationDepth) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = groups;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE);
this.currentTimeMillis = System.currentTimeMillis();
@@ -243,23 +238,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- int notificationDepth,
- String serverBase) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, int notificationDepth, String serverBase) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = Collections.EMPTY_SET;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = serverBase;
this.currentTimeMillis = System.currentTimeMillis();
@@ -267,24 +258,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- Set<String> groups,
- int notificationDepth,
- String serverBase) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, Set<String> groups, int notificationDepth, String serverBase) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = groups;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = serverBase;
this.currentTimeMillis = System.currentTimeMillis();
@@ -299,8 +285,10 @@ public class DBSerializer {
setEdgeIngestor(ei);
EdgeSerializer es = ctx.getBean(EdgeSerializer.class);
setEdgeSerializer(es);
- isDeltaEventsEnabled = Boolean.parseBoolean(SpringContextAware.getApplicationContext().getEnvironment().getProperty("delta.events.enabled", FALSE));
- isMultiTenancyEnabled = Boolean.parseBoolean(SpringContextAware.getApplicationContext().getEnvironment().getProperty("multi.tenancy.enabled", FALSE));
+ isDeltaEventsEnabled = Boolean.parseBoolean(
+ SpringContextAware.getApplicationContext().getEnvironment().getProperty("delta.events.enabled", FALSE));
+ isMultiTenancyEnabled = Boolean.parseBoolean(SpringContextAware.getApplicationContext().getEnvironment()
+ .getProperty("multi.tenancy.enabled", FALSE));
}
public void setEdgeSerializer(EdgeSerializer edgeSer) {
@@ -333,7 +321,8 @@ public class DBSerializer {
/**
* Touch standard vertex properties.
- * @param v the v
+ *
+ * @param v the v
* @param isNewVertex the is new vertex
*/
public void touchStandardVertexProperties(Vertex v, boolean isNewVertex) {
@@ -347,7 +336,7 @@ public class DBSerializer {
v.property(AAIProperties.LAST_MOD_TS, currentTimeMillis);
v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, this.sourceOfTruth);
} else {
- if(isDeltaEventsEnabled) {
+ if (isDeltaEventsEnabled) {
standardVertexPropsDeltas(v, timeNowInSec);
}
v.property(AAIProperties.RESOURCE_VERSION, timeNowInSec);
@@ -364,42 +353,37 @@ public class DBSerializer {
getObjectDeltas().get(uri).setAction(objDeltaAction);
}
- addPropDelta(uri, AAIProperties.AAI_UUID, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.AAI_UUID).value()),
- objDeltaAction);
- addPropDelta(uri, AAIProperties.NODE_TYPE, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.NODE_TYPE).value()),
- objDeltaAction);
- addPropDelta(uri, AAIProperties.SOURCE_OF_TRUTH, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.SOURCE_OF_TRUTH).value()),
- objDeltaAction);
- addPropDelta(uri, AAIProperties.CREATED_TS, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.CREATED_TS).value()),
- objDeltaAction);
+ addPropDelta(uri, AAIProperties.AAI_UUID,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.AAI_UUID).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.NODE_TYPE,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.NODE_TYPE).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.SOURCE_OF_TRUTH,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.SOURCE_OF_TRUTH).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.CREATED_TS,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.CREATED_TS).value()),
+ objDeltaAction);
if (objDeltaAction.equals(DeltaAction.UPDATE)) {
+ addPropDelta(uri, AAIProperties.RESOURCE_VERSION, PropertyDeltaFactory.getDelta(objDeltaAction,
+ timeNowInSec, v.property(AAIProperties.RESOURCE_VERSION).value()), objDeltaAction);
+ addPropDelta(uri, AAIProperties.LAST_MOD_TS, PropertyDeltaFactory.getDelta(objDeltaAction,
+ currentTimeMillis, v.property(AAIProperties.LAST_MOD_TS).value()), objDeltaAction);
addPropDelta(
- uri,
- AAIProperties.RESOURCE_VERSION,
- PropertyDeltaFactory.getDelta(objDeltaAction, timeNowInSec, v.property(AAIProperties.RESOURCE_VERSION).value()),
- objDeltaAction
- );
- addPropDelta(
- uri,
- AAIProperties.LAST_MOD_TS,
- PropertyDeltaFactory.getDelta(objDeltaAction, currentTimeMillis, v.property(AAIProperties.LAST_MOD_TS).value()),
- objDeltaAction
- );
- addPropDelta(
- uri,
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH,
- PropertyDeltaFactory.getDelta(objDeltaAction, this.sourceOfTruth, v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()),
- objDeltaAction
- );
+ uri, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, PropertyDeltaFactory.getDelta(objDeltaAction,
+ this.sourceOfTruth, v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()),
+ objDeltaAction);
} else {
- addPropDelta(uri, AAIProperties.RESOURCE_VERSION, PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.RESOURCE_VERSION).value()), objDeltaAction);
- addPropDelta(uri, AAIProperties.LAST_MOD_TS, PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.LAST_MOD_TS).value()), objDeltaAction);
- addPropDelta(uri, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()), objDeltaAction);
+ addPropDelta(uri, AAIProperties.RESOURCE_VERSION,
+ PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.RESOURCE_VERSION).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.LAST_MOD_TS,
+ PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.LAST_MOD_TS).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, PropertyDeltaFactory.getDelta(objDeltaAction,
+ v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()), objDeltaAction);
}
}
@@ -408,13 +392,15 @@ public class DBSerializer {
}
private void addPropDelta(String uri, String prop, PropertyDelta delta, DeltaAction objDeltaAction) {
- ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri, new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
+ ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri,
+ new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
objectDelta.addPropertyDelta(prop, delta);
objectDeltas.put(uri, objectDelta);
}
private void addRelationshipDelta(String uri, RelationshipDelta delta, DeltaAction objDeltaAction) {
- ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri, new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
+ ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri,
+ new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
objectDelta.addRelationshipDelta(delta);
objectDeltas.put(uri, objectDelta);
}
@@ -552,12 +538,12 @@ public class DBSerializer {
List<Vertex> dependentVertexes = new ArrayList<>();
List<Vertex> processedVertexes = new ArrayList<>();
- boolean isComplexType ;
+ boolean isComplexType;
boolean isListType;
// If the notification depth is set to maximum
// this is the behavior of the expected clients
- if(notificationDepth == AAIProperties.MAXIMUM_DEPTH) {
+ if (notificationDepth == AAIProperties.MAXIMUM_DEPTH) {
if (!obj.isContainer()) {
this.touchStandardVertexProperties(v, false);
}
@@ -602,7 +588,9 @@ public class DBSerializer {
if (oldValue != null) {
v.property(dbProperty).remove();
if (isDeltaEventsEnabled) {
- addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldValue), DeltaAction.UPDATE);
+ addPropDelta(uri, dbProperty,
+ PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldValue),
+ DeltaAction.UPDATE);
}
this.updatedVertexes.putIfAbsent(v, false);
}
@@ -626,7 +614,8 @@ public class DBSerializer {
engine.setListProperty(v, property, list);
if (list == null || list.isEmpty()) { // property delete scenario, there is no new value
if (oldVal != null && !oldVal.isEmpty()) { // and there is an old value
- addPropDelta(uri, property, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldVal), DeltaAction.UPDATE);
+ addPropDelta(uri, property, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldVal),
+ DeltaAction.UPDATE);
}
} else { // is either a create or update and is handled by the called method
createDeltaProperty(uri, list, property, oldVal);
@@ -680,7 +669,8 @@ public class DBSerializer {
}
ImpliedDelete impliedDelete = new ImpliedDelete(engine, this);
- List<Vertex> impliedDeleteVertices = impliedDelete.execute(v.id(), sourceOfTruth, obj.getName(), dependentVertexes);
+ List<Vertex> impliedDeleteVertices =
+ impliedDelete.execute(v.id(), sourceOfTruth, obj.getName(), dependentVertexes);
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
for (Vertex curVertex : impliedDeleteVertices) {
@@ -694,7 +684,8 @@ public class DBSerializer {
LinkedHashMap<String, Introspector> curObjRelated = new LinkedHashMap<>();
if (!curObj.isTopLevel()) {
- curObjRelated.putAll(this.getRelatedObjects(engine.getQueryEngine(), curVertex, curObj, this.loader));
+ curObjRelated
+ .putAll(this.getRelatedObjects(engine.getQueryEngine(), curVertex, curObj, this.loader));
}
if (!impliedDeleteUriObjectPair.containsKey(curAaiUri)) {
@@ -707,14 +698,12 @@ public class DBSerializer {
// touch svp using vertex list for what changed
// if the notification depth is zero
- if(notificationDepth == AAIProperties.MINIMUM_DEPTH){
- this.updatedVertexes.entrySet().stream()
- .filter(e -> !e.getValue())
- .filter(e -> !edgeVertexes.contains(e.getKey()))
- .forEach(e -> {
- this.touchStandardVertexProperties(e.getKey(), false);
- e.setValue(true);
- });
+ if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
+ this.updatedVertexes.entrySet().stream().filter(e -> !e.getValue())
+ .filter(e -> !edgeVertexes.contains(e.getKey())).forEach(e -> {
+ this.touchStandardVertexProperties(e.getKey(), false);
+ e.setValue(true);
+ });
}
this.executePostSideEffects(obj, v);
return processedVertexes;
@@ -724,12 +713,14 @@ public class DBSerializer {
if (oldValue == null) {
addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.CREATE, value), DeltaAction.UPDATE);
} else {
- addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.UPDATE, value, oldValue), DeltaAction.UPDATE);
+ addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.UPDATE, value, oldValue),
+ DeltaAction.UPDATE);
}
}
- public HashMap<String, Introspector> getRelatedObjects(QueryEngine queryEngine, Vertex v,
- Introspector obj, Loader loader) throws IllegalArgumentException, SecurityException, UnsupportedEncodingException, AAIException {
+ public HashMap<String, Introspector> getRelatedObjects(QueryEngine queryEngine, Vertex v, Introspector obj,
+ Loader loader)
+ throws IllegalArgumentException, SecurityException, UnsupportedEncodingException, AAIException {
HashMap<String, Introspector> relatedVertices = new HashMap<>();
VertexProperty aaiUriProperty = v.property(AAIProperties.AAI_URI);
@@ -737,10 +728,10 @@ public class DBSerializer {
if (!aaiUriProperty.isPresent()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("For the given vertex {}, it seems aai-uri is not present so not getting related objects",
- v.id().toString());
+ v.id().toString());
} else {
LOGGER.info(
- "It seems aai-uri is not present in vertex, so not getting related objects, for more info enable debug log");
+ "It seems aai-uri is not present in vertex, so not getting related objects, for more info enable debug log");
}
return relatedVertices;
}
@@ -754,13 +745,14 @@ public class DBSerializer {
// into a list of aai-uris so falling back to the old mechanism for finding parents
if (uriList == null) {
LOGGER.info(
- "Falling back to the old mechanism due to unable to convert aai-uri to list of uris but this is not optimal");
+ "Falling back to the old mechanism due to unable to convert aai-uri to list of uris but this is not optimal");
vertexChain = queryEngine.findParents(v);
} else if (uriList.length == 1) {
// If the uri list is size 1 the only uri in the list is the one represented by v thus no need to query
vertexChain = Collections.singletonList(v);
} else {
- // the uriList at element 0 is the node in question and should not be included in the vertex chain lookup.
+ // the uriList at element 0 is the node in question and should not be included in the vertex chain
+ // lookup.
vertexChain = queryEngine.findParents(Arrays.copyOfRange(uriList, 1, uriList.length));
// inject v into start of vertexChain
vertexChain.add(0, v);
@@ -829,7 +821,7 @@ public class DBSerializer {
* @throws AAIException
*/
String[] convertIntrospectorToUriList(String aaiUri, Introspector obj, Loader loader)
- throws UnsupportedEncodingException, AAIException {
+ throws UnsupportedEncodingException, AAIException {
List<String> uriList = new ArrayList<>();
String template;
@@ -893,17 +885,15 @@ public class DBSerializer {
* @throws AAIException the AAI exception
*/
private void processRelationshipList(Introspector wrapped, Vertex v)
- throws UnsupportedEncodingException, AAIException {
+ throws UnsupportedEncodingException, AAIException {
List<Object> relationships = wrapped.getValue("relationship");
String mainUri = getURIForVertex(v).toString();
String aNodeType = v.property(AAIProperties.NODE_TYPE).value().toString();
- EdgeRuleQuery.Builder cousinQueryBuilder = new EdgeRuleQuery.Builder(aNodeType)
- .edgeType(EdgeType.COUSIN)
- .version(wrapped.getVersion());
- EdgeRuleQuery.Builder treeQueryBuilder = new EdgeRuleQuery.Builder(aNodeType)
- .edgeType(EdgeType.TREE)
- .version(wrapped.getVersion());
+ EdgeRuleQuery.Builder cousinQueryBuilder =
+ new EdgeRuleQuery.Builder(aNodeType).edgeType(EdgeType.COUSIN).version(wrapped.getVersion());
+ EdgeRuleQuery.Builder treeQueryBuilder =
+ new EdgeRuleQuery.Builder(aNodeType).edgeType(EdgeType.TREE).version(wrapped.getVersion());
EdgeIngestor edgeIngestor = SpringContextAware.getBean(EdgeIngestor.class);
@@ -918,8 +908,9 @@ public class DBSerializer {
QueryParser parser = engine.getQueryBuilder().createQueryFromRelationship(wrappedRel);
List<Vertex> results = parser.getQueryBuilder().toList();
if (results.isEmpty()) {
- final AAIException ex = new AAIException(AAI_6129,
- String.format("Node of type %s. Could not find object at: %s", parser.getResultType(), parser.getUri()));
+ final AAIException ex =
+ new AAIException(AAI_6129, String.format("Node of type %s. Could not find object at: %s",
+ parser.getResultType(), parser.getUri()));
ex.getTemplateVars().add(parser.getResultType());
ex.getTemplateVars().add(parser.getUri().toString());
throw ex;
@@ -928,7 +919,8 @@ public class DBSerializer {
if (results.get(0).property(AAIProperties.AAI_URI).isPresent()) {
relUri = results.get(0).value(AAIProperties.AAI_URI);
} else {
- LOGGER.warn("Not processing the vertex {} because its missing required property aai-uri", results.get(0).id());
+ LOGGER.warn("Not processing the vertex {} because its missing required property aai-uri",
+ results.get(0).id());
continue;
}
}
@@ -943,19 +935,18 @@ public class DBSerializer {
if (!edgeIngestor.hasRule(ruleQuery)) {
EdgeRuleQuery treeQuery = treeQueryBuilder.to(bNodeType).build();
if (edgeIngestor.hasRule(treeQuery)) {
- throw new AAIException(AAI_6145); //attempted to create cousin edge for a parent-child edge rule
+ throw new AAIException(AAI_6145); // attempted to create cousin edge for a parent-child edge
+ // rule
}
- throw new AAIException("AAI_6120", String.format(
- "No EdgeRule found for passed nodeTypes: %s, %s.",
- aNodeType, bNodeType));
+ throw new AAIException("AAI_6120",
+ String.format("No EdgeRule found for passed nodeTypes: %s, %s.", aNodeType, bNodeType));
} else {
try {
final List<EdgeRule> rules = new ArrayList<>(edgeIngestor.getRules(ruleQuery).values());
if (rules.size() == 1) {
label = rules.get(0).getLabel();
} else {
- Optional<EdgeRule>
- defaultRule = rules.stream().filter(EdgeRule::isDefault).findFirst();
+ Optional<EdgeRule> defaultRule = rules.stream().filter(EdgeRule::isDefault).findFirst();
if (defaultRule.isPresent()) {
label = defaultRule.get().getLabel();
} else {
@@ -973,18 +964,17 @@ public class DBSerializer {
List<Path> paths = this.engine.getQueryEngine().findCousinsAsPath(v);
Set<Path> toRemove = new HashSet<>();
-
- // for each path 3 things can happen:
- // 1. The edge rule that created it is not in this version no action is to be taken on that edge
- // 2. The edge rule exits in this version it's included in the request the edge is left alone
- // 3. The edge rule exits in this version and is not included in the request it is marked for removal
+ // for each path 3 things can happen:
+ // 1. The edge rule that created it is not in this version no action is to be taken on that edge
+ // 2. The edge rule exits in this version it's included in the request the edge is left alone
+ // 3. The edge rule exits in this version and is not included in the request it is marked for removal
for (Path path : paths) {
if (path.size() < 3) {
continue;
}
// Path represents
- // v ----related-to--> otherV
+ // v ----related-to--> otherV
// In the above case,
// path objects get(0) returns vertex v
// path objects.get(1) returns edge related-to
@@ -1028,7 +1018,7 @@ public class DBSerializer {
List<Vertex> results = parser.getQueryBuilder().toList();
if (results.isEmpty()) {
final AAIException ex = new AAIException(AAI_6129,
- "Node of type " + parser.getResultType() + ". Could not find object at: " + parser.getUri());
+ "Node of type " + parser.getResultType() + ". Could not find object at: " + parser.getUri());
ex.getTemplateVars().add(parser.getResultType());
ex.getTemplateVars().add(parser.getUri().toString());
throw ex;
@@ -1043,11 +1033,11 @@ public class DBSerializer {
EdgeRuleQuery.Builder baseQ = new EdgeRuleQuery.Builder(vType, cousinType).label(label);
if (!edgeRules.hasRule(baseQ.build())) {
- throw new AAIException("AAI_6120", String.format(
- "No EdgeRule found for passed nodeTypes: %s, %s%s.",
- aNodeType, cousinType, label != null ? (" with label " + label) : ""));
+ throw new AAIException("AAI_6120",
+ String.format("No EdgeRule found for passed nodeTypes: %s, %s%s.", aNodeType, cousinType,
+ label != null ? (" with label " + label) : ""));
} else if (edgeRules.hasRule(baseQ.edgeType(EdgeType.TREE).build())
- && !edgeRules.hasRule(baseQ.edgeType(EdgeType.COUSIN).build())) {
+ && !edgeRules.hasRule(baseQ.edgeType(EdgeType.COUSIN).build())) {
throw new AAIException(AAI_6145);
}
@@ -1060,7 +1050,7 @@ public class DBSerializer {
}
for (Path path : toRemove) {
- if(isDeltaEventsEnabled) {
+ if (isDeltaEventsEnabled) {
deltaForEdge(mainUri, path.get(1), DeltaAction.DELETE_REL, DeltaAction.UPDATE);
}
this.updatedVertexes.putIfAbsent(v, false);
@@ -1070,7 +1060,8 @@ public class DBSerializer {
for (Pair<Vertex, String> create : toBeCreated) {
try {
- Edge e = edgeSer.addEdge(this.engine.asAdmin().getTraversalSource(), v, create.getValue0(), create.getValue1());
+ Edge e = edgeSer.addEdge(this.engine.asAdmin().getTraversalSource(), v, create.getValue0(),
+ create.getValue1());
if (isDeltaEventsEnabled) {
deltaForEdge(mainUri, e, DeltaAction.CREATE_REL, DeltaAction.UPDATE);
}
@@ -1082,15 +1073,12 @@ public class DBSerializer {
}
}
-
private void deltaForEdge(String mainUri, Edge edge, DeltaAction edgeAction, DeltaAction mainAction) {
- RelationshipDelta relationshipDelta = new RelationshipDelta(
- edgeAction,
- edge.inVertex().property(AAIProperties.AAI_UUID).value().toString(),
- edge.outVertex().property(AAIProperties.AAI_UUID).value().toString(),
- edge.inVertex().property(AAIProperties.AAI_URI).value().toString(),
- edge.outVertex().property(AAIProperties.AAI_URI).value().toString(),
- edge.label());
+ RelationshipDelta relationshipDelta =
+ new RelationshipDelta(edgeAction, edge.inVertex().property(AAIProperties.AAI_UUID).value().toString(),
+ edge.outVertex().property(AAIProperties.AAI_UUID).value().toString(),
+ edge.inVertex().property(AAIProperties.AAI_URI).value().toString(),
+ edge.outVertex().property(AAIProperties.AAI_URI).value().toString(), edge.label());
edge.properties().forEachRemaining(p -> relationshipDelta.addProp(p.key(), p.value().toString()));
addRelationshipDelta(mainUri, relationshipDelta, mainAction);
}
@@ -1196,8 +1184,9 @@ public class DBSerializer {
}
}
e = edgeSer.addTreeEdge(this.engine.asAdmin().getTraversalSource(), parent, child);
- if(isDeltaEventsEnabled) {
- deltaForEdge(child.property(AAIProperties.AAI_URI).value().toString(), e, DeltaAction.CREATE_REL, DeltaAction.CREATE);
+ if (isDeltaEventsEnabled) {
+ deltaForEdge(child.property(AAIProperties.AAI_URI).value().toString(), e, DeltaAction.CREATE_REL,
+ DeltaAction.CREATE);
}
}
return child;
@@ -1230,7 +1219,7 @@ public class DBSerializer {
* @throws URISyntaxException
*/
public Introspector dbToObject(List<Vertex> vertices, final Introspector obj, int depth, boolean nodeOnly,
- String cleanUp, boolean isSkipRelatedTo) throws UnsupportedEncodingException, AAIException {
+ String cleanUp, boolean isSkipRelatedTo) throws UnsupportedEncodingException, AAIException {
final int internalDepth;
if (depth == Integer.MAX_VALUE) {
internalDepth = depth--;
@@ -1241,7 +1230,7 @@ public class DBSerializer {
if (vertices.size() > 1 && !obj.isContainer()) {
dbTimeMsecs += StopWatch.stopIfStarted();
throw new AAIException("AAI_6136",
- "query object mismatch: this object cannot hold multiple items." + obj.getDbName());
+ "query object mismatch: this object cannot hold multiple items." + obj.getDbName());
} else if (obj.isContainer()) {
final List getList;
String listProperty = null;
@@ -1357,7 +1346,7 @@ public class DBSerializer {
* @throws URISyntaxException
*/
private Introspector dbToObject(Introspector obj, Vertex v, Set<Vertex> seen, int depth, boolean nodeOnly,
- String cleanUp, boolean isSkipRelatedTo) throws AAIException, UnsupportedEncodingException {
+ String cleanUp, boolean isSkipRelatedTo) throws AAIException, UnsupportedEncodingException {
if (depth < 0) {
return null;
@@ -1406,7 +1395,7 @@ public class DBSerializer {
try {
rule = edgeRules.getRule(
- new EdgeRuleQuery.Builder(vType, childDbName).edgeType(EdgeType.TREE).build());
+ new EdgeRuleQuery.Builder(vType, childDbName).edgeType(EdgeType.TREE).build());
} catch (EdgeRuleNotFoundException e) {
throw new NoEdgeRuleFoundException(e);
} catch (AmbiguousRuleChoiceException e) {
@@ -1429,8 +1418,8 @@ public class DBSerializer {
if (!seen.contains(childVertex)) {
Introspector argumentObject = obj.newIntrospectorInstanceOfNestedProperty(property);
- Object result =
- dbToObject(argumentObject, childVertex, seen, depth, nodeOnly, cleanUp, isSkipRelatedTo);
+ Object result = dbToObject(argumentObject, childVertex, seen, depth, nodeOnly,
+ cleanUp, isSkipRelatedTo);
if (result != null && getList != null) {
getList.add(argumentObject.getUnderlyingObject());
}
@@ -1438,7 +1427,7 @@ public class DBSerializer {
processed++;
} else {
LOGGER.warn("Cycle found while serializing vertex id={}",
- childVertex.id().toString());
+ childVertex.id().toString());
}
}
if (processed == 0) {
@@ -1532,7 +1521,8 @@ public class DBSerializer {
return simplePropsHashMap;
}
- public Introspector dbToRelationshipObject(Vertex v, boolean isSkipRelatedTo) throws UnsupportedEncodingException, AAIException {
+ public Introspector dbToRelationshipObject(Vertex v, boolean isSkipRelatedTo)
+ throws UnsupportedEncodingException, AAIException {
Introspector relationshipList = this.latestLoader.introspectorFromName("relationship-list");
relationshipList = createRelationshipList(v, relationshipList, FALSE, isSkipRelatedTo);
return relationshipList;
@@ -1588,9 +1578,8 @@ public class DBSerializer {
EdgeIngestor edgeIngestor = SpringContextAware.getBean(EdgeIngestor.class);
- EdgeRuleQuery.Builder queryBuilder = new EdgeRuleQuery.Builder(aNodeType)
- .edgeType(EdgeType.COUSIN)
- .version(obj.getVersion());
+ EdgeRuleQuery.Builder queryBuilder =
+ new EdgeRuleQuery.Builder(aNodeType).edgeType(EdgeType.COUSIN).version(obj.getVersion());
for (Path path : paths) {
if (path.size() < 3) {
@@ -1598,7 +1587,7 @@ public class DBSerializer {
}
// Path represents
- // v ----related-to--> otherV
+ // v ----related-to--> otherV
// In the above case,
// path objects get(0) returns vertex v
// path objects.get(1) returns edge related-to
@@ -1627,7 +1616,7 @@ public class DBSerializer {
EdgeRuleQuery ruleQuery = queryBuilder.to(bNodeType).label(edgeLabel).build();
if (!edgeIngestor.hasRule(ruleQuery)) {
- LOGGER.debug( "Caught an edge rule not found for query {}", ruleQuery);
+ LOGGER.debug("Caught an edge rule not found for query {}", ruleQuery);
continue;
}
@@ -1724,7 +1713,6 @@ public class DBSerializer {
return uri;
}
-
public void addRelatedToProperty(Introspector relationship, Vertex cousinVertex, String cousinType)
throws AAIUnknownObjectException {
@@ -1816,8 +1804,9 @@ public class DBSerializer {
e = this.getEdgeBetween(EdgeType.COUSIN, inputVertex, relatedVertex, label);
if (e == null) {
e = edgeSer.addEdge(this.engine.asAdmin().getTraversalSource(), inputVertex, relatedVertex, label);
- if(isDeltaEventsEnabled) {
- deltaForEdge(inputVertex.property(AAIProperties.AAI_URI).value().toString(), e, DeltaAction.CREATE_REL, DeltaAction.UPDATE);
+ if (isDeltaEventsEnabled) {
+ deltaForEdge(inputVertex.property(AAIProperties.AAI_URI).value().toString(), e,
+ DeltaAction.CREATE_REL, DeltaAction.UPDATE);
}
} else {
// attempted to link two vertexes already linked
@@ -2046,23 +2035,22 @@ public class DBSerializer {
for (Vertex v : vertices) {
LOGGER.debug("Removing vertex {} with label {}", v.id(), v.label());
- if(isDeltaEventsEnabled) {
+ if (isDeltaEventsEnabled) {
deltaForVertexDelete(v);
}
- //add the cousin vertexes of v to have their resource-version updated and notified on.
- v.edges(Direction.BOTH)
- .forEachRemaining(e -> {
- if (e.property(EdgeProperty.CONTAINS.toString()).isPresent()
+ // add the cousin vertexes of v to have their resource-version updated and notified on.
+ v.edges(Direction.BOTH).forEachRemaining(e -> {
+ if (e.property(EdgeProperty.CONTAINS.toString()).isPresent()
&& AAIDirection.NONE.toString().equals(e.<String>value(EdgeProperty.CONTAINS.toString()))) {
- e.bothVertices().forEachRemaining(cousinV -> {
- if (!v.equals(cousinV)) {
- edgeVertexes.add(cousinV);
- }
- });
- }
- });
+ e.bothVertices().forEachRemaining(cousinV -> {
+ if (!v.equals(cousinV)) {
+ edgeVertexes.add(cousinV);
+ }
+ });
+ }
+ });
- //if somewhere along the way v was added to the sets tracking the what is to be updated/notified on
+ // if somewhere along the way v was added to the sets tracking the what is to be updated/notified on
// it should be removed from them as v is to be deleted
edgeVertexes.remove(v);
updatedVertexes.remove(v);
@@ -2078,16 +2066,15 @@ public class DBSerializer {
List<Object> list = new ArrayList<>();
vertex.properties(k).forEachRemaining(vp -> list.add(vp.value()));
if (list.size() == 1) {
- addPropDelta(aaiUri, k,
- PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list.get(0)),
- DeltaAction.DELETE);
+ addPropDelta(aaiUri, k, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list.get(0)),
+ DeltaAction.DELETE);
} else {
- addPropDelta(aaiUri, k, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list),
- DeltaAction.DELETE);
+ addPropDelta(aaiUri, k, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list), DeltaAction.DELETE);
}
});
- vertex.edges(Direction.BOTH).forEachRemaining(e -> deltaForEdge(aaiUri, e, DeltaAction.DELETE, DeltaAction.DELETE));
+ vertex.edges(Direction.BOTH)
+ .forEachRemaining(e -> deltaForEdge(aaiUri, e, DeltaAction.DELETE, DeltaAction.DELETE));
}
/**
@@ -2162,7 +2149,7 @@ public class DBSerializer {
nodeType = vertex.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if (enableResourceVersion) {
this.verifyResourceVersion("delete", nodeType,
- vertex.<String>property(AAIProperties.RESOURCE_VERSION).orElse(null), resourceVersion, nodeType);
+ vertex.<String>property(AAIProperties.RESOURCE_VERSION).orElse(null), resourceVersion, nodeType);
}
List<Vertex> vertices = new ArrayList<>();
vertices.add(vertex);
@@ -2202,10 +2189,9 @@ public class DBSerializer {
dbTimeMsecs += StopWatch.stopIfStarted();
if (!preventDeleteVertices.isEmpty()) {
aaiExceptionCode = "AAI_6110";
- errorDetail = String.format(
- "Object is being reference by additional objects preventing it from being deleted." +
- " Please clean up references from the following types %s",
- preventDeleteVertices);
+ errorDetail =
+ String.format("Object is being reference by additional objects preventing it from being deleted."
+ + " Please clean up references from the following types %s", preventDeleteVertices);
result = false;
}
if (!result) {
@@ -2319,9 +2305,8 @@ public class DBSerializer {
private void executePreSideEffects(Introspector obj, Vertex self) throws AAIException {
- SideEffectRunner.Builder runnerBuilder =
- new SideEffectRunner.Builder(this.engine, this).addSideEffect(DataCopy.class)
- .addSideEffect(PrivateEdge.class);
+ SideEffectRunner.Builder runnerBuilder = new SideEffectRunner.Builder(this.engine, this)
+ .addSideEffect(DataCopy.class).addSideEffect(PrivateEdge.class);
if (isMultiTenancyEnabled) {
runnerBuilder.addSideEffect(OwnerCheck.class);
}
@@ -2339,7 +2324,7 @@ public class DBSerializer {
private void enrichData(Introspector obj, Vertex self) throws AAIException {
SideEffectRunner.Builder runnerBuilder =
- new SideEffectRunner.Builder(this.engine, this).addSideEffect(DataLinkReader.class);
+ new SideEffectRunner.Builder(this.engine, this).addSideEffect(DataLinkReader.class);
if (isMultiTenancyEnabled) {
runnerBuilder.addSideEffect(OwnerCheck.class);
@@ -2373,11 +2358,10 @@ public class DBSerializer {
* @throws AAIUnknownObjectException
* @throws URISyntaxException
*/
- public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertex, Set<Vertex> seen, int depth, boolean nodeOnly,
- List<String> filterCousinNodes, List<String> filterParentNodes)
- throws AAIException, UnsupportedEncodingException {
- return dbToObjectWithFilters(obj, vertex, seen, depth, nodeOnly,
- filterCousinNodes, filterParentNodes, false);
+ public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertex, Set<Vertex> seen, int depth,
+ boolean nodeOnly, List<String> filterCousinNodes, List<String> filterParentNodes)
+ throws AAIException, UnsupportedEncodingException {
+ return dbToObjectWithFilters(obj, vertex, seen, depth, nodeOnly, filterCousinNodes, filterParentNodes, false);
}
/**
@@ -2405,8 +2389,8 @@ public class DBSerializer {
* @throws URISyntaxException
*/
// TODO - See if you can merge the 2 dbToObjectWithFilters
- public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertexParam, Set<Vertex> seen, int depth, boolean nodeOnly,
- List<String> filterCousinNodes, List<String> filterParentNodes, boolean isSkipRelatedTo)
+ public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertexParam, Set<Vertex> seen, int depth,
+ boolean nodeOnly, List<String> filterCousinNodes, List<String> filterParentNodes, boolean isSkipRelatedTo)
throws AAIException, UnsupportedEncodingException {
String cleanUp = FALSE;
if (depth < 0) {
@@ -2436,8 +2420,7 @@ public class DBSerializer {
} else if (property.equals("relationship-list") && !nodeOnly) {
/* relationships need to be handled correctly */
Introspector relationshipList = obj.newIntrospectorInstanceOfProperty(property);
- relationshipList =
- createFilteredRelationshipList(vertexParam, relationshipList, cleanUp,
+ relationshipList = createFilteredRelationshipList(vertexParam, relationshipList, cleanUp,
filterCousinNodes, isSkipRelatedTo);
if (relationshipList != null) {
obj.setValue(property, relationshipList.getUnderlyingObject());
@@ -2459,7 +2442,8 @@ public class DBSerializer {
boolean isThisParentRequired =
filterParentNodes.parallelStream().anyMatch(childDbName::contains);
- EdgeRuleQuery query = new EdgeRuleQuery.Builder(vertexType, childDbName).edgeType(EdgeType.TREE).build();
+ EdgeRuleQuery query =
+ new EdgeRuleQuery.Builder(vertexType, childDbName).edgeType(EdgeType.TREE).build();
try {
rule = edgeRules.getRule(query);
@@ -2547,7 +2531,7 @@ public class DBSerializer {
Iterator<Vertex> cousinVertices = allCousins.stream().filter(item -> {
String node = (String) item.property(AAIProperties.NODE_TYPE).orElse("");
return filterNodes.parallelStream().anyMatch(node::contains);
- }).iterator();
+ }).iterator();
List<Object> relationshipObjList = obj.getValue(RELATIONSHIP);
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java b/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java
index 3a7c6d2d..f7d97f33 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java
@@ -20,11 +20,11 @@
package org.onap.aai.serialization.db;
+import java.util.concurrent.atomic.AtomicInteger;
+
import org.janusgraph.core.JanusGraph;
import org.onap.aai.dbmap.AAIGraph;
-import java.util.concurrent.atomic.AtomicInteger;
-
/* This class simply calls AAIGraph under the covers for now */
public class GraphSingleton {
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java b/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java
index f8f057d6..2c0a91c2 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.serialization.db;
import java.util.List;
@@ -57,7 +58,7 @@ public class ImpliedDelete implements AAIConfigProxy {
private TransactionalGraphEngine engine;
private DBSerializer serializer;
- public ImpliedDelete(TransactionalGraphEngine engine, DBSerializer serializer){
+ public ImpliedDelete(TransactionalGraphEngine engine, DBSerializer serializer) {
this.engine = engine;
this.serializer = serializer;
}
@@ -83,22 +84,21 @@ public class ImpliedDelete implements AAIConfigProxy {
* @param dependentVertexes - list of children vertexes
* @throws AAIException if the user is not allowed to implicitly delete children
*/
- public List<Vertex> execute(Object id, String sot, String objectType, List<Vertex> dependentVertexes) throws AAIException {
- if(dependentVertexes != null && !dependentVertexes.isEmpty()){
+ public List<Vertex> execute(Object id, String sot, String objectType, List<Vertex> dependentVertexes)
+ throws AAIException {
+ if (dependentVertexes != null && !dependentVertexes.isEmpty()) {
// Find all the deletable vertices from the dependent vertices that should be deleted
// So for each of the following dependent vertices,
// we will use the edge properties and do the cascade delete
QueryEngine queryEngine = this.engine.getQueryEngine();
List<Vertex> impliedDeleteVertices = queryEngine.findDeletable(dependentVertexes);
- if(this.allow(sot, objectType)){
+ if (this.allow(sot, objectType)) {
int impliedDeleteCount = impliedDeleteVertices.size();
LOGGER.warn(
- "For the vertex with id {}, doing an implicit delete on update will delete total of {} vertexes",
- id,
- impliedDeleteCount
- );
+ "For the vertex with id {}, doing an implicit delete on update will delete total of {} vertexes",
+ id, impliedDeleteCount);
String impliedDeleteLogEnabled = get(AAIConstants.AAI_IMPLIED_DELETE_LOG_ENABLED, "true");
@@ -120,8 +120,8 @@ public class ImpliedDelete implements AAIConfigProxy {
}
} catch (Exception ex) {
LOGGER.warn(
- "Encountered an exception during retrieval of vertex properties with vertex-id {} -> {}",
- id, LogFormatTools.getStackTop(ex));
+ "Encountered an exception during retrieval of vertex properties with vertex-id {} -> {}",
+ id, LogFormatTools.getStackTop(ex));
}
}
}
@@ -136,11 +136,11 @@ public class ImpliedDelete implements AAIConfigProxy {
}
}
- public void delete(List<Vertex> vertices){
- // After all the appropriate logging, calling the serializer delete to delete the affected vertices
- if(vertices != null && !vertices.isEmpty()){
- serializer.delete(vertices);
- }
+ public void delete(List<Vertex> vertices) {
+ // After all the appropriate logging, calling the serializer delete to delete the affected vertices
+ if (vertices != null && !vertices.isEmpty()) {
+ serializer.delete(vertices);
+ }
}
/**
@@ -157,13 +157,13 @@ public class ImpliedDelete implements AAIConfigProxy {
* So in the above code, the expectation is for any of the following user:
*
* <ul>
- * <li>SDC</li>
- * <li>SDc</li>
- * <li>Sdc</li>
- * <li>sDc</li>
- * <li>SdC</li>
- * <li>sdC</li>
- * <li>sdc</li>
+ * <li>SDC</li>
+ * <li>SDc</li>
+ * <li>Sdc</li>
+ * <li>sDc</li>
+ * <li>SdC</li>
+ * <li>sdC</li>
+ * <li>sdc</li>
* </ul>
*
* They are allowed to delete the children of pserver and vserver by implicit delete
@@ -175,28 +175,28 @@ public class ImpliedDelete implements AAIConfigProxy {
* or loading into an set which is unnecessary and it could potentially be done for every request
*
* @param sourceOfTruth - the original requester that the request is coming from,
- * derived from HTTP Header X-FromAppId
+ * derived from HTTP Header X-FromAppId
* @param parentObjectType - parent object in which they are trying to do the implicit delete against
*
- * @return true - if the requester is allowed to implicit delete against the object type
+ * @return true - if the requester is allowed to implicit delete against the object type
* false - if they are not allowed
*/
- private boolean allow(String sourceOfTruth, String parentObjectType){
+ private boolean allow(String sourceOfTruth, String parentObjectType) {
Objects.requireNonNull(sourceOfTruth);
Objects.requireNonNull(parentObjectType);
String propertyName = AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + sourceOfTruth.toLowerCase();
String whitelist = get(propertyName, StringUtils.EMPTY);
- if(whitelist.isEmpty()){
+ if (whitelist.isEmpty()) {
return false;
}
- if(STAR.equals(whitelist)){
+ if (STAR.equals(whitelist)) {
return true;
}
- if(whitelist.contains("'" + parentObjectType + "'")){
+ if (whitelist.contains("'" + parentObjectType + "'")) {
return true;
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java
index 66509c97..e11b4aef 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java
@@ -20,6 +20,10 @@
package org.onap.aai.serialization.engines;
+import java.util.ArrayList;
+import java.util.Iterator;
+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;
@@ -32,10 +36,6 @@ import org.onap.aai.serialization.db.InMemoryGraphSingleton;
import org.onap.aai.serialization.engines.query.GraphTraversalQueryEngine;
import org.onap.aai.serialization.engines.query.QueryEngine;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
public class InMemoryDBEngine extends TransactionalGraphEngine {
/**
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java
index 2a4511d0..f2e40afb 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java
@@ -20,15 +20,15 @@
package org.onap.aai.serialization.engines;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.introspection.Loader;
import org.onap.aai.serialization.db.JanusGraphSingleton;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
public class JanusGraphDBEngine extends TransactionalGraphEngine {
/**
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java
index b945db05..6327272b 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java
@@ -20,6 +20,9 @@
package org.onap.aai.serialization.engines;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
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;
@@ -32,9 +35,6 @@ import org.onap.aai.serialization.db.GraphSingleton;
import org.onap.aai.serialization.engines.query.GraphTraversalQueryEngine;
import org.onap.aai.serialization.engines.query.QueryEngine;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
public abstract class TransactionalGraphEngine {
protected GraphSingleton singleton = null;
@@ -163,7 +163,7 @@ public abstract class TransactionalGraphEngine {
throw new IllegalArgumentException("History Traversal needs history traversal source");
} else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {
throw new IllegalArgumentException("History Gremlin Traversal needs history traversal source");
- }else {
+ } else {
throw new IllegalArgumentException("Query Builder type not recognized");
}
return queryBuilder;
@@ -182,9 +182,9 @@ public abstract class TransactionalGraphEngine {
return new TraversalURIOptimizedQuery<>(loader, source);
} else if (style.equals(QueryStyle.HISTORY_TRAVERSAL)) {
return new HistoryTraversalURIOptimizedQuery<>(loader, source);
- }else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {
+ } else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {
return new HistoryGremlinTraversal<>(loader, source);
- }else {
+ } else {
throw new IllegalArgumentException("Query Builder type not recognized");
}
return queryBuilder;
@@ -225,7 +225,7 @@ public abstract class TransactionalGraphEngine {
if (this.tx() == null) {
this.currentTx = this.getGraph().newTransaction();
this.currentTraversal = this.tx().traversal();
- this.readOnlyTraversal =this.tx().traversal().withStrategies(ReadOnlyStrategy.instance());
+ this.readOnlyTraversal = this.tx().traversal().withStrategies(ReadOnlyStrategy.instance());
}
return currentTx;
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java
index 376a2798..c96e8d22 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java
@@ -20,6 +20,14 @@
package org.onap.aai.serialization.engines.query;
+import static org.onap.aai.edges.enums.AAIDirection.*;
+import static org.onap.aai.edges.enums.EdgeField.PRIVATE;
+import static org.onap.aai.edges.enums.EdgeProperty.CONTAINS;
+import static org.onap.aai.edges.enums.EdgeProperty.DELETE_OTHER_V;
+
+import java.util.List;
+import java.util.Set;
+
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Path;
@@ -37,14 +45,6 @@ import org.onap.aai.edges.enums.EdgeProperty;
import org.onap.aai.introspection.Loader;
import org.onap.aai.logging.StopWatch;
-import java.util.List;
-import java.util.Set;
-
-import static org.onap.aai.edges.enums.AAIDirection.*;
-import static org.onap.aai.edges.enums.EdgeField.PRIVATE;
-import static org.onap.aai.edges.enums.EdgeProperty.CONTAINS;
-import static org.onap.aai.edges.enums.EdgeProperty.DELETE_OTHER_V;
-
/*
* This class needs some big explanation despite its compact size.
* This controls all the queries performed by the CRUD API in A&AI.
@@ -257,13 +257,9 @@ public class GraphTraversalQueryEngine extends QueryEngine {
return pipeline.toList();
}
- public List<Path> findCousinsAsPath(Vertex start){
- return this.g.V(start).bothE().where(
- __.and(
- __.has(EdgeProperty.CONTAINS.toString(), NONE.toString()),
- __.not(__.has(EdgeField.PRIVATE.toString(), true))
- )
- ).otherV().path().toList();
+ public List<Path> findCousinsAsPath(Vertex start) {
+ return this.g.V(start).bothE().where(__.and(__.has(EdgeProperty.CONTAINS.toString(), NONE.toString()),
+ __.not(__.has(EdgeField.PRIVATE.toString(), true)))).otherV().path().toList();
}
public double getDBTimeMsecs() {
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
index 9ce343f6..28362826 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
@@ -20,11 +20,13 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.*;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
+
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.db.props.AAIProperties;
@@ -40,11 +42,8 @@ import org.onap.aai.serialization.queryformats.params.AsTree;
import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-
-import java.io.UnsupportedEncodingException;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Aggregate extends MultiFormatMapper {
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleFormat.class);
@@ -65,13 +64,14 @@ public class Aggregate extends MultiFormatMapper {
}
@Override
- public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException{
+ public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
JsonObject outer = new JsonObject();
- Optional<JsonObject> properties = this.createSelectedPropertiesObject(v,selectedProps);
+ Optional<JsonObject> properties = this.createSelectedPropertiesObject(v, selectedProps);
if (properties.isPresent()) {
json.add("properties", properties.get());
- outer.add(this.urlBuilder.pathed(v),json.getAsJsonObject());
+ outer.add(this.urlBuilder.pathed(v), json.getAsJsonObject());
} else {
return Optional.empty();
}
@@ -86,7 +86,7 @@ public class Aggregate extends MultiFormatMapper {
public Optional<JsonObject> createPropertiesObject(Vertex v) throws AAIFormatVertexException {
try {
final Introspector obj =
- loader.introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
+ loader.introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
final List<Vertex> wrapper = new ArrayList<>();
wrapper.add(v);
@@ -95,7 +95,7 @@ public class Aggregate extends MultiFormatMapper {
serializer.dbToObject(wrapper, obj, 0, true, "false");
} catch (AAIException | UnsupportedEncodingException e) {
throw new AAIFormatVertexException(
- "Failed to format vertex - error while serializing: " + e.getMessage(), e);
+ "Failed to format vertex - error while serializing: " + e.getMessage(), e);
}
final String json = obj.marshal(false);
@@ -105,7 +105,8 @@ public class Aggregate extends MultiFormatMapper {
}
}
- public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException {
+ public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
Set<String> propList = null;
String nodeType = v.<String>value(AAIProperties.NODE_TYPE);
@@ -140,10 +141,9 @@ public class Aggregate extends MultiFormatMapper {
return Optional.of(json);
}
- private Set<String> removeSingleQuotesForProperties(List<String> props){
+ private Set<String> removeSingleQuotesForProperties(List<String> props) {
if (props != null && !props.isEmpty()) {
- return props.stream().map(
- e -> e.substring(1, e.length()-1)).collect(Collectors.toSet());
+ return props.stream().map(e -> e.substring(1, e.length() - 1)).collect(Collectors.toSet());
} else {
return Collections.emptySet();
}
@@ -169,23 +169,21 @@ public class Aggregate extends MultiFormatMapper {
}
return Optional.<JsonObject>empty();
- }).filter(Optional::isPresent)
- .map(Optional::get)
- .forEach(json -> {
- if (isParallel) {
- synchronized (body) {
- body.add(json);
- }
- } else {
+ }).filter(Optional::isPresent).map(Optional::get).forEach(json -> {
+ if (isParallel) {
+ synchronized (body) {
body.add(json);
}
- });
+ } else {
+ body.add(json);
+ }
+ });
return body;
}
@Override
public Optional<JsonObject> formatObject(Object input, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
JsonObject json = new JsonObject();
if (input instanceof ArrayList) {
Optional<JsonArray> ja = processInput(input, properties);
@@ -198,7 +196,7 @@ public class Aggregate extends MultiFormatMapper {
private Optional<JsonArray> processInput(Object input, Map properties) throws AAIFormatVertexException {
JsonArray json = new JsonArray();
- for (Object l : (ArrayList) input) {
+ for (Object l : (ArrayList) input) {
if (l instanceof ArrayList) {
JsonArray inner = new JsonArray();
for (Vertex o : (ArrayList<Vertex>) l) {
@@ -213,8 +211,9 @@ public class Aggregate extends MultiFormatMapper {
}
json.add(inner);
} else {
- Optional<JsonObject> obj = this.getJsonFromVertex((Vertex)l, properties);
- if(obj.isPresent()) json.add(obj.get());
+ Optional<JsonObject> obj = this.getJsonFromVertex((Vertex) l, properties);
+ if (obj.isPresent())
+ json.add(obj.get());
}
}
return Optional.of(json);
@@ -237,7 +236,9 @@ public class Aggregate extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
@@ -293,7 +294,7 @@ public class Aggregate extends MultiFormatMapper {
}
public Aggregate build() {
- return new Aggregate(this);
+ return new Aggregate(this);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java
index bbaed360..7caa1bd3 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java
@@ -22,15 +22,16 @@ package org.onap.aai.serialization.queryformats;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
public class ChangesFormat extends MultiFormatMapper {
private Long startTs = 0L;
@@ -39,9 +40,11 @@ public class ChangesFormat extends MultiFormatMapper {
/*
* StartTs = truncate time
*/
- if (startTime == null || startTime.isEmpty() || "now".equals(startTime) || "0".equals(startTime) || "-1".equals(startTime)){
- String historyTruncateDays = SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.truncate.window.days", "365");
- this.startTs = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(Long.parseLong(historyTruncateDays));
+ if (startTime == null || startTime.isEmpty() || "now".equals(startTime) || "0".equals(startTime)
+ || "-1".equals(startTime)) {
+ String historyTruncateDays = SpringContextAware.getApplicationContext().getEnvironment()
+ .getProperty("history.truncate.window.days", "365");
+ this.startTs = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(Long.parseLong(historyTruncateDays));
} else {
this.startTs = Long.parseLong(startTime);
}
@@ -50,29 +53,28 @@ public class ChangesFormat extends MultiFormatMapper {
@Override
protected Optional<JsonObject> getJsonFromVertex(Vertex v) {
JsonObject json = new JsonObject();
- if (!v.properties(AAIProperties.RESOURCE_VERSION).hasNext() ||
- !v.properties(AAIProperties.NODE_TYPE).hasNext() ||
- !v.properties(AAIProperties.AAI_URI).hasNext()) {
+ if (!v.properties(AAIProperties.RESOURCE_VERSION).hasNext() || !v.properties(AAIProperties.NODE_TYPE).hasNext()
+ || !v.properties(AAIProperties.AAI_URI).hasNext()) {
return Optional.empty();
}
json.addProperty("node-type", v.<String>value(AAIProperties.NODE_TYPE));
json.addProperty("uri", v.<String>value(AAIProperties.AAI_URI));
final Set<Long> changes = new HashSet<>();
- v.properties(AAIProperties.RESOURCE_VERSION).forEachRemaining(o->
- o.properties(AAIProperties.START_TS, AAIProperties.END_TS)
- .forEachRemaining(p -> {
- Long val = (Long) p.value();
- if(val >= startTs) {
- changes.add(val);
- }
- }
- ));
+ v.properties(AAIProperties.RESOURCE_VERSION).forEachRemaining(
+ o -> o.properties(AAIProperties.START_TS, AAIProperties.END_TS).forEachRemaining(p -> {
+ Long val = (Long) p.value();
+ if (val >= startTs) {
+ changes.add(val);
+ }
+ }));
v.edges(Direction.BOTH).forEachRemaining(e -> {
- if(e.property(AAIProperties.START_TS).isPresent() && (Long)e.property(AAIProperties.START_TS).value() >= startTs) {
+ if (e.property(AAIProperties.START_TS).isPresent()
+ && (Long) e.property(AAIProperties.START_TS).value() >= startTs) {
changes.add((Long) e.property(AAIProperties.START_TS).value());
}
- if(e.property(AAIProperties.END_TS).isPresent() && (Long)e.property(AAIProperties.END_TS).value() >= startTs) {
+ if (e.property(AAIProperties.END_TS).isPresent()
+ && (Long) e.property(AAIProperties.END_TS).value() >= startTs) {
changes.add((Long) e.property(AAIProperties.END_TS).value());
}
});
@@ -88,7 +90,8 @@ public class ChangesFormat extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java
index 7e230c3a..0e7642cd 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java
@@ -41,7 +41,8 @@ public class Console implements FormatMapper {
}
@Override
- public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties)
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
JsonObject json = new JsonObject();
json.addProperty("result", o.toString());
return Optional.of(json);
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java
index 60a10c51..216d021d 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java
@@ -52,7 +52,8 @@ public class Count implements FormatMapper {
}
@Override
- public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties)
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java
index 50aa8dd4..e102f1f4 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java
@@ -20,6 +20,9 @@
package org.onap.aai.serialization.queryformats;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.serialization.db.DBSerializer;
@@ -28,9 +31,6 @@ import org.onap.aai.serialization.queryformats.utils.QueryParamInjector;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.setup.SchemaVersions;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-
public class FormatFactory {
private final Loader loader;
@@ -46,8 +46,8 @@ public class FormatFactory {
this.injector = QueryParamInjector.getInstance();
}
- public FormatFactory(Loader loader, DBSerializer serializer, SchemaVersions schemaVersions, String basePath, String serverBase)
- throws AAIException {
+ public FormatFactory(Loader loader, DBSerializer serializer, SchemaVersions schemaVersions, String basePath,
+ String serverBase) throws AAIException {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = new UrlBuilder(loader.getVersion(), serializer, serverBase, schemaVersions, basePath);
@@ -67,34 +67,43 @@ public class FormatFactory {
formatter = new Formatter(inject(new GraphSON(), params));
break;
case pathed:
- formatter = new Formatter(inject(new PathedURL.Builder(loader, serializer, urlBuilder), params).build(), params);
+ formatter = new Formatter(inject(new PathedURL.Builder(loader, serializer, urlBuilder), params).build(),
+ params);
break;
case pathed_resourceversion:
- formatter = new Formatter(inject(new PathedURL.Builder(loader, serializer, urlBuilder).includeUrl(), params).build(), params);
+ formatter = new Formatter(
+ inject(new PathedURL.Builder(loader, serializer, urlBuilder).includeUrl(), params).build(),
+ params);
break;
case id:
- formatter = new Formatter(inject(new IdURL.Builder(loader, serializer, urlBuilder), params).build(), params);
+ formatter = new Formatter(inject(new IdURL.Builder(loader, serializer, urlBuilder), params).build(),
+ params);
break;
case resource:
- formatter = new Formatter(inject(new Resource.Builder(loader, serializer, urlBuilder, params), params).build(), params);
+ formatter = new Formatter(
+ inject(new Resource.Builder(loader, serializer, urlBuilder, params), params).build(), params);
break;
case resource_and_url:
formatter = new Formatter(
- inject(new Resource.Builder(loader, serializer, urlBuilder, params).includeUrl(), params).build(), params);
+ inject(new Resource.Builder(loader, serializer, urlBuilder, params).includeUrl(), params)
+ .build(),
+ params);
break;
case raw:
- formatter =
- new Formatter(inject(new RawFormat.Builder(loader, serializer, urlBuilder), params).build(), params);
+ formatter = new Formatter(inject(new RawFormat.Builder(loader, serializer, urlBuilder), params).build(),
+ params);
break;
case simple:
formatter = new Formatter(
inject(new RawFormat.Builder(loader, serializer, urlBuilder).depth(0).modelDriven(), params)
- .build(), params);
+ .build(),
+ params);
break;
case aggregate:
formatter = new Formatter(
- inject(new Aggregate.Builder(loader, serializer, urlBuilder).depth(0).modelDriven(), params)
- .build(), params);
+ inject(new Aggregate.Builder(loader, serializer, urlBuilder).depth(0).modelDriven(), params)
+ .build(),
+ params);
break;
case console:
formatter = new Formatter(inject(new Console(), params));
@@ -107,20 +116,19 @@ public class FormatFactory {
inject(new ResourceWithSoT.Builder(loader, serializer, urlBuilder), params).build(), params);
break;
case changes:
- formatter =
- new Formatter(inject(new ChangesFormat(), params));
+ formatter = new Formatter(inject(new ChangesFormat(), params));
break;
case state:
- formatter =
- new Formatter(inject(new StateFormat.Builder(loader, serializer, urlBuilder), params).build(format));
+ formatter = new Formatter(
+ inject(new StateFormat.Builder(loader, serializer, urlBuilder), params).build(format));
break;
case lifecycle:
- formatter =
- new Formatter(inject(new LifecycleFormat.Builder(loader, serializer, urlBuilder), params).build(format));
+ formatter = new Formatter(
+ inject(new LifecycleFormat.Builder(loader, serializer, urlBuilder), params).build(format));
break;
case tree:
- formatter = new Formatter(
- inject(new TreeFormat.Builder(loader, serializer, urlBuilder), params).build());
+ formatter =
+ new Formatter(inject(new TreeFormat.Builder(loader, serializer, urlBuilder), params).build());
break;
default:
break;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java
index cf967f0f..5369c060 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java
@@ -32,7 +32,9 @@ import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexExcepti
public interface FormatMapper {
Optional<JsonObject> formatObject(Object o) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported;
- Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported;
+
+ Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties)
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported;
int parallelThreshold();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java
index 0e15173a..da5d5425 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java
@@ -20,26 +20,22 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.json.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported;
-import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-import javax.ws.rs.core.MultivaluedMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.onap.aai.logging.LogFormatTools;
+import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported;
+import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class Formatter {
private static final Logger LOGGER = LoggerFactory.getLogger(Formatter.class);
@@ -94,7 +90,7 @@ public class Formatter {
stream.map(o -> {
try {
- if (properties!= null && !properties.isEmpty()){
+ if (properties != null && !properties.isEmpty()) {
return format.formatObject(o, properties);
} else {
return format.formatObject(o);
@@ -106,24 +102,21 @@ public class Formatter {
}
return Optional.<JsonObject>empty();
- }).filter(Optional::isPresent)
- .map(Optional::get)
- .forEach(json -> {
- if (isParallel) {
- synchronized (body) {
- body.add(json);
- }
- } else {
+ }).filter(Optional::isPresent).map(Optional::get).forEach(json -> {
+ if (isParallel) {
+ synchronized (body) {
body.add(json);
}
- });
+ } else {
+ body.add(json);
+ }
+ });
}
- if (params !=null && params.containsKey("as-tree")) {
+ if (params != null && params.containsKey("as-tree")) {
String isAsTree = params.get("as-tree").get(0);
- if (isAsTree != null && isAsTree.equalsIgnoreCase("true")
- && body != null && body.size() != 0) {
+ if (isAsTree != null && isAsTree.equalsIgnoreCase("true") && body != null && body.size() != 0) {
JsonObject jsonObjectBody = body.get(0).getAsJsonObject();
if (jsonObjectBody != null && jsonObjectBody.size() > 0) {
return body.get(0).getAsJsonObject();
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
index e3c2989d..fc3316d4 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
@@ -24,6 +24,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -31,6 +32,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
@@ -84,7 +86,7 @@ public class GraphSON implements FormatMapper {
@Override
public Optional<JsonObject> formatObject(Object obj, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
index b11f14aa..fccc17c6 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
@@ -20,12 +20,17 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import org.apache.tinkerpop.gremlin.structure.*;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.introspection.Loader;
@@ -36,12 +41,8 @@ import org.onap.aai.serialization.queryformats.params.EndTs;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.params.StartTs;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class HistoryFormat extends MultiFormatMapper {
@@ -69,8 +70,8 @@ public abstract class HistoryFormat extends MultiFormatMapper {
protected long startTs;
protected long endTs;
protected static final Set<String> ignoredKeys =
- Stream.of(AAIProperties.LAST_MOD_TS, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, AAIProperties.CREATED_TS)
- .collect(Collectors.toSet());
+ Stream.of(AAIProperties.LAST_MOD_TS, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, AAIProperties.CREATED_TS)
+ .collect(Collectors.toSet());
protected HistoryFormat(Builder builder) {
this.urlBuilder = builder.getUrlBuilder();
@@ -145,8 +146,6 @@ public abstract class HistoryFormat extends MultiFormatMapper {
protected abstract JsonObject getRelatedObject(Edge e, Vertex related) throws AAIFormatVertexException;
-
-
public static class Builder implements NodesOnly<Builder>, Depth<Builder>, StartTs<Builder>, EndTs<Builder> {
protected final Loader loader;
@@ -197,7 +196,6 @@ public abstract class HistoryFormat extends MultiFormatMapper {
return this;
}
-
public boolean isNodesOnly() {
return this.nodesOnly;
}
@@ -234,7 +232,7 @@ public abstract class HistoryFormat extends MultiFormatMapper {
public HistoryFormat build(Format format) {
- if(Format.state.equals(format)) {
+ if (Format.state.equals(format)) {
return new StateFormat(this);
} else {
return new LifecycleFormat(this);
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
index c2c252a2..10bba7f6 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
@@ -40,8 +42,6 @@ import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-import javax.ws.rs.core.MultivaluedMap;
-
public class IdURL extends MultiFormatMapper {
private final UrlBuilder urlBuilder;
@@ -86,7 +86,8 @@ public class IdURL extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
@@ -107,7 +108,8 @@ public class IdURL extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder, MultivaluedMap<String, String> params) {
+ public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder,
+ MultivaluedMap<String, String> params) {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = urlBuilder;
@@ -126,7 +128,9 @@ public class IdURL extends MultiFormatMapper {
return this.urlBuilder;
}
- protected MultivaluedMap<String, String> getParams() { return this.params; }
+ protected MultivaluedMap<String, String> getParams() {
+ return this.params;
+ }
public boolean isSkipRelatedTo() {
if (params != null) {
@@ -143,7 +147,9 @@ public class IdURL extends MultiFormatMapper {
return true;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java
index 57bb17c2..74742c98 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java
@@ -20,10 +20,13 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -31,14 +34,11 @@ import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-
public class LifecycleFormat extends HistoryFormat {
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleFormat.class);
@@ -52,11 +52,11 @@ public class LifecycleFormat extends HistoryFormat {
Iterator<VertexProperty<Object>> iter = v.properties();
List<JsonObject> jsonList = new ArrayList<>();
- Map<String, Set<Long>> propStartTimes = new HashMap<>(); //vertex end
+ Map<String, Set<Long>> propStartTimes = new HashMap<>(); // vertex end
while (iter.hasNext()) {
JsonObject json = new JsonObject();
VertexProperty<Object> prop = iter.next();
- if(prop.key() != null && ignoredKeys.contains(prop.key())){
+ if (prop.key() != null && ignoredKeys.contains(prop.key())) {
continue;
}
if (!propStartTimes.containsKey(prop.key())) {
@@ -79,10 +79,9 @@ public class LifecycleFormat extends HistoryFormat {
jsonList.add(jo);
propStartTimes.get(prop.key()).add(metaProperties.get(AAIProperties.START_TS).getAsLong());
}
- if (!AAIProperties.RESOURCE_VERSION.equals(prop.key())
- && metaProperties.has(AAIProperties.END_TS)
- && isTsInRange(metaProperties.get(AAIProperties.END_TS).getAsLong())
- && !propStartTimes.get(prop.key()).contains(metaProperties.get(AAIProperties.END_TS).getAsLong())) {
+ if (!AAIProperties.RESOURCE_VERSION.equals(prop.key()) && metaProperties.has(AAIProperties.END_TS)
+ && isTsInRange(metaProperties.get(AAIProperties.END_TS).getAsLong())
+ && !propStartTimes.get(prop.key()).contains(metaProperties.get(AAIProperties.END_TS).getAsLong())) {
JsonObject jo = new JsonObject();
jo.add(KEY, json.get(KEY));
jo.add(VALUE, null);
@@ -94,16 +93,17 @@ public class LifecycleFormat extends HistoryFormat {
}
jsonList.stream()
- // remove all the null values that is the start time for another value
- .filter(jo -> !jo.get(VALUE).isJsonNull() || !propStartTimes.get(jo.get(KEY).getAsString()).contains(jo.get(TIMESTAMP).getAsLong()))
- // sort by ts in decreasing order
- .sorted((o1, o2) -> {
- if (o1.get(TIMESTAMP).getAsLong() == o2.get(TIMESTAMP).getAsLong()) {
- return o1.get(KEY).getAsString().compareTo(o2.get(KEY).getAsString());
- } else {
- return Long.compare(o2.get(TIMESTAMP).getAsLong(), o1.get(TIMESTAMP).getAsLong());
- }
- }).forEach(jsonArray::add);
+ // remove all the null values that is the start time for another value
+ .filter(jo -> !jo.get(VALUE).isJsonNull()
+ || !propStartTimes.get(jo.get(KEY).getAsString()).contains(jo.get(TIMESTAMP).getAsLong()))
+ // sort by ts in decreasing order
+ .sorted((o1, o2) -> {
+ if (o1.get(TIMESTAMP).getAsLong() == o2.get(TIMESTAMP).getAsLong()) {
+ return o1.get(KEY).getAsString().compareTo(o2.get(KEY).getAsString());
+ } else {
+ return Long.compare(o2.get(TIMESTAMP).getAsLong(), o1.get(TIMESTAMP).getAsLong());
+ }
+ }).forEach(jsonArray::add);
return jsonArray;
}
@@ -112,7 +112,6 @@ public class LifecycleFormat extends HistoryFormat {
return ts >= startTs && ts <= endTs;
}
-
@Override
protected boolean isValidEdge(Edge e) {
if (e.property(AAIProperties.END_TS).isPresent()) {
@@ -139,21 +138,27 @@ public class LifecycleFormat extends HistoryFormat {
json.addProperty("uri", "NA");
}
- if(e.property(AAIProperties.START_TS).isPresent()) {
+ if (e.property(AAIProperties.START_TS).isPresent()) {
long edgeStartTimestamp = e.<Long>value(AAIProperties.START_TS);
if (isTsInRange(edgeStartTimestamp)) {
- json.addProperty(TIMESTAMP, e.property(AAIProperties.START_TS).isPresent()? e.<Long>value(AAIProperties.START_TS) : 0);
- json.addProperty(SOT, e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent()? e.value(AAIProperties.SOURCE_OF_TRUTH) : "");
- json.addProperty(TX_ID, e.property(AAIProperties.START_TX_ID).isPresent()? e.value(AAIProperties.START_TX_ID) : "N/A");
+ json.addProperty(TIMESTAMP,
+ e.property(AAIProperties.START_TS).isPresent() ? e.<Long>value(AAIProperties.START_TS) : 0);
+ json.addProperty(SOT,
+ e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent() ? e.value(AAIProperties.SOURCE_OF_TRUTH)
+ : "");
+ json.addProperty(TX_ID,
+ e.property(AAIProperties.START_TX_ID).isPresent() ? e.value(AAIProperties.START_TX_ID) : "N/A");
}
}
- if(e.property(AAIProperties.END_TS).isPresent()) {
+ if (e.property(AAIProperties.END_TS).isPresent()) {
long edgeEndTimestamp = e.<Long>value(AAIProperties.END_TS);
if (isTsInRange(edgeEndTimestamp)) {
json.addProperty(END_TIMESTAMP, edgeEndTimestamp);
- json.addProperty(END_SOT, e.property(AAIProperties.END_SOT).isPresent() ? e.value(AAIProperties.END_SOT) : "");
- json.addProperty(END_TX_ID, e.property(AAIProperties.END_TX_ID).isPresent() ? e.value(AAIProperties.END_TX_ID) : "N/A");
+ json.addProperty(END_SOT,
+ e.property(AAIProperties.END_SOT).isPresent() ? e.value(AAIProperties.END_SOT) : "");
+ json.addProperty(END_TX_ID,
+ e.property(AAIProperties.END_TX_ID).isPresent() ? e.value(AAIProperties.END_TX_ID) : "N/A");
}
}
@@ -182,14 +187,14 @@ public class LifecycleFormat extends HistoryFormat {
json.add(NODE_ACTIONS, getNodeActions(v, json));
if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray().size() == 0
- && json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() == 0
- && json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() == 0) {
+ && json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() == 0
+ && json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() == 0) {
return Optional.empty();
} else if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray().size() == 1
- && (json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() > 0
- || json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() > 0)) {
- if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray()
- .get(0).getAsJsonObject().get("key").getAsString().equals(AAIProperties.END_TS)) {
+ && (json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() > 0
+ || json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() > 0)) {
+ if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray().get(0).getAsJsonObject().get("key")
+ .getAsString().equals(AAIProperties.END_TS)) {
json.getAsJsonObject().add(PROPERTIES, new JsonArray());
}
}
@@ -198,7 +203,8 @@ public class LifecycleFormat extends HistoryFormat {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
@@ -212,7 +218,8 @@ public class LifecycleFormat extends HistoryFormat {
action.addProperty("action", "DELETED");
action.addProperty(TIMESTAMP, deletedTs);
if (v.property(AAIProperties.END_TS).property(AAIProperties.SOURCE_OF_TRUTH).isPresent()) {
- action.addProperty(SOT, v.property(AAIProperties.END_TS).<String>value(AAIProperties.SOURCE_OF_TRUTH));
+ action.addProperty(SOT,
+ v.property(AAIProperties.END_TS).<String>value(AAIProperties.SOURCE_OF_TRUTH));
}
if (v.property(AAIProperties.END_TS).property(AAIProperties.END_TX_ID).isPresent()) {
action.addProperty(TX_ID, v.property(AAIProperties.END_TS).<String>value(AAIProperties.END_TX_ID));
@@ -229,7 +236,8 @@ public class LifecycleFormat extends HistoryFormat {
action.addProperty(TIMESTAMP, createdTs);
action.addProperty(SOT, v.<String>value(AAIProperties.SOURCE_OF_TRUTH));
if (v.property(AAIProperties.SOURCE_OF_TRUTH).property(AAIProperties.START_TX_ID).isPresent()) {
- action.addProperty(TX_ID, v.property(AAIProperties.SOURCE_OF_TRUTH).<String>value(AAIProperties.START_TX_ID));
+ action.addProperty(TX_ID,
+ v.property(AAIProperties.SOURCE_OF_TRUTH).<String>value(AAIProperties.START_TX_ID));
} else {
action.addProperty(TX_ID, "N/A");
}
@@ -259,17 +267,15 @@ public class LifecycleFormat extends HistoryFormat {
}
return Optional.<JsonObject>empty();
- }).filter(Optional::isPresent)
- .map(Optional::get)
- .forEach(json -> {
- if (isParallel) {
- synchronized (body) {
- body.add(json);
- }
- } else {
+ }).filter(Optional::isPresent).map(Optional::get).forEach(json -> {
+ if (isParallel) {
+ synchronized (body) {
body.add(json);
}
- });
+ } else {
+ body.add(json);
+ }
+ });
JsonArray result = organizeBody(body);
result.forEach(jsonElement -> jsonElement.getAsJsonObject().remove(TIMESTAMP));
return result;
@@ -282,21 +288,23 @@ public class LifecycleFormat extends HistoryFormat {
toBeMerged.add(body.get(i).getAsJsonObject().get("uri").getAsString(), i);
}
- final List<List<Integer>> dupes = toBeMerged.values().stream().filter(l -> l.size() > 1).collect(Collectors.toList());
+ final List<List<Integer>> dupes =
+ toBeMerged.values().stream().filter(l -> l.size() > 1).collect(Collectors.toList());
if (dupes.isEmpty()) {
return body;
} else {
Set<Integer> remove = new HashSet<>();
for (List<Integer> dupe : dupes) {
- dupe.sort((a,b) -> Long.compare(body.get(b).getAsJsonObject().get(TIMESTAMP).getAsLong(), body.get(a).getAsJsonObject().get(TIMESTAMP).getAsLong()));
+ dupe.sort((a, b) -> Long.compare(body.get(b).getAsJsonObject().get(TIMESTAMP).getAsLong(),
+ body.get(a).getAsJsonObject().get(TIMESTAMP).getAsLong()));
int keep = dupe.remove(0);
for (Integer idx : dupe) {
body.get(keep).getAsJsonObject().getAsJsonArray(NODE_ACTIONS)
- .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(NODE_ACTIONS));
+ .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(NODE_ACTIONS));
body.get(keep).getAsJsonObject().getAsJsonArray(PROPERTIES)
- .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(PROPERTIES));
+ .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(PROPERTIES));
body.get(keep).getAsJsonObject().getAsJsonArray(RELATED_TO)
- .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(RELATED_TO));
+ .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(RELATED_TO));
remove.add(idx);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java
index 12e046b9..186816e0 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java
@@ -20,6 +20,10 @@
package org.onap.aai.serialization.queryformats;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,10 +41,6 @@ import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexExcepti
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
public abstract class MultiFormatMapper implements FormatMapper {
private static final Logger logger = LoggerFactory.getLogger(MultiFormatMapper.class);
@@ -50,11 +50,11 @@ public abstract class MultiFormatMapper implements FormatMapper {
protected static final String NODE_TYPE_KEY = "node-type";
protected static final String RETURNED_EMPTY_JSONARRAY_MSG =
- "Returned empty JsonArray - Could not populate nested json objects for wrapper: {}";
+ "Returned empty JsonArray - Could not populate nested json objects for wrapper: {}";
@Override
public Optional<JsonObject> formatObject(Object input)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
if (input instanceof Vertex) {
logger.debug("Formatting vertex object");
return this.getJsonFromVertex((Vertex) input);
@@ -75,7 +75,7 @@ public abstract class MultiFormatMapper implements FormatMapper {
@Override
public Optional<JsonObject> formatObject(Object input, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
if (input instanceof Vertex) {
logger.debug("Formatting vertex object with properties map filter");
return this.getJsonFromVertex((Vertex) input, properties);
@@ -95,7 +95,9 @@ public abstract class MultiFormatMapper implements FormatMapper {
}
protected abstract Optional<JsonObject> getJsonFromVertex(Vertex input) throws AAIFormatVertexException;
- protected abstract Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException;
+
+ protected abstract Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException;
protected Optional<JsonObject> getJsonFromPath(Path input) throws AAIFormatVertexException {
List<Object> path = input.objects();
@@ -116,6 +118,7 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns an Optional<JsonObject> object using "nodes" as a wrapper to encapsulate json objects
+ *
* @param tree
* @return
* @throws AAIFormatVertexException
@@ -140,12 +143,14 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns an Optional<JsonObject> object using "related-nodes" to encapsulate nested json objects.
* Primarily intended to be utilized by the "as-tree" query parameter feature
+ *
* @param tree
* @param properties
* @return
* @throws AAIFormatVertexException
*/
- protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
if (tree.isEmpty()) {
return Optional.of(new JsonObject());
}
@@ -168,13 +173,15 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns JsonArray Object populated with nested json wrapped by the nodeIdentifier parameter
+ *
* @param tree
* @param filterPropertiesMap
* @param nodeIdentifier
* @return
* @throws AAIFormatVertexException
*/
- protected JsonArray getNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap, String nodeIdentifier) throws AAIFormatVertexException {
+ protected JsonArray getNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap, String nodeIdentifier)
+ throws AAIFormatVertexException {
JsonArray nodes = new JsonArray();
for (Map.Entry<?, ? extends Tree<?>> entry : tree.entrySet()) {
JsonObject me = new JsonObject();
@@ -199,6 +206,7 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a Map<String, Set<String>> object through converting given map parameter
+ *
* @param properties
* @return
*/
@@ -206,19 +214,16 @@ public abstract class MultiFormatMapper implements FormatMapper {
if (properties == null)
return new HashMap<>();
- return properties.entrySet().stream()
- .map(entry -> {
- Set<String> newSet = entry.getValue().stream()
- .map(this::truncateApostrophes)
- .collect(Collectors.toSet());
+ return properties.entrySet().stream().map(entry -> {
+ Set<String> newSet = entry.getValue().stream().map(this::truncateApostrophes).collect(Collectors.toSet());
- return Pair.of(entry.getKey(), newSet);
- }
- ).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
+ return Pair.of(entry.getKey(), newSet);
+ }).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}
/**
* Returns a string with it's apostrophes truncated at the start and end.
+ *
* @param s
* @return
*/
@@ -235,40 +240,39 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Filters the given Optional<JsonObject> with the properties under a properties field
* or the properties under its respective node type.
+ *
* @param obj
* @param filterPropertiesMap
* @return
*/
protected JsonObject getPropertyFilteredObject(Optional<JsonObject> obj,
- Map<String, Set<String>> filterPropertiesMap) {
- return obj.map(
- jsonObj -> {
- if (filterPropertiesMap == null || filterPropertiesMap.isEmpty()) {
- return jsonObj;
- } else {
- ImmutableTriple<JsonObject, Optional<String>, Optional<JsonObject>> triple =
+ Map<String, Set<String>> filterPropertiesMap) {
+ return obj.map(jsonObj -> {
+ if (filterPropertiesMap == null || filterPropertiesMap.isEmpty()) {
+ return jsonObj;
+ } else {
+ ImmutableTriple<JsonObject, Optional<String>, Optional<JsonObject>> triple =
cloneObjectAndExtractNodeTypeAndProperties(jsonObj);
- JsonObject result = triple.left;
- Optional<String> nodeType = triple.middle;
- Optional<JsonObject> properties = triple.right;
+ JsonObject result = triple.left;
+ Optional<String> nodeType = triple.middle;
+ Optional<JsonObject> properties = triple.right;
- // Filter current object based on it containing fields: "node-type" and "properties"
- if (nodeType.isPresent() && properties.isPresent()) {
- filterByNodeTypeAndProperties(result, nodeType.get(), properties.get(), filterPropertiesMap);
- } else {
- // filter current object based on the: key - nodeType & value - JsonObject of nodes properties
- filterByJsonObj(result, jsonObj, filterPropertiesMap);
- }
-
- return result;
+ // Filter current object based on it containing fields: "node-type" and "properties"
+ if (nodeType.isPresent() && properties.isPresent()) {
+ filterByNodeTypeAndProperties(result, nodeType.get(), properties.get(), filterPropertiesMap);
+ } else {
+ // filter current object based on the: key - nodeType & value - JsonObject of nodes properties
+ filterByJsonObj(result, jsonObj, filterPropertiesMap);
}
+
+ return result;
}
- ).orElseGet(JsonObject::new);
+ }).orElseGet(JsonObject::new);
}
private ImmutableTriple<JsonObject, Optional<String>, Optional<JsonObject>> cloneObjectAndExtractNodeTypeAndProperties(
- JsonObject jsonObj) {
+ JsonObject jsonObj) {
JsonObject result = new JsonObject();
Optional<String> nodeType = Optional.empty();
Optional<JsonObject> properties = Optional.empty();
@@ -293,20 +297,25 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a JsonObject with filtered properties using "node-type" and "properties"
* Used for formats with payloads similar to simple and raw
+ *
* @param result
* @param nodeType
* @param properties
* @param filterPropertiesMap
* @return
*/
- private JsonObject filterByNodeTypeAndProperties(JsonObject result, String nodeType, JsonObject properties, Map<String, Set<String>> filterPropertiesMap) {
- if (result == null || nodeType == null || nodeType.isEmpty() || properties == null || filterPropertiesMap == null) {
+ private JsonObject filterByNodeTypeAndProperties(JsonObject result, String nodeType, JsonObject properties,
+ Map<String, Set<String>> filterPropertiesMap) {
+ if (result == null || nodeType == null || nodeType.isEmpty() || properties == null
+ || filterPropertiesMap == null) {
return result;
}
- if (filterPropertiesMap.containsKey(nodeType)) { // filterPropertiesMap keys are nodeTypes - keys are obtained from the incoming query request
+ if (filterPropertiesMap.containsKey(nodeType)) { // filterPropertiesMap keys are nodeTypes - keys are obtained
+ // from the incoming query request
Set<String> filterSet = filterPropertiesMap.get(nodeType);
JsonObject filteredProperties = new JsonObject();
- for (String property : filterSet) { // Each nodeType should have a set of properties to be retained in the response
+ for (String property : filterSet) { // Each nodeType should have a set of properties to be retained in the
+ // response
if (properties.get(property) != null) {
filteredProperties.add(property, properties.get(property));
}
@@ -319,12 +328,14 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a JsonObject with its properties filtered
+ *
* @param result
* @param jsonObj
* @param filterPropertiesMap
* @return
*/
- private JsonObject filterByJsonObj(JsonObject result, JsonObject jsonObj, Map<String, Set<String>> filterPropertiesMap) {
+ private JsonObject filterByJsonObj(JsonObject result, JsonObject jsonObj,
+ Map<String, Set<String>> filterPropertiesMap) {
if (result == null || jsonObj == null || filterPropertiesMap == null) {
return result;
}
@@ -350,12 +361,13 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a filtered JsonObject with properties contained in the parameter filterPropertiesMap
+ *
* @param properties
* @param filterPropertiesMap
* @return
*/
protected JsonObject filterProperties(Optional<JsonObject> properties, String nodeType,
- Map<String, Set<String>> filterPropertiesMap) {
+ Map<String, Set<String>> filterPropertiesMap) {
return properties.map(jo -> {
if (filterPropertiesMap == null || filterPropertiesMap.isEmpty()) {
return properties.get();
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
index e21be992..f052f778 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
@@ -40,8 +42,6 @@ import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-import javax.ws.rs.core.MultivaluedMap;
-
public final class PathedURL extends MultiFormatMapper {
private final UrlBuilder urlBuilder;
@@ -91,7 +91,8 @@ public final class PathedURL extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
@@ -112,7 +113,8 @@ public final class PathedURL extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder, MultivaluedMap<String, String> params) {
+ public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder,
+ MultivaluedMap<String, String> params) {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = urlBuilder;
@@ -131,7 +133,9 @@ public final class PathedURL extends MultiFormatMapper {
return this.urlBuilder;
}
- protected MultivaluedMap<String, String> getParams() { return this.params; }
+ protected MultivaluedMap<String, String> getParams() {
+ return this.params;
+ }
public boolean isSkipRelatedTo() {
if (params != null) {
@@ -148,7 +152,9 @@ public final class PathedURL extends MultiFormatMapper {
return true;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
index a41ed2b3..bd858f4b 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
@@ -24,6 +24,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -31,6 +32,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -62,7 +64,8 @@ public class RawFormat extends MultiFormatMapper {
}
@Override
- public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException {
+ public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
json.addProperty("id", v.id().toString());
json.addProperty("node-type", v.<String>value(AAIProperties.NODE_TYPE));
@@ -110,7 +113,8 @@ public class RawFormat extends MultiFormatMapper {
return Optional.of(json);
}
- public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException {
+ public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
String nodeType = v.<String>value(AAIProperties.NODE_TYPE);
Set<String> propList = removeSingleQuotesForProperties(selectedProps.get(nodeType));
@@ -142,10 +146,9 @@ public class RawFormat extends MultiFormatMapper {
return Optional.of(json);
}
- private Set<String> removeSingleQuotesForProperties(List<String> props){
+ private Set<String> removeSingleQuotesForProperties(List<String> props) {
if (props != null && !props.isEmpty()) {
- return props.stream().map(
- e -> e.substring(1, e.length()-1)).collect(Collectors.toSet());
+ return props.stream().map(e -> e.substring(1, e.length() - 1)).collect(Collectors.toSet());
} else {
return Collections.emptySet();
}
@@ -215,7 +218,9 @@ public class RawFormat extends MultiFormatMapper {
return this.urlBuilder;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
index c4b7f575..f4fd921f 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
@@ -24,13 +24,16 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+
import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
@@ -73,7 +76,8 @@ public class Resource extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
if (tree.isEmpty()) {
return Optional.of(new JsonObject());
}
@@ -81,7 +85,7 @@ public class Resource extends MultiFormatMapper {
Map<String, Set<String>> filterPropertiesMap = createFilteredPropertyMap(properties);
JsonObject t = new JsonObject();
- JsonArray ja = this.getRelatedNodesArray(tree, filterPropertiesMap,"related-nodes");
+ JsonArray ja = this.getRelatedNodesArray(tree, filterPropertiesMap, "related-nodes");
if (ja.size() > 0) {
t.add("results", ja);
return Optional.of(t);
@@ -90,7 +94,8 @@ public class Resource extends MultiFormatMapper {
return Optional.empty();
}
- protected JsonArray getRelatedNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap, String nodeIdentifier) throws AAIFormatVertexException {
+ protected JsonArray getRelatedNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap,
+ String nodeIdentifier) throws AAIFormatVertexException {
JsonArray nodes = new JsonArray();
if (tree.isEmpty()) {
return nodes;
@@ -114,7 +119,7 @@ public class Resource extends MultiFormatMapper {
value.getAsJsonObject().add(nodeIdentifier, ja);
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
logger.debug("Failed to add related-nodes array: {}", e.getMessage());
throw new AAIFormatVertexException("Failed to add related-nodes array: " + e.getMessage(), e);
}
@@ -142,7 +147,8 @@ public class Resource extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
if (this.includeUrl) {
@@ -151,7 +157,10 @@ public class Resource extends MultiFormatMapper {
Optional<JsonObject> jsonObject = this.vertexToJsonObject(v);
if (jsonObject.isPresent()) {
String nodeType = v.<String>value(AAIProperties.NODE_TYPE);
- Map<String, Set<String>> filterPropertiesMap = createFilteredPropertyMap(properties); // this change is for resource_and_url with/out as-tree. and no as-tree req
+ Map<String, Set<String>> filterPropertiesMap = createFilteredPropertyMap(properties); // this change is for
+ // resource_and_url
+ // with/out as-tree.
+ // and no as-tree req
JsonObject jo = filterProperties(jsonObject, nodeType, filterPropertiesMap);
json.add(v.<String>property(AAIProperties.NODE_TYPE).orElse(null), jo);
} else {
@@ -166,7 +175,7 @@ public class Resource extends MultiFormatMapper {
}
try {
final Introspector obj =
- getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
+ getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
final List<Vertex> wrapper = new ArrayList<>();
@@ -176,7 +185,7 @@ public class Resource extends MultiFormatMapper {
getSerializer().dbToObject(wrapper, obj, this.depth, this.nodesOnly, "false", isSkipRelatedTo);
} catch (AAIException | UnsupportedEncodingException e) {
throw new AAIFormatVertexException(
- "Failed to format vertex - error while serializing: " + e.getMessage(), e);
+ "Failed to format vertex - error while serializing: " + e.getMessage(), e);
}
final String json = obj.marshal(false);
@@ -221,7 +230,8 @@ public class Resource extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder, MultivaluedMap<String, String> params) {
+ public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder,
+ MultivaluedMap<String, String> params) {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = urlBuilder;
@@ -240,7 +250,9 @@ public class Resource extends MultiFormatMapper {
return this.urlBuilder;
}
- protected MultivaluedMap<String, String> getParams() { return this.params; }
+ protected MultivaluedMap<String, String> getParams() {
+ return this.params;
+ }
public boolean isSkipRelatedTo() {
if (params != null) {
@@ -257,14 +269,15 @@ public class Resource extends MultiFormatMapper {
return true;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
return this;
}
-
public Builder includeUrl() {
this.includeUrl = true;
return this;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
index 1a56805c..076f665d 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
@@ -22,9 +22,11 @@ package org.onap.aai.serialization.queryformats;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.util.List;
import java.util.Map;
import java.util.Optional;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.introspection.Loader;
@@ -92,7 +94,9 @@ public class ResourceWithSoT extends MultiFormatMapper {
return this;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
@@ -185,7 +189,8 @@ public class ResourceWithSoT extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java
index b2813476..24405953 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java
@@ -20,17 +20,18 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+
+import java.util.*;
+
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-
-import java.util.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class StateFormat extends HistoryFormat {
@@ -102,18 +103,29 @@ public class StateFormat extends HistoryFormat {
LOGGER.warn("Vertex {} is missing aai-uri", related.id());
json.addProperty("uri", "NA");
}
- json.addProperty(TIMESTAMP, e.property(AAIProperties.START_TS).isPresent()? e.value(AAIProperties.START_TS) : 0);
- json.addProperty(SOT, e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent()? e.value(AAIProperties.SOURCE_OF_TRUTH) : "");
- json.addProperty(TX_ID, e.property(AAIProperties.START_TX_ID).isPresent()? e.value(AAIProperties.START_TX_ID) : "N/A");
+ json.addProperty(TIMESTAMP,
+ e.property(AAIProperties.START_TS).isPresent() ? e.value(AAIProperties.START_TS) : 0);
+ json.addProperty(SOT,
+ e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent() ? e.value(AAIProperties.SOURCE_OF_TRUTH) : "");
+ json.addProperty(TX_ID,
+ e.property(AAIProperties.START_TX_ID).isPresent() ? e.value(AAIProperties.START_TX_ID) : "N/A");
return json;
}
-
protected void addMetaProperties(JsonObject json, JsonObject metaProperties) {
- json.addProperty(TIMESTAMP, metaProperties.get(AAIProperties.START_TS) != null ? metaProperties.get(AAIProperties.START_TS).getAsLong() : 0);
- json.addProperty(SOT, metaProperties.get(AAIProperties.SOURCE_OF_TRUTH) != null ? metaProperties.get(AAIProperties.SOURCE_OF_TRUTH).getAsString() : "");
- json.addProperty(TX_ID, metaProperties.get(AAIProperties.START_TX_ID) != null ? metaProperties.get(AAIProperties.START_TX_ID).getAsString() : "N/A");
+ json.addProperty(TIMESTAMP,
+ metaProperties.get(AAIProperties.START_TS) != null
+ ? metaProperties.get(AAIProperties.START_TS).getAsLong()
+ : 0);
+ json.addProperty(SOT,
+ metaProperties.get(AAIProperties.SOURCE_OF_TRUTH) != null
+ ? metaProperties.get(AAIProperties.SOURCE_OF_TRUTH).getAsString()
+ : "");
+ json.addProperty(TX_ID,
+ metaProperties.get(AAIProperties.START_TX_ID) != null
+ ? metaProperties.get(AAIProperties.START_TX_ID).getAsString()
+ : "N/A");
}
@Override
@@ -137,7 +149,8 @@ public class StateFormat extends HistoryFormat {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
index d94c4b92..2e1cbf6e 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
@@ -26,7 +26,11 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.io.UnsupportedEncodingException;
+import java.util.*;
import java.util.Map.Entry;
+
import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -43,9 +47,6 @@ import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-import java.io.UnsupportedEncodingException;
-import java.util.*;
-
public class TreeFormat extends MultiFormatMapper {
private static final EELFLogger TREE_FORMAT_LOGGER = EELFManager.getInstance().getLogger(TreeFormat.class);
protected JsonParser parser = new JsonParser();
@@ -141,12 +142,13 @@ public class TreeFormat extends MultiFormatMapper {
JsonArray body = new JsonArray();
for (Object o : queryResults) {
try {
- return this.formatObjectToJsonArray(o, properties).orElseGet( () -> {
+ return this.formatObjectToJsonArray(o, properties).orElseGet(() -> {
TREE_FORMAT_LOGGER.warn("Empty Optional returned by 'formatObjectToJsonArray'");
return body;
});
} catch (AAIFormatVertexException e) {
- TREE_FORMAT_LOGGER.warn("Failed to format vertex, returning a partial list " + LogFormatTools.getStackTop(e));
+ TREE_FORMAT_LOGGER
+ .warn("Failed to format vertex, returning a partial list " + LogFormatTools.getStackTop(e));
} catch (AAIFormatQueryResultFormatNotSupported e) {
TREE_FORMAT_LOGGER.warn("Failed to format result type of the query " + LogFormatTools.getStackTop(e));
}
@@ -155,7 +157,7 @@ public class TreeFormat extends MultiFormatMapper {
}
public Optional<JsonArray> formatObjectToJsonArray(Object input, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
JsonArray json = new JsonArray();
if (input == null)
return Optional.of(json);
@@ -185,13 +187,11 @@ public class TreeFormat extends MultiFormatMapper {
if (obj.isPresent()) {
jsonObject = obj.get();
for (Map.Entry<String, JsonElement> mapEntry : jsonObject.entrySet()) {
- JsonElement jsonRootElementContents = mapEntry.getValue(); // getting everyObject inside
+ JsonElement jsonRootElementContents = mapEntry.getValue(); // getting everyObject inside
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
JsonObject relatedJsonNode = (JsonObject) jsonRootElementContents;
- addRelatedNodesToJsonObject(
- jsonRootElementContents.getAsJsonObject(),
- getRelatedNodes(relatedJsonNode)
- );
+ addRelatedNodesToJsonObject(jsonRootElementContents.getAsJsonObject(),
+ getRelatedNodes(relatedJsonNode));
}
}
jsonArray.add(jsonObject);
@@ -206,9 +206,8 @@ public class TreeFormat extends MultiFormatMapper {
for (Map.Entry<String, JsonElement> mapEntry : jsonObject.entrySet()) {
JsonElement jsonRootElementContents = mapEntry.getValue();
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
- addRelatedNodesToJsonObject(
- jsonRootElementContents.getAsJsonObject(),
- getRelatedNodes(entry.getValue()));
+ addRelatedNodesToJsonObject(jsonRootElementContents.getAsJsonObject(),
+ getRelatedNodes(entry.getValue()));
}
}
jsonArray.add(jsonObject);
@@ -225,10 +224,7 @@ public class TreeFormat extends MultiFormatMapper {
JsonElement jsonRootElementContents = jsonObj.get(s);
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
JsonObject relatedJsonNode = jsonRootElementContents.getAsJsonObject();
- addRelatedNodesToJsonObject(
- relatedJsonNode,
- this.getRelatedNodes(relatedJsonNode)
- );
+ addRelatedNodesToJsonObject(relatedJsonNode, this.getRelatedNodes(relatedJsonNode));
relatedNodes.add(relatedJsonNode);
}
}
@@ -248,25 +244,23 @@ public class TreeFormat extends MultiFormatMapper {
}
private void processVertex(JsonArray relatedNodes, Entry<Object, Tree<Object>> entry, Vertex o)
- throws AAIFormatVertexException {
+ throws AAIFormatVertexException {
Optional<JsonObject> obj = this.getJsonFromVertex(o);
if (obj.isPresent()) {
JsonObject jsonObj = obj.get();
for (Entry<String, JsonElement> mapEntry : jsonObj.entrySet()) {
JsonElement jsonRootElementContents = mapEntry.getValue();
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
- JsonObject jsonObject = addRelatedNodesToJsonObject(
- jsonRootElementContents.getAsJsonObject(),
- getRelatedNodes(entry.getValue()));
+ JsonObject jsonObject = addRelatedNodesToJsonObject(jsonRootElementContents.getAsJsonObject(),
+ getRelatedNodes(entry.getValue()));
relatedNodes.add(jsonObject);
}
}
}
}
-
private static JsonObject addRelatedNodesToJsonObject(JsonObject jsonObject, Optional<JsonArray> relatedNodesOpt) {
- relatedNodesOpt.ifPresent( relatedNodes -> {
+ relatedNodesOpt.ifPresent(relatedNodes -> {
if (relatedNodes.size() > 0) {
jsonObject.add("related-nodes", relatedNodes);
}
@@ -303,7 +297,7 @@ public class TreeFormat extends MultiFormatMapper {
protected Optional<JsonObject> vertexToJsonObject(Vertex v) throws AAIFormatVertexException {
try {
final Introspector obj =
- getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
+ getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
final List<Vertex> wrapper = new ArrayList<>();
@@ -313,7 +307,7 @@ public class TreeFormat extends MultiFormatMapper {
getSerializer().dbToObject(wrapper, obj, this.depth, this.nodesOnly, "false");
} catch (AAIException | UnsupportedEncodingException e) {
throw new AAIFormatVertexException(
- "Failed to format vertex - error while serializing: " + e.getMessage(), e);
+ "Failed to format vertex - error while serializing: " + e.getMessage(), e);
}
final String json = obj.marshal(false);
@@ -336,9 +330,9 @@ public class TreeFormat extends MultiFormatMapper {
return parser;
}
-
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java
index f90907e2..a0693a8e 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java
@@ -20,23 +20,19 @@
package org.onap.aai.serialization.queryformats.utils;
-import org.onap.aai.serialization.queryformats.exceptions.QueryParamInjectionException;
-import org.onap.aai.serialization.queryformats.params.*;
-
-import javax.ws.rs.core.MultivaluedMap;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.onap.aai.serialization.queryformats.exceptions.QueryParamInjectionException;
+import org.onap.aai.serialization.queryformats.params.*;
+
public class QueryParamInjector {
- //TODO reimplement this using reflections.
- private static final Class<?>[] PARAM_CLASSES = new Class[] {
- AsTree.class,
- Depth.class,
- EndTs.class,
- NodesOnly.class,
- StartTs.class
- };
+ // TODO reimplement this using reflections.
+ private static final Class<?>[] PARAM_CLASSES =
+ new Class[] {AsTree.class, Depth.class, EndTs.class, NodesOnly.class, StartTs.class};
private static class Helper {
private static final QueryParamInjector INSTANCE = new QueryParamInjector();
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java
index 2d37f1b4..3fcecf6a 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java
@@ -57,8 +57,8 @@ public class UrlBuilder {
String basePath) throws AAIException {
this.serializer = serializer;
this.version = version;
- if(serverBase == null){
- this.serverBase = getServerBase();
+ if (serverBase == null) {
+ this.serverBase = getServerBase();
} else {
this.serverBase = serverBase;
}
diff --git a/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java b/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java
index 6c57616e..ca4666ae 100644
--- a/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java
+++ b/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java
@@ -20,12 +20,11 @@
package org.onap.aai.service;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import javax.annotation.PostConstruct;
import org.onap.aai.validation.nodes.NodeValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.PropertySource;
diff --git a/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java b/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java
index 282d8819..64d67c0c 100644
--- a/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java
+++ b/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java
@@ -53,7 +53,7 @@ public class ScheduledTasks {
// configuration properties files
@Scheduled(fixedRate = PROPERTY_READ_INTERVAL)
public void loadAAIProperties() {
- auditLog.logBefore("LoadAaiPropertiesTask", ONAPComponents.AAI.toString() );
+ auditLog.logBefore("LoadAaiPropertiesTask", ONAPComponents.AAI.toString());
String dir = FilenameUtils.getFullPathNoEndSeparator(GlobalPropFileName);
if (dir == null || dir.length() < 3) {
dir = "/opt/aai/etc";
diff --git a/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java b/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java
index ce7ead4f..9ff146be 100644
--- a/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java
+++ b/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java
@@ -17,17 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.transforms;
import com.bazaarvoice.jolt.Chainr;
import com.bazaarvoice.jolt.JsonUtils;
+
+import java.util.List;
+
import org.json.JSONObject;
import org.json.XML;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-
public class XmlFormatTransformer {
private static final Logger LOGGER = LoggerFactory.getLogger(XmlFormatTransformer.class);
@@ -39,19 +41,19 @@ public class XmlFormatTransformer {
public XmlFormatTransformer() {
List<Object> spec = JsonUtils.classpathToList("/specs/transform-related-to-node.json");
- this.chainr = Chainr.fromSpec(spec);
+ this.chainr = Chainr.fromSpec(spec);
}
public String transform(String input) {
Object transformedOutput;
- if(!input.contains(RESULT_WITH_QUOTES)){
+ if (!input.contains(RESULT_WITH_QUOTES)) {
Object inputMap = JsonUtils.jsonToMap(input);
transformedOutput = chainr.transform(inputMap);
JSONObject jsonObject;
- if(transformedOutput == null){
+ if (transformedOutput == null) {
LOGGER.debug("For the input {}, unable to transform it so returning null", input);
jsonObject = new JSONObject();
} else {
diff --git a/aai-core/src/main/java/org/onap/aai/util/Entity.java b/aai-core/src/main/java/org/onap/aai/util/Entity.java
index 4605414b..52a78d3c 100644
--- a/aai-core/src/main/java/org/onap/aai/util/Entity.java
+++ b/aai-core/src/main/java/org/onap/aai/util/Entity.java
@@ -20,6 +20,13 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -31,13 +38,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"equipment-role", "action", "key-value-list", "self-link"})
diff --git a/aai-core/src/main/java/org/onap/aai/util/EntityList.java b/aai-core/src/main/java/org/onap/aai/util/EntityList.java
index 375614bc..e2bab6f5 100644
--- a/aai-core/src/main/java/org/onap/aai/util/EntityList.java
+++ b/aai-core/src/main/java/org/onap/aai/util/EntityList.java
@@ -20,6 +20,13 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -31,13 +38,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"entity"})
diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
index 0cc3aef8..f8f0b65e 100644
--- a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
+++ b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
@@ -26,6 +26,7 @@ import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.client.urlconnection.HTTPSProperties;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyManagementException;
@@ -34,11 +35,13 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
+
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
+
import org.onap.aai.aailog.filter.RestControllerClientLoggingInterceptor;
import org.onap.aai.exceptions.AAIException;
import org.slf4j.Logger;
@@ -71,6 +74,7 @@ public class HttpsAuthClient {
logger.debug("HttpsAuthClient error : {}", e.getMessage());
}
}
+
/**
* Gets the client.
*
@@ -81,7 +85,9 @@ public class HttpsAuthClient {
* @return the client
* @throws KeyManagementException the key management exception
*/
- public static Client getClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
+ public static Client getClient(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException,
+ NoSuchAlgorithmException, KeyStoreException, IOException {
ClientConfig config = new DefaultClientConfig();
config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
@@ -112,12 +118,12 @@ public class HttpsAuthClient {
ctx.init(kmf.getKeyManagers(), null, null);
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- new HTTPSProperties(new HostnameVerifier() {
- @Override
- public boolean verify(String s, SSLSession sslSession) {
- return true;
- }
- }, ctx));
+ new HTTPSProperties(new HostnameVerifier() {
+ @Override
+ public boolean verify(String s, SSLSession sslSession) {
+ return true;
+ }
+ }, ctx));
} catch (Exception e) {
System.out.println("Error setting up config: exiting " + e.getMessage());
throw e;
@@ -130,22 +136,22 @@ public class HttpsAuthClient {
return client;
}
+
/**
* Gets the client.
*
* @return the client
* @throws KeyManagementException the key management exception
*/
- public static Client getClient() throws KeyManagementException, AAIException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
+ public static Client getClient() throws KeyManagementException, AAIException, UnrecoverableKeyException,
+ CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
String truststorePath = null;
String truststorePassword = null;
String keystorePath = null;
String keystorePassword = null;
- truststorePath =
- AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
+ truststorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
truststorePassword = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
- keystorePath =
- AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
+ keystorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
keystorePassword = AAIConfig.get(AAIConstants.AAI_KEYSTORE_PASSWD);
return getClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java b/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java
index c3382b2d..8c9ea52b 100644
--- a/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java
+++ b/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java
@@ -20,6 +20,13 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
import java.util.HashMap;
import java.util.Map;
@@ -29,13 +36,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"key", "value"})
diff --git a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java
index d83c9ec3..f974ba14 100644
--- a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java
+++ b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java
@@ -20,6 +20,17 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+import com.google.common.base.CaseFormat;
+import com.google.common.collect.Multimap;
+
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
@@ -45,28 +56,17 @@ import org.eclipse.persistence.jaxb.MarshallerProperties;
import org.onap.aai.domain.model.AAIResource;
import org.onap.aai.exceptions.AAIException;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
-import com.google.common.base.CaseFormat;
-import com.google.common.collect.Multimap;
-
public class PojoUtils {
/**
* Gets the key value list.
*
- * @param <T> the generic type
- * @param e the e
+ * @param <T> the generic type
+ * @param e the e
* @param clazz the clazz
* @return the key value list
- * @throws IllegalAccessException the illegal access exception
- * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws IllegalArgumentException the illegal argument exception
* @throws InvocationTargetException the invocation target exception
*/
public <T> List<KeyValueList> getKeyValueList(Entity e, T clazz)
@@ -99,12 +99,12 @@ public class PojoUtils {
/**
* Gets the json from object.
*
- * @param <T> the generic type
+ * @param <T> the generic type
* @param clazz the clazz
* @return the json from object
* @throws JsonGenerationException the json generation exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws JsonMappingException the json mapping exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
public <T> String getJsonFromObject(T clazz) throws JsonGenerationException, JsonMappingException, IOException {
return getJsonFromObject(clazz, false, true);
@@ -113,26 +113,24 @@ public class PojoUtils {
/**
* Gets the json from object.
*
- * @param <T> the generic type
- * @param clazz the clazz
+ * @param <T> the generic type
+ * @param clazz the clazz
* @param wrapRoot the wrap root
- * @param indent the indent
+ * @param indent the indent
* @return the json from object
* @throws JsonGenerationException the json generation exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws JsonMappingException the json mapping exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
public <T> String getJsonFromObject(T clazz, boolean wrapRoot, boolean indent)
throws JsonGenerationException, JsonMappingException, IOException {
- ObjectMapper mapper = JsonMapper.builder()
- .serializationInclusion(JsonInclude.Include.NON_NULL)
- .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
- .configure(SerializationFeature.INDENT_OUTPUT, indent)
- .configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot)
- .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
- .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot)
- .addModule(new JaxbAnnotationModule())
- .build();
+ ObjectMapper mapper = JsonMapper.builder().serializationInclusion(JsonInclude.Include.NON_NULL)
+ .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
+ .configure(SerializationFeature.INDENT_OUTPUT, indent)
+ .configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot)
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot).addModule(new JaxbAnnotationModule())
+ .build();
return mapper.writeValueAsString(clazz);
}
@@ -140,14 +138,14 @@ public class PojoUtils {
/**
* Gets the json from dynamic object.
*
- * @param ent the ent
+ * @param ent the ent
* @param jaxbContext the jaxb context
* @param includeRoot the include root
* @return the json from dynamic object
* @throws JsonGenerationException the json generation exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws JAXBException the JAXB exception
+ * @throws JsonMappingException the json mapping exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws JAXBException the JAXB exception
*/
public String getJsonFromDynamicObject(DynamicEntity ent, org.eclipse.persistence.jaxb.JAXBContext jaxbContext,
boolean includeRoot) throws JsonGenerationException, JsonMappingException, IOException, JAXBException {
@@ -166,7 +164,7 @@ public class PojoUtils {
/**
* Gets the xml from object.
*
- * @param <T> the generic type
+ * @param <T> the generic type
* @param clazz the clazz
* @return the xml from object
* @throws JAXBException the JAXB exception
@@ -179,7 +177,7 @@ public class PojoUtils {
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(clazz, baos);
-
+
return baos.toString(Charset.defaultCharset());
}
}
@@ -187,9 +185,9 @@ public class PojoUtils {
/**
* Gets the lookup key.
*
- * @param baseKey the base key
+ * @param baseKey the base key
* @param lookupHash the lookup hash
- * @param keyProps the key props
+ * @param keyProps the key props
* @return the lookup key
*/
public String getLookupKey(String baseKey, HashMap<String, Object> lookupHash, Collection<String> keyProps) {
@@ -213,7 +211,7 @@ public class PojoUtils {
/**
* Gets the lookup keys.
*
- * @param lookupHashes the lookup hashes
+ * @param lookupHashes the lookup hashes
* @param _dbRulesNodeKeyProps the db rules node key props
* @return the lookup keys
*/
@@ -237,16 +235,16 @@ public class PojoUtils {
/**
* Gets the example object.
*
- * @param <T> the generic type
- * @param clazz the clazz
+ * @param <T> the generic type
+ * @param clazz the clazz
* @param singleton the singleton
* @return the example object
- * @throws IllegalAccessException the illegal access exception
- * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws IllegalArgumentException the illegal argument exception
* @throws InvocationTargetException the invocation target exception
- * @throws NoSuchMethodException the no such method exception
- * @throws SecurityException the security exception
- * @throws AAIException the AAI exception
+ * @throws NoSuchMethodException the no such method exception
+ * @throws SecurityException the security exception
+ * @throws AAIException the AAI exception
*/
public <T> void getExampleObject(T clazz, boolean singleton)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
@@ -304,8 +302,8 @@ public class PojoUtils {
* Gets the dynamic example object.
*
* @param childObject the child object
- * @param aaiRes the aai res
- * @param singleton the singleton
+ * @param aaiRes the aai res
+ * @param singleton the singleton
* @return the dynamic example object
*/
public void getDynamicExampleObject(DynamicEntity childObject, AAIResource aaiRes, boolean singleton) {
diff --git a/aai-core/src/main/java/org/onap/aai/util/Request.java b/aai-core/src/main/java/org/onap/aai/util/Request.java
index 890398d5..c373738d 100644
--- a/aai-core/src/main/java/org/onap/aai/util/Request.java
+++ b/aai-core/src/main/java/org/onap/aai/util/Request.java
@@ -20,16 +20,6 @@
package org.onap.aai.util;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-
-import javax.ws.rs.core.UriBuilder;
-
-import org.onap.aai.exceptions.AAIException;
-
public class Request<T> {
public static final String V14 = "v14";
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java
index 433458ac..6c57040d 100644
--- a/aai-core/src/main/java/org/onap/aai/util/RestController.java
+++ b/aai-core/src/main/java/org/onap/aai/util/RestController.java
@@ -20,8 +20,6 @@
package org.onap.aai.util;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.sun.jersey.api.client.Client;
@@ -31,14 +29,16 @@ import com.sun.jersey.api.client.ClientResponse;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
-import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.onap.aai.exceptions.AAIException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RestController implements RestControllerInterface {
@@ -85,15 +85,18 @@ public class RestController implements RestControllerInterface {
public static final String REST_APIPATH_LOGICALLINKS = "network/logical-links/";
public static final String REST_APIPATH_LOGICALLINK = "network/logical-links/logical-link/";
- public RestController(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws AAIException {
+ public RestController(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws AAIException {
this.initRestClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
}
+
/**
* Inits the rest client.
*
* @throws AAIException the AAI exception
*/
- public void initRestClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws AAIException {
+ public void initRestClient(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws AAIException {
if (client == null) {
try {
client = getHttpsAuthClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
@@ -104,13 +107,18 @@ public class RestController implements RestControllerInterface {
}
}
}
- public Client getHttpsAuthClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
+
+ public Client getHttpsAuthClient(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException,
+ NoSuchAlgorithmException, KeyStoreException, IOException {
return HttpsAuthClient.getClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
}
- public Client getHttpsAuthClient() throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, AAIException {
+ public Client getHttpsAuthClient() throws KeyManagementException, UnrecoverableKeyException, CertificateException,
+ NoSuchAlgorithmException, KeyStoreException, IOException, AAIException {
return HttpsAuthClient.getClient();
}
+
/**
* Sets the rest srvr base URL.
*
@@ -335,7 +343,7 @@ public class RestController implements RestControllerInterface {
+ cres.getEntity(String.class));
}
}
-
+
/**
* Put.
*
@@ -347,14 +355,13 @@ public class RestController implements RestControllerInterface {
* @param apiVersion version number
* @throws AAIException the AAI exception
*/
- public <T> void Put(T t, String sourceID, String transId, String path, String apiVersion)
- throws AAIException {
+ public <T> void Put(T t, String sourceID, String transId, String path, String apiVersion) throws AAIException {
String methodName = "Put";
String url = "";
transId += ":" + UUID.randomUUID().toString();
LOGGER.debug(methodName + " start");
-
+
url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java b/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
index f5eed42d..3304e9a5 100644
--- a/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
+++ b/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
@@ -21,7 +21,6 @@
package org.onap.aai.util;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.util.RestObject;
public interface RestControllerInterface {
diff --git a/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java b/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java
index 01d21ca7..598ef231 100644
--- a/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java
+++ b/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java
@@ -20,9 +20,6 @@
package org.onap.aai.util;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.StringWriter;
import java.util.Iterator;
import java.util.UUID;
@@ -40,6 +37,8 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
@@ -273,7 +272,7 @@ public class StoreNotificationEvent {
if (eventHeader.getValue("sequence-number") == null) {
eventHeader.setValue("sequence-number",
- AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK"));
+ AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK"));
}
if (eventHeader.getValue("severity") == null) {
@@ -286,7 +285,7 @@ public class StoreNotificationEvent {
if (notificationEvent.getValue("cambria-partition") == null) {
notificationEvent.setValue("cambria-partition",
- AAIConfig.get("aai.notificationEvent.default.partition", AAIConstants.UEB_PUB_PARTITION_AAI));
+ AAIConfig.get("aai.notificationEvent.default.partition", AAIConstants.UEB_PUB_PARTITION_AAI));
}
notificationEvent.setValue("event-header", eventHeader.getUnderlyingObject());
@@ -322,7 +321,8 @@ public class StoreNotificationEvent {
}
}
- public String storeEventAndSendToJms(Loader loader, Introspector eventHeader, Introspector obj) throws AAIException {
+ public String storeEventAndSendToJms(Loader loader, Introspector eventHeader, Introspector obj)
+ throws AAIException {
if (obj == null) {
throw new AAIException("AAI_7350");
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java
index 1b1e49ae..7db4e834 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java
@@ -21,10 +21,5 @@
package org.onap.aai.util.delta;
public enum DeltaAction {
- CREATE,
- UPDATE,
- DELETE,
- CREATE_REL,
- DELETE_REL,
- STATIC
+ CREATE, UPDATE, DELETE, CREATE_REL, DELETE_REL, STATIC
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java
index 138652a4..10d47cd6 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java
@@ -20,26 +20,26 @@
package org.onap.aai.util.delta;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.*;
-import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dmaap.AAIDmaapEventJMSProducer;
-import org.onap.aai.dmaap.MessageProducer;
-import org.onap.aai.util.AAIConfig;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dmaap.AAIDmaapEventJMSProducer;
+import org.onap.aai.dmaap.MessageProducer;
+import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class DeltaEvents {
private static final Logger LOGGER = LoggerFactory.getLogger(DeltaEvents.class);
- private static final Gson gson = new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES)
- .create();
+ private static final Gson gson =
+ new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create();
private String transId;
private String sourceName;
@@ -53,7 +53,8 @@ public class DeltaEvents {
this(transId, sourceName, schemaVersion, objectDeltas, new AAIDmaapEventJMSProducer());
}
- public DeltaEvents(String transId, String sourceName, String schemaVersion, Map<String, ObjectDelta> objectDeltas, MessageProducer messageProducer) {
+ public DeltaEvents(String transId, String sourceName, String schemaVersion, Map<String, ObjectDelta> objectDeltas,
+ MessageProducer messageProducer) {
this.transId = transId;
this.sourceName = sourceName;
this.schemaVersion = schemaVersion;
@@ -125,11 +126,12 @@ public class DeltaEvents {
/**
* Given Long timestamp convert to format YYYYMMdd-HH:mm:ss:SSS
+ *
* @param timestamp milliseconds since epoc
* @return long timestamp in format YYYYMMdd-HH:mm:ss:SSS
*/
private String getTimeStamp(long timestamp) {
- //SimpleDateFormat is not thread safe new instance needed
+ // SimpleDateFormat is not thread safe new instance needed
DateFormat df = new SimpleDateFormat("yyyyMMdd-HH:mm:ss:SSS");
return df.format(new Date(timestamp));
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java
index 5ba99aff..23476675 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java
@@ -20,6 +20,8 @@
package org.onap.aai.util.delta;
+import com.google.gson.annotations.SerializedName;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -27,8 +29,6 @@ import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.google.gson.annotations.SerializedName;
-
public class ObjectDelta {
@SerializedName("uri")
@@ -64,7 +64,6 @@ public class ObjectDelta {
relationshipDeltas.add(relationshipDelta);
}
-
public String getUri() {
return uri;
}
@@ -115,13 +114,8 @@ public class ObjectDelta {
@Override
public String toString() {
- return new ToStringBuilder(this)
- .append("uri", uri)
- .append("action", action)
- .append("sourceOfTruth", sourceOfTruth)
- .append("timestamp", timestamp)
- .append("propertyDeltas", propertyDeltas)
- .append("relationshipDeltas", relationshipDeltas)
- .toString();
+ return new ToStringBuilder(this).append("uri", uri).append("action", action)
+ .append("sourceOfTruth", sourceOfTruth).append("timestamp", timestamp)
+ .append("propertyDeltas", propertyDeltas).append("relationshipDeltas", relationshipDeltas).toString();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java
index 3f4da75a..98296d35 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java
@@ -17,12 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.util.delta;
-import org.apache.commons.lang3.builder.ToStringBuilder;
+package org.onap.aai.util.delta;
import com.google.gson.annotations.SerializedName;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
public class PropertyDelta {
@SerializedName("action")
@@ -34,7 +35,6 @@ public class PropertyDelta {
@SerializedName("old-value")
private Object oldValue;
-
public PropertyDelta(DeltaAction action, Object value) {
this.action = action;
this.value = value;
@@ -71,10 +71,7 @@ public class PropertyDelta {
@Override
public String toString() {
- return new ToStringBuilder(this)
- .append("action", action)
- .append("value", value)
- .append("oldValue", oldValue)
- .toString();
+ return new ToStringBuilder(this).append("action", action).append("value", value).append("oldValue", oldValue)
+ .toString();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java
index 366d6886..a6641c2c 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java
@@ -23,12 +23,12 @@ package org.onap.aai.util.delta;
public class PropertyDeltaFactory {
public static PropertyDelta getDelta(DeltaAction action, Object value, Object oldValue) {
- //TODO handle if action is not UPDATE
+ // TODO handle if action is not UPDATE
return new PropertyDelta(action, value, oldValue);
}
public static PropertyDelta getDelta(DeltaAction action, Object value) {
- //TODO handle if action is UPDATE
+ // TODO handle if action is UPDATE
return new PropertyDelta(action, value);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java
index 75349ea3..8d8f9c4c 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java
@@ -20,13 +20,13 @@
package org.onap.aai.util.delta;
+import com.google.gson.annotations.SerializedName;
+
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.google.gson.annotations.SerializedName;
-
public class RelationshipDelta {
@SerializedName("action")
@@ -50,7 +50,8 @@ public class RelationshipDelta {
@SerializedName("props")
private Map<String, Object> props = new HashMap<>();
- public RelationshipDelta(DeltaAction action, String inVUUID, String outVUUID, String inVUri, String outVUri, String label) {
+ public RelationshipDelta(DeltaAction action, String inVUUID, String outVUUID, String inVUri, String outVUri,
+ String label) {
this.action = action;
this.inVUuid = inVUUID;
this.outVUuid = outVUUID;
@@ -121,14 +122,8 @@ public class RelationshipDelta {
@Override
public String toString() {
- return new ToStringBuilder(this)
- .append("action", action)
- .append("inVUuid", inVUuid)
- .append("outVUuid", outVUuid)
- .append("inVUri", inVUri)
- .append("outVUri", outVUri)
- .append("label", label)
- .append("props", props)
- .toString();
+ return new ToStringBuilder(this).append("action", action).append("inVUuid", inVUuid)
+ .append("outVUuid", outVUuid).append("inVUri", inVUri).append("outVUri", outVUri).append("label", label)
+ .append("props", props).toString();
}
}
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;