diff options
38 files changed, 306 insertions, 249 deletions
@@ -8,6 +8,7 @@ bundleconfig-local/etc/logback.xml /.pydevproject /bin/ /.classpath +**/.classpath **/.idea/ */.idea *.iml diff --git a/aai-traversal/.classpath b/aai-traversal/.classpath deleted file mode 100644 index d51354a..0000000 --- a/aai-traversal/.classpath +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="target/generated-sources/annotations"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="ignore_optional_problems" value="true"/> - <attribute name="m2e-apt" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/docker"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - <attribute name="test" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/classes" path="src/main/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/classes" path="target/generated-sources/antlr4"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="test" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="ignore_optional_problems" value="true"/> - <attribute name="m2e-apt" value="true"/> - <attribute name="test" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="output" path="target/classes"/> -</classpath> diff --git a/aai-traversal/pom.xml b/aai-traversal/pom.xml index e0162fb..ff973e2 100644 --- a/aai-traversal/pom.xml +++ b/aai-traversal/pom.xml @@ -94,6 +94,12 @@ <schema.version.api.default>v27</schema.version.api.default> <schema.version.list>v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27</schema.version.list> <schema.uri.base.path>/aai</schema.uri.base.path> + + <!-- versions --> + <spring.boot.version>2.2.0.RELEASE</spring.boot.version> + <spring.version>5.2.0.RELEASE</spring.version> + <spring.test.version>${spring.version}</spring.test.version> + <spring.jms.version>${spring.version}</spring.jms.version> <keycloak.version>11.0.2</keycloak.version> <micrometer-spring-legacy.version>1.3.19</micrometer-spring-legacy.version> <micrometer-core.version>1.6.6</micrometer-core.version> @@ -907,7 +913,7 @@ <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> - <configuration combine.children="append"> + <configuration> <excludes> <exclude>**/*WebSecurityConfig.*</exclude> </excludes> diff --git a/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java b/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java index 5ac3ff1..14bfca0 100644 --- a/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java +++ b/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java @@ -45,6 +45,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.core.env.Environment; +import org.springframework.core.env.Profiles; @SpringBootApplication( exclude = {DataSourceAutoConfiguration.class, @@ -96,8 +97,8 @@ public class TraversalApp { logger.debug("Starting AAIGraph connections and the NodeInjestor"); - if (env.acceptsProfiles(Profiles.TWO_WAY_SSL) - && env.acceptsProfiles(Profiles.ONE_WAY_SSL)) { + if (env.acceptsProfiles(Profiles.of(TraversalProfiles.TWO_WAY_SSL)) + && env.acceptsProfiles(Profiles.of(TraversalProfiles.ONE_WAY_SSL))) { logger.debug("You have seriously misconfigured your application"); } diff --git a/aai-traversal/src/main/java/org/onap/aai/Profiles.java b/aai-traversal/src/main/java/org/onap/aai/TraversalProfiles.java index 0a886af..c1cb6ea 100644 --- a/aai-traversal/src/main/java/org/onap/aai/Profiles.java +++ b/aai-traversal/src/main/java/org/onap/aai/TraversalProfiles.java @@ -19,7 +19,7 @@ */ package org.onap.aai; -public final class Profiles { +public final class TraversalProfiles { public static final String DMAAP = "dmaap"; public static final String DME2 = "dme2"; @@ -31,6 +31,6 @@ public final class Profiles { public static final String AAF_CERT_AUTHENTICATION = "aaf-cert-auth"; public static final String TWO_WAY_SSL = "two-way-ssl"; - private Profiles() { + private TraversalProfiles() { } } diff --git a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java index 1dc8ac1..8e925a5 100644 --- a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java +++ b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java @@ -73,7 +73,6 @@ import org.onap.aai.util.GenericQueryBuilder; import org.onap.aai.util.NodesQueryBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; /** * Database Mapping class which acts as the middle man between the REST interface objects for the @@ -90,7 +89,6 @@ public class SearchGraph { private SchemaVersions schemaVersions; - @Autowired public SearchGraph(LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, SchemaVersions schemaVersions) { this.loaderFactory = loaderFactory; diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java index 78ab1a9..4cd6548 100644 --- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java +++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java @@ -31,7 +31,7 @@ import javax.ws.rs.container.PreMatching; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.aai.Profiles; +import org.onap.aai.TraversalProfiles; import org.onap.aai.exceptions.AAIException; import org.onap.aai.interceptors.AAIContainerFilter; import org.onap.aai.logging.ErrorLogHelper; @@ -39,7 +39,7 @@ import org.onap.aai.service.AuthorizationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; -@Profile(Profiles.ONE_WAY_SSL) +@Profile(TraversalProfiles.ONE_WAY_SSL) @PreMatching @Priority(AAIRequestFilterPriority.AUTHORIZATION) public class OneWaySslAuthorization extends AAIContainerFilter implements ContainerRequestFilter { diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/CQ2Gremlin.java b/aai-traversal/src/main/java/org/onap/aai/rest/CQ2Gremlin.java index 6e76c29..c8f1f0b 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/CQ2Gremlin.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/CQ2Gremlin.java @@ -27,7 +27,11 @@ import javax.ws.rs.Consumes; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.core.*; +import javax.ws.rs.core.Context; +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.config.SpringContextAware; import org.onap.aai.introspection.LoaderFactory; diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/CQ2GremlinTest.java b/aai-traversal/src/main/java/org/onap/aai/rest/CQ2GremlinTest.java index 626c5f3..8c6477f 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/CQ2GremlinTest.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/CQ2GremlinTest.java @@ -19,10 +19,13 @@ */ package org.onap.aai.rest; -import com.beust.jcommander.internal.Lists; -import com.beust.jcommander.internal.Maps; - -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -30,7 +33,11 @@ import javax.ws.rs.Consumes; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.core.*; +import javax.ws.rs.core.Context; +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.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; @@ -59,6 +66,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.RequestBody; +import com.beust.jcommander.internal.Lists; +import com.beust.jcommander.internal.Maps; + @Path("/cq2gremlintest") public class CQ2GremlinTest extends RESTAPI { diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java index 2b6bbb9..bbb1aea 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java @@ -19,19 +19,30 @@ */ package org.onap.aai.rest; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import io.micrometer.core.annotation.Timed; - -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.SchemaViolationException; @@ -61,6 +72,12 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import io.micrometer.core.annotation.Timed; + @Path("{version: v[1-9][0-9]*|latest}/dsl") @Timed public class DslConsumer extends TraversalConsumer { @@ -147,7 +164,7 @@ public class DslConsumer extends TraversalConsumer { traversalUriHttpEntry.setHttpEntryProperties(version, serverBase); traversalUriHttpEntry.setPaginationParameters(resultIndex, resultSize); dbEngine = traversalUriHttpEntry.getDbEngine(); - JsonObject input = new JsonParser().parse(content).getAsJsonObject(); + JsonObject input = JsonParser.parseString(content).getAsJsonObject(); JsonElement dslElement = input.get("dsl"); String dsl = ""; if (dslElement != null) { diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java index 460065e..cade20c 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java @@ -19,20 +19,30 @@ */ package org.onap.aai.rest; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import io.micrometer.core.annotation.Timed; - import java.net.URI; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -64,6 +74,12 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import io.micrometer.core.annotation.Timed; + @Path("{version: v[1-9][0-9]*|latest}/query") @Timed public class QueryConsumer extends TraversalConsumer { @@ -134,8 +150,7 @@ public class QueryConsumer extends TraversalConsumer { } SubGraphStyle subGraphStyle = SubGraphStyle.valueOf(subgraph); - JsonParser parser = new JsonParser(); - JsonObject input = parser.parse(content).getAsJsonObject(); + JsonObject input = JsonParser.parseString(content).getAsJsonObject(); JsonElement startElement = input.get("start"); JsonElement queryElement = input.get("query"); JsonElement gremlinElement = input.get("gremlin"); diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java index 7f40979..5f2f161 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java @@ -19,15 +19,22 @@ */ package org.onap.aai.rest; -import io.micrometer.core.annotation.Timed; - import java.util.List; import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; import org.onap.aai.concurrent.AaiCallable; import org.onap.aai.exceptions.AAIException; @@ -55,6 +62,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import io.micrometer.core.annotation.Timed; + @Path("/recents/{version: v[1-9][0-9]*|latest}") @Timed public class RecentAPIConsumer extends RESTAPI { diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java index a21ca04..ffffaa6 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java @@ -39,7 +39,6 @@ import org.onap.aai.rest.dsl.validation.DslValidator; import org.onap.aai.rest.enums.QueryVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; /** * The Class DslQueryProcessor. @@ -58,7 +57,6 @@ public class DslQueryProcessor { private boolean isAggregate = false; - @Autowired public DslQueryProcessor(Map<QueryVersion, ParseTreeListener> dslListeners) { this.dslListeners = dslListeners; } diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v1/DslListener.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v1/DslListener.java index ad2899c..1987310 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v1/DslListener.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v1/DslListener.java @@ -39,7 +39,6 @@ import org.onap.aai.rest.dsl.validation.DslValidatorRule; import org.onap.aai.setup.SchemaVersions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; /** * The Class DslListener. @@ -73,7 +72,6 @@ public class DslListener extends AAIDslBaseListener { /** * Instantiates a new DslListener. */ - @Autowired public DslListener(EdgeIngestor edgeIngestor, SchemaVersions schemaVersions, LoaderFactory loaderFactory) { this.loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v2/DslListener.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v2/DslListener.java index 7e46c0b..5395af0 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v2/DslListener.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/v2/DslListener.java @@ -42,7 +42,6 @@ import org.onap.aai.rest.enums.EdgeDirection; import org.onap.aai.setup.SchemaVersions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; /** * The Class DslListener. @@ -86,7 +85,6 @@ public class DslListener extends AAIDslBaseListener { /** * Instantiates a new DslListener. */ - @Autowired public DslListener(EdgeIngestor edgeIngestor, SchemaVersions schemaVersions, LoaderFactory loaderFactory) { this.loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java index 98eb551..edd882c 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java @@ -19,6 +19,10 @@ */ package org.onap.aai.rest.search; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -26,10 +30,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - public class GetCustomQueryConfig { private JsonArray storedQueries = null; @@ -46,8 +46,7 @@ public class GetCustomQueryConfig { } private void init(String customQueryJson) { - JsonParser parser = new JsonParser(); - JsonObject queriesObject = parser.parse(customQueryJson).getAsJsonObject(); + JsonObject queriesObject = JsonParser.parseString(customQueryJson).getAsJsonObject(); if (queriesObject.has(STORED_QUERIES_CONFIG)) { storedQueries = queriesObject.getAsJsonArray(STORED_QUERIES_CONFIG); diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java index a3bb074..8ddf815 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java @@ -40,7 +40,6 @@ import org.onap.aai.logging.LogFormatTools; import org.onap.aai.util.AAIConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; public class GremlinServerSingleton { @@ -61,7 +60,6 @@ public class GremlinServerSingleton { * the properties object * */ - @Autowired public GremlinServerSingleton(CQConfig customQueryInfo) { this.customQueryInfo = customQueryInfo; } diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java index 5c8b055..cb31d1a 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java @@ -28,8 +28,12 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.core.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; import org.onap.aai.aailog.logs.AaiDBTraversalMetricLog; import org.onap.aai.concurrent.AaiCallable; diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java index 17edbc5..27fccb8 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java @@ -19,17 +19,23 @@ */ package org.onap.aai.rest.search; -import io.micrometer.core.annotation.Timed; - import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Optional; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.*; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; import org.onap.aai.aailog.logs.AaiDBTraversalMetricLog; import org.onap.aai.concurrent.AaiCallable; @@ -57,6 +63,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import io.micrometer.core.annotation.Timed; + /** * Implements the search subdomain in the REST API. All API calls must include X-FromAppId and * X-TransactionId in the header. diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/security/WebSecurityConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/security/WebSecurityConfig.java index e24013b..e77c3b3 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/security/WebSecurityConfig.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/security/WebSecurityConfig.java @@ -72,7 +72,7 @@ public class WebSecurityConfig extends KeycloakWebSecurityConfigurerAdapter { } @Override - public void configure(WebSecurity web) throws Exception { + public void configure(WebSecurity web) { web.ignoring().regexMatchers("^.*/util/echo$"); } } diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java b/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java index 2e42e4c..c3409f8 100644 --- a/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java +++ b/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java @@ -36,6 +36,7 @@ import javax.ws.rs.core.Response.Status; import org.onap.aai.exceptions.AAIException; import org.onap.aai.logging.ErrorLogHelper; import org.onap.aai.restcore.RESTAPI; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -51,6 +52,7 @@ public class EchoResponse extends RESTAPI { private AaiGraphChecker aaiGraphChecker; + @Autowired public EchoResponse(AaiGraphChecker aaiGraphChecker) { this.aaiGraphChecker = aaiGraphChecker; } diff --git a/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java b/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java index b448bc8..10bee2b 100644 --- a/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java +++ b/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java @@ -31,7 +31,7 @@ import java.util.stream.Stream; import javax.annotation.PostConstruct; import org.eclipse.jetty.util.security.Password; -import org.onap.aai.Profiles; +import org.onap.aai.TraversalProfiles; import org.onap.aai.util.AAIConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +39,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; @Service -@Profile(Profiles.ONE_WAY_SSL) +@Profile(TraversalProfiles.ONE_WAY_SSL) public class AuthorizationService { private static final Logger logger = LoggerFactory.getLogger(AuthorizationService.class); diff --git a/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java b/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java index 87d6d8f..feb8d1d 100644 --- a/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java +++ b/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java @@ -38,7 +38,6 @@ import org.onap.aai.rest.search.ModelAndNamedQueryRestProvider; import org.onap.aai.rest.search.SearchProvider; import org.onap.aai.rest.util.EchoResponse; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @@ -56,7 +55,6 @@ public class JerseyConfiguration { private final Environment environment; - @Autowired public JerseyConfiguration(Environment environment) { this.environment = environment; } diff --git a/aai-traversal/src/main/resources/application.properties b/aai-traversal/src/main/resources/application.properties index 6b26c1a..9b374d4 100644 --- a/aai-traversal/src/main/resources/application.properties +++ b/aai-traversal/src/main/resources/application.properties @@ -27,8 +27,8 @@ server.tomcat.max-idle-time=60000 # If you get an application startup failure that the port is already taken # If thats not it, please check if the key-store file path makes sense -server.local.startpath=aai-traversal/src/main/resources/ -server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties +server.local.startpath=aai-traversal/src/main/resources +server.basic.auth.location=${server.local.startpath}/etc/auth/realm.properties server.port=8446 server.ssl.enabled-protocols=TLSv1.1,TLSv1.2 @@ -45,7 +45,7 @@ spring.profiles.active=production,one-way-ssl # Switch to keycloak #spring.profiles.active=production, keycloak ### -server.certs.location=${server.local.startpath}etc/auth/ +server.certs.location=${server.local.startpath}/etc/auth/ server.keystore.name.pkcs12=aai_keystore server.keystore.name=aai_keystore server.truststore.name=aai_keystore diff --git a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java index 266cb60..652c2f3 100644 --- a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java @@ -25,14 +25,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.fail; -import com.jayway.jsonpath.JsonPath; - -import java.util.*; +import java.util.Base64; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraphTransaction; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; import org.onap.aai.config.PropertyPasswordConfiguration; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; @@ -44,13 +50,20 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Import; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.rules.SpringClassRule; import org.springframework.test.context.junit4.rules.SpringMethodRule; import org.springframework.web.client.RestTemplate; +import com.jayway.jsonpath.JsonPath; + /** * A sample junit test using spring boot that provides the ability to spin * up the application from the junit layer and run rest requests against @@ -92,8 +105,8 @@ public class AAIGremlinQueryTest { @BeforeClass public static void setupConfig() throws AAIException { - System.setProperty("AJSC_HOME", "./"); - System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); AAIConfig.init(); } diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java index 8c6364d..e3351ae 100644 --- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java @@ -25,9 +25,6 @@ import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -57,6 +54,9 @@ import org.onap.aai.exceptions.AAIException; import org.onap.aai.rest.util.AAIExtensionMap; import org.onap.aai.util.AAIConstants; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + public class SearchGraphNamedQueryTest extends AAISetup { protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); @@ -83,7 +83,7 @@ public class SearchGraphNamedQueryTest extends AAISetup { private HttpTestUtil httpTestUtil; private String getJsonValue(String json, String key) { - JsonObject jsonObj = new JsonParser().parse(json).getAsJsonObject(); + JsonObject jsonObj = JsonParser.parseString(json).getAsJsonObject(); String strValue = ""; if (jsonObj.isJsonObject()) { strValue = jsonObj.get(key).getAsString(); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java index ac71b57..21a7862 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java @@ -29,10 +29,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphTransaction; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; import org.onap.aai.TraversalApp; import org.onap.aai.TraversalTestConfiguration; -import org.onap.aai.config.PropertyPasswordConfiguration; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; import org.onap.aai.nodes.NodeIngestor; @@ -44,7 +47,6 @@ import org.springframework.context.annotation.Import; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.rules.SpringClassRule; import org.springframework.test.context.junit4.rules.SpringMethodRule; @@ -79,8 +81,8 @@ public abstract class AbstractSpringRestTest { @BeforeClass public static void setupConfig() throws AAIException { - System.setProperty("AJSC_HOME", "./"); - System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); } @Before diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java index b72107f..b02911a 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java @@ -22,14 +22,16 @@ package org.onap.aai.rest; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -42,7 +44,16 @@ import org.onap.aai.util.AAIConfig; import org.onap.aai.util.TraversalConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; public class DslConsumerTest extends AbstractSpringRestTest { @@ -330,8 +341,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("properties").getAsJsonObject(); @@ -358,8 +368,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("properties").getAsJsonObject(); @@ -387,8 +396,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -416,8 +424,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -446,8 +453,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -475,8 +481,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -502,8 +507,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); assertNull( @@ -546,8 +550,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonArray resultsValue = resultsArray.get(0).getAsJsonArray(); assertNotNull(resultsValue.get(1).getAsJsonObject() @@ -592,8 +595,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject properties = resultsArray.get(0).getAsJsonObject() .get("/aai/v16/cloud-infrastructure/pservers/pserver/test-pserver-dsl") @@ -626,8 +628,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); assertEquals(1, resultsArray.size()); // Returns only test-pserver-dsl, does not return // test-pserver-dsl-03 since it does not have an edge @@ -654,8 +655,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); assertEquals(1, resultsArray.size()); // Returns only test-pserver-dsl-02 assertEquals(null, resultsArray.get(0).getAsJsonObject() @@ -698,8 +698,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultValue = resultsArray.get(0).getAsJsonObject(); JsonObject complex = resultValue.get("complex").getAsJsonObject(); @@ -721,8 +720,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { String responseString = responseEntity.getBody().toString(); // Extract the properties array from the response and compare in assert statements - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); for (JsonElement je : resultsArray) { JsonObject jo = je.getAsJsonObject(); @@ -752,8 +750,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); // pnf should have no results - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); boolean hasPserver1 = false, hasPserver2 = false; for (JsonElement je : resultsArray) { @@ -791,8 +788,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); for (JsonElement je : resultsArray) { JsonObject jo = je.getAsJsonObject(); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java index 472cffb..7442386 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java @@ -20,12 +20,9 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import java.util.Arrays; import java.util.HashSet; @@ -45,6 +42,11 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + @Ignore("The state format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -146,7 +148,7 @@ public class CQAllChildernFromPnfStateTest extends AbstractSpringHistoryRestTest httpEntity = new HttpEntity(payload.toString(), headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); @@ -162,7 +164,7 @@ public class CQAllChildernFromPnfStateTest extends AbstractSpringHistoryRestTest httpEntity = new HttpEntity(payload.toString(), headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java index d26eff2..3411c2a 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java @@ -20,14 +20,18 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -44,6 +48,11 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + @Ignore("The lifecycle format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -148,7 +157,7 @@ public class DslConsumerHistoryLifecycleEdgeTest extends AbstractSpringHistoryRe httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java index dc794b8..4a94504 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java @@ -20,13 +20,16 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.JanusGraphTransaction; @@ -42,6 +45,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + @Ignore("The lifecycle format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -200,7 +207,7 @@ public class DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java index 6d1a36c..88cc91c 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java @@ -20,13 +20,16 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.JanusGraphTransaction; @@ -42,6 +45,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + @Ignore("The lifecycle format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -141,7 +148,7 @@ public class DslConsumerHistoryLifecycleSingleNodeTest extends AbstractSpringHis httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java index 6b9815c..1a88c8b 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java @@ -20,14 +20,20 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -44,6 +50,11 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + @Ignore("The state format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -148,7 +159,7 @@ public class DslConsumerHistoryStateEdgeTest extends AbstractSpringHistoryRestTe httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java index 5b08d83..1596fd4 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java @@ -20,13 +20,18 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.JanusGraphTransaction; @@ -42,6 +47,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + @Ignore("The state format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -179,7 +188,7 @@ public class DslConsumerHistoryStateTest extends AbstractSpringHistoryRestTest { httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java index 08136c2..bdd52ee 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java @@ -157,9 +157,9 @@ public abstract class QueryTest { addParam(params); when(dbEngine.getQueryBuilder(any(QueryStyle.class))) .thenReturn(new GremlinTraversal<>(loader, graph.traversal())); - logger.info("Stored query in abstraction form {}", query); + logger.debug("Stored query in abstraction form {}", query); query = new GroovyQueryBuilder().executeTraversal(dbEngine, query, params); - logger.info("After converting to gremlin query {}", query); + logger.debug("After converting to gremlin query {}", query); query = "g" + query; GraphTraversal<Vertex, Vertex> g = graph.traversal().V(); addStartNode(g); @@ -173,8 +173,8 @@ public abstract class QueryTest { List<Vertex> vertices = result.toList(); - logger.info("Expected result set of vertexes [{}]", convert(expectedResult)); - logger.info("Actual Result set of vertexes [{}]", convert(vertices)); + logger.debug("Expected result set of vertexes [{}]", convert(expectedResult)); + logger.debug("Actual Result set of vertexes [{}]", convert(vertices)); List<Vertex> nonDuplicateExpectedResult = new ArrayList<>(new HashSet<>(expectedResult)); vertices = new ArrayList<>(new HashSet<>(vertices)); diff --git a/aai-traversal/src/test/resources/application-onap-test.properties b/aai-traversal/src/test/resources/application-onap-test.properties index 7d70fac..24bff05 100644 --- a/aai-traversal/src/test/resources/application-onap-test.properties +++ b/aai-traversal/src/test/resources/application-onap-test.properties @@ -7,7 +7,7 @@ info.build.version=1.1.0 spring.application.name=aai-traversal spring.jersey.type=filter -server.contextPath=/ +server.servlet.context-path=/ spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration spring.jersey.application-path=${schema.uri.base.path} @@ -25,14 +25,14 @@ server.context_parameters.p-name=value #context parameter with p-name as key and # If you get an application startup failure that the port is already taken # If thats not it, please check if the key-store file path makes sense -server.local.startpath=src/main/resources/ -server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties +server.local.startpath=src/main/resources +server.basic.auth.location=${server.local.startpath}/etc/auth/realm.properties server.port=8446 server.ssl.enabled-protocols=TLSv1.1,TLSv1.2 -server.ssl.key-store=${server.local.startpath}etc/auth/aai-client-cert.p12 +server.ssl.key-store=${server.local.startpath}/etc/auth/aai-client-cert.p12 server.ssl.key-store-password=password(1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o) -server.ssl.trust-store=${server.local.startpath}etc/auth/tomcat_keystore +server.ssl.trust-store=${server.local.startpath}/etc/auth/tomcat_keystore server.ssl.trust-store-password=password(1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o) server.ssl.client-auth=want server.ssl.key-store-type=JKS diff --git a/aai-traversal/src/test/resources/application-test.properties b/aai-traversal/src/test/resources/application-test.properties index 72f28b7..d2ad6a6 100644 --- a/aai-traversal/src/test/resources/application-test.properties +++ b/aai-traversal/src/test/resources/application-test.properties @@ -30,14 +30,14 @@ server.context_parameters.p-name=value #context parameter with p-name as key and # If you get an application startup failure that the port is already taken # If thats not it, please check if the key-store file path makes sense -server.local.startpath=src/main/resources/ -server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties +server.local.startpath=src/main/resources +server.basic.auth.location=${server.local.startpath}/etc/auth/realm.properties server.port=8446 security.require-ssl=false server.ssl.enabled=false #server.ssl.enabled-protocols=TLSv1.1,TLSv1.2 -#server.ssl.key-store=${server.local.startpath}etc/auth/aai_keystore +#server.ssl.key-store=${server.local.startpath}/etc/auth/aai_keystore #server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0) #server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0) #server.ssl.client-auth=want diff --git a/aai-traversal/src/test/resources/logback.xml b/aai-traversal/src/test/resources/logback.xml index 4b969b1..fc275dd 100644 --- a/aai-traversal/src/test/resources/logback.xml +++ b/aai-traversal/src/test/resources/logback.xml @@ -299,7 +299,7 @@ <logger name="org.zookeeper" level="OFF" /> - <logger name="org.onap.aai" level="DEBUG" additivity="false"> + <logger name="org.onap.aai" level="INFO" additivity="false"> <appender-ref ref="asyncDEBUG" /> <appender-ref ref="asyncSANE" /> <appender-ref ref="STDOUT" /> @@ -338,6 +338,9 @@ <appender-ref ref="dmaapAAIEventConsumerInfo" /> </logger> + <logger name="org.onap.aai.dbgen" level="WARN"/> + <logger name="org.onap.aai.aailog" level="WARN"/> + <!-- ============================================================================ --> <!-- General EELF logger --> <!-- ============================================================================ --> @@ -347,7 +350,7 @@ <appender-ref ref="asyncMETRIC" /> </logger> - <root level="DEBUG"> + <root level="INFO"> <appender-ref ref="external" /> <appender-ref ref="STDOUT" /> </root> |