diff options
Diffstat (limited to 'aai-core')
21 files changed, 66 insertions, 50 deletions
diff --git a/aai-core/pom.xml b/aai-core/pom.xml index 3b653924..d210f4e0 100644 --- a/aai-core/pom.xml +++ b/aai-core/pom.xml @@ -26,7 +26,7 @@ limitations under the License. <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.13.0-SNAPSHOT</version> + <version>1.13.1-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-core</artifactId> @@ -38,7 +38,7 @@ limitations under the License. <jacoco.line.coverage.limit>0.50</jacoco.line.coverage.limit> <gremlin.version>3.2.2</gremlin.version> <groovy.version>2.5.15</groovy.version> - <mockito.core.version>2.4.0</mockito.core.version> + <mockito.core.version>3.4.0</mockito.core.version> <!-- Start of Default ONAP Schema Properties --> <aai.wiki.link>https://wiki.onap.org/</aai.wiki.link> <gendoc.version>v15</gendoc.version> @@ -257,21 +257,9 @@ limitations under the License. <artifactId>slf4j-api</artifactId> </dependency> <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.dataformat</groupId> - <artifactId>jackson-dataformat-yaml</artifactId> - </dependency> - <dependency> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> - </dependency> - <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> + <version>1.4.01</version> </dependency> <dependency> <groupId>com.beust</groupId> @@ -280,7 +268,6 @@ limitations under the License. <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> - </dependency> <dependency> <groupId>com.bazaarvoice.jolt</groupId> @@ -355,11 +342,6 @@ limitations under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-javaagent</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.skyscreamer</groupId> <artifactId>jsonassert</artifactId> <scope>test</scope> @@ -394,12 +376,16 @@ limitations under the License. <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j</artifactId> - <version>${log4j.version}</version> - <type>pom</type> - </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-yaml</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j</artifactId> + <version>${log4j.version}</version> + <type>pom</type> + </dependency> </dependencies> <!-- Plugins and repositories --> diff --git a/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java b/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java index 4dc8860e..c04e4e3c 100644 --- a/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java +++ b/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java @@ -5,6 +5,7 @@ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright © 2018 IBM. + * Modifications Copyright © 2024 DEUTSCHE TELEKOM AG. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +30,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; +import org.springframework.web.context.annotation.RequestScope; @Configuration public class RestBeanConfig { @@ -44,4 +46,26 @@ public class RestBeanConfig { return new HttpEntry(ModelType.MOXY, QueryStyle.TRAVERSAL); } + /** + * The HttpEntry class is not thread-safe due to the contained JanusGraphDBEngine. + * As such, assure that a new instance is returned for every injection by making it + * request scoped. + */ + @RequestScope + @Bean(name = "requestScopedTraversalUriHttpEntry") + public HttpEntry requestScopedTraversalUriHttpEntry() { + return new HttpEntry(ModelType.MOXY, QueryStyle.TRAVERSAL_URI); + } + + /** + * The HttpEntry class is not thread-safe due to the contained JanusGraphDBEngine. + * As such, assure that a new instance is returned for every injection by making it + * request scoped. + */ + @RequestScope + @Bean(name = "requestScopedTraversalHttpEntry") + public HttpEntry requestScopedTraversalHttpEntry() { + return new HttpEntry(ModelType.MOXY, QueryStyle.TRAVERSAL); + } + } 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 6327272b..73cdc3c8 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,10 +20,13 @@ package org.onap.aai.serialization.engines; +import java.util.Collections; 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.optimization.InlineFilterStrategy; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -149,16 +152,17 @@ public abstract class TransactionalGraphEngine { } public QueryBuilder<Vertex> getQueryBuilder(QueryStyle style, Loader loader) { + GraphTraversalSource source = this.asAdmin().getTraversalSource(); if (style.equals(QueryStyle.GREMLIN_TRAVERSAL)) { - return new GremlinTraversal<>(loader, this.asAdmin().getTraversalSource()); + return new GremlinTraversal<>(loader, source); } else if (style.equals(QueryStyle.GREMLIN_UNIQUE)) { - return new GremlinUnique<>(loader, this.asAdmin().getTraversalSource()); + return new GremlinUnique<>(loader, source); } else if (style.equals(QueryStyle.GREMLINPIPELINE_TRAVERSAL)) { // return new GremlinPipelineTraversal(loader); } else if (style.equals(QueryStyle.TRAVERSAL)) { - return new TraversalQuery<>(loader, this.asAdmin().getTraversalSource()); + return new TraversalQuery<>(loader, source != null ? source.withoutStrategies(InlineFilterStrategy.class) : source); } else if (style.equals(QueryStyle.TRAVERSAL_URI)) { - return new TraversalURIOptimizedQuery<>(loader, this.asAdmin().getTraversalSource()); + return new TraversalURIOptimizedQuery<>(loader, source != null ? source.withoutStrategies(InlineFilterStrategy.class) : source); } else if (style.equals(QueryStyle.HISTORY_TRAVERSAL)) { throw new IllegalArgumentException("History Traversal needs history traversal source"); } else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) { 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 24405953..b010b19b 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 @@ -104,7 +104,7 @@ public class StateFormat extends HistoryFormat { json.addProperty("uri", "NA"); } json.addProperty(TIMESTAMP, - e.property(AAIProperties.START_TS).isPresent() ? e.value(AAIProperties.START_TS) : 0); + e.property(AAIProperties.START_TS).isPresent() ? (String) e.value(AAIProperties.START_TS) : String.valueOf(0)); json.addProperty(SOT, e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent() ? e.value(AAIProperties.SOURCE_OF_TRUTH) : ""); json.addProperty(TX_ID, 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 72d8273a..a44226c8 100644 --- a/aai-core/src/test/java/org/onap/aai/AAISetup.java +++ b/aai-core/src/test/java/org/onap/aai/AAISetup.java @@ -43,7 +43,9 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.rules.SpringClassRule; import org.springframework.test.context.junit4.rules.SpringMethodRule; +import org.springframework.test.context.web.WebAppConfiguration; +@WebAppConfiguration @ContextConfiguration( classes = {ConfigConfiguration.class, AAIConfigTranslator.class, EdgeIngestor.class, EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class, RestBeanConfig.class, 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 e83d3bd3..779139e7 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 @@ -123,7 +123,7 @@ public class DataCopyTest extends AAISetup { @Before public void initMock() { loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion()); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); dbEngine = new JanusGraphDBEngine(queryStyle, loader); } 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 440d2797..2a68e53d 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 @@ -169,7 +169,7 @@ public class DataLinkTest extends DataLinkSetup { @Before public void initMock() { loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion()); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); dbEngine = new JanusGraphDBEngine(queryStyle, loader); } 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 a349f85e..7ca4e047 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 @@ -109,7 +109,7 @@ public class OwnerCheckTest extends AAISetup { @Before public void initMock() { loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion()); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); dbEngine = new JanusGraphDBEngine(queryStyle, loader); } 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 edace19d..d99b14e8 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 @@ -121,7 +121,7 @@ public class PrivateEdgeTest extends AAISetup { public void initMock() { Loader loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion()); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); dbEngine = new JanusGraphDBEngine(queryStyle, loader); } 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 7f6e5610..8ef1d706 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 @@ -42,7 +42,7 @@ import org.mockito.Mockito; import org.onap.aai.PayloadUtil; import org.onap.aai.exceptions.AAIException; import org.onap.aai.restclient.RestClient; -import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.system.OutputCaptureRule; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -53,7 +53,7 @@ public class ValidationServiceTest { private ValidationService validationService; @Rule - public OutputCapture capture = new OutputCapture(); + public OutputCaptureRule capture = new OutputCaptureRule(); private Gson gson; 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 27f52d1b..d1aee226 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 @@ -36,7 +36,7 @@ import org.onap.aai.introspection.Introspector; import org.onap.aai.serialization.engines.TransactionalGraphEngine; import org.onap.aai.serialization.engines.query.QueryEngine; import org.onap.aai.util.AAIConstants; -import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.system.OutputCaptureRule; public class ImpliedDeleteUnitTest { @@ -46,7 +46,7 @@ public class ImpliedDeleteUnitTest { private ImpliedDelete impliedDelete; @Rule - public final OutputCapture outputCapture = new OutputCapture(); + public final OutputCaptureRule outputCapture = new OutputCaptureRule(); @Before public void setup() { 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 2b80fb14..f7a7fde1 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 @@ -77,7 +77,7 @@ public class AggregateFormatTest extends AAISetup { version = schemaVersions.getDefaultVersion(); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); 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 daf7d474..5c6ca4b5 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 @@ -80,7 +80,7 @@ public class CountQuerySupportTest extends AAISetup { public void setUp() throws Exception { version = schemaVersions.getDefaultVersion(); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); 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 09a1d1b4..58fc0146 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 @@ -94,7 +94,7 @@ public class MultiFormatTest extends AAISetup { public void setUp() throws Exception { version = schemaVersions.getAppRootVersion(); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); 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 b38b20a8..6ed42539 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 @@ -80,7 +80,7 @@ public class PathedURLTest extends AAISetup { version = schemaVersions.getDefaultVersion(); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); 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 232e80b3..217ccd4f 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 @@ -77,7 +77,7 @@ public class RawFormatTest extends AAISetup { version = schemaVersions.getDefaultVersion(); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); 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 e26c56e2..587d943f 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 @@ -72,7 +72,7 @@ public class ResourceFormatTest extends AAISetup { @Before public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); 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 2bb3971d..ac08ae2c 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 @@ -73,7 +73,7 @@ public class ResourceWithSoTTest extends AAISetup { public void setUp() throws Exception { version = schemaVersions.getDefaultVersion(); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); 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 7634d22a..bfe41e1b 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 @@ -80,7 +80,7 @@ public class SimpleFormatTest extends AAISetup { @Before public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); graph = TinkerGraph.open(); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjectorTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjectorTest.java index 0ac12165..9b0639f1 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjectorTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjectorTest.java @@ -47,7 +47,7 @@ public class QueryParamInjectorTest { @Test public void test() throws AAIException { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); QueryParamInjector injector = QueryParamInjector.getInstance(); MultivaluedMap<String, String> params = new MultivaluedHashMap<>(); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java index 63671447..4174207f 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java @@ -52,7 +52,7 @@ public class UrlBuilderTest extends AAISetup { @Before public void before() throws UnsupportedEncodingException, URISyntaxException { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); when(serializer.getURIForVertex(any(Vertex.class))).thenReturn(new URI(uri)); when(v.id()).thenReturn(vId); } |