aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java21
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java17
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java3
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java13
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java19
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java56
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java52
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java37
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java30
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafProfiles.java10
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java37
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java15
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java38
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java1
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java66
-rw-r--r--aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java8
-rw-r--r--aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAISetup.java3
-rw-r--r--aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java4
-rw-r--r--aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java20
-rw-r--r--aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java10
-rw-r--r--aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java18
-rw-r--r--aai-annotations/src/main/java/org/onap/aai/schema/enums/ObjectMetadata.java3
-rw-r--r--aai-annotations/src/test/java/org/onap/aai/annotations/AnnotationsTest.java2
-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
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java17
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java32
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java41
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java12
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java4
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java23
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java8
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java2
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java8
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java5
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java3
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java6
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java10
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java26
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java4
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java9
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java44
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java11
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java5
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java2
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java1
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java1
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java1
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java1
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java5
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java2
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java16
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java2
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java30
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java2
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java1
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java124
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java36
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java11
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java27
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java119
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java126
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java7
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java10
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java25
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java17
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java32
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java6
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java13
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java62
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java4
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java38
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java24
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java6
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java13
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java8
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java11
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java12
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java6
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java5
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java10
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java2
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java5
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java3
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java2
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java2
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java103
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java20
-rw-r--r--aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java22
-rw-r--r--aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java11
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java5
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/NoAuthRestClient.java10
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/OneWaySSLRestClient.java16
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java7
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java5
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/RestClientResponseErrorHandler.java5
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/TwoWaySSLRestClient.java14
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java14
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderException.java8
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderMsgs.java8
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/EdgeSchema.java20
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/PropertySchema.java25
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/VertexSchema.java14
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/BooleanDataType.java5
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ComplexDataType.java14
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java9
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/FloatDataType.java9
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/IntDataType.java10
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ListDataType.java4
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/LongDataType.java9
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/MapDataType.java4
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/StringDataType.java6
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonEdgeSchema.java25
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonPropertySchema.java40
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonVertexSchema.java47
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java30
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProviderConfig.java16
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaInstance.java41
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java2
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java13
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/DataTypeDefinition.java25
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonEdgeSchema.java51
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonPropertySchema.java47
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonSchema.java55
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonVertexSchema.java32
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/EdgePropsConfiguration.java1
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmEdgeSchema.java18
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmPropertySchema.java21
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmVertexSchema.java24
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java13
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java51
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java12
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java22
-rw-r--r--aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java140
-rw-r--r--aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java49
-rw-r--r--aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java5
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java5
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java6
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java17
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java3
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java1
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java5
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java2
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java2
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java8
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java2
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java41
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java47
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java2
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java1
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java8
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java1
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java1
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java2
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java3
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java3
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java3
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java3
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java3
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java2
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java2
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java2
-rw-r--r--aai-utils/src/main/java/org/onap/aaiutils/oxm/OxmModelLoaderConstants.java8
-rw-r--r--pom.xml1
357 files changed, 4304 insertions, 4832 deletions
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java
index 0e170301..f591125c 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java
@@ -20,18 +20,11 @@
package org.onap.aai.aaf.auth;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.eclipse.jetty.util.security.Password;
-import org.onap.aai.aaf.auth.exceptions.AAIUnrecognizedFunctionException;
-import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.util.AAIConfig;
-import org.onap.aai.util.AAIConstants;
import java.io.File;
import java.io.FileNotFoundException;
@@ -43,6 +36,14 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.eclipse.jetty.util.security.Password;
+import org.onap.aai.aaf.auth.exceptions.AAIUnrecognizedFunctionException;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* The Class AAIAuthCore.
*/
@@ -69,14 +70,14 @@ public final class AAIAuthCore {
this(basePath, AAIConstants.AAI_AUTH_CONFIG_FILENAME);
}
- public AAIAuthCore(String basePath, String filename){
+ public AAIAuthCore(String basePath, String filename) {
this.basePath = basePath;
this.globalAuthFileName = filename;
authPolicyPattern = Pattern.compile("^" + this.basePath + "/v\\d+/([\\w\\-]*)");
init();
}
- public AAIAuthCore(String basePath, String filename, String pattern){
+ public AAIAuthCore(String basePath, String filename, String pattern) {
this.basePath = basePath;
this.globalAuthFileName = filename;
authPolicyPattern = Pattern.compile(pattern);
@@ -364,7 +365,7 @@ public final class AAIAuthCore {
* @return true, if successful
*/
private boolean authorize(AAIUser aaiUser, String aaiMethod, String httpMethod) {
- if ("info".equalsIgnoreCase(aaiMethod)|| aaiUser.hasAccess(aaiMethod, httpMethod)) {
+ if ("info".equalsIgnoreCase(aaiMethod) || aaiUser.hasAccess(aaiMethod, httpMethod)) {
LOGGER.debug("AUTH ACCEPTED: " + aaiUser.getUsername() + " on function " + aaiMethod + " request type "
+ httpMethod);
return true;
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java
index 9a02fe2c..cfaa61be 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java
@@ -20,20 +20,21 @@
package org.onap.aai.aaf.auth;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.onap.aaf.cadi.filter.CadiFilter;
+import static org.onap.aai.aaf.auth.ResponseFormatter.errorResponse;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
-import static org.onap.aai.aaf.auth.ResponseFormatter.errorResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.onap.aaf.cadi.filter.CadiFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class AafRequestFilter provides common auth filter methods
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java
index 0ecca679..f74ed3e4 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java
@@ -20,9 +20,10 @@
package org.onap.aai.aaf.auth;
+import java.util.*;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
-import java.util.*;
/**
* The AafRequestWrapper sets the user in the principal name
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java
index 26273a6a..139e46c8 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java
@@ -20,18 +20,19 @@
package org.onap.aai.aaf.auth;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Properties;
+import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.cert.X509Certificate;
-import java.util.stream.Collectors;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,8 +40,8 @@ import org.slf4j.LoggerFactory;
* The Class CertUtil provides cert related utility methods.
*/
public class CertUtil {
- public static final String DEFAULT_CADI_ISSUERS = "CN=ATT AAF CADI Test Issuing " +
- "CA 01, OU=CSO, O=ATT, C=US:CN=ATT AAF CADI Test Issuing CA 02, OU=CSO, O=ATT, C=US";
+ public static final String DEFAULT_CADI_ISSUERS = "CN=ATT AAF CADI Test Issuing "
+ + "CA 01, OU=CSO, O=ATT, C=US:CN=ATT AAF CADI Test Issuing CA 02, OU=CSO, O=ATT, C=US";
public static final String CADI_PROP_FILES = "cadi_prop_files";
public static final String CADI_ISSUERS_PROP_NAME = "cadi_x509_issuers";
public static final String CADI_ISSUERS_SEPARATOR = ":";
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java
index f5583b71..1748ed15 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java
@@ -20,15 +20,16 @@
package org.onap.aai.aaf.auth;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.logging.ErrorLogHelper;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.ErrorLogHelper;
public class ResponseFormatter {
@@ -43,9 +44,10 @@ public class ResponseFormatter {
errorResponse(new AAIException("AAI_3300"), request, response);
}
- public static void errorResponse(AAIException exception, HttpServletRequest request, HttpServletResponse response) throws IOException {
+ public static void errorResponse(AAIException exception, HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
- if(response.isCommitted()){
+ if (response.isCommitted()) {
return;
}
@@ -62,7 +64,8 @@ public class ResponseFormatter {
response.setStatus(exception.getErrorObject().getHTTPResponseCode().getStatusCode());
response.resetBuffer();
- String resp = ErrorLogHelper.getRESTAPIErrorResponse(Collections.singletonList(MediaType.valueOf(accept)), exception, new ArrayList<>());
+ String resp = ErrorLogHelper.getRESTAPIErrorResponse(Collections.singletonList(MediaType.valueOf(accept)),
+ exception, new ArrayList<>());
response.getOutputStream().print(resp);
response.flushBuffer();
}
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java
index 82651e9f..485fa7e3 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java
@@ -20,6 +20,17 @@
package org.onap.aai.aaf.filters;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.onap.aai.aaf.auth.ResponseFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -28,16 +39,6 @@ import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
/**
* AAF authorization filter
*/
@@ -59,52 +60,49 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter {
private List<String> advancedKeywordsList;
@Autowired
- public AafAuthorizationFilter(
- GremlinFilter gremlinFilter,
- @Value("${permission.type}") String type,
- @Value("${permission.instance}") String instance,
- @Value("${advanced.keywords.list:}") String advancedKeys
- ) {
+ public AafAuthorizationFilter(GremlinFilter gremlinFilter, @Value("${permission.type}") String type,
+ @Value("${permission.instance}") String instance,
+ @Value("${advanced.keywords.list:}") String advancedKeys) {
this.gremlinFilter = gremlinFilter;
this.type = type;
this.instance = instance;
- if(advancedKeys == null || advancedKeys.isEmpty()){
+ if (advancedKeys == null || advancedKeys.isEmpty()) {
this.advancedKeywordsList = new ArrayList<>();
} else {
- this.advancedKeywordsList = Arrays.stream(advancedKeys.split(","))
- .collect(Collectors.toList());
+ this.advancedKeywordsList = Arrays.stream(advancedKeys.split(",")).collect(Collectors.toList());
}
this.setOrder(FilterPriority.AAF_AUTHORIZATION.getPriority());
}
@Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
- if(request.getRequestURI().matches("^.*/util/echo$")){
- filterChain.doFilter(request, response);
- }
- if(request.getRequestURI().endsWith("/query")){
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ throws IOException, ServletException {
+ if (request.getRequestURI().matches("^.*/util/echo$")) {
+ filterChain.doFilter(request, response);
+ }
+ if (request.getRequestURI().endsWith("/query")) {
gremlinFilter.doBasicAuthFilter(request, response, filterChain);
} else {
String permission = null;
- if(advancedKeywordsList == null || advancedKeywordsList.size() == 0) {
+ if (advancedKeywordsList == null || advancedKeywordsList.size() == 0) {
permission = String.format("%s|%s|%s", type, instance, request.getMethod().toLowerCase());
} else {
boolean isAdvanced = this.containsAdvancedKeywords(request);
- //if the URI contains advanced.keywords it's an advanced query
+ // if the URI contains advanced.keywords it's an advanced query
String queryType = isAdvanced ? ADVANCED : BASIC;
permission = String.format("%s|%s|%s", type, instance, queryType);
}
boolean isAuthorized = request.isUserInRole(permission);
- if(!isAuthorized){
+ if (!isAuthorized) {
ResponseFormatter.errorResponse(request, response);
} else {
- filterChain.doFilter(request,response);
+ filterChain.doFilter(request, response);
}
}
@@ -112,7 +110,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter {
private boolean containsAdvancedKeywords(HttpServletRequest request) {
String uri = request.getRequestURI();
- for (String keyword: advancedKeywordsList) {
+ for (String keyword : advancedKeywordsList) {
if (uri.contains(keyword)) {
return true;
}
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java
index e0adf191..56799f1c 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java
@@ -20,6 +20,17 @@
package org.onap.aai.aaf.filters;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.onap.aai.aaf.auth.AafRequestFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -28,18 +39,6 @@ import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.stream.Collectors;
-
-
/**
* AAF with client cert authorization filter
*/
@@ -62,42 +61,41 @@ public class AafCertAuthorizationFilter extends OrderedRequestContextFilter {
private List<String> advancedKeywordsList;
@Autowired
- public AafCertAuthorizationFilter(
- @Value("${permission.type}") String type,
- @Value("${permission.instance}") String instance,
- @Value("${advanced.keywords.list:}") String advancedKeys,
- CadiProps cadiProps
- ) {
+ public AafCertAuthorizationFilter(@Value("${permission.type}") String type,
+ @Value("${permission.instance}") String instance, @Value("${advanced.keywords.list:}") String advancedKeys,
+ CadiProps cadiProps) {
this.type = type;
this.instance = instance;
this.cadiProps = cadiProps;
- if(advancedKeys == null || advancedKeys.isEmpty()){
+ if (advancedKeys == null || advancedKeys.isEmpty()) {
this.advancedKeywordsList = new ArrayList<>();
} else {
- this.advancedKeywordsList = Arrays.stream(advancedKeys.split(","))
- .collect(Collectors.toList());
+ this.advancedKeywordsList = Arrays.stream(advancedKeys.split(",")).collect(Collectors.toList());
}
this.setOrder(FilterPriority.AAF_CERT_AUTHORIZATION.getPriority());
}
@Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
- if(advancedKeywordsList == null || advancedKeywordsList.size() == 0){
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ throws IOException, ServletException {
+ if (advancedKeywordsList == null || advancedKeywordsList.size() == 0) {
String permission = String.format("%s|%s|%s", type, instance, request.getMethod().toLowerCase());
- AafRequestFilter.authorizationFilter(request, response, filterChain, permission, cadiProps.getCadiProperties());
+ AafRequestFilter.authorizationFilter(request, response, filterChain, permission,
+ cadiProps.getCadiProperties());
} else {
boolean isAdvanced = this.containsAdvancedKeywords(request);
- //if the URI contains advanced.keywords it's an advanced query
+ // if the URI contains advanced.keywords it's an advanced query
String queryType = isAdvanced ? ADVANCED : BASIC;
String permission = String.format("%s|%s|%s", type, instance, queryType);
- AafRequestFilter.authorizationFilter(request, response, filterChain, permission, cadiProps.getCadiProperties());
+ AafRequestFilter.authorizationFilter(request, response, filterChain, permission,
+ cadiProps.getCadiProperties());
}
}
private boolean containsAdvancedKeywords(HttpServletRequest request) {
String uri = request.getRequestURI();
- for (String keyword: advancedKeywordsList) {
+ for (String keyword : advancedKeywordsList) {
if (uri.contains(keyword)) {
return true;
}
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java
index 7a47b972..e423dc0a 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java
@@ -20,11 +20,18 @@
package org.onap.aai.aaf.filters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.filter.CadiFilter;
import org.onap.aai.aaf.auth.AafRequestFilter;
+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.boot.web.servlet.filter.OrderedRequestContextFilter;
@@ -32,12 +39,6 @@ import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
/**
* AAF with client cert authentication filter
*/
@@ -57,12 +58,12 @@ public class AafCertFilter extends OrderedRequestContextFilter {
private final CadiProps cadiProps;
@Autowired
- public AafCertFilter( @Value("${aaf.userchain.pattern}") String aafUserChainPattern,
- CadiProps cadiProps) throws IOException, ServletException {
+ public AafCertFilter(@Value("${aaf.userchain.pattern}") String aafUserChainPattern, CadiProps cadiProps)
+ throws IOException, ServletException {
this.aafUserChainPattern = aafUserChainPattern;
this.cadiProps = cadiProps;
- cadiFilter = new CadiFilter(new PropAccess((level,element)->{
+ cadiFilter = new CadiFilter(new PropAccess((level, element) -> {
switch (level) {
case DEBUG:
LOGGER.debug(buildMsg(element));
@@ -86,22 +87,24 @@ public class AafCertFilter extends OrderedRequestContextFilter {
case NONE:
break;
}
- }, new String[]{"cadi_prop_files=" + cadiProps.getCadiFileName()} ));
+ }, new String[] {"cadi_prop_files=" + cadiProps.getCadiFileName()}));
this.setOrder(FilterPriority.AAF_CERT_AUTHENTICATION.getPriority());
}
@Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
- AafRequestFilter.authenticationFilter(request, response, filterChain, cadiFilter, cadiProps.getCadiProperties(), aafUserChainPattern);
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ throws IOException, ServletException {
+ AafRequestFilter.authenticationFilter(request, response, filterChain, cadiFilter, cadiProps.getCadiProperties(),
+ aafUserChainPattern);
}
+
private String buildMsg(Object[] objects) {
StringBuilder sb = new StringBuilder();
boolean first = true;
- for ( Object o: objects ) {
+ for (Object o : objects) {
if (first) {
first = false;
- }
- else {
+ } else {
sb.append(' ');
}
sb.append(o.toString());
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java
index e6769dda..5dbc2e7a 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java
@@ -20,23 +20,23 @@
package org.onap.aai.aaf.filters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.filter.CadiFilter;
import org.onap.aai.aaf.auth.ResponseFormatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-
/**
* AAF authentication filter
*/
@@ -51,7 +51,7 @@ public class AafFilter extends OrderedRequestContextFilter {
@Autowired
public AafFilter(CadiProps cadiProps) throws IOException, ServletException {
- cadiFilter = new CadiFilter(new PropAccess((level,element)->{
+ cadiFilter = new CadiFilter(new PropAccess((level, element) -> {
switch (level) {
case DEBUG:
LOGGER.debug(buildMsg(element));
@@ -75,12 +75,13 @@ public class AafFilter extends OrderedRequestContextFilter {
case NONE:
break;
}
- }, new String[]{"cadi_prop_files=" + cadiProps.getCadiFileName()} ));
+ }, new String[] {"cadi_prop_files=" + cadiProps.getCadiFileName()}));
this.setOrder(FilterPriority.AAF_AUTHENTICATION.getPriority());
}
@Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ throws IOException, ServletException {
if (!request.getRequestURI().matches("^.*/util/echo$")) {
cadiFilter.doFilter(request, response, filterChain);
if (response.getStatus() == 401 || response.getStatus() == 403) {
@@ -94,11 +95,10 @@ public class AafFilter extends OrderedRequestContextFilter {
private String buildMsg(Object[] objects) {
StringBuilder sb = new StringBuilder();
boolean first = true;
- for ( Object o: objects ) {
+ for (Object o : objects) {
if (first) {
first = false;
- }
- else {
+ } else {
sb.append(' ');
}
sb.append(o.toString());
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafProfiles.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafProfiles.java
index b587716e..e87dc4a5 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafProfiles.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafProfiles.java
@@ -17,17 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aaf.filters;
public class AafProfiles {
// AAF Basic Auth
- public static final String AAF_AUTHENTICATION = "aaf-auth";
+ public static final String AAF_AUTHENTICATION = "aaf-auth";
// AAF Auth with Client Certs
- public static final String AAF_CERT_AUTHENTICATION = "aaf-cert-auth";
+ public static final String AAF_CERT_AUTHENTICATION = "aaf-cert-auth";
- public static final String TWO_WAY_SSL = "two-way-ssl";
+ public static final String TWO_WAY_SSL = "two-way-ssl";
- private AafProfiles(){}
+ private AafProfiles() {
+ }
}
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java
index 35e88f5f..4bf9ea82 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java
@@ -17,8 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aaf.filters;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.annotation.PostConstruct;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,20 +35,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
// This component will be created if and only if any of the following profiles are active
@Component
-@Profile({
- AafProfiles.AAF_CERT_AUTHENTICATION,
- AafProfiles.AAF_AUTHENTICATION,
- AafProfiles.TWO_WAY_SSL
-})
+@Profile({AafProfiles.AAF_CERT_AUTHENTICATION, AafProfiles.AAF_AUTHENTICATION, AafProfiles.TWO_WAY_SSL})
public class CadiProps {
private static final Logger LOGGER = LoggerFactory.getLogger(CadiProps.class);
@@ -49,18 +47,19 @@ public class CadiProps {
private Properties cadiProperties;
@Autowired
- public CadiProps(@Value("${aaf.cadi.file:./resources/cadi.properties}") String filename){
- cadiFileName = filename;
+ public CadiProps(@Value("${aaf.cadi.file:./resources/cadi.properties}") String filename) {
+ cadiFileName = filename;
cadiProperties = new Properties();
}
@PostConstruct
public void init() throws IOException {
- File cadiFile = new File(cadiFileName);
+ File cadiFile = new File(cadiFileName);
- if(!cadiFile.exists()){
- LOGGER.warn("Unable to find the cadi file in the given path {} so loading cadi.properties from classloader", cadiFileName);
+ if (!cadiFile.exists()) {
+ LOGGER.warn("Unable to find the cadi file in the given path {} so loading cadi.properties from classloader",
+ cadiFileName);
InputStream is = this.getClass().getClassLoader().getResourceAsStream("cadi.properties");
cadiProperties.load(is);
} else {
@@ -72,10 +71,12 @@ public class CadiProps {
}
}
+
public String getCadiFileName() {
return cadiFileName;
}
- public Properties getCadiProperties(){
+
+ public Properties getCadiProperties() {
return cadiProperties;
}
}
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java
index 17b9f0e4..e2423425 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java
@@ -17,17 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aaf.filters;
import org.springframework.core.Ordered;
public enum FilterPriority {
- AAF_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE),
- AAF_AUTHORIZATION(Ordered.HIGHEST_PRECEDENCE + 1), //higher number = lower priority
- AAF_CERT_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE + 2 ),
- AAF_CERT_AUTHORIZATION(Ordered.HIGHEST_PRECEDENCE + 3),
- TWO_WAY_SSL_AUTH(Ordered.HIGHEST_PRECEDENCE + 4);
+ AAF_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE), AAF_AUTHORIZATION(Ordered.HIGHEST_PRECEDENCE + 1), // higher number
+ // = lower
+ // priority
+ AAF_CERT_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE + 2), AAF_CERT_AUTHORIZATION(
+ Ordered.HIGHEST_PRECEDENCE + 3), TWO_WAY_SSL_AUTH(Ordered.HIGHEST_PRECEDENCE + 4);
private final int priority;
@@ -35,5 +36,7 @@ public enum FilterPriority {
priority = p;
}
- public int getPriority() { return priority; }
+ public int getPriority() {
+ return priority;
+ }
}
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java
index ce96acf1..dffa74ef 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aaf.filters;
import java.io.IOException;
@@ -38,10 +39,7 @@ import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
@Component
-@Profile({
- AafProfiles.AAF_CERT_AUTHENTICATION,
- AafProfiles.AAF_AUTHENTICATION
-})
+@Profile({AafProfiles.AAF_CERT_AUTHENTICATION, AafProfiles.AAF_AUTHENTICATION})
public class GremlinFilter {
private static final Logger LOGGER = LoggerFactory.getLogger(GremlinFilter.class);
@@ -57,44 +55,46 @@ public class GremlinFilter {
private CadiProps cadiProps;
@Autowired
- public GremlinFilter(
- @Value("${permission.type}") String type,
- @Value("${permission.instance}") String instance,
- CadiProps cadiProps
- ) {
+ public GremlinFilter(@Value("${permission.type}") String type, @Value("${permission.instance}") String instance,
+ CadiProps cadiProps) {
this.type = type;
this.instance = instance;
this.cadiProps = cadiProps;
}
- public void doBasicAuthFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
+ public void doBasicAuthFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ throws IOException, ServletException {
PayloadBufferingRequestWrapper requestBufferWrapper = new PayloadBufferingRequestWrapper(request);
- if(ECHO_ENDPOINT.matcher(request.getRequestURI()).matches()){
+ if (ECHO_ENDPOINT.matcher(request.getRequestURI()).matches()) {
filterChain.doFilter(requestBufferWrapper, response);
}
String payload = IOUtils.toString(requestBufferWrapper.getInputStream(), StandardCharsets.UTF_8.name());
boolean containsWordGremlin = payload.contains("\"gremlin\"");
- //if the requestBufferWrapper contains the word "gremlin" it's an "advanced" query needing an "advanced" role
+ // if the requestBufferWrapper contains the word "gremlin" it's an "advanced" query needing an "advanced" role
String permissionBasic = String.format("%s|%s|%s", type, instance, BASIC);
String permissionAdvanced = String.format("%s|%s|%s", type, instance, ADVANCED);
boolean isAuthorized;
- if(containsWordGremlin){
+ if (containsWordGremlin) {
isAuthorized = requestBufferWrapper.isUserInRole(permissionAdvanced);
- }else{
- isAuthorized = requestBufferWrapper.isUserInRole(permissionAdvanced) || requestBufferWrapper.isUserInRole(permissionBasic);
+ } else {
+ isAuthorized = requestBufferWrapper.isUserInRole(permissionAdvanced)
+ || requestBufferWrapper.isUserInRole(permissionBasic);
}
- if(!isAuthorized){
- String name = requestBufferWrapper.getUserPrincipal() != null ? requestBufferWrapper.getUserPrincipal().getName() : "unknown";
- LOGGER.info("User " + name + " does not have a role for " + (containsWordGremlin ? "gremlin" : "non-gremlin") + " query" );
+ if (!isAuthorized) {
+ String name =
+ requestBufferWrapper.getUserPrincipal() != null ? requestBufferWrapper.getUserPrincipal().getName()
+ : "unknown";
+ LOGGER.info("User " + name + " does not have a role for "
+ + (containsWordGremlin ? "gremlin" : "non-gremlin") + " query");
ResponseFormatter.errorResponse(request, response);
} else {
- filterChain.doFilter(requestBufferWrapper,response);
+ filterChain.doFilter(requestBufferWrapper, response);
}
}
}
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java
index 138189e4..e8c72dc3 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aaf.filters;
import java.io.ByteArrayInputStream;
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java
index 150802b8..3dad92df 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java
@@ -17,29 +17,31 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aaf.filters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.security.cert.X509Certificate;
+import java.util.*;
+
+import javax.security.auth.x500.X500Principal;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.onap.aai.aaf.auth.AAIAuthCore;
import org.onap.aai.aaf.auth.CertUtil;
import org.onap.aai.aaf.auth.ResponseFormatter;
import org.onap.aai.exceptions.AAIException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-import javax.security.auth.x500.X500Principal;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.security.cert.X509Certificate;
-import java.util.*;
-
@Component
@Profile("two-way-ssl")
public class TwoWaySslAuthorization extends OrderedRequestContextFilter {
@@ -59,12 +61,13 @@ public class TwoWaySslAuthorization extends OrderedRequestContextFilter {
@Autowired
private CadiProps cadiProps;
- public TwoWaySslAuthorization(){
+ public TwoWaySslAuthorization() {
this.setOrder(FilterPriority.TWO_WAY_SSL_AUTH.getPriority());
}
@Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
+ throws IOException, ServletException {
String uri = request.getRequestURI();
String httpMethod = getHttpMethod(request);
@@ -80,11 +83,11 @@ public class TwoWaySslAuthorization extends OrderedRequestContextFilter {
ResponseFormatter.errorResponse(aaie, request, response);
return;
}
- issuer = issuer.replaceAll("\\s+","").toUpperCase();
+ issuer = issuer.replaceAll("\\s+", "").toUpperCase();
List<String> cadiConfiguredIssuers = CertUtil.getCadiCertIssuers(cadiProperties);
boolean isAafAuthProfileActive = this.isAafAuthProfileActive();
- if ((!isAafAuthProfileActive) || (!cadiConfiguredIssuers.contains(issuer)) ) {
+ if ((!isAafAuthProfileActive) || (!cadiConfiguredIssuers.contains(issuer))) {
try {
this.authorize(uri, httpMethod, authUser.get(), this.getHaProxyUser(request), issuer);
} catch (AAIException e) {
@@ -100,11 +103,9 @@ public class TwoWaySslAuthorization extends OrderedRequestContextFilter {
filterChain.doFilter(request, response);
}
-
private String getHttpMethod(HttpServletRequest request) {
String httpMethod = request.getMethod();
- if ("POST".equalsIgnoreCase(httpMethod)
- && "PATCH".equals(request.getHeader(HTTP_METHOD_OVERRIDE))) {
+ if ("POST".equalsIgnoreCase(httpMethod) && "PATCH".equals(request.getHeader(HTTP_METHOD_OVERRIDE))) {
httpMethod = MERGE_PATCH;
}
if (httpMethod.equalsIgnoreCase(MERGE_PATCH) || "patch".equalsIgnoreCase(httpMethod)) {
@@ -148,26 +149,26 @@ public class TwoWaySslAuthorization extends OrderedRequestContextFilter {
private String getHaProxyUser(HttpServletRequest hsr) {
String haProxyUser;
- if (Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-CN"))
- || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-OU"))
- || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-O"))
- || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-L"))
- || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-ST"))
- || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-C"))) {
+ if (Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-CN")) || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-OU"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-O"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-L"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-ST"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-C"))) {
haProxyUser = "";
} else {
haProxyUser = String.format("CN=%s, OU=%s, O=\"%s\", L=%s, ST=%s, C=%s",
- Objects.toString(hsr.getHeader("X-AAI-SSL-Client-CN"), ""),
- Objects.toString(hsr.getHeader("X-AAI-SSL-Client-OU"), ""),
- Objects.toString(hsr.getHeader("X-AAI-SSL-Client-O"), ""),
- Objects.toString(hsr.getHeader("X-AAI-SSL-Client-L"), ""),
- Objects.toString(hsr.getHeader("X-AAI-SSL-Client-ST"), ""),
- Objects.toString(hsr.getHeader("X-AAI-SSL-Client-C"), "")).toLowerCase();
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-CN"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-OU"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-O"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-L"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-ST"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-C"), "")).toLowerCase();
}
return haProxyUser;
}
- private void authorize(String uri, String httpMethod, String authUser, String haProxyUser, String issuer) throws AAIException {
+ private void authorize(String uri, String httpMethod, String authUser, String haProxyUser, String issuer)
+ throws AAIException {
if (!aaiAuthCore.authorize(authUser, uri, httpMethod, haProxyUser, issuer)) {
throw new AAIException("AAI_9101", "Request on " + httpMethod + " " + uri + " status is not OK");
}
@@ -176,8 +177,7 @@ public class TwoWaySslAuthorization extends OrderedRequestContextFilter {
private boolean isAafAuthProfileActive() {
String[] profiles = environment.getActiveProfiles();
if (profiles != null) {
- if (Arrays.stream(profiles).anyMatch(
- env -> (env.equalsIgnoreCase(AafProfiles.AAF_CERT_AUTHENTICATION)))) {
+ if (Arrays.stream(profiles).anyMatch(env -> (env.equalsIgnoreCase(AafProfiles.AAF_CERT_AUTHENTICATION)))) {
return true;
}
}
diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java
index 6fca4fdb..813e8fa1 100644
--- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java
+++ b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java
@@ -20,14 +20,14 @@
package org.onap.aai.aaf.auth;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.aai.aaf.auth.exceptions.AAIUnrecognizedFunctionException;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.aaf.auth.exceptions.AAIUnrecognizedFunctionException;
+
public class AAIAuthCoreTest extends AAISetup {
private AAIAuthCore authCore;
diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAISetup.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAISetup.java
index 0827782e..3284d7a1 100644
--- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAISetup.java
+++ b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAISetup.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aaf.auth;
import org.junit.BeforeClass;
@@ -24,7 +25,7 @@ import org.junit.BeforeClass;
public class AAISetup {
@BeforeClass
- public static void preSetup(){
+ public static void preSetup() {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java
index e3b79cb7..5f02f1aa 100644
--- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java
+++ b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java
@@ -20,10 +20,10 @@
package org.onap.aai.aaf.auth;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
public class AAIUserTest extends AAISetup {
@Test
diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java
index ebc72e23..46389d02 100644
--- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java
+++ b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java
@@ -35,28 +35,26 @@
*
*
*/
-package org.onap.aai.aaf.auth;
-
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import javax.servlet.http.HttpServletRequest;
+package org.onap.aai.aaf.auth;
import static org.easymock.EasyMock.*;
import static org.junit.Assert.assertEquals;
-public class AafRequestWrapperTest {
+import javax.servlet.http.HttpServletRequest;
+import org.junit.Test;
+public class AafRequestWrapperTest {
@Test
- public void testGetHeader(){
+ public void testGetHeader() {
HttpServletRequest mockRequest = createMock(HttpServletRequest.class);
expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_OU_HDR)).andReturn("m55555@org.onap.com:TEST").times(1, 4);
replay(mockRequest);
- AafRequestWrapper af= new AafRequestWrapper(mockRequest);
- assertEquals(af.getHeader("X-AAI-SSL-Client-OU"),"m55555@org.onap.com:TEST");
- af.putHeader("X-AAI-SSL-Client-C","test@org.onap.com:test");
- assertEquals(af.getHeader("X-AAI-SSL-Client-C"),"test@org.onap.com:test");
+ AafRequestWrapper af = new AafRequestWrapper(mockRequest);
+ assertEquals(af.getHeader("X-AAI-SSL-Client-OU"), "m55555@org.onap.com:TEST");
+ af.putHeader("X-AAI-SSL-Client-C", "test@org.onap.com:test");
+ assertEquals(af.getHeader("X-AAI-SSL-Client-C"), "test@org.onap.com:test");
}
}
diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java
index 9f307ac2..81a9c1b6 100644
--- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java
+++ b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java
@@ -20,18 +20,18 @@
package org.onap.aai.aaf.auth;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertTrue;
-import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.assertTrue;
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Test;
/**
* The Class CertUtilTest
diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java
index c3973b1b..601b8292 100644
--- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java
+++ b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java
@@ -35,26 +35,22 @@
*
*
*/
-package org.onap.aai.aaf.filters;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.util.AAIConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-import java.io.IOException;
+package org.onap.aai.aaf.filters;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
public class CadiPropsTest {
@Autowired
- CadiProps ca =new CadiProps("src/test/resources/bundleconfig-local/aaf/org.onap.aai.props");
+ CadiProps ca = new CadiProps("src/test/resources/bundleconfig-local/aaf/org.onap.aai.props");
@Test
- public void testGetCadiFileName(){
- assertEquals(ca.getCadiFileName(),"src/test/resources/bundleconfig-local/aaf/org.onap.aai.props");
+ public void testGetCadiFileName() {
+ assertEquals(ca.getCadiFileName(), "src/test/resources/bundleconfig-local/aaf/org.onap.aai.props");
assertNotNull(ca.getCadiProperties());
}
}
diff --git a/aai-annotations/src/main/java/org/onap/aai/schema/enums/ObjectMetadata.java b/aai-annotations/src/main/java/org/onap/aai/schema/enums/ObjectMetadata.java
index 1534c8d1..406800fd 100644
--- a/aai-annotations/src/main/java/org/onap/aai/schema/enums/ObjectMetadata.java
+++ b/aai-annotations/src/main/java/org/onap/aai/schema/enums/ObjectMetadata.java
@@ -127,7 +127,8 @@ public enum ObjectMetadata {
ALLOW_DIRECT_WRITE("allowDirectWrite"),
/**
* properties that are allowed to be in start node in a DSL
- * <br><b>comma separated list</b>
+ * <br>
+ * <b>comma separated list</b>
*/
DSL_START_NODE_PROPS("dslStartNodeProps");
diff --git a/aai-annotations/src/test/java/org/onap/aai/annotations/AnnotationsTest.java b/aai-annotations/src/test/java/org/onap/aai/annotations/AnnotationsTest.java
index e41ae284..c988ddfa 100644
--- a/aai-annotations/src/test/java/org/onap/aai/annotations/AnnotationsTest.java
+++ b/aai-annotations/src/test/java/org/onap/aai/annotations/AnnotationsTest.java
@@ -20,8 +20,6 @@
package org.onap.aai.annotations;
-import org.onap.aai.annotations.Metadata;
-
public class AnnotationsTest {
public AnnotationsTest() {
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;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java
index c826df3d..cddf953c 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java
@@ -20,13 +20,6 @@
package org.onap.aai.aailog.filter;
-import org.onap.aai.aailog.logs.ServiceName;
-import org.onap.logging.filter.base.AuditLogContainerFilter;
-import org.onap.logging.filter.base.Constants;
-import org.onap.logging.filter.base.SimpleMap;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.slf4j.MDC;
-
import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
@@ -34,6 +27,13 @@ import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.UriInfo;
+import org.onap.aai.aailog.logs.ServiceName;
+import org.onap.logging.filter.base.AuditLogContainerFilter;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.base.SimpleMap;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.MDC;
+
@PreMatching
@Priority(1)
public class AaiAuditLogContainerFilter extends AuditLogContainerFilter {
@@ -43,7 +43,7 @@ public class AaiAuditLogContainerFilter extends AuditLogContainerFilter {
String partnerName = headers.get(ONAPLogConstants.Headers.PARTNER_NAME);
if (partnerName == null || partnerName.isEmpty()) {
logger.trace("No valid X-ONAP-PartnerName header value. Checking X-FromAppId header for partnerName.");
- partnerName = headers.get (Constants.HttpHeaders.HEADER_FROM_APP_ID);
+ partnerName = headers.get(Constants.HttpHeaders.HEADER_FROM_APP_ID);
if (partnerName == null || partnerName.isEmpty()) {
logger.trace("No valid X-FromAppId header value. Checking User-Agent header for partnerName.");
partnerName = headers.get(HttpHeaders.USER_AGENT);
@@ -59,6 +59,7 @@ public class AaiAuditLogContainerFilter extends AuditLogContainerFilter {
}
MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
}
+
@Override
protected void setServiceName(ContainerRequestContext containerRequest) {
UriInfo uriInfo = containerRequest.getUriInfo();
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java
index 629587d5..348aaa2e 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java
@@ -17,11 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
+
import org.onap.aai.aailog.logs.ServiceName;
import org.onap.logging.filter.base.AbstractMetricLogFilter;
import org.onap.logging.filter.base.Constants;
@@ -33,11 +35,11 @@ import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
-public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRequest, ClientHttpResponse, HttpHeaders> implements ClientHttpRequestInterceptor {
+public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRequest, ClientHttpResponse, HttpHeaders>
+ implements ClientHttpRequestInterceptor {
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
- throws IOException
- {
+ throws IOException {
this.setInvocationId(request.getHeaders());
pre(request, request.getHeaders());
ClientHttpResponse resp = execution.execute(request, body);
@@ -45,6 +47,7 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
return resp;
}
+
protected void pre(HttpRequest request, HttpHeaders requestHeaders) {
try {
setupMDC(request);
@@ -54,6 +57,7 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
logger.warn("Error in RestClientLoggingInterceptor pre", e);
}
}
+
protected void setupHeaders(HttpRequest clientRequest, HttpHeaders requestHeaders) {
String requestId = extractRequestID(requestHeaders);
addHeader(requestHeaders, ONAPLogConstants.Headers.REQUEST_ID, requestId);
@@ -69,6 +73,7 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
addHeader(requestHeaders, ONAPLogConstants.Headers.PARTNER_NAME, pName);
}
}
+
protected String extractRequestID(HttpHeaders requestHeaders) {
String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
if (requestId == null || requestId.isEmpty()) {
@@ -80,13 +85,14 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
}
return requestId;
}
+
public void setInvocationId(HttpHeaders headers) {
String invocationId = null;
List<String> headerList = headers.get(ONAPLogConstants.Headers.INVOCATION_ID);
if (headerList != null && (!headerList.isEmpty())) {
for (String h : headerList) {
- if ( h != null && (!h.isEmpty()) ) {
+ if (h != null && (!h.isEmpty())) {
invocationId = h;
break;
}
@@ -98,6 +104,7 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
}
MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
}
+
@Override
protected void addHeader(HttpHeaders requestHeaders, String headerName, String headerValue) {
requestHeaders.add(headerName, headerValue);
@@ -106,18 +113,18 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
protected String getTargetServiceName(HttpRequest request) {
return (getServiceName(request));
}
- protected String getServiceName(HttpRequest request){
+
+ protected String getServiceName(HttpRequest request) {
String path = request.getURI().getRawPath();
- return(ServiceName.extractServiceName(path));
+ return (ServiceName.extractServiceName(path));
}
protected int getHttpStatusCode(ClientHttpResponse response) {
int result = 0;
- if (response != null ) {
+ if (response != null) {
try {
result = response.getStatusCode().value();
- }
- catch (IOException e) {
+ } catch (IOException e) {
logger.warn("Error in RestClientLoggingInterceptor getHttpStatusCode {}", e.getMessage());
}
}
@@ -126,11 +133,10 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
protected String getResponseCode(ClientHttpResponse response) {
String result = "";
- if (response != null ) {
+ if (response != null) {
try {
result = response.getStatusCode().toString();
- }
- catch (IOException e) {
+ } catch (IOException e) {
logger.warn("Error in RestClientLoggingInterceptor getResponseCode {}", e.getMessage());
}
}
@@ -138,7 +144,7 @@ public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRe
}
protected String getTargetEntity(HttpRequest request) {
- //TODO where do we get this from?
+ // TODO where do we get this from?
return Constants.DefaultValues.UNKNOWN_TARGET_ENTITY;
}
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java
index 7e332ec5..c09023d1 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
import com.sun.jersey.api.client.ClientHandler;
@@ -24,25 +25,27 @@ import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientRequest;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.filter.ClientFilter;
-import org.onap.aai.aailog.logs.ServiceName;
-import org.onap.logging.filter.base.Constants;
-import org.onap.logging.filter.base.MDCSetup;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.slf4j.*;
-import javax.ws.rs.core.MultivaluedMap;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.onap.aai.aailog.logs.ServiceName;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.*;
+
public class RestControllerClientLoggingInterceptor extends ClientFilter {
private static final Logger logger = LoggerFactory.getLogger(RestControllerClientLoggingInterceptor.class);
private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
private final MDCSetup mdcSetup;
private final String partnerName;
- public RestControllerClientLoggingInterceptor () {
+ public RestControllerClientLoggingInterceptor() {
mdcSetup = new MDCSetup();
partnerName = getPartnerName();
}
@@ -62,11 +65,11 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter {
return clientResponse;
}
- protected String getTargetServiceName(ClientRequest clientRequest) {
+ protected String getTargetServiceName(ClientRequest clientRequest) {
return getServiceName(clientRequest);
}
- protected String getServiceName(ClientRequest clientRequest) {
+ protected String getServiceName(ClientRequest clientRequest) {
String path = clientRequest.getURI().getRawPath();
return ServiceName.extractServiceName(path);
}
@@ -75,12 +78,11 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter {
return response.getStatus();
}
- protected String getResponseCode(ClientResponse clientResponse) {
+ protected String getResponseCode(ClientResponse clientResponse) {
return String.valueOf(clientResponse.getStatus());
}
-
- protected String getTargetEntity(ClientRequest ClientRequest) {
+ protected String getTargetEntity(ClientRequest ClientRequest) {
return Constants.DefaultValues.UNKNOWN_TARGET_ENTITY;
};
@@ -94,12 +96,13 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter {
logger.warn("Error in RestControllerClientLoggingInterceptor pre", e.getMessage());
}
}
+
public void setInvocationId(ClientRequest clientRequest) {
String invocationId = null;
MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders();
Object id = requestHeaders.get(ONAPLogConstants.Headers.INVOCATION_ID);
if (id != null) {
- invocationId = (String)id;
+ invocationId = (String) id;
}
requestHeaders.remove(ONAPLogConstants.Headers.INVOCATION_ID);
if (invocationId == null) {
@@ -107,6 +110,7 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter {
}
MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
}
+
protected void setupHeaders(ClientRequest clientRequest) {
String requestId = extractRequestID(clientRequest);
MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders();
@@ -118,14 +122,14 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter {
}
addHeader(requestHeaders, Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId);
addHeader(requestHeaders, ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- if (partnerName != null && (!partnerName.isEmpty())){
+ if (partnerName != null && (!partnerName.isEmpty())) {
addHeader(requestHeaders, ONAPLogConstants.Headers.PARTNER_NAME, partnerName);
}
}
protected void setupMDC(ClientRequest clientRequest) {
MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, getTargetServiceName(clientRequest));
MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
mdcSetup.setInvocationIdFromMDC();
@@ -151,15 +155,15 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter {
MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders();
Object requestIdObj = requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID);
if (requestIdObj != null) {
- requestId = (String)requestIdObj;
+ requestId = (String) requestIdObj;
}
- if ( requestId == null || requestId.isEmpty() ) {
+ if (requestId == null || requestId.isEmpty()) {
requestId = UUID.randomUUID().toString();
}
mdcSetup.setLogTimestamp();
mdcSetup.setElapsedTimeInvokeTimestamp();
logger.warn("No value found in MDC when checking key {} value will be set to {}",
- ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ ONAPLogConstants.MDCs.REQUEST_ID, requestId);
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
}
return requestId;
@@ -178,6 +182,7 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter {
logger.warn("Error in RestControllerClientLoggingInterceptor post", e.getMessage());
}
}
+
protected String getPartnerName() {
return mdcSetup.getProperty(Constants.Property.PARTNER_NAME);
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java
index 0269943b..da5923d6 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java
@@ -20,14 +20,14 @@
package org.onap.aai.aailog.logs;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
import org.onap.logging.filter.base.AbstractMetricLogFilter;
import org.onap.logging.filter.base.ONAPComponents;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.*;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
public class AaiDBMetricLog
extends AbstractMetricLogFilter<DBRequestWrapper, Response, MultivaluedMap<String, Object>> {
@@ -35,6 +35,7 @@ public class AaiDBMetricLog
private final String partnerName;
private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
private static final String TARGET_ENTITY = ONAPComponents.AAI.toString() + ".DB";
+
public AaiDBMetricLog(String subcomponent) {
partnerName = getPartnerName(subcomponent);
}
@@ -85,6 +86,7 @@ public class AaiDBMetricLog
logger.warn("Error in AaiDBMetricLog pre", e);
}
}
+
public void post(DBRequestWrapper request, Response response) {
try {
setLogTimestamp();
@@ -98,13 +100,13 @@ public class AaiDBMetricLog
logger.warn("Error in AaiDBMetricLog post", e);
}
}
+
@Override
public void setResponseStatusCode(int code) {
String statusCode;
if (code / 100 == 2) {
statusCode = ONAPLogConstants.ResponseStatus.COMPLETE.toString();
- }
- else {
+ } else {
statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
setErrorCode(code);
setErrorDesc(code);
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java
index ef11f08e..60d90a9c 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java
@@ -20,12 +20,12 @@
package org.onap.aai.aailog.logs;
+import java.util.UUID;
+
import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
-import java.util.UUID;
-
public class AaiDebugLog extends MDCSetup {
public void setupMDC() {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
index 35d206f0..0d3a573d 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
@@ -20,16 +20,15 @@
package org.onap.aai.aailog.logs;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
import org.onap.aai.logging.AaiElsErrorCode;
import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.*;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.regex.PatternSyntaxException;
-
public class AaiDmaapMetricLog extends MDCSetup {
protected static final Logger logger = LoggerFactory.getLogger(AaiDmaapMetricLog.class);
@@ -37,15 +36,16 @@ public class AaiDmaapMetricLog extends MDCSetup {
private static final String TARGET_ENTITY = "DMaaP";
public AaiDmaapMetricLog() {
- if(MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN) == null) {
- setServerFQDN();
- }
+ if (MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN) == null) {
+ setServerFQDN();
+ }
}
+
public void pre(String targetServiceName, String event, String transactionId, String serviceName) {
try {
MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
setLogTimestamp();
setElapsedTimeInvokeTimestamp();
MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, targetServiceName);
@@ -58,7 +58,7 @@ public class AaiDmaapMetricLog extends MDCSetup {
MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName);
}
setInvocationIdFromMDC();
- logger.info(ONAPLogConstants.Markers.INVOKE, event );
+ logger.info(ONAPLogConstants.Markers.INVOKE, event);
} catch (Exception e) {
logger.warn("Error in AaiDmaapMetricLog pre", e.getMessage());
@@ -82,8 +82,7 @@ public class AaiDmaapMetricLog extends MDCSetup {
String statusCode;
if (AaiElsErrorCode.SUCCESS.equals(aaiElsErrorCode)) {
statusCode = ONAPLogConstants.ResponseStatus.COMPLETE.toString();
- }
- else {
+ } else {
statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
MDC.put(ONAPLogConstants.MDCs.ERROR_CODE, aaiElsErrorCode);
MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, errorDescription);
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java
index 60460fff..75b602ec 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java
@@ -18,8 +18,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.logs;
+import java.util.UUID;
+
+import javax.ws.rs.core.Response;
+
import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.Logger;
@@ -29,9 +34,6 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
-import javax.ws.rs.core.Response;
-import java.util.UUID;
-
@Component
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class AaiScheduledTaskAuditLog extends MDCSetup {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java
index 2b78613d..19a11999 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java
@@ -17,7 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.logs;
+
import java.net.URI;
public interface DBRequestWrapper {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java
index 97f042f0..3f34081b 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java
@@ -17,16 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.logs;
public class ServiceName {
/**
* Extract the service name from a URI path
* Service name should be the URI path up to two levels down from the version or less
+ *
* @param path the URI path
* @return the service name
*/
- public static String extractServiceName (String path) {
+ public static String extractServiceName(String path) {
StringBuilder sBuilder = new StringBuilder();
String[] parts = path.split("/");
String part = "";
@@ -38,8 +40,8 @@ public class ServiceName {
break;
}
}
- if ((sBuilder.length() > 0) && (sBuilder.charAt(sBuilder.length()-1) == '/')) {
- sBuilder.deleteCharAt(sBuilder.length()-1);
+ if ((sBuilder.length() > 0) && (sBuilder.charAt(sBuilder.length() - 1) == '/')) {
+ sBuilder.deleteCharAt(sBuilder.length() - 1);
}
String serviceName = sBuilder.toString();
if (serviceName != null && (!serviceName.isEmpty())) {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
index fe51ab05..f356275e 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
@@ -26,10 +26,11 @@
package org.onap.aai.domain.restPolicyException;
-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-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java
index d7837f9f..613c76d8 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java
@@ -54,8 +54,9 @@ public class ObjectFactory {
public ObjectFactory() {
}
- /**a
- * * Create an instance of {@link Fult }.
+ /**
+ * a
+ * * Create an instance of {@link Fult }.
*
* @return the fault
*/
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java
index ae6b6da1..16f52ef2 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java
@@ -22,12 +22,13 @@ package org.onap.aai.domain.restPolicyException;
import com.fasterxml.jackson.annotation.*;
-import javax.annotation.Generated;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.annotation.Generated;
+
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"messageId", "text", "variables"})
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java
index e1df4512..708a1117 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java
@@ -22,10 +22,11 @@ package org.onap.aai.domain.restPolicyException;
import com.fasterxml.jackson.annotation.*;
-import javax.annotation.Generated;
import java.util.HashMap;
import java.util.Map;
+import javax.annotation.Generated;
+
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"requestError"})
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java
index 2b041840..717c1059 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java
@@ -22,10 +22,11 @@ package org.onap.aai.domain.restPolicyException;
import com.fasterxml.jackson.annotation.*;
-import javax.annotation.Generated;
import java.util.HashMap;
import java.util.Map;
+import javax.annotation.Generated;
+
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"policyException"})
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
index f4a4b47f..3685e5aa 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
@@ -26,10 +26,11 @@
package org.onap.aai.domain.restResponseInfo;
-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-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java
index 09558455..36a8cb79 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java
@@ -26,10 +26,11 @@
package org.onap.aai.domain.restServiceException;
-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-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java
index d812c37b..a0687637 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java
@@ -22,10 +22,11 @@ package org.onap.aai.domain.restServiceException;
import com.fasterxml.jackson.annotation.*;
-import javax.annotation.Generated;
import java.util.HashMap;
import java.util.Map;
+import javax.annotation.Generated;
+
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"requestError"})
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java
index 79fca83f..cff5f69d 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java
@@ -22,10 +22,11 @@ package org.onap.aai.domain.restServiceException;
import com.fasterxml.jackson.annotation.*;
-import javax.annotation.Generated;
import java.util.HashMap;
import java.util.Map;
+import javax.annotation.Generated;
+
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"serviceException"})
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java
index f215bd58..e3339fae 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java
@@ -22,12 +22,13 @@ package org.onap.aai.domain.restServiceException;
import com.fasterxml.jackson.annotation.*;
-import javax.annotation.Generated;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.annotation.Generated;
+
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"messageId", "text", "variables"})
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java
index 24228e83..320d5630 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java
@@ -22,13 +22,13 @@
package org.onap.aai.exceptions;
+import java.util.Collection;
+import java.util.LinkedList;
+
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.ErrorObject;
import org.onap.aai.logging.ErrorObjectNotFoundException;
-import java.util.Collection;
-import java.util.LinkedList;
-
public class AAIException extends Exception {
private static final String UPDATE_ERROR_PROPERTIES_BEFORE_USING_THIS_EXCEPTION_CODE =
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java
index 10e4782e..bdf5346d 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java
@@ -20,16 +20,18 @@
package org.onap.aai.logging;
+import static java.util.Base64.getDecoder;
+
import ch.qos.logback.access.pattern.AccessConverter;
import ch.qos.logback.access.spi.IAccessEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import java.security.cert.X509Certificate;
import javax.security.auth.x500.X500Principal;
import javax.servlet.http.HttpServletRequest;
-import java.security.cert.X509Certificate;
-import static java.util.Base64.getDecoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CNName extends AccessConverter {
protected static final Logger LOGGER = LoggerFactory.getLogger(CNName.class);
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java
index 1bc33f49..1cdee738 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java
@@ -69,6 +69,7 @@ public class ErrorLogHelper {
/**
* Load properties.
+ *
* @throws IOException the exception
* @throws ErrorObjectFormatException
*/
@@ -78,9 +79,10 @@ public class ErrorLogHelper {
final Properties properties = new Properties();
try (final FileInputStream fis = new FileInputStream(filePath)) {
- LOGGER.info("Found the error.properties in the following location: {}", AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
+ LOGGER.info("Found the error.properties in the following location: {}",
+ AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
properties.load(fis);
- } catch(Exception ex){
+ } catch (Exception ex) {
LOGGER.info("Unable to find the error.properties from filesystem so using file in jar");
if (is != null) {
properties.load(is);
@@ -572,16 +574,16 @@ public class ErrorLogHelper {
public static void logException(AAIException e) {
final ErrorObject errorObject = e.getErrorObject();
/*
- String severityCode = errorObject.getSeverityCode(errorObject.getSeverity());
-
- Severify should be left empty per Logging Specification 2019.11
- if (!StringUtils.isEmpty(severityCode)) {
- int sevCode = Integer.parseInt(severityCode);
- if (sevCode > 0 && sevCode <= 3) {
- LoggingContext.severity(sevCode);
- }
- }
- */
+ * String severityCode = errorObject.getSeverityCode(errorObject.getSeverity());
+ *
+ * Severify should be left empty per Logging Specification 2019.11
+ * if (!StringUtils.isEmpty(severityCode)) {
+ * int sevCode = Integer.parseInt(severityCode);
+ * if (sevCode > 0 && sevCode <= 3) {
+ * LoggingContext.severity(sevCode);
+ * }
+ * }
+ */
String stackTrace = "";
try {
stackTrace = LogFormatTools.getStackTop(e);
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java
index 2e849d25..20068e9e 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java
@@ -75,6 +75,7 @@ public class ErrorObject {
/**
* Instantiates a new error object.
+ *
* @param severity the severity
* @param errorCode the error code
* @param errorText the error text
@@ -305,6 +306,7 @@ public class ErrorObject {
public void setDetails(String details) {
this.details = details == null ? "" : details;
}
+
/**
* Sets the aai els error code.
*
@@ -313,6 +315,7 @@ public class ErrorObject {
public void setAaiElsErrorCode(String elsErrorCode) {
aaiElsErrorCode = elsErrorCode;
}
+
/**
* Gets the aai els error code.
*
@@ -321,6 +324,7 @@ public class ErrorObject {
public String getAaiElsErrorCode() {
return (aaiElsErrorCode);
}
+
/**
* Gets the error code string. This is also the string
* configured in Nagios to alert on
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java
index 13f324ec..97288af8 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java
@@ -20,14 +20,14 @@
package org.onap.aai.logging;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
public class LoggingContext {
private static final Logger logger = LoggerFactory.getLogger(LoggingContext.class);
@@ -43,7 +43,6 @@ public class LoggingContext {
public static final Map<String, String> responseMap = new HashMap();
-
// Specific Log Event Fields
public static enum LoggingField {
START_TIME("startTime"), REQUEST_ID("requestId"), SERVICE_INSTANCE_ID("serviceInstanceId"), SERVER_NAME(
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
index 93969795..a7a87dca 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
@@ -88,7 +88,8 @@ public class AAIApplicationConfig {
TRUSTSTORE_PASSWORD = retrieveTruststorePassword();
KEYSTORE_PASSWORD = retrieveKeystorePassword();
} catch (Exception fnfe) {
- final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties");
+ final InputStream is =
+ Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties");
LOGGER.info("Unable to find the application.properties from filesystem so using file in jar");
if (is != null) {
try {
@@ -108,7 +109,7 @@ public class AAIApplicationConfig {
/**
* Gets the key value
*
- * @param key the key
+ * @param key the key
* @param defaultValue the default value
* @return the string
*/
@@ -165,6 +166,7 @@ public class AAIApplicationConfig {
public static String getKeystore() throws AAIException {
return (get(SERVER_SSL_KEYSTORE_PROP_NAME));
}
+
/**
* Gets the PKCS12 keystore path
*
@@ -174,6 +176,7 @@ public class AAIApplicationConfig {
public static String getKeystorePkcs12() throws AAIException {
return (get(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME));
}
+
/**
* Gets the keystore path
*
@@ -196,12 +199,12 @@ public class AAIApplicationConfig {
}
try {
certPath = replaceProperties(certPath);
- }
- catch (AAIException e) {
+ } catch (AAIException e) {
return null;
}
return (retrieveKeystorePasswordWithCertPath(certPath));
}
+
/**
* Retrieve the keystore password
*
@@ -236,6 +239,7 @@ public class AAIApplicationConfig {
}
return keystorePassword;
}
+
/**
* Get the keystore password
*
@@ -244,6 +248,7 @@ public class AAIApplicationConfig {
public static String getKeystorePassword() {
return (KEYSTORE_PASSWORD);
}
+
/**
* Gets the truststore password
*
@@ -258,7 +263,6 @@ public class AAIApplicationConfig {
passphrasesFile = new File(certPath + PASSPHRASSES_FILENAME);
passphrasesStream = new FileInputStream(passphrasesFile);
-
Properties passphrasesProps = new Properties();
passphrasesProps.load(passphrasesStream);
truststorePassword = passphrasesProps.getProperty(TRUSTSTORE_PASSWORD_PROP_NAME);
@@ -281,6 +285,7 @@ public class AAIApplicationConfig {
return truststorePassword;
}
+
/**
* Gets the truststore password
*
@@ -293,8 +298,7 @@ public class AAIApplicationConfig {
}
try {
certPath = replaceProperties(certPath);
- }
- catch (AAIException e) {
+ } catch (AAIException e) {
return null;
}
return (retrieveTruststorePasswordWithCertPath(certPath));
@@ -352,17 +356,19 @@ public class AAIApplicationConfig {
private static String replaceProperties(String originalValue) throws AAIException {
final Pattern p = Pattern.compile(PROPERTY_REGEX);
Matcher m = p.matcher(originalValue);
- /*if (!m.matches()) {
- return originalValue;
- }*/
+ /*
+ * if (!m.matches()) {
+ * return originalValue;
+ * }
+ */
StringBuffer sb = new StringBuffer();
- while(m.find()) {
+ while (m.find()) {
String text = m.group(1);
String replacement = get(text);
m.appendReplacement(sb, replacement);
}
m.appendTail(sb);
- return(sb.toString());
+ return (sb.toString());
}
public static Properties retrieveKeystoreProps() throws AAIException {
@@ -374,7 +380,7 @@ public class AAIApplicationConfig {
String keystorePassword = System.getProperty(KEYSTORE_PASSWORD_NAME);
String certLocation = System.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
- if (truststorePath == null || truststorePath.isEmpty()){
+ if (truststorePath == null || truststorePath.isEmpty()) {
truststorePath = AAIApplicationConfig.getTruststore();
}
if (truststorePath != null) {
@@ -383,8 +389,7 @@ public class AAIApplicationConfig {
if (truststorePassword == null || truststorePassword.isEmpty()) {
if (certLocation != null && (!certLocation.isEmpty())) {
truststorePassword = AAIApplicationConfig.retrieveTruststorePasswordWithCertPath(certLocation);
- }
- else {
+ } else {
truststorePassword = AAIApplicationConfig.getTruststorePassword();
}
@@ -392,23 +397,22 @@ public class AAIApplicationConfig {
if (truststorePassword != null) {
props.setProperty(TRUSTSTORE_PASSWORD_NAME, truststorePassword);
}
- if (keystorePath == null || keystorePath.isEmpty()){
+ if (keystorePath == null || keystorePath.isEmpty()) {
keystorePath = AAIApplicationConfig.getKeystorePkcs12();
}
if (keystorePath != null) {
props.setProperty(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME, keystorePath);
}
- if (keystorePassword == null || keystorePassword.isEmpty()){
+ if (keystorePassword == null || keystorePassword.isEmpty()) {
if (certLocation != null && (!certLocation.isEmpty())) {
keystorePassword = AAIApplicationConfig.retrieveKeystorePasswordWithCertPath(certLocation);
- }
- else {
+ } else {
keystorePassword = AAIApplicationConfig.getKeystorePassword();
}
}
if (keystorePassword != null) {
props.setProperty(KEYSTORE_PASSWORD_NAME, keystorePassword);
}
- return(props);
+ return (props);
}
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java
index 2428f1e9..106640d8 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java
@@ -20,15 +20,15 @@
package org.onap.aai.util;
-import org.eclipse.jetty.util.security.Password;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.logging.ErrorLogHelper;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.util.Properties;
+
+import org.eclipse.jetty.util.security.Password;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.ErrorLogHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,7 +90,8 @@ public class AAIConfig {
propsInitialized = true;
serverProps = newServerProps;
} catch (Exception fnfe) {
- final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("aaiconfig.properties");
+ final InputStream is =
+ Thread.currentThread().getContextClassLoader().getResourceAsStream("aaiconfig.properties");
LOGGER.info("Unable to find the aaiconfig.properties from filesystem so using file in jar");
if (is != null) {
try {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java
index faacc527..e79bfec9 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
/**
@@ -31,11 +32,11 @@ package org.onap.aai.util;
// TODO - Find an better name for this interface name
public interface AAIConfigProxy {
- default String get(String key, String defaultValue){
+ default String get(String key, String defaultValue) {
return AAIConfig.get(key, defaultValue);
}
- default int getInt(String key, String defaultValue){
+ default int getInt(String key, String defaultValue) {
return AAIConfig.getInt(key, defaultValue);
}
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
index 95f9c1b7..1708b8c7 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
@@ -27,7 +27,7 @@ package org.onap.aai.util;
* as these keys are generated in a couple places, I made a class to contain that logic
*/
public class HbaseSaltPrefixer {
- // the number of hbase region servers per cluster
+ // the number of hbase region servers per cluster
private static int NUM_REGION_BUCKETS = 3;
private static class SingletonHolder {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java
index d856999e..9373eb71 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+
import org.onap.aai.exceptions.AAIException;
public class MapperUtil {
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java
index ce2f4489..222b98c2 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java
@@ -21,6 +21,7 @@
package org.onap.logging.filter.base;
import javax.servlet.http.HttpServletRequest;
+
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
index ab1daab5..dea496a5 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
@@ -24,6 +24,7 @@ import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
+
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java
index 28495c84..7f8017f7 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java
@@ -21,6 +21,7 @@
package org.onap.logging.filter.base;
import java.util.Enumeration;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.HttpHeaders;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java
index a0194850..530d53b3 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java
@@ -21,15 +21,14 @@
package org.onap.logging.filter.base;
import java.io.IOException;
+
import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.*;
import javax.ws.rs.core.Context;
-import javax.ws.rs.ext.Provider;
import javax.ws.rs.ext.Providers;
+
import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@Priority(1)
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java
index a8f5eae9..c2d8a96f 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java
@@ -23,6 +23,7 @@
package org.onap.logging.filter.base;
import java.io.IOException;
+
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -31,6 +32,7 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java
index 369a9f20..9b2503b7 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java
@@ -27,9 +27,11 @@ import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.UUID;
+
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
+
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -86,7 +88,7 @@ public class MDCSetup {
return requestId;
}
if (requestId != null && !requestId.isEmpty()) {
- //invalid
+ // invalid
return UUID.randomUUID().toString();
}
logger.trace("No valid X-ONAP-RequestID header value. Checking X-RequestID header for requestId.");
@@ -95,7 +97,7 @@ public class MDCSetup {
return requestId;
}
if (requestId != null && !requestId.isEmpty()) {
- //invalid
+ // invalid
return UUID.randomUUID().toString();
}
logger.trace("No valid X-RequestID header value. Checking X-TransactionID header for requestId.");
@@ -104,7 +106,7 @@ public class MDCSetup {
return requestId;
}
if (requestId != null && !requestId.isEmpty()) {
- //invalid
+ // invalid
return UUID.randomUUID().toString();
}
logger.trace("No valid X-TransactionID header value. Checking X-ECOMP-RequestID header for requestId.");
@@ -113,11 +115,12 @@ public class MDCSetup {
return requestId;
}
if (requestId != null && !requestId.isEmpty()) {
- //invalid
+ // invalid
return UUID.randomUUID().toString();
}
return requestId;
}
+
protected boolean isValidUUID(String transId) {
try {
UUID.fromString(transId);
@@ -126,6 +129,7 @@ public class MDCSetup {
}
return true;
}
+
public void setInvocationId(SimpleMap headers) {
String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID);
if (invocationId == null || invocationId.isEmpty())
@@ -200,7 +204,7 @@ public class MDCSetup {
}
public void clearClientMDCs() {
- //MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID);
+ // MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID);
MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE);
MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE);
@@ -230,7 +234,7 @@ public class MDCSetup {
logger.info("System property was null or empty. Checking environment variable for: {}", property);
propertyValue = System.getenv(property);
if (propertyValue == null || propertyValue.isEmpty()) {
- logger.info("Environment variable: {} was null or empty", property );
+ logger.info("Environment variable: {} was null or empty", property);
}
}
return propertyValue;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java
index da4d9827..986d1895 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java
@@ -25,10 +25,8 @@ import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.client.ClientResponseContext;
import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.Provider;
import javax.ws.rs.ext.Providers;
@Priority(0)
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java
index 06fbba9a..5465b7ce 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java
@@ -24,35 +24,7 @@ import java.util.EnumSet;
import java.util.Set;
public enum ONAPComponents implements ONAPComponentsList {
- OPENSTACK_ADAPTER,
- BPMN,
- GRM,
- AAI,
- DMAAP,
- POLICY,
- CATALOG_DB,
- REQUEST_DB,
- SNIRO,
- SDC,
- EXTERNAL,
- VNF_ADAPTER,
- SDNC_ADAPTER,
- MULTICLOUD,
- CLAMP,
- PORTAL,
- VID,
- APPC,
- DCAE,
- HOLMES,
- SDNC,
- SO,
- VFC,
- ESR,
- DBC,
- DR,
- MR,
- OPTF;
-
+ OPENSTACK_ADAPTER, BPMN, GRM, AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, SNIRO, SDC, EXTERNAL, VNF_ADAPTER, SDNC_ADAPTER, MULTICLOUD, CLAMP, PORTAL, VID, APPC, DCAE, HOLMES, SDNC, SO, VFC, ESR, DBC, DR, MR, OPTF;
public static Set<ONAPComponents> getSOInternalComponents() {
return EnumSet.of(OPENSTACK_ADAPTER, BPMN, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER);
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java
index 88c95aa4..1908d45f 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java
@@ -28,6 +28,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
@@ -38,6 +39,7 @@ import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.WriterInterceptor;
import javax.ws.rs.ext.WriterInterceptorContext;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java
index fa8533a7..cae4ebd6 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java
@@ -30,6 +30,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.zip.GZIPInputStream;
+
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java
index aafc74d4..4670f500 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java
@@ -37,48 +37,56 @@ import org.slf4j.event.Level;
* Extensible adapter for cheaply meeting ONAP logging obligations using
* an SLF4J facade.
*
- * <p>This can be used with any SLF4J-compatible logging provider, with
- * appropriate provider configuration.</p>
+ * <p>
+ * This can be used with any SLF4J-compatible logging provider, with
+ * appropriate provider configuration.
+ * </p>
*
- * <p>The basics are that:
+ * <p>
+ * The basics are that:
* <ul>
- * <li>{@link #entering} sets all MDCs.</li>
- * <li>{@link #exiting} unsets all MDCs *and* logs response information.</li>
- * <li>{@link #invoke} logs and returns a UUID to passed during invocation,
- * and optionally sets these for you on your downstream request by way of
- * an adapter.</li>
- * <li>Call {@link #getServiceDescriptor()} and its setters to set service-related MDCs.</li>
- * <li>Call {@link #getResponseDescriptor()} and its setters to set response-related MDCs.</li>
+ * <li>{@link #entering} sets all MDCs.</li>
+ * <li>{@link #exiting} unsets all MDCs *and* logs response information.</li>
+ * <li>{@link #invoke} logs and returns a UUID to passed during invocation,
+ * and optionally sets these for you on your downstream request by way of
+ * an adapter.</li>
+ * <li>Call {@link #getServiceDescriptor()} and its setters to set service-related MDCs.</li>
+ * <li>Call {@link #getResponseDescriptor()} and its setters to set response-related MDCs.</li>
* </ul>
* </p>
*
- * <p>Minimal usage is:
+ * <p>
+ * Minimal usage is:
* <ol>
- * <li>#entering(RequestAdapter)</li>
- * <li>#invoke, #invoke, ...</li>
- * <li>#getResponse + setters (or #setResponse)</li>
- * <li>#exiting</li>
+ * <li>#entering(RequestAdapter)</li>
+ * <li>#invoke, #invoke, ...</li>
+ * <li>#getResponse + setters (or #setResponse)</li>
+ * <li>#exiting</li>
* </ol>
* </p>
*
- * <p> ... if you're happy for service information to be automatically derived as follows:
+ * <p>
+ * ... if you're happy for service information to be automatically derived as follows:
* <ul>
- * <li><tt>ServiceName</tt> - from <tt>HttpServletRequest#getRequestURI()</tt></li>
- * <li><tt>InstanceUUID</tt> - classloader-scope UUID.</li>
+ * <li><tt>ServiceName</tt> - from <tt>HttpServletRequest#getRequestURI()</tt></li>
+ * <li><tt>InstanceUUID</tt> - classloader-scope UUID.</li>
* </ul>
* </p>
*
- * <p>... and if those defaults don't suit, then you can override using properties on
+ * <p>
+ * ... and if those defaults don't suit, then you can override using properties on
* {@link #getServiceDescriptor()}, or by injecting your own adapter using
* {@link #setServiceDescriptor(ServiceDescriptor)}, or by overriding
- * a <tt>protected</tt> methods like{@link #setEnteringMDCs}.</p>
+ * a <tt>protected</tt> methods like{@link #setEnteringMDCs}.
+ * </p>
*
- * <p>For everything else:
+ * <p>
+ * For everything else:
* <ul>
- * <li>The underlying SLF4J {@link Logger} can be retrieved using {@link #unwrap}.
- * Use this or create your own using the usual SLF4J factor.</li>
- * <li>Set whatever MDCs you like.</li>
- * <li>Log whatever else you like.</li>
+ * <li>The underlying SLF4J {@link Logger} can be retrieved using {@link #unwrap}.
+ * Use this or create your own using the usual SLF4J factor.</li>
+ * <li>Set whatever MDCs you like.</li>
+ * <li>Log whatever else you like.</li>
* </ul>
* </p>
*/
@@ -178,8 +186,7 @@ public class ONAPLogAdapter {
try {
this.mResponseDescriptor.setMDCs();
this.mLogger.info(ONAPLogConstants.Markers.EXIT, EMPTY_MESSAGE);
- }
- finally {
+ } finally {
MDC.clear();
}
return this;
@@ -188,8 +195,10 @@ public class ONAPLogAdapter {
/**
* Report pending invocation with <tt>INVOKE</tt> marker.
*
- * <p>If you call this variant, then YOU are assuming responsibility for
- * setting the requisite ONAP headers.</p>
+ * <p>
+ * If you call this variant, then YOU are assuming responsibility for
+ * setting the requisite ONAP headers.
+ * </p>
*
* @param sync whether synchronous.
* @return invocation ID to be passed with invocation.
@@ -218,8 +227,7 @@ public class ONAPLogAdapter {
* @param sync whether synchronous, nullable.
* @return invocation ID to be passed with invocation.
*/
- public UUID invoke(final RequestBuilder builder,
- final ONAPLogConstants.InvocationMode sync) {
+ public UUID invoke(final RequestBuilder builder, final ONAPLogConstants.InvocationMode sync) {
// Sync can be defaulted. Builder cannot.
@@ -233,8 +241,7 @@ public class ONAPLogAdapter {
builder.setHeader(ONAPLogConstants.Headers.REQUEST_ID,
defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)));
- builder.setHeader(ONAPLogConstants.Headers.INVOCATION_ID,
- defaultToEmpty(invocationID));
+ builder.setHeader(ONAPLogConstants.Headers.INVOCATION_ID, defaultToEmpty(invocationID));
builder.setHeader(ONAPLogConstants.Headers.PARTNER_NAME,
defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)));
@@ -245,15 +252,16 @@ public class ONAPLogAdapter {
* Report vanilla <tt>INVOKE</tt> marker.
*
* @param builder builder for downstream requests, if you want the
- * standard ONAP headers to be added automatically.
+ * standard ONAP headers to be added automatically.
* @return invocation ID to be passed with invocation.
*/
public UUID invoke(final RequestBuilder builder) {
- return this.invoke(builder, (ONAPLogConstants.InvocationMode)null);
+ return this.invoke(builder, (ONAPLogConstants.InvocationMode) null);
}
/**
* Get descriptor, for overriding service details.
+ *
* @return non-null descriptor.
*/
public ServiceDescriptor getServiceDescriptor() {
@@ -262,6 +270,7 @@ public class ONAPLogAdapter {
/**
* Override {@link ServiceDescriptor}.
+ *
* @param d non-null override.
* @return this.
*/
@@ -272,6 +281,7 @@ public class ONAPLogAdapter {
/**
* Get descriptor, for setting response details.
+ *
* @return non-null descriptor.
*/
public ResponseDescriptor getResponseDescriptor() {
@@ -280,6 +290,7 @@ public class ONAPLogAdapter {
/**
* Override {@link ResponseDescriptor}.
+ *
* @param d non-null override.
* @return this.
*/
@@ -297,9 +308,11 @@ public class ONAPLogAdapter {
/**
* Set MDCs that persist for the duration of an invocation.
*
- * <p>It would be better to roll this into {@link #entering}, like
+ * <p>
+ * It would be better to roll this into {@link #entering}, like
* with {@link #exiting}. Then it would be easier to do, but it
- * would mean more work. </p>
+ * would mean more work.
+ * </p>
*
* @param request incoming HTTP request.
* @return this.
@@ -318,8 +331,7 @@ public class ONAPLogAdapter {
// ServiceDescriptor to add them.
MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC)
- .format(DateTimeFormatter.ISO_INSTANT));
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestID);
MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationID);
MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
@@ -333,8 +345,8 @@ public class ONAPLogAdapter {
// Default the service name to the requestURI, in the event that
// no value has been provided.
- if (MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME) == null ||
- MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME).equalsIgnoreCase(EMPTY_MESSAGE)) {
+ if (MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME) == null
+ || MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME).equalsIgnoreCase(EMPTY_MESSAGE)) {
MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI());
}
@@ -390,7 +402,9 @@ public class ONAPLogAdapter {
/**
* Extensible descriptor for reporting service details.
*
- * <p>In most cases extension isn't required. </p>
+ * <p>
+ * In most cases extension isn't required.
+ * </p>
*/
public static class ServiceDescriptor {
@@ -402,6 +416,7 @@ public class ONAPLogAdapter {
/**
* Set name.
+ *
* @param name <tt>ServiceName</tt>.
* @return this.
*/
@@ -412,6 +427,7 @@ public class ONAPLogAdapter {
/**
* Set name.
+ *
* @param uuid <tt>InstanceUUID</tt>.
* @return this.
*/
@@ -507,11 +523,15 @@ public class ONAPLogAdapter {
/**
* Adapter for reading information from an incoming HTTP request.
*
- * <p>Incoming is generally easy, because in most cases you'll be able to
- * get your hands on the <tt>HttpServletRequest</tt>.</p>
+ * <p>
+ * Incoming is generally easy, because in most cases you'll be able to
+ * get your hands on the <tt>HttpServletRequest</tt>.
+ * </p>
*
- * <p>Perhaps should be generalized to refer to constants instead of
- * requiring the implementation of specific methods.</p>
+ * <p>
+ * Perhaps should be generalized to refer to constants instead of
+ * requiring the implementation of specific methods.
+ * </p>
*
* @param <T> type, for chaining.
*/
@@ -519,6 +539,7 @@ public class ONAPLogAdapter {
/**
* Get header by name.
+ *
* @param name header name.
* @return header value, or null.
*/
@@ -526,18 +547,21 @@ public class ONAPLogAdapter {
/**
* Get client address.
+ *
* @return address, if available.
*/
String getClientAddress();
/**
* Get server address.
+ *
* @return address, if available.
*/
String getServerAddress();
/**
* Get default service name, from service URI.
+ *
* @return service name default.
*/
String getRequestURI();
@@ -554,6 +578,7 @@ public class ONAPLogAdapter {
/**
* Construct adapter for HTTP request.
+ *
* @param request to be wrapped;
*/
public HttpServletRequestAdapter(final HttpServletRequest request) {
@@ -598,8 +623,10 @@ public class ONAPLogAdapter {
* vary a lot from caller to caller, since they each get to choose their
* own REST (or HTTP, or whatever) client APIs.
*
- * <p>No default implementation, because there's no HTTP client that's
- * sufficiently ubiquitous to warrant incurring a mandatory dependency.</p>
+ * <p>
+ * No default implementation, because there's no HTTP client that's
+ * sufficiently ubiquitous to warrant incurring a mandatory dependency.
+ * </p>
*
* @param <T> type, for chaining.
*/
@@ -607,6 +634,7 @@ public class ONAPLogAdapter {
/**
* Set HTTP header.
+ *
* @param name header name.
* @param value header value.
* @return this.
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java
index 77ca084d..027a99db 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java
@@ -27,7 +27,9 @@ import org.slf4j.MarkerFactory;
/**
* Constants for standard ONAP headers, MDCs, etc.
*
- * <p>See <tt>package-info.java</tt>.</p>
+ * <p>
+ * See <tt>package-info.java</tt>.
+ * </p>
*/
public final class ONAPLogConstants {
@@ -57,7 +59,7 @@ public final class ONAPLogConstants {
/** Marker reporting invocation. */
public static final Marker INVOKE = MarkerFactory.getMarker("INVOKE");
-
+
/** Marker reporting invocation return. */
public static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE_RETURN");
@@ -75,6 +77,7 @@ public final class ONAPLogConstants {
/**
* Build nested, detached marker.
+ *
* @param m1 top token.
* @param m2 sub-token.
* @return detached Marker.
@@ -114,7 +117,7 @@ public final class ONAPLogConstants {
/** MDC recording target service. */
public static final String TARGET_SERVICE_NAME = "TargetServiceName";
-
+
/** MDC recording target entity. */
public static final String TARGET_ENTITY = "TargetEntity";
@@ -124,7 +127,7 @@ public final class ONAPLogConstants {
/** MDC recording current service instance id. */
public static final String SERVICE_INSTANCE_ID = "ServiceInstanceID";
- /** MDC recording current instance id. */
+ /** MDC recording current instance id. */
public static final String INSTANCE_UUID = "InstanceID";
// Network. ////////////////////////////////////////////////////////////
@@ -148,14 +151,21 @@ public final class ONAPLogConstants {
* MDC recording timestamp at the start of the current request,
* with the same scope as {@link #REQUEST_ID}.
*
- * <p>Open issues:
+ * <p>
+ * Open issues:
+ * <ul>
* <ul>
- * <ul>Easily confused with {@link #INVOKE_TIMESTAMP}.</ul>
- * <ul>No mechanism for propagation between components, e.g. via HTTP headers.</ul>
- * <ul>Whatever mechanism we define, it's going to be costly.</ul>
+ * Easily confused with {@link #INVOKE_TIMESTAMP}.
+ * </ul>
+ * <ul>
+ * No mechanism for propagation between components, e.g. via HTTP headers.
+ * </ul>
+ * <ul>
+ * Whatever mechanism we define, it's going to be costly.
+ * </ul>
* </ul>
* </p>
- * */
+ */
public static final String ENTRY_TIMESTAMP = "EntryTimestamp";
/** MDC recording timestamp at the start of the current invocation. */
@@ -164,7 +174,7 @@ public final class ONAPLogConstants {
/** MDC recording elapsed time. */
public static final String ELAPSED_TIME = "ElapsedTime";
- /** MDC recording log timestamp. */
+ /** MDC recording log timestamp. */
public static final String LOG_TIMESTAMP = "LogTimestamp";
// Outcomes. ///////////////////////////////////////////////////////////
@@ -182,8 +192,8 @@ public final class ONAPLogConstants {
public static final String RESPONSE_STATUS_CODE = "StatusCode";
/** MDC recording error code. */
- public static final String ERROR_CODE = "ErrorCode";
-
+ public static final String ERROR_CODE = "ErrorCode";
+
/** MDC recording error description. */
public static final String ERROR_DESC = "ErrorDesc";
@@ -235,7 +245,7 @@ public final class ONAPLogConstants {
/** Not. */
ERROR,
-
+
/** In Progress. */
INPROGRESS
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java
index d9a62472..561cc94b 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java
@@ -9,7 +9,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,11 +22,12 @@
package org.onap.logging.ref.slf4j;
/**
- * <p>Code in here has potential application outside this reference
+ * <p>
+ * Code in here has potential application outside this reference
* example, and accordingly:
* <ul>
- * <li>Packaged in <tt>common</tt>.</li>
- * <li>Has minimal dependencies.</li>
+ * <li>Packaged in <tt>common</tt>.</li>
+ * <li>Has minimal dependencies.</li>
* </ul>
* </p>
- */ \ No newline at end of file
+ */
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java
index 5f23e668..246586d0 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java
@@ -17,8 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriInfo;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,16 +42,6 @@ import org.onap.logging.filter.base.Constants;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriInfo;
-import java.net.URI;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class AaiAuditLogContainerFilterTest {
@Mock
@@ -59,6 +61,7 @@ public class AaiAuditLogContainerFilterTest {
public void tearDown() {
MDC.clear();
}
+
@Test
public void partnerAndServiceNameValueTest() throws java.net.URISyntaxException {
@@ -69,8 +72,7 @@ public class AaiAuditLogContainerFilterTest {
URI uri = null;
try {
uri = new URI("https://localhost:9999/onap/aai/network/logical-link");
- }
- catch (java.net.URISyntaxException e) {
+ } catch (java.net.URISyntaxException e) {
throw e;
}
when(uriInfo.getAbsolutePath()).thenReturn(uri);
@@ -82,4 +84,3 @@ public class AaiAuditLogContainerFilterTest {
}
}
-
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java
index 601a13be..f8d23f39 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java
@@ -17,8 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.doReturn;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,75 +42,66 @@ import org.slf4j.MDC;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-
@RunWith(MockitoJUnitRunner.class)
public class RestClientLoggingInterceptorTest {
- @Mock
- private HttpRequest httpRequest;
+ @Mock
+ private HttpRequest httpRequest;
- @Spy
- @InjectMocks
- private RestClientLoggingInterceptor restClientLoggingInterceptor;
+ @Spy
+ @InjectMocks
+ private RestClientLoggingInterceptor restClientLoggingInterceptor;
- @After
- public void tearDown() {
- MDC.clear();
- }
+ @After
+ public void tearDown() {
+ MDC.clear();
+ }
- @Test
- public void setupHeadersTest() {
- String transId="37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
- HttpHeaders headers = new HttpHeaders();
- headers.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
- restClientLoggingInterceptor.setupHeaders(httpRequest, headers);
+ @Test
+ public void setupHeadersTest() {
+ String transId = "37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
+ HttpHeaders headers = new HttpHeaders();
+ headers.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
+ restClientLoggingInterceptor.setupHeaders(httpRequest, headers);
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
- assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
- }
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
+ assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
+ }
- @Test
- public void getServiceNameTest() throws URISyntaxException {
- URI uri = null;
- try {
- uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
- } catch (URISyntaxException e) {
- throw e;
- }
- doReturn(uri).when(httpRequest).getURI();
- String serviceName = restClientLoggingInterceptor.getServiceName(httpRequest);
-
- assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
+ @Test
+ public void getServiceNameTest() throws URISyntaxException {
+ URI uri = null;
+ try {
+ uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
+ } catch (URISyntaxException e) {
+ throw e;
}
+ doReturn(uri).when(httpRequest).getURI();
+ String serviceName = restClientLoggingInterceptor.getServiceName(httpRequest);
+
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
+ }
- @Test
- public void setupMDCTest() throws URISyntaxException {
- URI uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
- doReturn(uri).when(httpRequest).getURI();
- HttpHeaders headers = new HttpHeaders();
- restClientLoggingInterceptor.pre(httpRequest, headers);
- assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME) );
- assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- String serverFQDN = "";
- InetAddress addr = null;
- try {
- addr = InetAddress.getLocalHost();
- serverFQDN = addr.getCanonicalHostName();
+ @Test
+ public void setupMDCTest() throws URISyntaxException {
+ URI uri = new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1");
+ doReturn(uri).when(httpRequest).getURI();
+ HttpHeaders headers = new HttpHeaders();
+ restClientLoggingInterceptor.pre(httpRequest, headers);
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
+ assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ String serverFQDN = "";
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getLocalHost();
+ serverFQDN = addr.getCanonicalHostName();
- } catch (UnknownHostException e) {
- serverFQDN = "";
- }
- assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
- assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
+ } catch (UnknownHostException e) {
+ serverFQDN = "";
}
+ assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
+ assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
+ }
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java
index 48cb3efc..9c4b2655 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java
@@ -17,91 +17,91 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.aailog.filter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import com.sun.jersey.api.client.ClientRequest;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.logging.filter.base.Constants;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-
@RunWith(MockitoJUnitRunner.class)
public class RestControllerClientLoggingInterceptorTest {
- private ClientRequest clientRequest;
+ private ClientRequest clientRequest;
- @Spy
- @InjectMocks
- private RestControllerClientLoggingInterceptor restControllerClientLoggingInterceptor;
+ @Spy
+ @InjectMocks
+ private RestControllerClientLoggingInterceptor restControllerClientLoggingInterceptor;
- @Before
- public void init() throws URISyntaxException {
- System.setProperty("javax.ws.rs.ext.RuntimeDelegate", "com.sun.ws.rs.ext.RuntimeDelegateImpl");
- clientRequest = ClientRequest.create().build(new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1"),
- "GET");
- }
+ @Before
+ public void init() throws URISyntaxException {
+ System.setProperty("javax.ws.rs.ext.RuntimeDelegate", "com.sun.ws.rs.ext.RuntimeDelegateImpl");
+ clientRequest = ClientRequest.create().build(
+ new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1"), "GET");
+ }
- @After
- public void tearDown() {
- MDC.clear();
- }
+ @After
+ public void tearDown() {
+ MDC.clear();
+ }
- @Test
- public void setupHeadersTest() throws java.net.URISyntaxException {
-
- String transId="37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
- MultivaluedMap<String, Object> requestHeaders = new MultivaluedHashMap<String, Object>();
- requestHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
- clientRequest.getHeaders().putAll(requestHeaders);
- restControllerClientLoggingInterceptor.pre(clientRequest);
- MultivaluedMap<String, Object> headers = clientRequest.getHeaders();
-
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
- assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
- assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
- assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
- }
+ @Test
+ public void setupHeadersTest() throws java.net.URISyntaxException {
- @Test
- public void getServiceNameTest() {
- String serviceName = restControllerClientLoggingInterceptor.getServiceName(clientRequest);
- assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
- }
+ String transId = "37b3ab2a-e57e-4fe8-8d8f-eee3019efce6";
+ MultivaluedMap<String, Object> requestHeaders = new MultivaluedHashMap<String, Object>();
+ requestHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, transId);
+ clientRequest.getHeaders().putAll(requestHeaders);
+ restControllerClientLoggingInterceptor.pre(clientRequest);
+ MultivaluedMap<String, Object> headers = clientRequest.getHeaders();
+
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID));
+ assertEquals(transId, headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID));
+ assertEquals(transId, headers.getFirst(Constants.HttpHeaders.HEADER_REQUEST_ID));
+ assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID));
+ }
+
+ @Test
+ public void getServiceNameTest() {
+ String serviceName = restControllerClientLoggingInterceptor.getServiceName(clientRequest);
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", serviceName);
+ }
+
+ @Test
+ public void setupMDCTest() throws URISyntaxException {
+ restControllerClientLoggingInterceptor.pre(clientRequest);
+ assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
+ assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
+ String serverFQDN = "";
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getLocalHost();
+ serverFQDN = addr.getCanonicalHostName();
- @Test
- public void setupMDCTest() throws URISyntaxException {
- restControllerClientLoggingInterceptor.pre(clientRequest);
- assertEquals("/aai/v1/cloud-infrastructure/complexes", MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME) );
- assertEquals("INPROGRESS", MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
- String serverFQDN = "";
- InetAddress addr = null;
- try {
- addr = InetAddress.getLocalHost();
- serverFQDN = addr.getCanonicalHostName();
-
- } catch (UnknownHostException e) {
- serverFQDN = "";
- }
- assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
+ } catch (UnknownHostException e) {
+ serverFQDN = "";
}
+ assertEquals(serverFQDN, MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN));
+ }
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java
index 1d19e5bf..6e1b0ea4 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/InfoTest.java
@@ -26,11 +26,11 @@
package org.onap.aai.domain.restResponseInfo;
-import org.junit.Test;
+import static org.junit.Assert.assertTrue;
import java.util.List;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
public class InfoTest {
private Info info = new Info();
@@ -38,7 +38,8 @@ public class InfoTest {
@Test
public void infoTest() {
Info.ResponseMessages responseMessages = info.getResponseMessages();
- if (responseMessages == null) responseMessages = new Info.ResponseMessages();
+ if (responseMessages == null)
+ responseMessages = new Info.ResponseMessages();
List<Info.ResponseMessages.ResponseMessage> list = responseMessages.getResponseMessage();
Info.ResponseMessages.ResponseMessage respMsg = new Info.ResponseMessages.ResponseMessage();
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java
index 55205794..fe95d183 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/domain/restResponseInfo/ObjectFactoryTest.java
@@ -26,17 +26,19 @@
package org.onap.aai.domain.restResponseInfo;
-import org.junit.Test;
-
import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+
public class ObjectFactoryTest {
private ObjectFactory objectFactory = new ObjectFactory();
@Test
public void objectFactoryTest() {
- Info.ResponseMessages.ResponseMessage.Variables variables = objectFactory.createInfoResponseMessagesResponseMessageVariables();
- Info.ResponseMessages.ResponseMessage responseMessage = objectFactory.createInfoResponseMessagesResponseMessage();
+ Info.ResponseMessages.ResponseMessage.Variables variables =
+ objectFactory.createInfoResponseMessagesResponseMessageVariables();
+ Info.ResponseMessages.ResponseMessage responseMessage =
+ objectFactory.createInfoResponseMessagesResponseMessage();
Info.ResponseMessages responseMessages = objectFactory.createInfoResponseMessages();
Info info = objectFactory.createInfo();
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
index 4f08607f..b489a0ab 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java
@@ -17,25 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.exceptions;
-import org.junit.Test;
-import org.onap.aai.logging.AaiElsErrorCode;
-import org.onap.aai.logging.ErrorObject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import javax.ws.rs.core.Response;
import java.io.IOException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import javax.ws.rs.core.Response;
+import org.junit.Test;
+import org.onap.aai.logging.AaiElsErrorCode;
+import org.onap.aai.logging.ErrorObject;
public class AAIExceptionTest {
private AAIException aaiException;
@Test
public void defaultAAIExceptionTest() {
- //AAI_4000=5:4:ERROR:4000:500:3002:Internal Error:900
+ // AAI_4000=5:4:ERROR:4000:500:3002:Internal Error:900
aaiException = new AAIException();
assertEquals(AAIException.DEFAULT_EXCEPTION_CODE, aaiException.getCode());
@@ -53,7 +54,8 @@ public class AAIExceptionTest {
@Test
public void aaiExceptionTest() {
- //5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry:500
+ // 5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and
+ // retry:500
aaiException = new AAIException("AAI_3303");
assertEquals("AAI_3303", aaiException.getCode());
@@ -65,13 +67,15 @@ public class AAIExceptionTest {
assertEquals(errorObject.getRESTErrorCode(), "3300");
assertEquals(errorObject.getErrorCode(), "3303");
assertEquals(errorObject.getAaiElsErrorCode(), AaiElsErrorCode.BUSINESS_PROCESS_ERROR);
- assertEquals(errorObject.getErrorText(), "Too many objects would be returned by this request, please refine your request and retry");
+ assertEquals(errorObject.getErrorText(),
+ "Too many objects would be returned by this request, please refine your request and retry");
assertNotNull(aaiException.getTemplateVars());
}
@Test
public void aaiExceptionTestWithDetails() {
- //5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry:500
+ // 5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and
+ // retry:500
final String testDetails = "Test details";
aaiException = new AAIException("AAI_3303", testDetails);
assertEquals(testDetails, aaiException.getMessage());
@@ -98,4 +102,3 @@ public class AAIExceptionTest {
assertNotNull(aaiException.getTemplateVars());
}
}
-
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java
index dbfe60d5..84284ec5 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java
@@ -17,15 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.exceptions;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.HashMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
public class AAIExceptionWithInfoTest {
@@ -36,7 +37,7 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithInfoTest() {
- aaiException = new AAIExceptionWithInfo(new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo(new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertNotNull(aaiException.getInfoHash());
@@ -44,7 +45,7 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithCodeInfoTest() {
- aaiException = new AAIExceptionWithInfo("AAI_3300", new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo("AAI_3300", new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertEquals("AAI_3300", aaiException.getCode());
@@ -54,7 +55,7 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithCodeDetailsInfoTest() {
- aaiException = new AAIExceptionWithInfo("AAI_3300", testDetails, new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo("AAI_3300", testDetails, new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertEquals("AAI_3300", aaiException.getCode());
@@ -65,7 +66,8 @@ public class AAIExceptionWithInfoTest {
@Test
public void aaiExceptionWithCodeThrowableDetailsInfoTest() {
- aaiException = new AAIExceptionWithInfo("AAI_3300", new IOException("File not found"), testDetails, new HashMap<String, Object>(), testInfo );
+ aaiException = new AAIExceptionWithInfo("AAI_3300", new IOException("File not found"), testDetails,
+ new HashMap<String, Object>(), testInfo);
assertEquals(testInfo, aaiException.getInfo());
assertEquals("AAI_3300", aaiException.getCode());
@@ -76,4 +78,3 @@ public class AAIExceptionWithInfoTest {
}
}
-
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java
index 01b7bda1..d95aefa0 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java
@@ -20,7 +20,15 @@
package org.onap.aai.logging;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
import ch.qos.logback.access.spi.IAccessEvent;
+
+import java.security.cert.X509Certificate;
+
+import javax.security.auth.x500.X500Principal;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,12 +38,6 @@ import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.mock.web.MockHttpServletRequest;
-import javax.security.auth.x500.X500Principal;
-import java.security.cert.X509Certificate;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class CNNameTest {
@Mock
@@ -52,8 +54,9 @@ public class CNNameTest {
public void setup() {
when(cnName.isStarted()).thenReturn(true);
}
+
@Test
- public void basicAuthTest(){
+ public void basicAuthTest() {
MockHttpServletRequest https = new MockHttpServletRequest();
https.addHeader("Authorization", "Basic dXNlcjpwYXNzd29yZA==");
@@ -64,8 +67,9 @@ public class CNNameTest {
assertEquals("user", cnName.convert(accessEvent));
}
+
@Test
- public void incorrectHeaderBasicAuthTest(){
+ public void incorrectHeaderBasicAuthTest() {
MockHttpServletRequest https = new MockHttpServletRequest();
@@ -77,8 +81,9 @@ public class CNNameTest {
assertEquals("-", cnName.convert(accessEvent));
}
+
@Test
- public void noCipherSuiteTest(){
+ public void noCipherSuiteTest() {
MockHttpServletRequest https = new MockHttpServletRequest();
@@ -90,17 +95,18 @@ public class CNNameTest {
assertEquals("-", cnName.convert(accessEvent));
}
+
@Test
- public void certificateTest(){
+ public void certificateTest() {
String testSubject = "CN=TestName, OU=TestOU, O=TestOrg, C=Country";
- X509Certificate[] certChain = { cert };
+ X509Certificate[] certChain = {cert};
MockHttpServletRequest https = new MockHttpServletRequest();
https.setAttribute("javax.servlet.request.cipher_suite", "");
- https.setAttribute("javax.servlet.request.X509Certificate", certChain );
+ https.setAttribute("javax.servlet.request.X509Certificate", certChain);
when(accessEvent.getRequest()).thenReturn(https);
- when(cert.getSubjectX500Principal()).thenReturn(new X500Principal(testSubject) );
+ when(cert.getSubjectX500Principal()).thenReturn(new X500Principal(testSubject));
assertEquals(testSubject, cnName.convert(accessEvent));
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java
index 71a07aa1..28be0bf0 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java
@@ -20,16 +20,16 @@
package org.onap.aai.logging;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
public class CustomLogPatternLayoutTest {
private CustomLogPatternLayout customLogPatternLayout = new CustomLogPatternLayout();
@Test
- public void defaultConverterTest(){
+ public void defaultConverterTest() {
assertEquals(customLogPatternLayout.getDefaultConverterMap().get("z"), CNName.class.getName());
assertEquals(customLogPatternLayout.getDefaultConverterMap().get("y"), DME2RestFlag.class.getName());
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
index 737cb624..c29e29d6 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java
@@ -20,7 +20,11 @@
package org.onap.aai.logging;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
import ch.qos.logback.access.spi.IAccessEvent;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,9 +33,6 @@ import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class DME2RestFlagTest {
@@ -46,8 +47,9 @@ public class DME2RestFlagTest {
public void setup() {
when(dme2RestFlag.isStarted()).thenReturn(true);
}
+
@Test
- public void dme2Test(){
+ public void dme2Test() {
String[] contextArray = {"a", "b", "c"};
String[] routeOfferArray = {"d", "e", "f"};
String[] versionArray = {"1", "2", "3"};
@@ -56,8 +58,9 @@ public class DME2RestFlagTest {
when(accessEvent.getRequestParameter("version")).thenReturn(versionArray);
assertEquals("DME2", dme2RestFlag.convert(accessEvent));
}
+
@Test
- public void restTest(){
+ public void restTest() {
String[] contextArray = {""};
String[] routeOfferArray = {""};
String[] versionArray = {""};
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java
index ae174691..99522771 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java
@@ -20,6 +20,16 @@
package org.onap.aai.logging;
+import static java.lang.Thread.sleep;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -32,15 +42,6 @@ import org.onap.aai.util.LogFile;
import org.onap.aai.util.MapperUtil;
import org.slf4j.MDC;
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static java.lang.Thread.sleep;
-import static org.junit.Assert.*;
-
public class ErrorLogHelperTest {
private static final String ErrorLogFileName = "error.log";
@@ -50,14 +51,16 @@ public class ErrorLogHelperTest {
System.setProperty("AJSC_HOME", ".");
}
+
@After
- public void cleanup() throws IOException{
+ public void cleanup() throws IOException {
MDC.clear();
LogFile.deleteContents(ErrorLogFileName);
}
+
@Test
public void logErrorTest() throws IOException, InterruptedException {
- //||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110
+ // ||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110
ErrorLogHelper.logError("AAI_6110");
sleep(5000);
String logContents = LogFile.getContents(ErrorLogFileName);
@@ -66,15 +69,15 @@ public class ErrorLogHelperTest {
String logContentParts[] = logContents.split("\\|");
- assertTrue(logContentParts.length >= 11 );
- assertEquals ("ERROR", logContentParts[7]);
- assertEquals (AaiElsErrorCode.BUSINESS_PROCESS_ERROR, logContentParts[8]);
- assertTrue (logContentParts[10].startsWith("ERR.5.4.6110"));
+ assertTrue(logContentParts.length >= 11);
+ assertEquals("ERROR", logContentParts[7]);
+ assertEquals(AaiElsErrorCode.BUSINESS_PROCESS_ERROR, logContentParts[8]);
+ assertTrue(logContentParts[10].startsWith("ERR.5.4.6110"));
}
@Test
public void logErrorWithMessageTest() throws IOException, InterruptedException {
- //||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110 message
+ // ||main|UNKNOWN||||ERROR|500|Node cannot be deleted:3100:Bad Request:|ERR.5.4.6110 message
String errorMessage = "Object is referenced by additional objects";
ErrorLogHelper.logError("AAI_6110", errorMessage);
sleep(5000);
@@ -84,14 +87,14 @@ public class ErrorLogHelperTest {
String logContentParts[] = logContents.split("\\|");
- assertTrue(logContentParts.length >= 11 );
- assertTrue (logContentParts[9].contains(errorMessage));
- assertTrue (logContentParts[10].startsWith("ERR.5.4.6110"));
+ assertTrue(logContentParts.length >= 11);
+ assertTrue(logContentParts[9].contains(errorMessage));
+ assertTrue(logContentParts[10].startsWith("ERR.5.4.6110"));
}
@Test
- public void getRESTAPIPolicyErrorResponseTest() throws AAIException{
- //AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2:300
+ public void getRESTAPIPolicyErrorResponseTest() throws AAIException {
+ // AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2:300
ArrayList<MediaType> headers = new ArrayList<MediaType>(Arrays.asList(MediaType.APPLICATION_JSON_TYPE));
ArrayList<String> args = new ArrayList<String>(Arrays.asList("PUT", "resource"));
@@ -110,9 +113,10 @@ public class ErrorLogHelperTest {
assertTrue(vars.contains("PUT"));
assertTrue(vars.contains("resource"));
}
+
@Test
- public void getRESTAPIServiceErrorResponseTest() throws AAIException{
- //AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
+ public void getRESTAPIServiceErrorResponseTest() throws AAIException {
+ // AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
ArrayList<MediaType> headers = new ArrayList<MediaType>(Arrays.asList(MediaType.APPLICATION_JSON_TYPE));
ArrayList<String> args = new ArrayList<String>();
@@ -120,7 +124,8 @@ public class ErrorLogHelperTest {
String errorResponse = ErrorLogHelper.getRESTAPIErrorResponse(headers, aaie, args);
assertNotNull(errorResponse);
- org.onap.aai.domain.restServiceException.RESTResponse resp = MapperUtil.readAsObjectOf(org.onap.aai.domain.restServiceException.RESTResponse.class, errorResponse);
+ org.onap.aai.domain.restServiceException.RESTResponse resp =
+ MapperUtil.readAsObjectOf(org.onap.aai.domain.restServiceException.RESTResponse.class, errorResponse);
org.onap.aai.domain.restServiceException.RequestError requestError = resp.getRequestError();
assertNotNull(requestError);
ServiceException serviceException = requestError.getServiceException();
@@ -128,9 +133,10 @@ public class ErrorLogHelperTest {
assertEquals("SVC3009", serviceException.getMessageId());
}
+
@Test
- public void getRESTAPIServiceErrorResponseWithLoggingTest() throws IOException, InterruptedException{
- //AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
+ public void getRESTAPIServiceErrorResponseWithLoggingTest() throws IOException, InterruptedException {
+ // AAI_3009=5:6:WARN:3009:400:3009:Malformed URL:300
ArrayList<MediaType> headers = new ArrayList<MediaType>(Arrays.asList(MediaType.APPLICATION_JSON_TYPE));
ArrayList<String> args = new ArrayList<String>();
@@ -143,8 +149,8 @@ public class ErrorLogHelperTest {
assertNotNull(logContents);
String logContentParts[] = logContents.split("\\|");
- assertTrue(logContentParts.length >= 11 );
- assertTrue (logContentParts[10].startsWith("ERR.5.6.3009"));
+ assertTrue(logContentParts.length >= 11);
+ assertTrue(logContentParts[10].startsWith("ERR.5.6.3009"));
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java
index a5a8e496..97934723 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java
@@ -20,10 +20,10 @@
package org.onap.aai.logging;
-import org.junit.Test;
-
import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
public class ErrorObjectFormatExceptionTest {
@Test
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java
index 8bffe4ff..6be89425 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java
@@ -20,11 +20,11 @@
package org.onap.aai.logging;
-import org.junit.Test;
+import static org.junit.Assert.*;
import java.io.IOException;
-import static org.junit.Assert.*;
+import org.junit.Test;
public class ErrorObjectNotFoundExceptionTest {
@@ -33,18 +33,21 @@ public class ErrorObjectNotFoundExceptionTest {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException();
assertTrue(e instanceof Exception);
}
+
@Test
public void errorObjectNotFoundExceptionWithMessageTest() {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException("Error Message");
assertTrue(e instanceof Exception);
assertEquals("Error Message", e.getMessage());
}
+
@Test
public void errorObjectNotFoundExceptionWithCauseTest() {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException(new ArithmeticException());
assertTrue(e instanceof Exception);
assertTrue(e.getCause() instanceof ArithmeticException);
}
+
@Test
public void errorObjectNotFoundExceptionWithMsgCauseTest() {
ErrorObjectNotFoundException e = new ErrorObjectNotFoundException("Error Message", new ArithmeticException());
@@ -52,10 +55,12 @@ public class ErrorObjectNotFoundExceptionTest {
assertTrue(e.getCause() instanceof ArithmeticException);
assertEquals("Error Message", e.getMessage());
}
+
@Test
public void errorObjectNotFoundExceptionTest() {
- ErrorObjectNotFoundException e = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
+ ErrorObjectNotFoundException e =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
assertTrue(e instanceof Exception);
assertTrue(e.getCause() instanceof ArithmeticException);
assertEquals("Error Message", e.getMessage());
@@ -63,7 +68,8 @@ public class ErrorObjectNotFoundExceptionTest {
assertTrue((e.getSuppressed())[0] instanceof IOException);
assertEquals("Test IO Exception", (e.getSuppressed())[0].getMessage());
- ErrorObjectNotFoundException e1 = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), false, true);
+ ErrorObjectNotFoundException e1 =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), false, true);
e1.addSuppressed(new IOException("Test IO Exception"));
assertTrue((e1.getSuppressed() == null) || e1.getSuppressed().length == 0);
@@ -72,29 +78,31 @@ public class ErrorObjectNotFoundExceptionTest {
@Test
public void errorObjectNotFoundExceptionStackTraceTest() {
- ErrorObjectNotFoundException e1 = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
+ ErrorObjectNotFoundException e1 =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, true);
try {
throw e1;
- }
- catch (ErrorObjectNotFoundException e) {
+ } catch (ErrorObjectNotFoundException e) {
StackTraceElement[] stackTrace = e.getStackTrace();
assertNotNull(stackTrace);
assertTrue(stackTrace.length > 0);
}
- ErrorObjectNotFoundException e2 = new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, false);
+ ErrorObjectNotFoundException e2 =
+ new ErrorObjectNotFoundException("Error Message", new ArithmeticException(), true, false);
try {
throw e2;
- }
- catch (ErrorObjectNotFoundException e) {
+ } catch (ErrorObjectNotFoundException e) {
StackTraceElement[] stackTrace = e.getStackTrace();
assertTrue(stackTrace == null || stackTrace.length == 0);
}
}
- /*public ErrorObjectNotFoundException(String message, Throwable cause, boolean enableSuppression,
- boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- // TODO Auto-generated constructor stub
- }*/
+ /*
+ * public ErrorObjectNotFoundException(String message, Throwable cause, boolean enableSuppression,
+ * boolean writableStackTrace) {
+ * super(message, cause, enableSuppression, writableStackTrace);
+ * // TODO Auto-generated constructor stub
+ * }
+ */
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
index ff20105c..a0fcf655 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
@@ -20,11 +20,11 @@
package org.onap.aai.logging;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import javax.ws.rs.core.Response;
-import static org.junit.Assert.assertEquals;
+import org.junit.Test;
public class ErrorObjectTest {
private ErrorObject errorObject;
@@ -37,18 +37,21 @@ public class ErrorObjectTest {
private static final String ERROR_TEXT = "Test data error";
private static final String ERROR_PATTERN = "ERR.5.4.4000";
private static final String ERROR_SEVERITY_CODE = "2";
+
@Test
public void errorObjectDefaultConstructorTest() {
errorObject = new ErrorObject();
assertEquals("3002", errorObject.getRESTErrorCode());
- assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()), errorObject.getHTTPResponseCode());
- assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
+ assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()),
+ errorObject.getHTTPResponseCode());
+ assertEquals(AaiElsErrorCode.UNKNOWN_ERROR, errorObject.getAaiElsErrorCode());
assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
}
+
@Test
public void errorObjectConstructor7Test() {
errorObject = new ErrorObject(ERROR_DISPOSITION, ERROR_CATEGORY, ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE,
- ERROR_REST_CODE, ERROR_CODE, ERROR_TEXT);
+ ERROR_REST_CODE, ERROR_CODE, ERROR_TEXT);
assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
assertEquals(ERROR_CATEGORY, errorObject.getCategory());
@@ -56,7 +59,7 @@ public class ErrorObjectTest {
assertEquals(ERROR_REST_CODE, errorObject.getRESTErrorCode());
assertEquals(ERROR_CODE, errorObject.getErrorCode());
assertEquals(ERROR_TEXT, errorObject.getErrorText());
- assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
+ assertEquals(AaiElsErrorCode.UNKNOWN_ERROR, errorObject.getAaiElsErrorCode());
assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
}
@@ -66,18 +69,20 @@ public class ErrorObjectTest {
assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
assertEquals(ERROR_CATEGORY, errorObject.getCategory());
- assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()), errorObject.getHTTPResponseCode());
+ assertEquals(Response.Status.fromStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()),
+ errorObject.getHTTPResponseCode());
assertEquals("3002", errorObject.getRESTErrorCode());
assertEquals(ERROR_CODE, errorObject.getErrorCode());
assertEquals(ERROR_TEXT, errorObject.getErrorText());
- assertEquals(AaiElsErrorCode.UNKNOWN_ERROR,errorObject.getAaiElsErrorCode());
+ assertEquals(AaiElsErrorCode.UNKNOWN_ERROR, errorObject.getAaiElsErrorCode());
assertEquals(ERROR_PATTERN, errorObject.getErrorCodeString());
assertEquals(ERROR_SEVERITY_CODE, errorObject.getSeverityCode(ERROR_SEVERITY));
}
@Test
public void errorObjectConstructor6Test() {
- errorObject = new ErrorObject(ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE, ERROR_CODE, ERROR_TEXT, ERROR_DISPOSITION, ERROR_CATEGORY);
+ errorObject = new ErrorObject(ERROR_SEVERITY, ERROR_HTTP_RESPONSE_CODE, ERROR_CODE, ERROR_TEXT,
+ ERROR_DISPOSITION, ERROR_CATEGORY);
assertEquals(ERROR_DISPOSITION, errorObject.getDisposition());
assertEquals(ERROR_SEVERITY, errorObject.getSeverity());
assertEquals(ERROR_CATEGORY, errorObject.getCategory());
@@ -91,5 +96,4 @@ public class ErrorObjectTest {
}
-
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java
index 695d7c08..b352cb14 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java
@@ -20,12 +20,12 @@
package org.onap.aai.logging;
-import org.junit.Test;
-import org.onap.aai.exceptions.AAIException;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+
public class LogFormatToolsTest {
@Test
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java
index 4fe60315..d793eb77 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java
@@ -20,20 +20,21 @@
package org.onap.aai.logging;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.MDC;
+import static org.junit.Assert.*;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Test;
+import org.slf4j.MDC;
public class LoggingContextTest {
@After
- public void cleanup(){
+ public void cleanup() {
MDC.clear();
}
+
@Test
public void elapsedTimeTest() {
LoggingContext.elapsedTime(300, TimeUnit.MILLISECONDS);
@@ -41,6 +42,7 @@ public class LoggingContextTest {
LoggingContext.init();
assertNull(MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString()));
}
+
@Test
public void stopWatchTest() {
LoggingContext.init();
@@ -53,6 +55,7 @@ public class LoggingContextTest {
assertFalse(LoggingContext.isStopWatchStarted());
assertTrue(elapsedTime > 0);
}
+
@Test
public void putClearTest() {
String testServiceName = "TEST-SVC-NAME";
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java
index 8a4123f0..2c9c52c5 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java
@@ -20,31 +20,33 @@
package org.onap.aai.logging;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class StopWatchNotStartedExceptionTest {
+import org.junit.Test;
+public class StopWatchNotStartedExceptionTest {
@Test
public void stopWatchNotStartedExceptionTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException();
assertTrue(e instanceof RuntimeException);
}
+
@Test
public void stopWatchNotStartedExceptionWithMessageTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException("Error Message");
assertTrue(e instanceof RuntimeException);
assertEquals("Error Message", e.getMessage());
}
+
@Test
public void stopWatchNotStartedExceptionWithCauseTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException(new ArithmeticException());
assertTrue(e instanceof RuntimeException);
assertTrue(e.getCause() instanceof ArithmeticException);
}
+
@Test
public void stopWatchNotStartedExceptionWithMsgCauseTest() {
StopWatchNotStartedException e = new StopWatchNotStartedException("Error Message", new ArithmeticException());
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java
index 50a2d053..34aecd56 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java
@@ -20,19 +20,20 @@
package org.onap.aai.logging;
+import static java.lang.Thread.sleep;
+import static org.junit.Assert.*;
+
import org.junit.After;
import org.junit.Test;
import org.slf4j.MDC;
-import static java.lang.Thread.sleep;
-import static org.junit.Assert.*;
-
public class StopWatchTest {
@After
public void cleanup() {
MDC.clear();
}
+
@Test
public void elapsedTimeTest() throws InterruptedException {
StopWatch.start();
@@ -40,6 +41,7 @@ public class StopWatchTest {
StopWatch.stop();
assertTrue(Long.parseLong(MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString())) >= 1000L);
}
+
@Test
public void elapsedTimeConditionalTest() throws InterruptedException {
StopWatch.conditionalStart();
@@ -49,12 +51,13 @@ public class StopWatchTest {
long elapsedTime = Long.parseLong(elapsedTimeStr);
assertTrue(elapsedTime >= 1000L);
}
+
@Test
public void clearTest() throws InterruptedException {
StopWatch.start();
sleep(1010);
StopWatch.stop();
- assertNotNull( MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString()));
+ assertNotNull(MDC.get(LoggingContext.LoggingField.ELAPSED_TIME.toString()));
StopWatch.clear();
assertNull(MDC.get(LoggingContext.LoggingField.STOP_WATCH_START.toString()));
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java
index 24efee3d..7d51ccc2 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java
@@ -19,15 +19,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class AAIApplicationConfigTest {
@Before
@@ -39,6 +40,7 @@ public class AAIApplicationConfigTest {
public void truststoreTest() throws AAIException {
assertEquals("truststore.jks", AAIApplicationConfig.getTruststore());
}
+
@Test
public void keystoreTest() throws AAIException {
assertEquals("keystore.jks", AAIApplicationConfig.getKeystore());
@@ -58,6 +60,7 @@ public class AAIApplicationConfigTest {
public void getValueTest() throws AAIException {
assertEquals("certificates", AAIApplicationConfig.get("server.certs.location"));
}
+
@Test
public void getIntValueTest() throws AAIException {
assertTrue(8446 == AAIApplicationConfig.getInt("server.port"));
@@ -70,6 +73,7 @@ public class AAIApplicationConfigTest {
@Test
public void getValueWithReplacementTest() throws AAIException {
- assertEquals("/opt/app/aai/etc/auth/aai-client-cert.p12", AAIApplicationConfig.get("schema.service.ssl.key-store"));
+ assertEquals("/opt/app/aai/etc/auth/aai-client-cert.p12",
+ AAIApplicationConfig.get("schema.service.ssl.key-store"));
}
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java
index 86d6c202..dad8c351 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java
@@ -19,14 +19,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
+import static org.junit.Assert.*;
+
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.Assert.*;
-
public class AAIConfigTest {
@Before
@@ -43,6 +44,7 @@ public class AAIConfigTest {
public void getValueTest() throws AAIException {
assertEquals("10", AAIConfig.get("aai.logging.maxStackTraceEntries"));
}
+
@Test
public void getIntValueTest() throws AAIException {
assertTrue(10 == AAIConfig.getInt("aai.logging.maxStackTraceEntries"));
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java
index 38ac5de5..b1be62a1 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java
@@ -19,13 +19,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
+import static org.junit.Assert.assertNotNull;
+
import org.junit.Test;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.Assert.assertNotNull;
-
public class FormatDateTest {
private FormatDate formatDate = null;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java
index b94686bb..3ace6f01 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/LogFile.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.util;
import java.io.File;
@@ -31,7 +32,7 @@ import org.apache.commons.io.IOUtils;
* Utility class to read/delete contents of log file
*/
public class LogFile {
-
+
public static String getContents(String fileName) throws IOException {
FileInputStream fileInputStream = null;
@@ -39,12 +40,13 @@ public class LogFile {
try {
fileInputStream = new FileInputStream("logs/" + fileName);
contents = IOUtils.toString(fileInputStream, "UTF-8");
- }
- finally {
- if (fileInputStream != null) fileInputStream.close();
+ } finally {
+ if (fileInputStream != null)
+ fileInputStream.close();
}
return contents;
}
+
public static void deleteContents(String fileName) throws IOException {
FileUtils.write(new File("logs/" + fileName), "", Charset.defaultCharset());
}
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java
index 119bdf1e..8ac9f12d 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java
@@ -22,11 +22,13 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,7 +63,6 @@ public class AuditLogContainerFilterTest {
MDC.clear();
}
-
@Test
public void filterTest() {
MultivaluedMap<String, String> headerMap = new MultivaluedHashMap<>();
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java
index d3f0f9f5..afdfe059 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java
@@ -21,12 +21,13 @@
package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.when;
+
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java
index 4d1f102a..6390c8ea 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java
@@ -21,8 +21,10 @@
package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
+
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
index 9c89da5a..e47db8ce 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java
@@ -24,11 +24,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;
+
import java.util.HashMap;
+
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java
index 6f6a0ff1..daa57625 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java
@@ -23,16 +23,17 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doReturn;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.HashMap;
-import java.util.Map;
+
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java
index c2446a3f..61e7014b 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java
@@ -22,11 +22,14 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+
import java.io.IOException;
import java.net.URISyntaxException;
+
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java
index e2c5da9c..0ae919fc 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java
@@ -21,8 +21,10 @@
package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
+
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
+
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java
index fff67768..ccde0000 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java
@@ -22,7 +22,9 @@ package org.onap.logging.filter.base;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
+
import javax.servlet.http.HttpServletRequest;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java
index 9549eaa9..f6ed9614 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java
@@ -21,20 +21,6 @@
package org.onap.logging.ref.slf4j;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.event.Level;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import javax.xml.bind.DatatypeConverter;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
@@ -44,6 +30,21 @@ import static org.hamcrest.core.IsSame.sameInstance;
import static org.hamcrest.core.StringEndsWith.endsWith;
import static org.hamcrest.number.OrderingComparison.lessThan;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.bind.DatatypeConverter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.event.Level;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
/**
* Tests for {@link ONAPLogAdapter}.
*/
@@ -68,8 +69,7 @@ public class ONAPLogAdapterTest {
try {
ONAPLogAdapter.checkNotNull(null);
Assert.fail("Should throw NullPointerException");
- }
- catch (final NullPointerException e) {
+ } catch (final NullPointerException e) {
}
}
@@ -126,12 +126,11 @@ public class ONAPLogAdapterTest {
assertThat(invokeTimestampString, endsWith("Z"));
final long invokeTimestamp = DatatypeConverter.parseDateTime(invokeTimestampString).getTimeInMillis();
assertThat(Math.abs(System.currentTimeMillis() - invokeTimestamp), lessThan(5000L));
- }
- finally {
+ } finally {
MDC.clear();
}
}
-
+
/**
* Test ENTERING with an EMPTY_STRING serviceName.
*/
@@ -166,8 +165,7 @@ public class ONAPLogAdapterTest {
assertThat(invokeTimestampString, endsWith("Z"));
final long invokeTimestamp = DatatypeConverter.parseDateTime(invokeTimestampString).getTimeInMillis();
assertThat(Math.abs(System.currentTimeMillis() - invokeTimestamp), lessThan(5000L));
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -217,8 +215,7 @@ public class ONAPLogAdapterTest {
assertThat(MDC.get("somekey"), is("somevalue"));
adapter.exiting();
assertThat(MDC.get("somekey"), nullValue());
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -238,7 +235,7 @@ public class ONAPLogAdapterTest {
final UUID asyncUUID = adapter.invoke(ONAPLogConstants.InvocationMode.SYNCHRONOUS);
assertThat(asyncUUID, notNullValue());
- final UUID agnosticUUID = adapter.invoke((ONAPLogConstants.InvocationMode)null);
+ final UUID agnosticUUID = adapter.invoke((ONAPLogConstants.InvocationMode) null);
assertThat(agnosticUUID, notNullValue());
}
@@ -253,13 +250,14 @@ public class ONAPLogAdapterTest {
final ONAPLogAdapter adapter = new ONAPLogAdapter(logger);
final Map<String, String> headers = new HashMap<>();
- final ONAPLogAdapter.RequestBuilder builder = new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
- @Override
- public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
- headers.put(name, value);
- return this;
- }
- };
+ final ONAPLogAdapter.RequestBuilder builder =
+ new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
+ @Override
+ public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
+ headers.put(name, value);
+ return this;
+ }
+ };
try {
final UUID uuid = adapter.invoke(builder, ONAPLogConstants.InvocationMode.SYNCHRONOUS);
@@ -267,8 +265,7 @@ public class ONAPLogAdapterTest {
assertThat(headers.get(ONAPLogConstants.Headers.INVOCATION_ID), is(uuid.toString()));
assertThat(headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME), is(true));
assertThat(headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID), is(true));
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -283,13 +280,14 @@ public class ONAPLogAdapterTest {
final ONAPLogAdapter adapter = new ONAPLogAdapter(logger);
final Map<String, String> headers = new HashMap<>();
- final ONAPLogAdapter.RequestBuilder builder = new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
- @Override
- public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
- headers.put(name, value);
- return this;
- }
- };
+ final ONAPLogAdapter.RequestBuilder builder =
+ new ONAPLogAdapter.RequestBuilder<ONAPLogAdapter.RequestBuilder>() {
+ @Override
+ public ONAPLogAdapter.RequestBuilder setHeader(final String name, final String value) {
+ headers.put(name, value);
+ return this;
+ }
+ };
try {
final UUID uuid = adapter.invoke(builder);
@@ -297,8 +295,7 @@ public class ONAPLogAdapterTest {
assertThat(headers.get(ONAPLogConstants.Headers.INVOCATION_ID), is(uuid.toString()));
assertThat(headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME), is(true));
assertThat(headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID), is(true));
- }
- finally {
+ } finally {
MDC.clear();
}
}
@@ -312,8 +309,7 @@ public class ONAPLogAdapterTest {
request.setRequestURI("/ctx0");
request.setServerName("srv0");
- final ONAPLogAdapter.HttpServletRequestAdapter adapter
- = new ONAPLogAdapter.HttpServletRequestAdapter(request);
+ final ONAPLogAdapter.HttpServletRequestAdapter adapter = new ONAPLogAdapter.HttpServletRequestAdapter(request);
assertThat(adapter.getHeader("uuid"), is(uuid.toString()));
assertThat(adapter.getRequestURI(), is("/ctx0"));
assertThat(adapter.getServerAddress(), is("srv0"));
@@ -323,8 +319,7 @@ public class ONAPLogAdapterTest {
public void testServiceDescriptor() {
final String uuid = UUID.randomUUID().toString();
- final ONAPLogAdapter.ServiceDescriptor adapter
- = new ONAPLogAdapter.ServiceDescriptor();
+ final ONAPLogAdapter.ServiceDescriptor adapter = new ONAPLogAdapter.ServiceDescriptor();
adapter.setServiceUUID(uuid);
adapter.setServiceName("name0");
@@ -341,8 +336,7 @@ public class ONAPLogAdapterTest {
public void testResponseDescriptor() {
final String uuid = UUID.randomUUID().toString();
- final ONAPLogAdapter.ResponseDescriptor adapter
- = new ONAPLogAdapter.ResponseDescriptor();
+ final ONAPLogAdapter.ResponseDescriptor adapter = new ONAPLogAdapter.ResponseDescriptor();
adapter.setResponseCode("code0");
adapter.setResponseDescription("desc0");
adapter.setResponseSeverity(Level.INFO);
@@ -385,20 +379,17 @@ public class ONAPLogAdapterTest {
// Generate (and log) an invocationID, then use it to
// invoke another component.
- final RESTClient client = new RESTClient(); // implements ONAPLogAdapter.RequestBuilder<RESTClient>.
+ final RESTClient client = new RESTClient(); // implements ONAPLogAdapter.RequestBuilder<RESTClient>.
adapter.invoke(client, ONAPLogConstants.InvocationMode.SYNCHRONOUS);
- final RESTRequest request = null; // TODO: build real request.
- final RESTResponse response = client.execute(request); // TODO: handle real response.
+ final RESTRequest request = null; // TODO: build real request.
+ final RESTResponse response = client.execute(request); // TODO: handle real response.
// Set response details prior to #exiting.
// (Obviously there'd be errorhandling, etc. IRL).
- adapter.getResponseDescriptor()
- .setResponseCode((String)null)
- .setResponseSeverity(Level.INFO)
+ adapter.getResponseDescriptor().setResponseCode((String) null).setResponseSeverity(Level.INFO)
.setResponseStatus(ONAPLogConstants.ResponseStatus.COMPLETE);
- }
- finally {
+ } finally {
// Return, logging EXIT marker, with response MDCs.
diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java
index 9a46f05b..6dc5e59c 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java
@@ -21,16 +21,16 @@
package org.onap.logging.ref.slf4j;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.testng.Assert;
import org.testng.annotations.Test;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-
/**
* Tests for {@link ONAPLogConstants}.
*/
@@ -51,8 +51,7 @@ public class ONAPLogConstantsTest {
c.setAccessible(true);
c.newInstance();
Assert.fail("Should fail for hidden constructor.");
- }
- catch (final InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class));
}
}
@@ -82,8 +81,7 @@ public class ONAPLogConstantsTest {
@Test
public void testInvocationModeToString() {
- assertThat(ONAPLogConstants.InvocationMode.SYNCHRONOUS.toString(),
- is("SYNCHRONOUS"));
+ assertThat(ONAPLogConstants.InvocationMode.SYNCHRONOUS.toString(), is("SYNCHRONOUS"));
}
@Test
@@ -114,8 +112,7 @@ public class ONAPLogConstantsTest {
try {
c.getDeclaredConstructors()[0].newInstance();
Assert.fail("Should fail for hidden constructor.");
- }
- catch (final IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
}
@@ -124,8 +121,7 @@ public class ONAPLogConstantsTest {
constructor.setAccessible(true);
constructor.newInstance();
Assert.fail("Should fail even when invoked.");
- }
- catch (final InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class));
}
}
diff --git a/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java b/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java
index ee21d167..660cac91 100644
--- a/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java
+++ b/aai-failover/src/main/java/org/onap/aai/failover/FailoverAspect.java
@@ -17,8 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.failover;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicLong;
+
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@@ -27,9 +31,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicLong;
-
@Aspect
@Component
public class FailoverAspect {
@@ -39,7 +40,7 @@ public class FailoverAspect {
private final FailoverMonitor failoverMonitor;
private final AtomicLong atomicLong;
- public FailoverAspect(FailoverMonitor failoverMonitor){
+ public FailoverAspect(FailoverMonitor failoverMonitor) {
this.failoverMonitor = failoverMonitor;
this.atomicLong = new AtomicLong(1l);
}
@@ -69,25 +70,22 @@ public class FailoverAspect {
@Around("@annotation(org.springframework.scheduling.annotation.Scheduled)")
public void preSchedule(ProceedingJoinPoint pointcut) throws Throwable {
- Object target = pointcut.getTarget();
+ Object target = pointcut.getTarget();
MethodSignature signature = (MethodSignature) pointcut.getSignature();
- String method = signature.getMethod().getName();
+ String method = signature.getMethod().getName();
- if(failoverMonitor.shouldRun()){
+ if (failoverMonitor.shouldRun()) {
atomicLong.set(1l);
pointcut.proceed();
} else {
long currentTime = new Date().getTime();
long lastMessageTime = atomicLong.get();
- if((currentTime - lastMessageTime) > 120000){
+ if ((currentTime - lastMessageTime) > 120000) {
atomicLong.compareAndSet(lastMessageTime, new Date().getTime());
LOGGER.debug("Not proceeding the task {}#{} due to is_primary set to false in failover.properties",
- target.getClass(),
- method
- );
+ target.getClass(), method);
}
}
}
}
-
diff --git a/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java b/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java
index cadddc24..731abe7c 100644
--- a/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java
+++ b/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.failover;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
+package org.onap.aai.failover;
import java.io.IOException;
import java.io.InputStream;
@@ -29,6 +27,9 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
@Component
public class FailoverMonitor {
@@ -43,9 +44,9 @@ public class FailoverMonitor {
Path failoverPath = Paths.get(failoverPropertiesPath);
- if(Files.exists(failoverPath)){
+ if (Files.exists(failoverPath)) {
Properties properties = new Properties();
- try (InputStream is = Files.newInputStream(failoverPath)){
+ try (InputStream is = Files.newInputStream(failoverPath)) {
properties.load(is);
// If the property is_primary is missing then it should proceed
return TRUE.equals(properties.getProperty(IS_PRIMARY, DEFAULT_FOR_PRIMARY));
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java b/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java
index 3470de9d..05d5ec0f 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java
@@ -20,12 +20,11 @@
package org.onap.aai.restclient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.Collections;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/NoAuthRestClient.java b/aai-rest/src/main/java/org/onap/aai/restclient/NoAuthRestClient.java
index b11b0333..b5585460 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/NoAuthRestClient.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/NoAuthRestClient.java
@@ -20,18 +20,16 @@
package org.onap.aai.restclient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
+
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.onap.aai.aailog.filter.RestClientLoggingInterceptor;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.http.client.ClientHttpRequestFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
-import javax.annotation.PostConstruct;
-
public abstract class NoAuthRestClient extends RestClient {
private static Logger logger = LoggerFactory.getLogger(NoAuthRestClient.class);
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/OneWaySSLRestClient.java b/aai-rest/src/main/java/org/onap/aai/restclient/OneWaySSLRestClient.java
index 5c359e27..614f6770 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/OneWaySSLRestClient.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/OneWaySSLRestClient.java
@@ -20,20 +20,19 @@
package org.onap.aai.restclient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
+import javax.net.ssl.SSLContext;
+
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.onap.aai.aailog.filter.RestClientLoggingInterceptor;
-import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.ResourceUtils;
import org.springframework.web.client.RestTemplate;
-import javax.annotation.PostConstruct;
-import javax.net.ssl.SSLContext;
-
public abstract class OneWaySSLRestClient extends RestClient {
private static Logger logger = LoggerFactory.getLogger(OneWaySSLRestClient.class);
@@ -61,12 +60,11 @@ public abstract class OneWaySSLRestClient extends RestClient {
String trustStore = getTruststorePath();
- SSLContext sslContext =
- SSLContextBuilder.create()
+ SSLContext sslContext = SSLContextBuilder.create()
.loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword).build();
HttpClient client =
- HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier((s, sslSession) -> true).build();
+ HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier((s, sslSession) -> true).build();
return client;
}
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java b/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java
index 47dd2f2d..9ed35def 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import java.io.File;
@@ -117,7 +118,8 @@ public class PropertyPasswordConfiguration implements ApplicationContextInitiali
Map<String, Object> propertyOverrides = new LinkedHashMap<>();
decodePasswords(propertySource, propertyOverrides);
if (!propertyOverrides.isEmpty()) {
- PropertySource<?> decodedProperties = new MapPropertySource("decoded "+ propertySource.getName(), propertyOverrides);
+ PropertySource<?> decodedProperties =
+ new MapPropertySource("decoded " + propertySource.getName(), propertyOverrides);
environment.getPropertySources().addBefore(propertySource.getName(), decodedProperties);
}
@@ -143,7 +145,8 @@ public class PropertyPasswordConfiguration implements ApplicationContextInitiali
}
private String decodePasswordsInString(String input) {
- if (input == null) return null;
+ if (input == null)
+ return null;
StringBuffer output = new StringBuffer();
Matcher matcher = decodePasswordPattern.matcher(input);
while (matcher.find()) {
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java b/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java
index 67fb01e1..6fd2ab60 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/RestClient.java
@@ -22,13 +22,12 @@
package org.onap.aai.restclient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/RestClientResponseErrorHandler.java b/aai-rest/src/main/java/org/onap/aai/restclient/RestClientResponseErrorHandler.java
index 9945275a..fdf1a1ce 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/RestClientResponseErrorHandler.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/RestClientResponseErrorHandler.java
@@ -20,11 +20,10 @@
package org.onap.aai.restclient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.ResponseErrorHandler;
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/TwoWaySSLRestClient.java b/aai-rest/src/main/java/org/onap/aai/restclient/TwoWaySSLRestClient.java
index f43d21c8..5ea4fc33 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/TwoWaySSLRestClient.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/TwoWaySSLRestClient.java
@@ -20,9 +20,6 @@
package org.onap.aai.restclient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -34,11 +31,12 @@ import javax.net.ssl.SSLContext;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
-import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.onap.aai.aailog.filter.RestClientLoggingInterceptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.ResourceUtils;
import org.springframework.web.client.RestTemplate;
-import org.onap.aai.aailog.filter.RestClientLoggingInterceptor;
public abstract class TwoWaySSLRestClient extends RestClient {
@@ -69,11 +67,11 @@ public abstract class TwoWaySSLRestClient extends RestClient {
String trustStore = getTruststorePath();
SSLContext sslContext =
- SSLContextBuilder.create().loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword)
- .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword).build();
+ SSLContextBuilder.create().loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword)
+ .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword).build();
HttpClient client =
- HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier((s, sslSession) -> true).build();
+ HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier((s, sslSession) -> true).build();
return client;
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java
index 5aa8d688..2e93ef95 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java
@@ -21,12 +21,12 @@
package org.onap.aai.schemaif;
-import org.onap.aai.schemaif.definitions.EdgeSchema;
-import org.onap.aai.schemaif.definitions.VertexSchema;
-
import java.util.Map;
import java.util.Set;
+import org.onap.aai.schemaif.definitions.EdgeSchema;
+import org.onap.aai.schemaif.definitions.VertexSchema;
+
public interface SchemaProvider {
/**
@@ -61,7 +61,8 @@ public interface SchemaProvider {
*
* @return The edge schema definition
*/
- EdgeSchema getEdgeSchema(String edgeType, String sourceVertex, String targetVertex, String version) throws SchemaProviderException;
+ EdgeSchema getEdgeSchema(String edgeType, String sourceVertex, String targetVertex, String version)
+ throws SchemaProviderException;
/**
* Get the list of edge definitions which are adjacent to the given vertex
@@ -82,7 +83,8 @@ public interface SchemaProvider {
*
* @return The list of edge schema definitions
*/
- Set<EdgeSchema> getEdgeSchemaForSourceTarget(String sourceType, String targetType, String version) throws SchemaProviderException;
+ Set<EdgeSchema> getEdgeSchemaForSourceTarget(String sourceType, String targetType, String version)
+ throws SchemaProviderException;
/**
* Get vertex map for a schema version
@@ -92,4 +94,4 @@ public interface SchemaProvider {
* @return The list of vertex types
*/
Map<String, VertexSchema> getVertexMap(String schemaVersion) throws SchemaProviderException;
- }
+}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderException.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderException.java
index 9a95c337..4fb99f0e 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderException.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderException.java
@@ -21,13 +21,12 @@
package org.onap.aai.schemaif;
-
public class SchemaProviderException extends Exception {
private static final long serialVersionUID = 8162385108397238865L;
-
- public SchemaProviderException() {}
+ public SchemaProviderException() {
+ }
public SchemaProviderException(String message) {
super(message);
@@ -41,7 +40,8 @@ public class SchemaProviderException extends Exception {
super(message, cause);
}
- public SchemaProviderException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ public SchemaProviderException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderMsgs.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderMsgs.java
index 9b2c1518..b3b32576 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderMsgs.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProviderMsgs.java
@@ -21,16 +21,16 @@
* ECOMP and OpenECOMP are trademarks
* and service marks of AT&T Intellectual Property.
*/
+
package org.onap.aai.schemaif;
import com.att.eelf.i18n.EELFResourceManager;
+
import org.onap.aai.cl.eelf.LogMessageEnum;
public enum SchemaProviderMsgs implements LogMessageEnum {
- SCHEMA_LOAD_ERROR,
- LOADED_SCHEMA_FILE,
- LOADED_DB_RULE_FILE;
-
+ SCHEMA_LOAD_ERROR, LOADED_SCHEMA_FILE, LOADED_DB_RULE_FILE;
+
static {
EELFResourceManager.loadMessageBundle("logging/SchemaProviderMsgs");
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/EdgeSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/EdgeSchema.java
index 5d259128..e2dbc09c 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/EdgeSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/EdgeSchema.java
@@ -18,24 +18,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.definitions;
import java.util.Map;
-
public class EdgeSchema {
protected String name;
protected String source;
protected String target;
protected Multiplicity multiplicity;
- protected Map<String,String> annotations;
- protected Map<String,PropertySchema> properties;
+ protected Map<String, String> annotations;
+ protected Map<String, PropertySchema> properties;
public enum Multiplicity {
- MANY_2_MANY,
- MANY_2_ONE,
- ONE_2_MANY,
- ONE_2_ONE
+ MANY_2_MANY, MANY_2_ONE, ONE_2_MANY, ONE_2_ONE
}
public String getName() {
@@ -58,7 +55,7 @@ public class EdgeSchema {
return properties.get(propName.toLowerCase());
}
- public Map<String,PropertySchema> getPropertySchemaList() {
+ public Map<String, PropertySchema> getPropertySchemaList() {
return properties;
}
@@ -66,7 +63,7 @@ public class EdgeSchema {
return annotations.get(annotation.toLowerCase());
}
- public Map<String,String> getAnnotations() {
+ public Map<String, String> getAnnotations() {
return annotations;
}
@@ -88,9 +85,8 @@ public class EdgeSchema {
EdgeSchema other = (EdgeSchema) obj;
- return (source.equals(other.getSource()))
- && (target.equals(other.getTarget()))
- && (name.equals(other.getName()));
+ return (source.equals(other.getSource())) && (target.equals(other.getTarget()))
+ && (name.equals(other.getName()));
}
public String toString() {
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/PropertySchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/PropertySchema.java
index a512da0b..c1021189 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/PropertySchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/PropertySchema.java
@@ -26,7 +26,6 @@ import java.util.Map;
import org.onap.aai.schemaif.SchemaProviderException;
import org.onap.aai.schemaif.definitions.types.DataType;
-
public class PropertySchema {
protected String name;
protected DataType dataType;
@@ -34,7 +33,7 @@ public class PropertySchema {
protected String defaultValue;
protected Boolean unique;
protected Boolean isReserved;
- protected Map<String,String> annotations;
+ protected Map<String, String> annotations;
public String getName() {
return name;
@@ -47,11 +46,11 @@ public class PropertySchema {
public Boolean isRequired() {
return required;
}
-
+
public Boolean isKey() {
return (unique && required);
}
-
+
public Boolean isUnique() {
return unique;
}
@@ -59,17 +58,17 @@ public class PropertySchema {
public String getDefaultValue() {
return defaultValue;
}
-
+
public Boolean isReserved() {
return isReserved;
}
-
+
public String getAnnotationValue(String annotation) {
return annotations.get(annotation.toLowerCase());
}
-
+
public Map<String, String> getAnnotations() {
- return annotations;
+ return annotations;
}
public Object validateValue(String value) throws SchemaProviderException {
@@ -77,10 +76,10 @@ public class PropertySchema {
if (obj == null) {
throw new SchemaProviderException("Invalid value for porperty '" + name + "': " + value);
}
-
- return obj;
+
+ return obj;
}
-
+
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(" property: " + getName() + "\n");
@@ -90,11 +89,11 @@ public class PropertySchema {
sb.append(" reserved: " + isReserved() + "\n");
sb.append(" default: " + getDefaultValue() + "\n");
sb.append(" annotations: " + "\n");
-
+
for (String annotation : annotations.keySet()) {
sb.append(" " + annotation + ": " + annotations.get(annotation) + "\n");
}
-
+
return sb.toString();
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/VertexSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/VertexSchema.java
index 7ad1cfc6..a31c70e2 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/VertexSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/VertexSchema.java
@@ -18,15 +18,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.definitions;
import java.util.Map;
-
public class VertexSchema {
protected String name;
- protected Map<String,PropertySchema> properties;
- protected Map<String,String> annotations;
+ protected Map<String, PropertySchema> properties;
+ protected Map<String, String> annotations;
public String getName() {
return name;
@@ -36,14 +36,14 @@ public class VertexSchema {
return properties.get(propName.toLowerCase());
}
- public Map<String,PropertySchema> getPropertySchemaList() {
+ public Map<String, PropertySchema> getPropertySchemaList() {
return properties;
}
- public Map<String,String> getAnnotationSchemaList() {
- return annotations;
+ public Map<String, String> getAnnotationSchemaList() {
+ return annotations;
}
-
+
public String getAnnotationValue(String annotation) {
return annotations.get(annotation.toLowerCase());
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/BooleanDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/BooleanDataType.java
index 52fb4ca5..a1d35138 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/BooleanDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/BooleanDataType.java
@@ -21,8 +21,7 @@
package org.onap.aai.schemaif.definitions.types;
-
-public class BooleanDataType extends DataType {
+public class BooleanDataType extends DataType {
public BooleanDataType() {
super(Type.BOOL);
}
@@ -32,7 +31,7 @@ public class BooleanDataType extends DataType {
if (value.equalsIgnoreCase("true") || (value.equalsIgnoreCase("false"))) {
return Boolean.parseBoolean(value);
}
-
+
return null;
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ComplexDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ComplexDataType.java
index e09c18fd..98a74d8e 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ComplexDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ComplexDataType.java
@@ -25,9 +25,9 @@ import java.util.List;
import org.onap.aai.schemaif.definitions.PropertySchema;
-public class ComplexDataType extends DataType {
+public class ComplexDataType extends DataType {
private List<PropertySchema> subProperties;
-
+
public ComplexDataType(List<PropertySchema> subProperties) {
super(Type.COMPLEX);
this.subProperties = subProperties;
@@ -36,23 +36,23 @@ public class ComplexDataType extends DataType {
public List<PropertySchema> getSubProperties() {
return subProperties;
}
-
+
@Override
public Object validateValue(String value) {
// TODO: Validate the complex type against the subProperties
return value;
}
-
+
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("COMPLEX[ ");
-
+
for (PropertySchema prop : getSubProperties()) {
sb.append(prop.getDataType().toString() + " ");
}
-
+
sb.append("]");
-
+
return sb.toString();
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java
index 2e2884b4..a51d70f9 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java
@@ -23,14 +23,7 @@ package org.onap.aai.schemaif.definitions.types;
public abstract class DataType {
public enum Type {
- STRING,
- BOOL,
- INT,
- LONG,
- FLOAT,
- LIST,
- MAP,
- COMPLEX
+ STRING, BOOL, INT, LONG, FLOAT, LIST, MAP, COMPLEX
}
private final Type type;
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/FloatDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/FloatDataType.java
index 17fb9485..d40a9845 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/FloatDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/FloatDataType.java
@@ -21,23 +21,22 @@
package org.onap.aai.schemaif.definitions.types;
-public class FloatDataType extends DataType {
+public class FloatDataType extends DataType {
public FloatDataType() {
super(Type.FLOAT);
}
@Override
public Object validateValue(String value) {
- // TODO: In Tosca, you can impose constraints such as min/max value.
+ // TODO: In Tosca, you can impose constraints such as min/max value.
// In future we can add this type of validation
Float floatValue;
try {
floatValue = Float.parseFloat(value);
- }
- catch (NumberFormatException e) {
+ } catch (NumberFormatException e) {
return null;
}
-
+
return floatValue;
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/IntDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/IntDataType.java
index 59eb788f..0911c8a5 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/IntDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/IntDataType.java
@@ -23,28 +23,26 @@ package org.onap.aai.schemaif.definitions.types;
import java.text.DecimalFormat;
-public class IntDataType extends DataType {
+public class IntDataType extends DataType {
public IntDataType() {
super(Type.INT);
}
@Override
public Object validateValue(String value) {
- // TODO: In Tosca, you can impose constraints such as min/max value.
+ // TODO: In Tosca, you can impose constraints such as min/max value.
// In future we can add this type of validation
Integer intValue;
try {
intValue = Integer.parseInt(value);
- }
- catch (NumberFormatException e) {
+ } catch (NumberFormatException e) {
// There is an edge case where an int value is stored as "x.0" in champ.
// In that case, we just want to drop the ".0" and treat it as a proper
// integer
try {
DecimalFormat decimalFormat = new DecimalFormat("0.#");
intValue = Integer.parseInt(decimalFormat.format(Double.valueOf(value)));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
return null;
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ListDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ListDataType.java
index 84adefec..4169ba1b 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ListDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/ListDataType.java
@@ -23,7 +23,7 @@ package org.onap.aai.schemaif.definitions.types;
public class ListDataType extends DataType {
private DataType listType;
-
+
public ListDataType(DataType listType) {
super(Type.LIST);
this.listType = listType;
@@ -32,7 +32,7 @@ public class ListDataType extends DataType {
public DataType getListType() {
return listType;
}
-
+
@Override
public Object validateValue(String value) {
// TODO: Break the string into a list and validate each element against the listType
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/LongDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/LongDataType.java
index 38195f9c..1c30054d 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/LongDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/LongDataType.java
@@ -21,23 +21,22 @@
package org.onap.aai.schemaif.definitions.types;
-public class LongDataType extends DataType {
+public class LongDataType extends DataType {
public LongDataType() {
super(Type.LONG);
}
@Override
public Object validateValue(String value) {
- // TODO: In Tosca, you can impose constraints such as min/max value.
+ // TODO: In Tosca, you can impose constraints such as min/max value.
// In future we can add this type of validation
Long longInt;
try {
longInt = Long.parseLong(value);
- }
- catch (NumberFormatException e) {
+ } catch (NumberFormatException e) {
return null;
}
-
+
return longInt;
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/MapDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/MapDataType.java
index 443f460e..b08cdb5f 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/MapDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/MapDataType.java
@@ -23,7 +23,7 @@ package org.onap.aai.schemaif.definitions.types;
public class MapDataType extends DataType {
private DataType mapType;
-
+
public MapDataType(DataType mapType) {
super(Type.MAP);
this.mapType = mapType;
@@ -32,7 +32,7 @@ public class MapDataType extends DataType {
public DataType getMapType() {
return mapType;
}
-
+
@Override
public Object validateValue(String value) {
// TODO: Break the string into a map and validate each element against the mapType
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/StringDataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/StringDataType.java
index 39487ea2..787ccda9 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/StringDataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/StringDataType.java
@@ -21,15 +21,15 @@
package org.onap.aai.schemaif.definitions.types;
-public class StringDataType extends DataType {
+public class StringDataType extends DataType {
public StringDataType() {
super(Type.STRING);
}
@Override
public Object validateValue(String value) {
- // TODO: In Tosca, you can impose constraints such as string length, regex matches, valid values,
- // string length maximums, etc. In future we can add this type of validation
+ // TODO: In Tosca, you can impose constraints such as string length, regex matches, valid values,
+ // string length maximums, etc. In future we can add this type of validation
return value;
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonEdgeSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonEdgeSchema.java
index e3bc450b..89a9eb83 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonEdgeSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonEdgeSchema.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json;
import java.util.HashMap;
@@ -30,10 +31,10 @@ import org.onap.aai.schemaif.json.definitions.JsonEdgeSchema;
public class FromJsonEdgeSchema extends EdgeSchema {
public static final String WILDCARD_CHAR = "*";
-
+
public FromJsonEdgeSchema() {
}
-
+
public FromJsonEdgeSchema(EdgeSchema other) {
// A shallow copy should suffice, as edge definitions don't change.
name = other.getName();
@@ -43,38 +44,38 @@ public class FromJsonEdgeSchema extends EdgeSchema {
properties = other.getPropertySchemaList();
annotations = other.getAnnotations();
}
-
+
public void fromJson(JsonEdgeSchema jsonEdge) throws SchemaProviderException {
name = jsonEdge.getLabel();
source = jsonEdge.getFrom();
target = jsonEdge.getTo();
-
- // TODO: At present, multiplicity isn't described in the JSON schema. By default, make everything
+
+ // TODO: At present, multiplicity isn't described in the JSON schema. By default, make everything
// many-to-many
multiplicity = Multiplicity.MANY_2_MANY;
-
+
// Populate annotation schema
- annotations = new HashMap<String,String>();
+ annotations = new HashMap<String, String>();
if (jsonEdge.getAnnotations() != null) {
- for (Map.Entry<String,String> entry : jsonEdge.getAnnotations().entrySet()) {
+ for (Map.Entry<String, String> entry : jsonEdge.getAnnotations().entrySet()) {
annotations.put(entry.getKey().toLowerCase(), entry.getValue());
}
}
-
+
// Currently edge properties are not supported in the json schema
- properties = new HashMap<String,PropertySchema>();
+ properties = new HashMap<String, PropertySchema>();
}
public void replaceWildcard(String vertexName) throws SchemaProviderException {
if (source.equals(WILDCARD_CHAR) && target.equals(WILDCARD_CHAR)) {
throw new SchemaProviderException("Edge definition with wildcard source and target: " + toString());
}
-
+
if (source.equals(WILDCARD_CHAR)) {
source = vertexName;
}
-
+
if (target.equals(WILDCARD_CHAR)) {
target = vertexName;
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonPropertySchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonPropertySchema.java
index ea522191..ad1cec27 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonPropertySchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonPropertySchema.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json;
import java.util.ArrayList;
@@ -40,7 +41,8 @@ import org.onap.aai.schemaif.json.definitions.JsonPropertySchema;
public class FromJsonPropertySchema extends PropertySchema {
- public void fromJson(JsonPropertySchema pSchema, boolean reserved, List<DataTypeDefinition> dataTypes) throws SchemaProviderException {
+ public void fromJson(JsonPropertySchema pSchema, boolean reserved, List<DataTypeDefinition> dataTypes)
+ throws SchemaProviderException {
name = pSchema.getName();
defaultValue = pSchema.getDefaultValue() == null ? "" : pSchema.getDefaultValue();
required = pSchema.getRequired() == null ? false : pSchema.getRequired();
@@ -49,68 +51,70 @@ public class FromJsonPropertySchema extends PropertySchema {
dataType = resolveDataType(pSchema.getDataType(), dataTypes);
// Populate annotations
- annotations = new HashMap<String,String>();
+ annotations = new HashMap<String, String>();
if (pSchema.getAnnotations() != null) {
- for (Map.Entry<String,String> entry : pSchema.getAnnotations().entrySet()) {
+ for (Map.Entry<String, String> entry : pSchema.getAnnotations().entrySet()) {
annotations.put(entry.getKey().toLowerCase(), entry.getValue());
}
}
}
-
- private DataType resolveDataType(String typeString, List<DataTypeDefinition> dataTypes) throws SchemaProviderException {
- if (typeString.equalsIgnoreCase("string")) {
+
+ private DataType resolveDataType(String typeString, List<DataTypeDefinition> dataTypes)
+ throws SchemaProviderException {
+ if (typeString.equalsIgnoreCase("string")) {
return new StringDataType();
}
-
+
if (typeString.equalsIgnoreCase("integer")) {
return new IntDataType();
}
if (typeString.equalsIgnoreCase("long")) {
- return new LongDataType();
+ return new LongDataType();
}
-
+
if (typeString.equalsIgnoreCase("boolean")) {
return new BooleanDataType();
}
-
+
if (typeString.startsWith("list:")) {
String segments[] = typeString.split(":");
DataType subType = resolveDataType(segments[1], dataTypes);
return new ListDataType(subType);
}
-
+
if (typeString.startsWith("map:")) {
String segments[] = typeString.split(":");
DataType subType = resolveDataType(segments[1], dataTypes);
return new MapDataType(subType);
}
-
+
// Must be a complex type
return resolveComplexDataType(typeString, dataTypes);
}
-
- private DataType resolveComplexDataType(String typeString, List<DataTypeDefinition> dataTypes) throws SchemaProviderException {
+
+ private DataType resolveComplexDataType(String typeString, List<DataTypeDefinition> dataTypes)
+ throws SchemaProviderException {
// It must be a custom/complex type.
DataTypeDefinition dType = null;
for (DataTypeDefinition d : dataTypes) {
- if ( (d.getName().equals(typeString)) ) {
+ if ((d.getName().equals(typeString))) {
dType = d;
break;
}
}
-
+
if (dType == null) {
throw new SchemaProviderException("Invalid data type: " + typeString);
}
-
+
List<PropertySchema> propList = new ArrayList<PropertySchema>();
for (JsonPropertySchema p : dType.getProperties()) {
FromJsonPropertySchema pSchema = new FromJsonPropertySchema();
pSchema.fromJson(p, false, dataTypes);
propList.add(pSchema);
}
-
+
return new ComplexDataType(propList);
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonVertexSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonVertexSchema.java
index 7a3251f1..5ce4b469 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonVertexSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/FromJsonVertexSchema.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json;
import java.util.HashMap;
@@ -31,12 +32,12 @@ import org.onap.aai.schemaif.json.definitions.DataTypeDefinition;
import org.onap.aai.schemaif.json.definitions.JsonPropertySchema;
import org.onap.aai.schemaif.json.definitions.JsonVertexSchema;
-
public class FromJsonVertexSchema extends VertexSchema {
- public void fromJson(JsonVertexSchema jsonVertex, List<DataTypeDefinition> dataTypes, List<JsonPropertySchema> commonProps) throws SchemaProviderException {
+ public void fromJson(JsonVertexSchema jsonVertex, List<DataTypeDefinition> dataTypes,
+ List<JsonPropertySchema> commonProps) throws SchemaProviderException {
name = jsonVertex.getName();
- properties = new HashMap<String,PropertySchema>();
- annotations = new HashMap<String,String>();
+ properties = new HashMap<String, PropertySchema>();
+ annotations = new HashMap<String, String>();
// Populate property schema
if (jsonVertex.getProperties() != null) {
@@ -46,7 +47,7 @@ public class FromJsonVertexSchema extends VertexSchema {
properties.put(propSchema.getName().toLowerCase(), propSchema);
}
}
-
+
// Add common properties
if (commonProps != null) {
for (JsonPropertySchema pSchema : commonProps) {
@@ -54,40 +55,39 @@ public class FromJsonVertexSchema extends VertexSchema {
propSchema.fromJson(pSchema, true, dataTypes);
properties.put(propSchema.getName().toLowerCase(), propSchema);
}
- }
- else {
- // TODO: This is a hack until the schema-service return the list of common props
+ } else {
+ // TODO: This is a hack until the schema-service return the list of common props
addCommonProps();
}
-
+
// Populate annotation schema
if (jsonVertex.getAnnotations() != null) {
- for (Map.Entry<String,String> entry : jsonVertex.getAnnotations().entrySet()) {
+ for (Map.Entry<String, String> entry : jsonVertex.getAnnotations().entrySet()) {
annotations.put(entry.getKey().toLowerCase(), entry.getValue());
}
}
-
- // The searchable and indexed annotations, need to grab these from the property annotations
+
+ // The searchable and indexed annotations, need to grab these from the property annotations
// and store them at the vertex level as well (backwards compatibility with OXM)
StringBuilder searchableVal = new StringBuilder();
StringBuilder indexedVal = new StringBuilder();
for (PropertySchema pSchema : properties.values()) {
- if ( (pSchema.getAnnotationValue("searchable") != null)
- && (pSchema.getAnnotationValue("searchable").equalsIgnoreCase("true")) ) {
+ if ((pSchema.getAnnotationValue("searchable") != null)
+ && (pSchema.getAnnotationValue("searchable").equalsIgnoreCase("true"))) {
if (searchableVal.length() > 0) {
searchableVal.append(",");
}
searchableVal.append(pSchema.getName());
}
- if ( (pSchema.getAnnotationValue("indexed") != null)
- && (pSchema.getAnnotationValue("indexed").equalsIgnoreCase("true")) ) {
+ if ((pSchema.getAnnotationValue("indexed") != null)
+ && (pSchema.getAnnotationValue("indexed").equalsIgnoreCase("true"))) {
if (indexedVal.length() > 0) {
indexedVal.append(",");
}
indexedVal.append(pSchema.getName());
}
}
-
+
if (searchableVal.length() > 0) {
annotations.put("searchable", searchableVal.toString());
}
@@ -105,10 +105,11 @@ public class FromJsonVertexSchema extends VertexSchema {
addCommonProperty("aai-last-mod-ts", false, false, "string", "false");
addCommonProperty("source-of-truth", false, false, "string", "false");
addCommonProperty("aai-uri", false, false, "string", "false");
-
+
}
-
- private void addCommonProperty(String name, boolean req, boolean unique, String type, String indexed) throws SchemaProviderException {
+
+ private void addCommonProperty(String name, boolean req, boolean unique, String type, String indexed)
+ throws SchemaProviderException {
JsonPropertySchema pSchema = new JsonPropertySchema();
pSchema.setName(name);
pSchema.setRequired(req);
@@ -116,14 +117,14 @@ public class FromJsonVertexSchema extends VertexSchema {
pSchema.setDataType(type);
pSchema.setDescription("");
pSchema.setDefaultValue("");
-
- Map<String,String> propAnnotations = new HashMap<String,String>();
+
+ Map<String, String> propAnnotations = new HashMap<String, String>();
propAnnotations.put("indexed", indexed);
propAnnotations.put("searchable", "false");
propAnnotations.put("source_of_truth_type", "AAI");
pSchema.setAnnotations(propAnnotations);
-
+
FromJsonPropertySchema propSchema = new FromJsonPropertySchema();
propSchema.fromJson(pSchema, true, null);
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
index 78ae6a6d..637bbfe4 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json;
import java.io.BufferedOutputStream;
@@ -50,13 +51,12 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
-
public class JsonSchemaProvider implements SchemaProvider {
// Logger logger = LoggerFactory.getInstance().getLogger(JsonSchemaProvider.class.getName());
Logger logger = LoggerFactory.getInstance().getLogger(SchemaProvider.class);
private JsonSchemaProviderConfig config;
- private Map<String,SchemaInstance> schemaCache = new ConcurrentHashMap<>();
+ private Map<String, SchemaInstance> schemaCache = new ConcurrentHashMap<>();
private RestTemplate restTemplate = null;
public JsonSchemaProvider(JsonSchemaProviderConfig config) {
@@ -140,7 +140,6 @@ public class JsonSchemaProvider implements SchemaProvider {
return;
}
-
String url = config.getSchemaServiceBaseUrl() + "/" + version;
HttpHeaders headers = new HttpHeaders();
@@ -148,30 +147,28 @@ public class JsonSchemaProvider implements SchemaProvider {
headers.put("X-TransactionId", Arrays.asList(java.util.UUID.randomUUID().toString()));
headers.setAccept(Arrays.asList(org.springframework.http.MediaType.APPLICATION_OCTET_STREAM));
- HttpEntity <String> entity = new HttpEntity<>(headers);
+ HttpEntity<String> entity = new HttpEntity<>(headers);
ResponseEntity<byte[]> response = restTemplate.exchange(url, HttpMethod.GET, entity, byte[].class);
-
if (response.getStatusCodeValue() == HttpStatus.NOT_FOUND.value()) {
logger.warn(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "version " + version + " not found");
throw new SchemaProviderException("Schema version " + version + " not found");
- }
- else if (response.getStatusCodeValue() != HttpStatus.OK.value()) {
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "failed to load version " + version + ": " + response.getBody());
+ } else if (response.getStatusCodeValue() != HttpStatus.OK.value()) {
+ logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR,
+ "failed to load version " + version + ": " + response.getBody());
throw new SchemaProviderException("Error getting schema version " + version + ":" + response.getBody());
}
try {
SchemaServiceResponse resp = SchemaServiceResponse.fromJson(unzipAndGetJSONString(response.getBody()));
loadSchema(resp.getData().toJson(), version);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "failed to load version " + version + ": "
- + response.getBody() + "\n" + writer.toString());
+ logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR,
+ "failed to load version " + version + ": " + response.getBody() + "\n" + writer.toString());
throw new SchemaProviderException("Error loading schema version " + version + ":" + ex.getMessage());
}
@@ -181,14 +178,15 @@ public class JsonSchemaProvider implements SchemaProvider {
static final int BUFFER = 512;
static final long TOOBIG = 0x6400000; // Max size of unzipped data, 100MB
- static final int TOOMANY = 1024; // Max number of files
+ static final int TOOMANY = 1024; // Max number of files
protected String unzipAndGetJSONString(byte[] inputData) throws java.io.IOException {
ZipEntry entry;
String result = "";
int entries = 0;
long total = 0;
- try (ByteArrayInputStream bis = new ByteArrayInputStream(inputData); ZipInputStream zis = new ZipInputStream(bis)) {
+ try (ByteArrayInputStream bis = new ByteArrayInputStream(inputData);
+ ZipInputStream zis = new ZipInputStream(bis)) {
while ((entry = zis.getNextEntry()) != null) {
int count;
byte[] data = new byte[BUFFER];
@@ -218,7 +216,7 @@ public class JsonSchemaProvider implements SchemaProvider {
}
private SchemaInstance getSchemaVersion(String version) throws SchemaProviderException {
- // TODO: For now, we are only supporting a single version of the schema. Load that
+ // TODO: For now, we are only supporting a single version of the schema. Load that
// version regardless of what the client asks for.
String versionToLoad = getLatestSchemaVersion();
SchemaInstance inst = schemaCache.get(versionToLoad);
@@ -236,7 +234,7 @@ public class JsonSchemaProvider implements SchemaProvider {
@Override
public Map<String, VertexSchema> getVertexMap(String schemaVersion) throws SchemaProviderException {
- return getSchemaVersion(schemaVersion).getVertexMap();
+ return getSchemaVersion(schemaVersion).getVertexMap();
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProviderConfig.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProviderConfig.java
index 3a235f63..b5d85d82 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProviderConfig.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProviderConfig.java
@@ -18,40 +18,44 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.schemaif.json;
+package org.onap.aai.schemaif.json;
public class JsonSchemaProviderConfig {
-
+
private String schemaServiceBaseUrl;
private String schemaServiceCertFile;
private String schemaServiceCertPwd;
private String serviceName;
-
+
public String getSchemaServiceBaseUrl() {
return schemaServiceBaseUrl;
}
+
public void setSchemaServiceBaseUrl(String schemaServiceBaseUrl) {
this.schemaServiceBaseUrl = schemaServiceBaseUrl;
}
-
+
public String getSchemaServiceCertFile() {
return schemaServiceCertFile;
}
+
public void setSchemaServiceCertFile(String schemaServiceCertFile) {
this.schemaServiceCertFile = schemaServiceCertFile;
}
-
+
public String getSchemaServiceCertPwd() {
return schemaServiceCertPwd;
}
+
public void setSchemaServiceCertPwd(String schemaServiceCertPwd) {
this.schemaServiceCertPwd = schemaServiceCertPwd;
}
-
+
public String getServiceName() {
return serviceName;
}
+
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaInstance.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaInstance.java
index 77a1c56b..cfd93862 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaInstance.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaInstance.java
@@ -33,49 +33,48 @@ import org.onap.aai.schemaif.definitions.VertexSchema;
public class SchemaInstance {
// vertex-name -> vertex-schema
private Map<String, VertexSchema> vertexMap = new HashMap<>();
-
+
// source:target:type -> edge-schema
private Map<String, EdgeSchema> edgeKeyMap = new HashMap<>();
-
+
// source:target -> edge-schema
private Map<String, Set<EdgeSchema>> edgeSourceTargetMap = new HashMap<>();
-
+
// vertex-name -> edge-schema
private Map<String, Set<EdgeSchema>> vertexEdgeMap = new HashMap<>();
-
+
public VertexSchema getVertexSchema(String vertexName) {
return vertexMap.get(vertexName.toLowerCase());
}
-
+
public EdgeSchema getEdgeSchema(String source, String target, String type) {
return edgeKeyMap.get(generateEdgeKey(source, target, type));
}
-
+
public Set<EdgeSchema> getEdgeSchemas(String source, String target) {
return edgeSourceTargetMap.get(source.toLowerCase() + ":" + target.toLowerCase());
}
-
+
public Set<EdgeSchema> getEdgeSchema(String vertexName) {
return vertexEdgeMap.get(vertexName.toLowerCase());
}
-
+
public void addVertex(VertexSchema v) {
vertexMap.put(v.getName().toLowerCase(), v);
}
-
+
public void addEdge(EdgeSchema e) throws SchemaProviderException {
- if (e.getSource().equals(FromJsonEdgeSchema.WILDCARD_CHAR) ||
- e.getTarget().equals(FromJsonEdgeSchema.WILDCARD_CHAR)) {
+ if (e.getSource().equals(FromJsonEdgeSchema.WILDCARD_CHAR)
+ || e.getTarget().equals(FromJsonEdgeSchema.WILDCARD_CHAR)) {
// Handle wildcard edges
for (VertexSchema vertex : vertexMap.values()) {
addWildcardEdge(e, vertex);
}
- }
- else {
+ } else {
addEdgeInternal(e);
}
}
-
+
private void addWildcardEdge(EdgeSchema e, VertexSchema vertex) throws SchemaProviderException {
FromJsonEdgeSchema newEdge = new FromJsonEdgeSchema(e);
newEdge.replaceWildcard(vertex.getName());
@@ -84,38 +83,38 @@ public class SchemaInstance {
private void addEdgeInternal(EdgeSchema e) {
edgeKeyMap.put(generateEdgeKey(e.getSource(), e.getTarget(), e.getName()), e);
-
+
Set<EdgeSchema> edgeListSource = vertexEdgeMap.get(e.getSource().toLowerCase());
Set<EdgeSchema> edgeListTarget = vertexEdgeMap.get(e.getTarget().toLowerCase());
-
+
if (edgeListSource == null) {
edgeListSource = new HashSet<EdgeSchema>();
}
if (edgeListTarget == null) {
edgeListTarget = new HashSet<EdgeSchema>();
}
-
+
edgeListSource.add(e);
edgeListTarget.add(e);
vertexEdgeMap.put(e.getSource().toLowerCase(), edgeListSource);
vertexEdgeMap.put(e.getTarget().toLowerCase(), edgeListTarget);
-
+
String sourceTargetKey = e.getSource().toLowerCase() + ":" + e.getTarget().toLowerCase();
Set<EdgeSchema> edgeList = edgeSourceTargetMap.get(sourceTargetKey);
if (edgeList == null) {
edgeList = new HashSet<EdgeSchema>();
}
-
+
edgeList.add(e);
edgeSourceTargetMap.put(sourceTargetKey, edgeList);
}
-
+
private String generateEdgeKey(String source, String target, String type) {
String key = source + ":" + target + ":" + type;
return key.toLowerCase();
}
public Map<String, VertexSchema> getVertexMap() {
- return vertexMap;
+ return vertexMap;
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java
index 0bc1760b..c5baf00a 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java
@@ -18,11 +18,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
+
import org.onap.aai.schemaif.SchemaProviderException;
import org.onap.aai.schemaif.json.definitions.JsonSchema;
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java
index 5be74c39..3f17c9be 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SecureClientHttpRequestFactory.java
@@ -21,7 +21,6 @@
package org.onap.aai.schemaif.json;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
@@ -38,7 +37,6 @@ import javax.net.ssl.X509TrustManager;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
-
public class SecureClientHttpRequestFactory extends SimpleClientHttpRequestFactory {
private static final String SSL_PROTOCOL = "TLS";
@@ -46,18 +44,15 @@ public class SecureClientHttpRequestFactory extends SimpleClientHttpRequestFacto
private static final String KEYSTORE_TYPE = "PKCS12";
private JsonSchemaProviderConfig config;
-
- public SecureClientHttpRequestFactory(JsonSchemaProviderConfig config) {
+ public SecureClientHttpRequestFactory(JsonSchemaProviderConfig config) {
super();
this.config = config;
}
@Override
- protected void prepareConnection(final HttpURLConnection connection, final String httpMethod)
- throws IOException {
+ protected void prepareConnection(final HttpURLConnection connection, final String httpMethod) throws IOException {
if (connection instanceof HttpsURLConnection) {
- ((HttpsURLConnection) connection)
- .setSSLSocketFactory(getSSLContext().getSocketFactory());
+ ((HttpsURLConnection) connection).setSSLSocketFactory(getSSLContext().getSocketFactory());
((HttpsURLConnection) connection).setHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String str, SSLSession sslSession) {
@@ -95,7 +90,7 @@ public class SecureClientHttpRequestFactory extends SimpleClientHttpRequestFacto
KeyStore ks = KeyStore.getInstance(KEYSTORE_TYPE);
char[] pwd = null;
- if (config.getSchemaServiceCertPwd()!= null) {
+ if (config.getSchemaServiceCertPwd() != null) {
pwd = config.getSchemaServiceCertPwd().toCharArray();
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/DataTypeDefinition.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/DataTypeDefinition.java
index 93c67bdc..59680538 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/DataTypeDefinition.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/DataTypeDefinition.java
@@ -18,22 +18,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json.definitions;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
import java.util.List;
import org.onap.aai.schemaif.SchemaProviderException;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
public class DataTypeDefinition {
private static final Gson gson = new GsonBuilder().create();
-
+
private String name;
private String description;
private List<JsonPropertySchema> properties;
-
+
public String getName() {
return name;
}
@@ -57,9 +58,9 @@ public class DataTypeDefinition {
public void setProperties(List<JsonPropertySchema> properties) {
this.properties = properties;
}
-
+
public void validate() throws SchemaProviderException {
- if ( (getName() == null) || (getName().isEmpty()) ) {
+ if ((getName() == null) || (getName().isEmpty())) {
throw new SchemaProviderException("Type definition missing a name");
}
@@ -69,19 +70,18 @@ public class DataTypeDefinition {
}
}
}
-
+
public String toJson() {
return gson.toJson(this);
}
-
+
public static DataTypeDefinition fromJson(String json) {
return gson.fromJson(json, DataTypeDefinition.class);
}
@Override
public String toString() {
- return "DataTypeDefinition [name=" + name + ", description=" + description + ", properties="
- + properties + "]";
+ return "DataTypeDefinition [name=" + name + ", description=" + description + ", properties=" + properties + "]";
}
@Override
@@ -120,6 +120,5 @@ public class DataTypeDefinition {
return false;
return true;
}
-
-
+
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonEdgeSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonEdgeSchema.java
index ffbc54de..b75f32d5 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonEdgeSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonEdgeSchema.java
@@ -18,78 +18,84 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json.definitions;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import java.util.Map;
import org.onap.aai.schemaif.SchemaProviderException;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
public class JsonEdgeSchema {
private static final Gson gson = new GsonBuilder().create();
-
+
private String from;
private String to;
private String label;
- private Map<String,String> annotations;
-
+ private Map<String, String> annotations;
+
public String getFrom() {
return from;
}
+
public void setFrom(String from) {
this.from = from;
}
-
+
public String getTo() {
return to;
}
+
public void setTo(String to) {
this.to = to;
}
-
+
public String getLabel() {
return label;
}
+
public void setLabel(String label) {
this.label = label;
}
-
- public Map<String,String> getAnnotations() {
+
+ public Map<String, String> getAnnotations() {
return annotations;
}
- public void setAnnotations(Map<String,String> annotations) {
+
+ public void setAnnotations(Map<String, String> annotations) {
this.annotations = annotations;
}
-
+
public void validate() throws SchemaProviderException {
- if ( (getTo() == null) || (getTo().isEmpty()) ) {
+ if ((getTo() == null) || (getTo().isEmpty())) {
throw new SchemaProviderException("Edge definition missing 'to'");
}
-
- if ( (getFrom() == null) || (getFrom().isEmpty()) ) {
+
+ if ((getFrom() == null) || (getFrom().isEmpty())) {
throw new SchemaProviderException("Edge definition missing 'from'");
}
-
- if ( (getLabel() == null) || (getLabel().isEmpty()) ) {
+
+ if ((getLabel() == null) || (getLabel().isEmpty())) {
throw new SchemaProviderException("Edge definition missing 'label'");
}
}
-
+
public String toJson() {
return gson.toJson(this);
}
-
+
public static JsonEdgeSchema fromJson(String json) {
return gson.fromJson(json, JsonEdgeSchema.class);
}
+
@Override
public String toString() {
- return "JsonEdgeSchema [from=" + from + ", to=" + to + ", label=" + label + ", annotations="
- + annotations + "]";
+ return "JsonEdgeSchema [from=" + from + ", to=" + to + ", label=" + label + ", annotations=" + annotations
+ + "]";
}
+
@Override
public int hashCode() {
final int prime = 31;
@@ -100,6 +106,7 @@ public class JsonEdgeSchema {
result = prime * result + ((to == null) ? 0 : to.hashCode());
return result;
}
+
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -131,5 +138,5 @@ public class JsonEdgeSchema {
return false;
return true;
}
-
+
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonPropertySchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonPropertySchema.java
index b6934eb8..25cd0a84 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonPropertySchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonPropertySchema.java
@@ -18,33 +18,34 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.schemaif.json.definitions;
-
-import java.util.Map;
-import org.onap.aai.schemaif.SchemaProviderException;
+package org.onap.aai.schemaif.json.definitions;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
+import java.util.Map;
+
+import org.onap.aai.schemaif.SchemaProviderException;
+
public class JsonPropertySchema {
private static final Gson gson = new GsonBuilder().create();
-
+
private String name;
private Boolean required;
private Boolean unique;
-
+
@SerializedName("type")
private String dataType;
-
+
private String description;
-
+
@SerializedName("default")
private String defaultValue;
-
- private Map<String,String> annotations;
-
+
+ private Map<String, String> annotations;
+
public String getName() {
return name;
}
@@ -76,7 +77,7 @@ public class JsonPropertySchema {
public void setDataType(String dataType) {
this.dataType = dataType;
}
-
+
public String getDefaultValue() {
return defaultValue;
}
@@ -92,39 +93,38 @@ public class JsonPropertySchema {
public void setDescription(String description) {
this.description = description;
}
-
- public Map<String,String> getAnnotations() {
+
+ public Map<String, String> getAnnotations() {
return annotations;
}
- public void setAnnotations(Map<String,String> annotations) {
+ public void setAnnotations(Map<String, String> annotations) {
this.annotations = annotations;
}
public void validate() throws SchemaProviderException {
- if ( (getName() == null) || (getName().isEmpty()) ) {
+ if ((getName() == null) || (getName().isEmpty())) {
throw new SchemaProviderException(getName() + " property has no name");
}
- if ( (getDataType() == null) || (getDataType().isEmpty()) ) {
+ if ((getDataType() == null) || (getDataType().isEmpty())) {
throw new SchemaProviderException(getName() + " property has no type");
}
}
-
public String toJson() {
return gson.toJson(this);
}
-
+
public static JsonVertexSchema fromJson(String json) {
return gson.fromJson(json, JsonVertexSchema.class);
}
@Override
public String toString() {
- return "JsonPropertySchema [name=" + name + ", required=" + required + ", unique=" + unique
- + ", dataType=" + dataType + ", description=" + description + ", defaultValue="
- + defaultValue + ", annotations=" + annotations + "]";
+ return "JsonPropertySchema [name=" + name + ", required=" + required + ", unique=" + unique + ", dataType="
+ + dataType + ", description=" + description + ", defaultValue=" + defaultValue + ", annotations="
+ + annotations + "]";
}
@Override
@@ -187,6 +187,5 @@ public class JsonPropertySchema {
return false;
return true;
}
-
-
+
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonSchema.java
index b9cacb87..5d292bd9 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonSchema.java
@@ -18,56 +18,56 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.schemaif.json.definitions;
-
-import java.util.List;
-import org.onap.aai.schemaif.SchemaProviderException;
+package org.onap.aai.schemaif.json.definitions;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
+import java.util.List;
+
+import org.onap.aai.schemaif.SchemaProviderException;
+
public class JsonSchema {
private static final Gson gson = new GsonBuilder().create();
@SerializedName("relationship_types")
private List<JsonEdgeSchema> relationshipTypes;
-
+
@SerializedName("node_types")
private List<JsonVertexSchema> nodeTypes;
-
+
@SerializedName("data_types")
private List<DataTypeDefinition> dataTypes;
-
+
@SerializedName("common_node_properties")
private List<JsonPropertySchema> commonNodeProps;
-
public void setRelationshipTypes(List<JsonEdgeSchema> relationshipTypes) {
- this.relationshipTypes = relationshipTypes;
- }
+ this.relationshipTypes = relationshipTypes;
+ }
- public void setNodeTypes(List<JsonVertexSchema> nodeTypes) {
- this.nodeTypes = nodeTypes;
- }
+ public void setNodeTypes(List<JsonVertexSchema> nodeTypes) {
+ this.nodeTypes = nodeTypes;
+ }
- public void setDataTypes(List<DataTypeDefinition> dataTypes) {
- this.dataTypes = dataTypes;
- }
+ public void setDataTypes(List<DataTypeDefinition> dataTypes) {
+ this.dataTypes = dataTypes;
+ }
- public List<JsonEdgeSchema> getRelationshipTypes() {
+ public List<JsonEdgeSchema> getRelationshipTypes() {
return relationshipTypes;
}
-
+
public List<JsonVertexSchema> getNodeTypes() {
return nodeTypes;
}
-
+
public List<DataTypeDefinition> getDataTypes() {
return dataTypes;
}
-
+
public List<JsonPropertySchema> getCommonProperties() {
return commonNodeProps;
}
@@ -75,21 +75,21 @@ public class JsonSchema {
public void setCommonProperties(List<JsonPropertySchema> properties) {
this.commonNodeProps = properties;
}
-
+
public void validate() throws SchemaProviderException {
if (getNodeTypes() != null) {
for (JsonVertexSchema vertexSchema : getNodeTypes()) {
vertexSchema.validate();
}
}
-
+
// Validate edges
if (getRelationshipTypes() != null) {
for (JsonEdgeSchema edgeSchema : getRelationshipTypes()) {
edgeSchema.validate();
}
}
-
+
// Validate data types
if (getDataTypes() != null) {
for (DataTypeDefinition typeSchema : getDataTypes()) {
@@ -97,7 +97,7 @@ public class JsonSchema {
}
}
}
-
+
public String toJson() {
return gson.toJson(this);
}
@@ -107,7 +107,7 @@ public class JsonSchema {
if (json == null || json.isEmpty()) {
throw new SchemaProviderException("Empty schema definition");
}
-
+
return gson.fromJson(json, JsonSchema.class);
} catch (Exception ex) {
throw new SchemaProviderException("Invalid json: " + ex.getMessage());
@@ -116,8 +116,8 @@ public class JsonSchema {
@Override
public String toString() {
- return "JsonSchema [relationshipTypes=" + relationshipTypes + ", nodeTypes=" + nodeTypes
- + ", dataTypes=" + dataTypes + ", commonNodeProps=" + commonNodeProps + "]";
+ return "JsonSchema [relationshipTypes=" + relationshipTypes + ", nodeTypes=" + nodeTypes + ", dataTypes="
+ + dataTypes + ", commonNodeProps=" + commonNodeProps + "]";
}
@Override
@@ -163,5 +163,4 @@ public class JsonSchema {
return true;
}
-
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonVertexSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonVertexSchema.java
index 87a1eac7..2fc2c802 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonVertexSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/definitions/JsonVertexSchema.java
@@ -18,24 +18,25 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.json.definitions;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
import java.util.List;
import java.util.Map;
import org.onap.aai.schemaif.SchemaProviderException;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
public class JsonVertexSchema {
private static final Gson gson = new GsonBuilder().create();
-
+
private String name;
private String description;
private List<JsonPropertySchema> properties;
- private Map<String,String> annotations;
-
+ private Map<String, String> annotations;
+
public String getName() {
return name;
}
@@ -59,17 +60,17 @@ public class JsonVertexSchema {
public void setProperties(List<JsonPropertySchema> properties) {
this.properties = properties;
}
-
- public Map<String,String> getAnnotations() {
+
+ public Map<String, String> getAnnotations() {
return annotations;
}
- public void setAnnotations(Map<String,String> annotations) {
+ public void setAnnotations(Map<String, String> annotations) {
this.annotations = annotations;
}
public void validate() throws SchemaProviderException {
- if ( (getName() == null) || (getName().isEmpty()) ) {
+ if ((getName() == null) || (getName().isEmpty())) {
throw new SchemaProviderException("Node definition missing a name");
}
@@ -79,19 +80,19 @@ public class JsonVertexSchema {
}
}
}
-
+
public String toJson() {
return gson.toJson(this);
}
-
+
public static JsonVertexSchema fromJson(String json) {
return gson.fromJson(json, JsonVertexSchema.class);
}
@Override
public String toString() {
- return "JsonVertexSchema [name=" + name + ", description=" + description + ", properties="
- + properties + ", annotations=" + annotations + "]";
+ return "JsonVertexSchema [name=" + name + ", description=" + description + ", properties=" + properties
+ + ", annotations=" + annotations + "]";
}
@Override
@@ -136,6 +137,5 @@ public class JsonVertexSchema {
return false;
return true;
}
-
-
+
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/EdgePropsConfiguration.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/EdgePropsConfiguration.java
index bd30e77e..abe0c5cd 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/EdgePropsConfiguration.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/EdgePropsConfiguration.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.oxm;
import org.springframework.beans.factory.annotation.Value;
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmEdgeSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmEdgeSchema.java
index 336b6d9e..3958a620 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmEdgeSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmEdgeSchema.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.oxm;
import java.util.HashMap;
@@ -29,14 +30,13 @@ import org.onap.aai.schemaif.definitions.EdgeSchema;
import org.onap.aai.schemaif.definitions.PropertySchema;
import org.onap.aai.schemaif.definitions.types.DataType;
-
public class FromOxmEdgeSchema extends EdgeSchema {
public void fromEdgeRule(EdgeRule edgeRule) throws SchemaProviderException {
name = edgeRule.getLabel();
source = edgeRule.getFrom();
target = edgeRule.getTo();
-
+
switch (edgeRule.getMultiplicityRule()) {
case MANY2MANY:
multiplicity = Multiplicity.MANY_2_MANY;
@@ -52,22 +52,22 @@ public class FromOxmEdgeSchema extends EdgeSchema {
break;
}
- annotations = new HashMap<String,String>();
- properties = new HashMap<String,PropertySchema>();
-
- // TODO: For now these are hard-coded ... should read them from a config file or something
+ annotations = new HashMap<String, String>();
+ properties = new HashMap<String, PropertySchema>();
+
+ // TODO: For now these are hard-coded ... should read them from a config file or something
annotations.put(EdgeProperty.CONTAINS.toString().toLowerCase(), edgeRule.getContains());
annotations.put(EdgeProperty.DELETE_OTHER_V.toString().toLowerCase(), edgeRule.getDeleteOtherV());
annotations.put(EdgeProperty.PREVENT_DELETE.toString().toLowerCase(), edgeRule.getPreventDelete());
-
+
FromOxmPropertySchema pSchema = new FromOxmPropertySchema();
pSchema.fromRelationship(EdgeProperty.CONTAINS.toString(), DataType.Type.STRING);
properties.put(EdgeProperty.CONTAINS.toString().toLowerCase(), pSchema);
-
+
pSchema = new FromOxmPropertySchema();
pSchema.fromRelationship(EdgeProperty.DELETE_OTHER_V.toString(), DataType.Type.STRING);
properties.put(EdgeProperty.DELETE_OTHER_V.toString().toLowerCase(), pSchema);
-
+
pSchema = new FromOxmPropertySchema();
pSchema.fromRelationship(EdgeProperty.PREVENT_DELETE.toString(), DataType.Type.STRING);
properties.put(EdgeProperty.PREVENT_DELETE.toString().toLowerCase(), pSchema);
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmPropertySchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmPropertySchema.java
index 2174bce2..bb9f3d8c 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmPropertySchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmPropertySchema.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.oxm;
import java.util.HashMap;
@@ -37,7 +38,6 @@ import org.onap.aai.schemaif.definitions.types.IntDataType;
import org.onap.aai.schemaif.definitions.types.LongDataType;
import org.onap.aai.schemaif.definitions.types.StringDataType;
-
public class FromOxmPropertySchema extends PropertySchema {
// Handle vertex properties from OXM
@@ -55,8 +55,7 @@ public class FromOxmPropertySchema extends PropertySchema {
if (isPrimaryKeyOxm(name, dynType)) {
unique = true;
required = true;
- }
- else {
+ } else {
required = ((XMLField) field).isRequired();
unique = false;
}
@@ -82,13 +81,13 @@ public class FromOxmPropertySchema extends PropertySchema {
throw new SchemaProviderException("Invalid OXM property type: " + oxmType);
}
}
-
+
// Check annotations
- annotations = new HashMap<String,String>();
+ annotations = new HashMap<String, String>();
Map<String, Object> oxmProps = mapping.getProperties();
for (Map.Entry<String, Object> entry : oxmProps.entrySet()) {
if (entry.getValue() instanceof String) {
- annotations.put(entry.getKey().toLowerCase(), (String)entry.getValue());
+ annotations.put(entry.getKey().toLowerCase(), (String) entry.getValue());
}
}
}
@@ -99,8 +98,8 @@ public class FromOxmPropertySchema extends PropertySchema {
required = false;
defaultValue = "";
unique = false;
- annotations = new HashMap<String,String>();
-
+ annotations = new HashMap<String, String>();
+
switch (propDataType) {
case STRING:
dataType = new StringDataType();
@@ -118,13 +117,13 @@ public class FromOxmPropertySchema extends PropertySchema {
dataType = new BooleanDataType();
break;
default:
- throw new SchemaProviderException("Invalid EdgeRule property type: " + propDataType);
+ throw new SchemaProviderException("Invalid EdgeRule property type: " + propDataType);
}
}
-
+
private boolean isPrimaryKeyOxm(String propName, DynamicType dynType) {
List<String> primaryKeyList = dynType.getDescriptor().getPrimaryKeyFieldNames();
- if ( (primaryKeyList == null) || (primaryKeyList.size() == 0) ) {
+ if ((primaryKeyList == null) || (primaryKeyList.size() == 0)) {
return false;
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmVertexSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmVertexSchema.java
index 6083429b..95ed2f50 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmVertexSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/FromOxmVertexSchema.java
@@ -18,8 +18,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.oxm;
+import com.google.common.base.CaseFormat;
+
import java.util.HashMap;
import java.util.Map;
@@ -32,13 +35,12 @@ import org.onap.aai.schemaif.SchemaProviderException;
import org.onap.aai.schemaif.definitions.PropertySchema;
import org.onap.aai.schemaif.definitions.VertexSchema;
-import com.google.common.base.CaseFormat;
-
public class FromOxmVertexSchema extends VertexSchema {
- public void fromOxm(String vertexType, DynamicJAXBContext jaxbContext, HashMap<String, DynamicType> xmlElementLookup) throws SchemaProviderException {
+ public void fromOxm(String vertexType, DynamicJAXBContext jaxbContext,
+ HashMap<String, DynamicType> xmlElementLookup) throws SchemaProviderException {
name = vertexType;
- properties = new HashMap<String,PropertySchema>();
- annotations = new HashMap<String,String>();
+ properties = new HashMap<String, PropertySchema>();
+ annotations = new HashMap<String, String>();
String javaTypeName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, vertexType);
DynamicType modelObjectType = jaxbContext.getDynamicType(javaTypeName);
@@ -62,21 +64,21 @@ public class FromOxmVertexSchema extends VertexSchema {
// Vertex isn't found in the OXM
throw new SchemaProviderException("Vertex " + vertexType + " not found in OXM");
}
-
+
// Check annotations
Map<String, Object> oxmProps = modelObjectType.getDescriptor().getProperties();
for (Map.Entry<String, Object> entry : oxmProps.entrySet()) {
if (entry.getValue() instanceof String) {
- annotations.put(entry.getKey().toLowerCase(), (String)entry.getValue());
+ annotations.put(entry.getKey().toLowerCase(), (String) entry.getValue());
}
}
// Regular props
for (DatabaseMapping mapping : modelObjectType.getDescriptor().getMappings()) {
if (mapping instanceof XMLAnyObjectMapping)
- continue;
- if(mapping instanceof XMLAnyCollectionMapping)
- continue;
+ continue;
+ if (mapping instanceof XMLAnyCollectionMapping)
+ continue;
FromOxmPropertySchema propSchema = new FromOxmPropertySchema();
propSchema.fromOxm(mapping, modelObjectType, false);
properties.put(propSchema.getName().toLowerCase(), propSchema);
@@ -90,6 +92,6 @@ public class FromOxmVertexSchema extends VertexSchema {
propSchema.fromOxm(mapping, reservedType, true);
properties.put(propSchema.getName().toLowerCase(), propSchema);
}
- }
+ }
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java
index 93508fc5..b404ccfe 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java
@@ -18,8 +18,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.oxm;
+import com.google.common.collect.Multimap;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -45,8 +48,6 @@ import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.google.common.collect.Multimap;
-
@Component
public class OxmEdgeRulesLoader {
@@ -63,10 +64,10 @@ public class OxmEdgeRulesLoader {
final static Pattern propsFilePattern = Pattern.compile(propsPrefix + "(.*)" + propsSuffix);
final static Pattern propsVersionPattern = Pattern.compile("(?i)v\\d*");
- private static Logger logger =
- LoggerFactory.getInstance().getLogger(OxmEdgeRulesLoader.class.getName());
+ private static Logger logger = LoggerFactory.getInstance().getLogger(OxmEdgeRulesLoader.class.getName());
- private OxmEdgeRulesLoader() {}
+ private OxmEdgeRulesLoader() {
+ }
/**
* This constructor presents an awkward marrying of Spring bean creation and static method use. This
@@ -88,7 +89,7 @@ public class OxmEdgeRulesLoader {
* Finds all DB Edge Rules and Edge Properties files for all OXM models.
*
* @throws SchemaProviderException
- * @throws SchemaProviderException
+ * @throws SchemaProviderException
*/
public static synchronized void loadModels() throws SchemaProviderException {
Map<String, File> propFiles = edgePropertyFiles(edgePropsConfiguration);
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java
index b3708b12..84bde101 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.oxm;
import java.io.IOException;
@@ -61,7 +62,8 @@ public class OxmSchemaLoader {
private static org.onap.aai.cl.api.Logger logger =
LoggerFactory.getInstance().getLogger(OxmSchemaLoader.class.getName());
- private OxmSchemaLoader() {}
+ private OxmSchemaLoader() {
+ }
/**
* This constructor presents an awkward marrying of Spring bean creation and static method use. This
@@ -172,24 +174,24 @@ public class OxmSchemaLoader {
}
xmlElementLookup.put(version, types);
}
-
+
private static void loadVertexLookupMap(String version, DynamicJAXBContext jaxbContext) {
- @SuppressWarnings("rawtypes")
- List<Descriptor> descriptorsList = jaxbContext.getXMLContext().getDescriptors();
- HashMap<String, VertexSchema> vertexMap = new HashMap<String, VertexSchema>();
-
- for (@SuppressWarnings("rawtypes")
- Descriptor desc : descriptorsList) {
- try {
- FromOxmVertexSchema vs = new FromOxmVertexSchema();
- vs.fromOxm(desc.getDefaultRootElement(), jaxbContext, getXmlLookupMap(version));
- vertexMap.put(vs.getName(), vs);
- } catch (SchemaProviderException e) {
- continue;
+ @SuppressWarnings("rawtypes")
+ List<Descriptor> descriptorsList = jaxbContext.getXMLContext().getDescriptors();
+ HashMap<String, VertexSchema> vertexMap = new HashMap<String, VertexSchema>();
+
+ for (@SuppressWarnings("rawtypes")
+ Descriptor desc : descriptorsList) {
+ try {
+ FromOxmVertexSchema vs = new FromOxmVertexSchema();
+ vs.fromOxm(desc.getDefaultRootElement(), jaxbContext, getXmlLookupMap(version));
+ vertexMap.put(vs.getName(), vs);
+ } catch (SchemaProviderException e) {
+ continue;
+ }
}
- }
- vertexLookup.put(version, vertexMap);
+ vertexLookup.put(version, vertexMap);
}
/**
@@ -223,14 +225,15 @@ public class OxmSchemaLoader {
return xmlElementLookup.get(version);
}
- public static HashMap<String, VertexSchema> getVertexLookupForVersion(String version) throws SchemaProviderException {
- // If we haven't already loaded in the available OXM models, then do so now.
- if (vertexLookup == null || vertexLookup.isEmpty()) {
- loadModels();
- } else if (!vertexLookup.containsKey(version)) {
- throw new SchemaProviderException("Error loading oxm model: " + version);
- }
- return vertexLookup.get(version);
+ public static HashMap<String, VertexSchema> getVertexLookupForVersion(String version)
+ throws SchemaProviderException {
+ // If we haven't already loaded in the available OXM models, then do so now.
+ if (vertexLookup == null || vertexLookup.isEmpty()) {
+ loadModels();
+ } else if (!vertexLookup.containsKey(version)) {
+ throw new SchemaProviderException("Error loading oxm model: " + version);
+ }
+ return vertexLookup.get(version);
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java
index bced602c..c8e6bea0 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemaif.oxm;
import java.util.HashSet;
@@ -32,7 +33,6 @@ import org.onap.aai.schemaif.SchemaProviderException;
import org.onap.aai.schemaif.definitions.EdgeSchema;
import org.onap.aai.schemaif.definitions.VertexSchema;
-
public class OxmSchemaProvider implements SchemaProvider {
@Override
@@ -53,9 +53,8 @@ public class OxmSchemaProvider implements SchemaProvider {
try {
vs.fromOxm(vertexName, jaxbContext, OxmSchemaLoader.getXmlLookupMap(schemaVersion));
- }
- catch (SchemaProviderException ex) {
- // Node doesn't exist in schema. Return null.
+ } catch (SchemaProviderException ex) {
+ // Node doesn't exist in schema. Return null.
return null;
}
@@ -95,7 +94,8 @@ public class OxmSchemaProvider implements SchemaProvider {
}
@Override
- public Set<EdgeSchema> getEdgeSchemaForSourceTarget(String sourceType, String targetType, String version) throws SchemaProviderException {
+ public Set<EdgeSchema> getEdgeSchemaForSourceTarget(String sourceType, String targetType, String version)
+ throws SchemaProviderException {
RelationshipSchema relSchema = OxmEdgeRulesLoader.getSchemaForVersion(version);
Set<EdgeSchema> edges = new HashSet<>();
Set<String> relTypes = relSchema.getValidRelationTypes(sourceType, targetType);
@@ -112,6 +112,6 @@ public class OxmSchemaProvider implements SchemaProvider {
@Override
public Map<String, VertexSchema> getVertexMap(String schemaVersion) throws SchemaProviderException {
- return OxmSchemaLoader.getVertexLookupForVersion(schemaVersion);
+ return OxmSchemaLoader.getVertexLookupForVersion(schemaVersion);
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java
index fa4fe45d..921cff33 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java
@@ -20,8 +20,11 @@
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
+
package org.onap.aai.schemaif.oxm;
+import com.google.common.collect.Multimap;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -38,12 +41,8 @@ import org.onap.aai.edges.EdgeRule;
import org.onap.aai.schemaif.SchemaProviderException;
import org.onap.aai.schemaif.SchemaProviderMsgs;
-import com.google.common.collect.Multimap;
-
-
public class RelationshipSchema {
-
public static final String SCHEMA_SOURCE_NODE_TYPE = "from";
public static final String SCHEMA_TARGET_NODE_TYPE = "to";
public static final String SCHEMA_RELATIONSHIP_TYPE = "label";
@@ -62,19 +61,18 @@ public class RelationshipSchema {
// A map storing the list of valid edge types for a source/target pair
private Map<String, Set<String>> edgeTypesForNodePair = new HashMap<>();
-
- public RelationshipSchema(Multimap<String, EdgeRule> rules, String props) throws SchemaProviderException, IOException {
+ public RelationshipSchema(Multimap<String, EdgeRule> rules, String props)
+ throws SchemaProviderException, IOException {
HashMap<String, String> properties = new ObjectMapper().readValue(props, HashMap.class);
- // hold the true values of the edge rules by key
+ // hold the true values of the edge rules by key
for (EdgeRule rule : rules.values()) {
String nodePairKey = buildNodePairKey(rule.getFrom(), rule.getTo());
if (edgeTypesForNodePair.get(nodePairKey) == null) {
Set<String> typeSet = new HashSet<String>();
typeSet.add(rule.getLabel());
edgeTypesForNodePair.put(nodePairKey, typeSet);
- }
- else {
+ } else {
edgeTypesForNodePair.get(nodePairKey).add(rule.getLabel());
}
@@ -138,8 +136,6 @@ public class RelationshipSchema {
});
}
-
-
public Map<String, Class<?>> lookupRelation(String key) {
return this.relations.get(key);
}
@@ -152,7 +148,6 @@ public class RelationshipSchema {
return relationTypes.containsKey(type);
}
-
private String buildRelation(String source, String target, String relation) {
return source + ":" + target + ":" + relation;
}
@@ -171,7 +166,6 @@ public class RelationshipSchema {
return source + ":" + target;
}
-
private Class<?> resolveClass(String type) throws SchemaProviderException, ClassNotFoundException {
Class<?> clazz = Class.forName(type);
validateClassTypes(clazz);
@@ -185,5 +179,3 @@ public class RelationshipSchema {
}
}
}
-
-
diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java
index 332d6672..9011dfa2 100644
--- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java
+++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java
@@ -38,6 +38,7 @@ import java.util.List;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.schemaif.SchemaProviderException;
@@ -54,7 +55,6 @@ import org.onap.aai.schemaif.json.definitions.JsonPropertySchema;
import org.onap.aai.schemaif.json.definitions.JsonSchema;
import org.onap.aai.schemaif.json.definitions.JsonVertexSchema;
-
public class JsonSchemaProviderTest {
JsonSchemaProviderConfig config = new JsonSchemaProviderConfig();
@@ -96,8 +96,8 @@ public class JsonSchemaProviderTest {
// Test Edge Schema
JsonEdgeSchema edgeSchema = null;
for (JsonEdgeSchema edge : jsonSchema.getRelationshipTypes()) {
- if ( (edge.getFrom().equals("onap.nodes.sdwan.uCPE"))
- && (edge.getTo().equals("onap.nodes.sdwan.service.SubscriberService")) ) {
+ if ((edge.getFrom().equals("onap.nodes.sdwan.uCPE"))
+ && (edge.getTo().equals("onap.nodes.sdwan.service.SubscriberService"))) {
edgeSchema = edge;
break;
}
@@ -109,7 +109,7 @@ public class JsonSchemaProviderTest {
// Test Node Schema
JsonVertexSchema vertexSchema = null;
for (JsonVertexSchema v : jsonSchema.getNodeTypes()) {
- if ( (v.getName().equals("org.onap.resource.NetworkRules")) ) {
+ if ((v.getName().equals("org.onap.resource.NetworkRules"))) {
vertexSchema = v;
break;
}
@@ -120,7 +120,7 @@ public class JsonSchemaProviderTest {
JsonPropertySchema propSchema = null;
for (JsonPropertySchema p : vertexSchema.getProperties()) {
- if ( (p.getName().equals("network_policy_entries")) ) {
+ if ((p.getName().equals("network_policy_entries"))) {
propSchema = p;
break;
}
@@ -136,7 +136,7 @@ public class JsonSchemaProviderTest {
// Test DataType Schema
DataTypeDefinition dataType = null;
for (DataTypeDefinition d : jsonSchema.getDataTypes()) {
- if ( (d.getName().equals("org.onap.datatypes.network.VlanRequirements")) ) {
+ if ((d.getName().equals("org.onap.datatypes.network.VlanRequirements"))) {
dataType = d;
break;
}
@@ -148,7 +148,7 @@ public class JsonSchemaProviderTest {
propSchema = null;
for (JsonPropertySchema p : dataType.getProperties()) {
- if ( (p.getName().equals("vlan_type")) ) {
+ if ((p.getName().equals("vlan_type"))) {
propSchema = p;
break;
}
@@ -158,8 +158,7 @@ public class JsonSchemaProviderTest {
assertEquals(false, propSchema.getRequired());
assertEquals("string", propSchema.getDataType());
assertEquals("", propSchema.getDefaultValue());
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -175,9 +174,8 @@ public class JsonSchemaProviderTest {
JsonSchemaProvider schemaProvider = new JsonSchemaProvider(config);
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
- VertexSchema vertSchema =
- schemaProvider.getVertexSchema("tosca.nodes.objectstorage",
- schemaProvider.getLatestSchemaVersion());
+ VertexSchema vertSchema = schemaProvider.getVertexSchema("tosca.nodes.objectstorage",
+ schemaProvider.getLatestSchemaVersion());
System.out.println(vertSchema.toString());
// Validate vertex schema
@@ -204,8 +202,7 @@ public class JsonSchemaProviderTest {
assertFalse(propSchema.isRequired());
assertTrue(propSchema.isReserved());
assertEquals(0, propSchema.getDataType().getType().compareTo(Type.STRING));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -222,8 +219,7 @@ public class JsonSchemaProviderTest {
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
EdgeSchema edgeSchema = schemaProvider.getEdgeSchema("tosca.relationships.hostedOn",
- "tosca.nodes.Softwarecomponent", "tosca.nodes.compute",
- schemaProvider.getLatestSchemaVersion());
+ "tosca.nodes.Softwarecomponent", "tosca.nodes.compute", schemaProvider.getLatestSchemaVersion());
System.out.println(edgeSchema.toString());
// Validate edge schema
@@ -233,9 +229,7 @@ public class JsonSchemaProviderTest {
assertEquals(edgeSchema.getMultiplicity(), EdgeSchema.Multiplicity.MANY_2_MANY);
assertEquals("NONE", edgeSchema.getAnnotationValue("contains-other-v"));
-
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -251,9 +245,8 @@ public class JsonSchemaProviderTest {
JsonSchemaProvider schemaProvider = new JsonSchemaProvider(config);
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
- Set<EdgeSchema> edgeSchemaList =
- schemaProvider.getAdjacentEdgeSchema("tosca.nodes.Database",
- schemaProvider.getLatestSchemaVersion());
+ Set<EdgeSchema> edgeSchemaList = schemaProvider.getAdjacentEdgeSchema("tosca.nodes.Database",
+ schemaProvider.getLatestSchemaVersion());
// Validate edge schema
assertEquals(3, edgeSchemaList.size());
@@ -277,8 +270,7 @@ public class JsonSchemaProviderTest {
break;
}
}
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -294,10 +286,8 @@ public class JsonSchemaProviderTest {
JsonSchemaProvider schemaProvider = new JsonSchemaProvider(config);
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
- Set<EdgeSchema> edgeSchemaList =
- schemaProvider.getEdgeSchemaForSourceTarget("tosca.nodes.LoadBalancer",
- "tosca.nodes.Database",
- schemaProvider.getLatestSchemaVersion());
+ Set<EdgeSchema> edgeSchemaList = schemaProvider.getEdgeSchemaForSourceTarget("tosca.nodes.LoadBalancer",
+ "tosca.nodes.Database", schemaProvider.getLatestSchemaVersion());
// Validate edge schema
assertEquals(2, edgeSchemaList.size());
@@ -308,18 +298,15 @@ public class JsonSchemaProviderTest {
assertEquals("tosca.nodes.LoadBalancer", es.getSource());
assertEquals("tosca.nodes.Database", es.getTarget());
assertEquals(es.getMultiplicity(), EdgeSchema.Multiplicity.MANY_2_MANY);
- }
- else if (es.getName().equals("tosca.relationships.RoutesTo")) {
+ } else if (es.getName().equals("tosca.relationships.RoutesTo")) {
assertEquals("tosca.nodes.LoadBalancer", es.getSource());
assertEquals("tosca.nodes.Database", es.getTarget());
assertEquals(es.getMultiplicity(), EdgeSchema.Multiplicity.MANY_2_MANY);
- }
- else {
+ } else {
fail();
}
}
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -335,9 +322,8 @@ public class JsonSchemaProviderTest {
JsonSchemaProvider schemaProvider = new JsonSchemaProvider(config);
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
- EdgeSchema edgeSchema =
- schemaProvider.getEdgeSchema("amdocs.linkedTo", "service-instance",
- "onap.nodes.sdwan.ManagementDomain", schemaProvider.getLatestSchemaVersion());
+ EdgeSchema edgeSchema = schemaProvider.getEdgeSchema("amdocs.linkedTo", "service-instance",
+ "onap.nodes.sdwan.ManagementDomain", schemaProvider.getLatestSchemaVersion());
assertEquals("amdocs.linkedTo", edgeSchema.getName());
assertEquals("service-instance", edgeSchema.getSource());
@@ -348,27 +334,22 @@ public class JsonSchemaProviderTest {
assertNull(edgeSchema);
-
- edgeSchema =
- schemaProvider.getEdgeSchema("amdocs.unknownRelationship", "unknown",
- "onap.nodes.sdwan.ManagementDomain", schemaProvider.getLatestSchemaVersion());
+ edgeSchema = schemaProvider.getEdgeSchema("amdocs.unknownRelationship", "unknown",
+ "onap.nodes.sdwan.ManagementDomain", schemaProvider.getLatestSchemaVersion());
assertEquals("amdocs.unknownRelationship", edgeSchema.getName());
assertEquals("unknown", edgeSchema.getSource());
assertEquals("onap.nodes.sdwan.ManagementDomain", edgeSchema.getTarget());
- edgeSchema =
- schemaProvider.getEdgeSchema("amdocs.unknownRelationship", "onap.nodes.sdwan.ManagementDomain",
- "unknown", schemaProvider.getLatestSchemaVersion());
+ edgeSchema = schemaProvider.getEdgeSchema("amdocs.unknownRelationship", "onap.nodes.sdwan.ManagementDomain",
+ "unknown", schemaProvider.getLatestSchemaVersion());
assertEquals("amdocs.unknownRelationship", edgeSchema.getName());
assertEquals("onap.nodes.sdwan.ManagementDomain", edgeSchema.getSource());
assertEquals("unknown", edgeSchema.getTarget());
- Set<EdgeSchema> edgeSchemaList =
- schemaProvider.getEdgeSchemaForSourceTarget("service-instance",
- "onap.nodes.sdwan.ManagementDomain",
- schemaProvider.getLatestSchemaVersion());
+ Set<EdgeSchema> edgeSchemaList = schemaProvider.getEdgeSchemaForSourceTarget("service-instance",
+ "onap.nodes.sdwan.ManagementDomain", schemaProvider.getLatestSchemaVersion());
assertEquals(1, edgeSchemaList.size());
edgeSchemaList = schemaProvider.getEdgeSchemaForSourceTarget("unknown", "unknown",
@@ -379,12 +360,11 @@ public class JsonSchemaProviderTest {
schemaProvider.getLatestSchemaVersion());
assertEquals(1, edgeSchemaList.size());
-
- edgeSchemaList = schemaProvider.getAdjacentEdgeSchema("service-instance", schemaProvider.getLatestSchemaVersion());
+ edgeSchemaList =
+ schemaProvider.getAdjacentEdgeSchema("service-instance", schemaProvider.getLatestSchemaVersion());
System.out.println("EDGE LIST: \n\n" + edgeSchemaList);
assertEquals(8, edgeSchemaList.size());
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -408,12 +388,10 @@ public class JsonSchemaProviderTest {
"cloud-region", "bad-node", schemaProvider.getLatestSchemaVersion());
assertNull(edgeSchema);
- Set<EdgeSchema> edgeSchemaList =
- schemaProvider.getAdjacentEdgeSchema("org.onap.nodes.bad-node",
- schemaProvider.getLatestSchemaVersion());
+ Set<EdgeSchema> edgeSchemaList = schemaProvider.getAdjacentEdgeSchema("org.onap.nodes.bad-node",
+ schemaProvider.getLatestSchemaVersion());
assertTrue(edgeSchemaList.isEmpty());
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -429,18 +407,16 @@ public class JsonSchemaProviderTest {
JsonSchemaProvider schemaProvider = new JsonSchemaProvider(config);
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
- VertexSchema vertSchema =
- schemaProvider.getVertexSchema("onap.nodes.sdwan.ManagementDomain",
- schemaProvider.getLatestSchemaVersion());
+ VertexSchema vertSchema = schemaProvider.getVertexSchema("onap.nodes.sdwan.ManagementDomain",
+ schemaProvider.getLatestSchemaVersion());
System.out.println(vertSchema.toString());
// Validate schema
PropertySchema propSchema = vertSchema.getPropertySchema("controllers");
assertEquals(0, propSchema.getDataType().getType().compareTo(Type.LIST));
- ListDataType listType = (ListDataType)propSchema.getDataType();
+ ListDataType listType = (ListDataType) propSchema.getDataType();
assertEquals(0, listType.getListType().getType().compareTo(Type.STRING));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -456,18 +432,16 @@ public class JsonSchemaProviderTest {
JsonSchemaProvider schemaProvider = new JsonSchemaProvider(config);
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
- VertexSchema vertSchema =
- schemaProvider.getVertexSchema("onap.nodes.sdwan.ManagementDomain",
- schemaProvider.getLatestSchemaVersion());
+ VertexSchema vertSchema = schemaProvider.getVertexSchema("onap.nodes.sdwan.ManagementDomain",
+ schemaProvider.getLatestSchemaVersion());
System.out.println(vertSchema.toString());
// Validate schema
PropertySchema propSchema = vertSchema.getPropertySchema("analyticClusters");
assertEquals(0, propSchema.getDataType().getType().compareTo(Type.MAP));
- MapDataType mapType = (MapDataType)propSchema.getDataType();
+ MapDataType mapType = (MapDataType) propSchema.getDataType();
assertEquals(0, mapType.getMapType().getType().compareTo(Type.STRING));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -483,9 +457,8 @@ public class JsonSchemaProviderTest {
JsonSchemaProvider schemaProvider = new JsonSchemaProvider(config);
schemaProvider.loadSchema(testSchema, schemaProvider.getLatestSchemaVersion());
- VertexSchema vertSchema =
- schemaProvider.getVertexSchema("org.onap.resource.extContrailCP",
- schemaProvider.getLatestSchemaVersion());
+ VertexSchema vertSchema = schemaProvider.getVertexSchema("org.onap.resource.extContrailCP",
+ schemaProvider.getLatestSchemaVersion());
System.out.println(vertSchema.toString());
System.out.println("\n\nSize: " + vertSchema.getPropertySchemaList().size());
@@ -495,7 +468,7 @@ public class JsonSchemaProviderTest {
// Validate property schema
PropertySchema propSchema = vertSchema.getPropertySchema("exCP_naming");
assertEquals(0, propSchema.getDataType().getType().compareTo(Type.COMPLEX));
- ComplexDataType complexType = (ComplexDataType)propSchema.getDataType();
+ ComplexDataType complexType = (ComplexDataType) propSchema.getDataType();
List<PropertySchema> complexProps = complexType.getSubProperties();
assertEquals(4, complexProps.size());
@@ -509,8 +482,7 @@ public class JsonSchemaProviderTest {
assertNotNull(subProp);
assertFalse(subProp.isRequired());
assertEquals(0, subProp.getDataType().getType().compareTo(Type.STRING));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -532,8 +504,7 @@ public class JsonSchemaProviderTest {
System.out.println(jsonSchema.toJson());
assertEquals(1, jsonSchema.getDataTypes().size());
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -548,8 +519,7 @@ public class JsonSchemaProviderTest {
String testSchema = readFile("src/test/resources/json/schemaServiceResponse.json");
SchemaServiceResponse schema = SchemaServiceResponse.fromJson(testSchema);
schema.getData().validate();
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -565,8 +535,7 @@ public class JsonSchemaProviderTest {
try {
String testSchema = readFile("src/test/resources/json/badEdgeSchema.json");
schema = SchemaServiceResponse.fromJson(testSchema);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
fail();
return;
}
@@ -581,8 +550,7 @@ public class JsonSchemaProviderTest {
try {
String testSchema = readFile("src/test/resources/json/badVertexSchema.json");
schema = SchemaServiceResponse.fromJson(testSchema);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
fail();
return;
}
@@ -599,8 +567,7 @@ public class JsonSchemaProviderTest {
try {
String testSchema = readFile("src/test/resources/json/badTypeSchema.json");
schema = SchemaServiceResponse.fromJson(testSchema);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
fail();
return;
}
@@ -615,8 +582,7 @@ public class JsonSchemaProviderTest {
try {
String testSchema = readFile("src/test/resources/json/badPropSchema.json");
schema = SchemaServiceResponse.fromJson(testSchema);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
fail();
return;
}
diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java
index 6cfb5a7d..21ba985b 100644
--- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java
+++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java
@@ -21,7 +21,6 @@
package org.onap.aai.schemaif.oxm;
-
import static org.junit.Assert.assertTrue;
import java.io.PrintWriter;
@@ -46,7 +45,8 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
OxmSchemaProvider schemaProvider = new OxmSchemaProvider();
schemaProvider.loadSchema();
- VertexSchema vertSchema = schemaProvider.getVertexSchema("pserver", schemaProvider.getLatestSchemaVersion());
+ VertexSchema vertSchema =
+ schemaProvider.getVertexSchema("pserver", schemaProvider.getLatestSchemaVersion());
System.out.println(vertSchema.toString());
EdgeSchema edgeSchema = schemaProvider.getEdgeSchema("org.onap.relationships.inventory.LocatedIn",
@@ -80,7 +80,6 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
assertTrue(obj instanceof Boolean);
assertTrue(propSchema.getDataType().validateValue("badValue") == null);
-
propSchema = vertSchema.getPropertySchema("aai-node-type");
assertTrue(propSchema.getName().equals("aai-node-type"));
assertTrue(propSchema.getDefaultValue().equals(""));
@@ -119,8 +118,7 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
// Validate 'dependentOn' annotation
vertSchema = schemaProvider.getVertexSchema("tenant", schemaProvider.getLatestSchemaVersion());
assertTrue(vertSchema.getAnnotationValue("dependentOn").equals("cloud-region"));
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -147,18 +145,15 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
assertTrue(es.getSource().equals("snapshot"));
assertTrue(es.getTarget().equals("cloud-region"));
assertTrue(es.getMultiplicity().equals(EdgeSchema.Multiplicity.MANY_2_ONE));
- }
- else if (es.getName().equals("org.onap.relationships.inventory.Uses")) {
+ } else if (es.getName().equals("org.onap.relationships.inventory.Uses")) {
assertTrue(es.getSource().equals("vserver"));
assertTrue(es.getTarget().equals("snapshot"));
assertTrue(es.getMultiplicity().equals(EdgeSchema.Multiplicity.ONE_2_ONE));
- }
- else {
+ } else {
assertTrue(false);
}
}
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -173,9 +168,8 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
OxmSchemaProvider schemaProvider = new OxmSchemaProvider();
schemaProvider.loadSchema();
- Set<EdgeSchema> edgeSchemaList =
- schemaProvider.getEdgeSchemaForSourceTarget("service-instance", "customer",
- schemaProvider.getLatestSchemaVersion());
+ Set<EdgeSchema> edgeSchemaList = schemaProvider.getEdgeSchemaForSourceTarget("service-instance", "customer",
+ schemaProvider.getLatestSchemaVersion());
// Validate edge schema
assertTrue(edgeSchemaList.size() == 1);
@@ -184,9 +178,8 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
assertTrue(edgeSchemaList.iterator().next().getTarget().equals("customer"));
assertTrue(edgeSchemaList.iterator().next().getMultiplicity().equals(EdgeSchema.Multiplicity.MANY_2_MANY));
- edgeSchemaList =
- schemaProvider.getEdgeSchemaForSourceTarget("cloud-region", "complex",
- schemaProvider.getLatestSchemaVersion());
+ edgeSchemaList = schemaProvider.getEdgeSchemaForSourceTarget("cloud-region", "complex",
+ schemaProvider.getLatestSchemaVersion());
// Validate edge schema
assertTrue(edgeSchemaList.size() == 2);
@@ -197,25 +190,21 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
assertTrue(es.getSource().equals("cloud-region"));
assertTrue(es.getTarget().equals("complex"));
assertTrue(es.getMultiplicity().equals(EdgeSchema.Multiplicity.MANY_2_MANY));
- }
- else if (es.getName().equals("org.onap.relationships.inventory.LocatedIn")) {
+ } else if (es.getName().equals("org.onap.relationships.inventory.LocatedIn")) {
assertTrue(es.getSource().equals("cloud-region"));
assertTrue(es.getTarget().equals("complex"));
assertTrue(es.getMultiplicity().equals(EdgeSchema.Multiplicity.MANY_2_ONE));
- }
- else {
+ } else {
assertTrue(false);
}
}
- edgeSchemaList =
- schemaProvider.getEdgeSchemaForSourceTarget("cloud-region", "bad-node",
- schemaProvider.getLatestSchemaVersion());
+ edgeSchemaList = schemaProvider.getEdgeSchemaForSourceTarget("cloud-region", "bad-node",
+ schemaProvider.getLatestSchemaVersion());
// Validate edge schema
assertTrue(edgeSchemaList.size() == 0);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
@@ -238,12 +227,10 @@ public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
"cloud-region", "bad-node", schemaProvider.getLatestSchemaVersion());
assertTrue(edgeSchema == null);
- Set<EdgeSchema> edgeSchemaList =
- schemaProvider.getAdjacentEdgeSchema("org.onap.nodes.bad-node",
- schemaProvider.getLatestSchemaVersion());
+ Set<EdgeSchema> edgeSchemaList = schemaProvider.getAdjacentEdgeSchema("org.onap.nodes.bad-node",
+ schemaProvider.getLatestSchemaVersion());
assertTrue(edgeSchemaList.isEmpty());
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java
index b0b76a21..e7055a3f 100644
--- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java
+++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java
@@ -26,6 +26,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -34,9 +35,9 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.AAIConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
import org.onap.aai.setup.Translator;
@RunWith(MockitoJUnitRunner.class)
@@ -65,7 +66,7 @@ public class OxmSchemaServiceSetup {
Mockito.when(schemaLocationsBean.getNodeDirectory()).thenReturn("src/test/resources/oxm/oxm");
Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/oxm/edge-rules");
- AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaConfigVersions);
+ AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaConfigVersions);
Set<Translator> translators = new HashSet<>();
translators.add(aaiConfigTranslator);
NodeIngestor nodeIngestor = new NodeIngestor(translators);
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
index 2e6847d2..c4f951a3 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
@@ -22,9 +22,6 @@
package org.onap.aai.config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -32,6 +29,8 @@ import java.util.Set;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.Translator;
+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.boot.autoconfigure.condition.ConditionalOnExpression;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
index 207f7e0a..c3222168 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
@@ -23,8 +23,6 @@ package org.onap.aai.edges;
import static com.jayway.jsonpath.Criteria.where;
import static com.jayway.jsonpath.Filter.filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -51,6 +49,8 @@ import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.setup.Translator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
index 8861c5cc..40761372 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
@@ -20,12 +20,12 @@
package org.onap.aai.edges;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.onap.aai.edges.enums.*;
-
import java.util.EnumMap;
import java.util.Map;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.onap.aai.edges.enums.*;
+
/**
* Container for A&AI edge rule information
*/
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
index 893ebad5..f7a2b9a7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
@@ -22,6 +22,10 @@
package org.onap.aai.edges;
+import com.jayway.jsonpath.Criteria;
+import com.jayway.jsonpath.Filter;
+import com.jayway.jsonpath.Predicate;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -34,10 +38,6 @@ import org.onap.aai.edges.enums.EdgeProperty;
import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.setup.SchemaVersion;
-import com.jayway.jsonpath.Criteria;
-import com.jayway.jsonpath.Filter;
-import com.jayway.jsonpath.Predicate;
-
/**
* For querying the edge rules schema (not the database)
*
@@ -57,7 +57,6 @@ public class EdgeRuleQuery {
public static class Builder {
-
// required
private String nodeA;
@@ -244,9 +243,11 @@ public class EdgeRuleQuery {
private Predicate addDirection(AAIDirection direction) {
if (direction == AAIDirection.OUT) {
- return Criteria.where(EdgeField.DIRECTION.toString()).in(AAIDirection.OUT.toString(), AAIDirection.BOTH.toString());
+ return Criteria.where(EdgeField.DIRECTION.toString()).in(AAIDirection.OUT.toString(),
+ AAIDirection.BOTH.toString());
} else if (direction == AAIDirection.IN) {
- return Criteria.where(EdgeField.DIRECTION.toString()).in(AAIDirection.IN.toString(), AAIDirection.BOTH.toString());
+ return Criteria.where(EdgeField.DIRECTION.toString()).in(AAIDirection.IN.toString(),
+ AAIDirection.BOTH.toString());
} else if (direction == AAIDirection.BOTH) {
return Criteria.where(EdgeField.DIRECTION.toString()).is(AAIDirection.BOTH.toString());
} else if (direction == AAIDirection.NONE) {
@@ -333,7 +334,7 @@ public class EdgeRuleQuery {
@Override
public int hashCode() {
return v.map(schemaVersion -> Objects.hash(schemaVersion, nodeA, nodeB, label, direction, type, isPrivate))
- .orElseGet(() -> Objects.hash(nodeA, nodeB, label, direction, type, isPrivate));
+ .orElseGet(() -> Objects.hash(nodeA, nodeB, label, direction, type, isPrivate));
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
index 9b1f0bd9..ec0e850b 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
@@ -20,8 +20,6 @@
package org.onap.aai.edges;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
@@ -35,6 +33,8 @@ import java.util.Map;
import java.util.Map.Entry;
import org.onap.aai.setup.SchemaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* JsonIngestor produces DocumentContexts from json files
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
index 014a4442..a3d477ee 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
@@ -23,6 +23,7 @@
package org.onap.aai.nodes;
import com.google.common.base.CaseFormat;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -34,12 +35,14 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import javax.annotation.PostConstruct;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+
import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
index a92005ea..e764dda6 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
@@ -20,6 +20,10 @@
package org.onap.aai.restclient;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -27,10 +31,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class SchemaServiceNoAuthClient extends NoAuthRestClient {
private static Logger logger = LoggerFactory.getLogger(SchemaServiceNoAuthClient.class);
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
index 1ab0999e..1f04bff1 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
@@ -20,6 +20,10 @@
package org.onap.aai.restclient;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -27,10 +31,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class SchemaServiceOneWayClient extends OneWaySSLRestClient {
private static Logger logger = LoggerFactory.getLogger(SchemaServiceOneWayClient.class);
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
index 62f4b68b..f7bdf6d7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
@@ -22,6 +22,10 @@
package org.onap.aai.restclient;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -29,10 +33,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class SchemaServiceRestClient extends TwoWaySSLRestClient {
private static Logger logger = LoggerFactory.getLogger(SchemaServiceRestClient.class);
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
index 10f1f542..27148a44 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import org.onap.aai.restclient.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
index 0094a161..1d140ea6 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
@@ -21,14 +21,9 @@
package org.onap.aai.setup;
import java.util.List;
-import java.util.stream.Collectors;
-
-import javax.annotation.PostConstruct;
import org.onap.aai.validation.AAISchemaValidationException;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
index 39efde54..3d415e62 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
@@ -23,8 +23,6 @@ package org.onap.aai.setup;
import java.io.*;
import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-
/**
* Converts the contents of the schema config file
* (which lists which schema files to be loaded) to
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java
index e3826576..6f896f88 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java
@@ -36,8 +36,6 @@ import org.onap.aai.edges.enums.AAIDirection;
import org.onap.aai.edges.enums.MultiplicityRule;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
-import org.onap.aai.restclient.MockProvider;
-import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.TestUtilConfigTranslator;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
index a9cd1f74..99693c16 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
@@ -27,7 +27,6 @@ import com.google.common.collect.Multimap;
import java.util.Collection;
import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -38,7 +37,6 @@ import org.onap.aai.edges.enums.MultiplicityRule;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.restclient.MockProvider;
-import org.onap.aai.restclient.MockRestClient;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -50,10 +48,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {MockProvider.class, EdgesConfiguration.class})
@TestPropertySource(
- properties = {
- "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties",
- "spring.main.allow-bean-definition-overriding=true"
- })
+ properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties",
+ "spring.main.allow-bean-definition-overriding=true"})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@SpringBootTest
public class EdgeIngestorTest {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
index 0a6a3f07..543ce273 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
@@ -24,13 +24,11 @@ import static org.junit.Assert.*;
import com.google.common.collect.Multimap;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.EdgesConfiguration;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java
index 83d7dc44..6e00eb73 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java
@@ -20,6 +20,27 @@
package org.onap.aai.nodes;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.junit.Rule;
@@ -37,26 +58,6 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.w3c.dom.Document;
-import javax.xml.bind.SchemaOutputResolver;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-
@RunWith(SpringRunner.class)
@TestPropertySource(
properties = {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
index b70b1bfc..fff22116 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
@@ -20,6 +20,27 @@
package org.onap.aai.nodes;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.junit.Rule;
@@ -37,32 +58,10 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Document;
-import javax.xml.bind.SchemaOutputResolver;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(
- properties = {
- "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties",
- "spring.main.allow-bean-definition-overriding=true"
- })
+ properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties",
+ "spring.main.allow-bean-definition-overriding=true"})
@ContextConfiguration(classes = {MockProvider.class, NodesConfiguration.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
index d2412c08..7ae0a2cd 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
@@ -24,12 +24,10 @@ import static org.junit.Assert.*;
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java
index 09b8d3a7..16af4842 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java
@@ -20,7 +20,6 @@
package org.onap.aai.restclient;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
index 8ce496ef..74d254b1 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
@@ -26,6 +26,10 @@ import static org.springframework.test.web.client.match.MockRestRequestMatchers.
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
@@ -48,10 +52,6 @@ import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-
@Component
public class MockRestClient extends RestClient {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java
index 53134075..cbbc63d3 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java
@@ -26,7 +26,6 @@ import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.aai.restclient.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpMethod;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java
index d2852925..fa6d8edc 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java
@@ -23,7 +23,6 @@ package org.onap.aai.validation;
import static org.junit.Assert.*;
import org.junit.Test;
-import org.onap.aai.validation.CheckEverythingStrategy;
public class CheckEverythingStrategyTest {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java
index ceced416..0dc68c48 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java
@@ -25,8 +25,6 @@ import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onap.aai.validation.AAISchemaValidationException;
-import org.onap.aai.validation.FailFastStrategy;
public class FailFastStrategyTest {
@Rule
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java
index 4bab99a1..4c6882c8 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java
@@ -22,13 +22,10 @@ package org.onap.aai.validation;
import static org.junit.Assert.*;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
-import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.BadNodeConfigForValidationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java
index 2598928e..a74f7ba9 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java
@@ -22,12 +22,9 @@ package org.onap.aai.validation;
import static org.junit.Assert.*;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
-import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java
index 75b27716..b1bf3146 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java
@@ -22,12 +22,9 @@ package org.onap.aai.validation.edges;
import static org.junit.Assert.*;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
-import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.BadEdgeConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java
index ca6b3171..60943219 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java
@@ -22,12 +22,9 @@ package org.onap.aai.validation.edges;
import static org.junit.Assert.*;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
-import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java
index cc38915c..e80e2fea 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java
@@ -25,13 +25,10 @@ import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
-import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.TestUtilConfigTranslator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java
index e164df04..93cb2ab3 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java
@@ -27,8 +27,6 @@ import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.testutils.BadNodeConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
-import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule;
-import org.onap.aai.validation.nodes.NodeValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java
index 288913b1..c2e7b7ba 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java
@@ -41,10 +41,8 @@ import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.SchemaIncompleteTranslator;
-import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java
index 81b69e6e..893dd04c 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java
@@ -27,8 +27,6 @@ import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
-import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule;
-import org.onap.aai.validation.nodes.NodeValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
diff --git a/aai-utils/src/main/java/org/onap/aaiutils/oxm/OxmModelLoaderConstants.java b/aai-utils/src/main/java/org/onap/aaiutils/oxm/OxmModelLoaderConstants.java
index f5494baf..61e8acf7 100644
--- a/aai-utils/src/main/java/org/onap/aaiutils/oxm/OxmModelLoaderConstants.java
+++ b/aai-utils/src/main/java/org/onap/aaiutils/oxm/OxmModelLoaderConstants.java
@@ -25,11 +25,9 @@ package org.onap.aaiutils.oxm;
public class OxmModelLoaderConstants {
public static final String AaiUtils_FILESEP =
- (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+ (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
- public static final String AaiUtils_SPECIFIC_CONFIG =
- System.getProperty("CONFIG_HOME") + AaiUtils_FILESEP;
+ public static final String AaiUtils_SPECIFIC_CONFIG = System.getProperty("CONFIG_HOME") + AaiUtils_FILESEP;
- public static final String AaiUtils_HOME_MODEL =
- AaiUtils_SPECIFIC_CONFIG + "model" + AaiUtils_FILESEP;
+ public static final String AaiUtils_HOME_MODEL = AaiUtils_SPECIFIC_CONFIG + "model" + AaiUtils_FILESEP;
}
diff --git a/pom.xml b/pom.xml
index 5831dfda..bb14f04f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,6 +99,7 @@
<importOrder>
<order>com,java,javax,org</order>
</importOrder>
+ <removeUnusedImports/>
</java>
</configuration>
<!-- https://github.com/diffplug/spotless/tree/master/plugin-maven