aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-resources/pom.xml164
-rw-r--r--aai-resources/src/main/docker/Dockerfile32
-rw-r--r--aai-resources/src/main/docker/docker-entrypoint.sh68
-rw-r--r--aai-resources/src/main/java/org/onap/aai/ResourcesApp.java13
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/NamespaceInterceptor.java128
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/ExceptionHandler.java1
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java183
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java50
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java1
-rw-r--r--aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java9
-rw-r--r--aai-resources/src/main/resources/application.properties9
-rw-r--r--aai-resources/src/main/scripts/install/addManualData.sh6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/AAISetup.java18
-rw-r--r--aai-resources/src/test/java/org/onap/aai/config/WebClientConfiguration.java49
-rw-r--r--aai-resources/src/test/java/org/onap/aai/entities/Model.java62
-rw-r--r--aai-resources/src/test/java/org/onap/aai/entities/ModelElement.java48
-rw-r--r--aai-resources/src/test/java/org/onap/aai/entities/ModelVersion.java72
-rw-r--r--aai-resources/src/test/java/org/onap/aai/entities/PServer.java60
-rw-r--r--aai-resources/src/test/java/org/onap/aai/entities/PServerListResponse.java30
-rw-r--r--aai-resources/src/test/java/org/onap/aai/it/performance/K6PerformanceTest.java12
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java18
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java11
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java30
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java10
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java2
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java252
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java165
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java14
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java14
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/EchoHealthIndicatorTest.java70
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java2
-rw-r--r--aai-resources/src/test/resources/application-test.properties5
-rw-r--r--aai-resources/src/test/resources/it/application-keycloak-test.properties2
-rw-r--r--aai-resources/src/test/resources/logback.xml2
-rw-r--r--aai-resources/src/test/resources/payloads/models/model-version.xml12
-rw-r--r--aai-resources/src/test/resources/payloads/models/network-service.xml15
-rw-r--r--onap-java-formatter.xml6
-rw-r--r--pom.xml21
-rw-r--r--releases/1.14.3-container-release.yaml7
-rw-r--r--releases/1.14.4-container-release.yaml7
-rw-r--r--releases/1.14.5-container-release.yaml7
-rw-r--r--releases/1.14.6-container-release.yaml7
-rw-r--r--releases/1.14.7-container-release.yaml7
-rw-r--r--version.properties2
49 files changed, 1135 insertions, 582 deletions
diff --git a/aai-resources/pom.xml b/aai-resources/pom.xml
index d50695d..83c6c92 100644
--- a/aai-resources/pom.xml
+++ b/aai-resources/pom.xml
@@ -28,10 +28,10 @@
<parent>
<groupId>org.onap.aai.resources</groupId>
<artifactId>resources</artifactId>
- <version>1.14.1-SNAPSHOT</version>
+ <version>1.14.7-SNAPSHOT</version>
</parent>
<properties>
- <java.version>1.8</java.version>
+ <java.version>11</java.version>
<start-class>org.onap.aai.ResourcesApp</start-class>
<!-- Default docker registry that maven fabric plugin will try to pull from -->
@@ -40,8 +40,6 @@
<!-- This value should be overwritten at runtime to wherever need to be pushed to -->
<docker.push.registry>localhost:5000</docker.push.registry>
<aai.docker.version>1.0.0</aai.docker.version>
- <aai.base.image>alpine</aai.base.image>
- <aai.base.image.version>1.13.4</aai.base.image.version>
<netty.handler.version>4.1.63.Final</netty.handler.version>
<netty.version>4.1.63.Final</netty.version>
@@ -81,26 +79,27 @@
<schema.ingest.file>${project.basedir}/src/main/resources/application.properties</schema.ingest.file>
<!-- End of Default ONAP Schema Properties -->
- <spring.boot.version>2.4.13</spring.boot.version>
- <spring.version>5.3.13</spring.version>
+ <janusgraph.version>0.6.4</janusgraph.version>
+ <gremlin.version>3.5.8</gremlin.version>
+
<javax.servlet.version>4.0.1</javax.servlet.version>
- <spring.jms.version>${spring.version}</spring.jms.version>
- <spring.test.version>${spring.version}</spring.test.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>
- <micrometer-registry-prometheus.version>1.6.6</micrometer-registry-prometheus.version>
- <micrometer-jersey2>1.6.6</micrometer-jersey2>
<testcontainers.version>1.6.1</testcontainers.version>
<mockito.core.version>4.4.0</mockito.core.version>
- <eclipse.persistence.version>2.6.2</eclipse.persistence.version>
+ <eclipse.persistence.version>2.7.7</eclipse.persistence.version>
<!-- Setting some default value to not complain by editor but it will be overridden by gmaven plugin -->
<!-- Integration tests will be skipped by default. Could be enabled here or by -DskipITs=false-->
<skipITs>true</skipITs>
<swagger.version>1.6.8</swagger.version>
- <spring-cloud.version>2020.0.2</spring-cloud.version>
+ <spring-cloud.version>2020.0.6</spring-cloud.version>
+ <!-- fix the driver version to match the one defined in janusgraph-cql
+ spring-boot (2.4) is otherwise downgrading it to 4.9.0 -->
+ <!-- see https://github.com/spring-projects/spring-boot/blob/d336a96b7f204a398b8237560c5dfa7095c53460/spring-boot-project/spring-boot-dependencies/build.gradle#L163 -->
+ <!-- see https://github.com/JanusGraph/janusgraph/blob/6105d67f412def90ed6e704fa01cbf656602e6c9/pom.xml#L112 -->
+ <cassandra-driver.version>4.17.0</cassandra-driver.version>
+ <datastax.native-protocol.version>1.5.1</datastax.native-protocol.version>
</properties>
<profiles>
<!-- Docker profile to be used for building docker image and pushing to nexus -->
@@ -109,36 +108,15 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <version>1.0</version>
- <executions>
- <execution>
- <phase>pre-clean</phase>
- </execution>
- <execution>
- <id>parse-base</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <source>
- def userAaiBaseImage = session.userProperties['aai.base.image']
- def userAaiCommonVersion = session.userProperties['aai.base.image.version']
- if (userAaiCommonVersion != null) {
- project.properties['aai.base.image.version'] = userAaiCommonVersion
- }
- if (userAaiBaseImage != null) {
- project.properties['aai.base.image'] = userAaiBaseImage
- }
- log.info 'Base image flavour: ' + project.properties['aai.base.image']
- log.info 'Base image version: ' + project.properties['aai.base.image.version']
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>pre-clean</phase>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
@@ -309,7 +287,21 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-hateoas</artifactId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
@@ -318,26 +310,14 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
- </dependency>
- <dependency>
- <groupId>io.micrometer</groupId>
- <artifactId>micrometer-spring-legacy</artifactId>
- <version>${micrometer-spring-legacy.version}</version>
- </dependency>
- <dependency>
- <groupId>io.micrometer</groupId>
- <artifactId>micrometer-core</artifactId>
- <version>${micrometer-core.version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
- <version>${micrometer-registry-prometheus.version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-jersey2</artifactId>
- <version>${micrometer-jersey2}</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
@@ -454,7 +434,8 @@
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-junit</artifactId>
+ <artifactId>hamcrest</artifactId>
+ <version>2.2</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
@@ -606,6 +587,24 @@
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.21.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-junit</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
@@ -640,20 +639,6 @@
<version>${netty.handler.version}</version>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-jetty</artifactId>
- </dependency>
- <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty.version}</version>
@@ -686,6 +671,12 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-inmemory</artifactId>
+ <version>${janusgraph.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-groovy</artifactId>
</dependency>
@@ -719,6 +710,12 @@
<artifactId>testcontainers</artifactId>
<version>1.19.8</version>
<scope>test</scope>
+ <!-- <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions> -->
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
@@ -733,6 +730,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-matchers</artifactId>
+ <version>2.7.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
@@ -764,6 +767,23 @@
<artifactId>guava</artifactId>
<version>25.0-jre</version>
</dependency>
+ <!-- cassandra driver -->
+ <dependency>
+ <groupId>com.datastax.oss</groupId>
+ <artifactId>java-driver-core</artifactId>
+ <version>${cassandra-driver.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.datastax.oss</groupId>
+ <artifactId>java-driver-query-builder</artifactId>
+ <version>${cassandra-driver.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.datastax.oss</groupId>
+ <artifactId>native-protocol</artifactId>
+ <version>${datastax.native-protocol.version}</version>
+ </dependency>
+ <!-- /cassandra driver -->
</dependencies>
</dependencyManagement>
<build>
diff --git a/aai-resources/src/main/docker/Dockerfile b/aai-resources/src/main/docker/Dockerfile
index 754c49a..b15abf9 100644
--- a/aai-resources/src/main/docker/Dockerfile
+++ b/aai-resources/src/main/docker/Dockerfile
@@ -1,32 +1,12 @@
-FROM @aai.docker.namespace@/aai-common-@aai.base.image@:@aai.base.image.version@
+FROM eclipse-temurin:11-jre-alpine
+USER nobody
-USER root
-RUN mkdir -p /opt/aaihome/aaiadmin /opt/aai/logroot/AAI-RES /opt/bulkprocess_load
-
-
-VOLUME /tmp
-VOLUME /opt/tools
-
-HEALTHCHECK --interval=40s --timeout=10s --retries=3 CMD nc -z -v localhost ${SERVER_PORT:-8447} || exit 1
-
-
-
-ENV AAI_BUILD_VERSION @aai.docker.version@
-# Expose the ports for outside linux to use
-# 8447 is the important one to be used
-EXPOSE 8447
+ENV SERVER_PORT=8447
+EXPOSE ${SERVER_PORT}
# Add the proper files into the docker image from your build
WORKDIR /opt/app/aai-resources
-RUN chown -R aaiadmin:aaiadmin \
- /opt/app/aai-resources \
- /etc/profile.d \
- /opt/aai/logroot/AAI-RES \
- /opt/bulkprocess_load
-
-COPY --chown=aaiadmin:aaiadmin /maven/aai-resources/ .
-
-USER aaiadmin
+COPY --chown=nobody:nobody /maven/aai-resources/ .
-ENTRYPOINT ["/bin/bash", "/opt/app/aai-resources/docker-entrypoint.sh"]
+ENTRYPOINT ["/bin/sh", "/opt/app/aai-resources/docker-entrypoint.sh"]
diff --git a/aai-resources/src/main/docker/docker-entrypoint.sh b/aai-resources/src/main/docker/docker-entrypoint.sh
index 97bcb76..849c5d2 100644
--- a/aai-resources/src/main/docker/docker-entrypoint.sh
+++ b/aai-resources/src/main/docker/docker-entrypoint.sh
@@ -7,9 +7,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,67 +26,14 @@ export SERVER_PORT=${SERVER_PORT:-8447};
USER_ID=${LOCAL_USER_ID:-9001}
GROUP_ID=${LOCAL_GROUP_ID:-9001}
-find /opt/app/ -name "*.sh" -exec chmod +x {} +
-
-if [ -f ${APP_HOME}/aai.sh ]; then
-
- ln -s bin scripts
- ln -s /opt/aai/logroot/AAI-RES logs
-
- mv ${APP_HOME}/aai.sh /etc/profile.d/aai.sh
- chmod 755 /etc/profile.d/aai.sh
-
- scriptName=$1;
-
- if [ ! -z $scriptName ]; then
-
- if [ -f ${APP_HOME}/bin/${scriptName} ]; then
- shift 1;
- ${APP_HOME}/bin/${scriptName} "$@" || {
- echo "Failed to run the ${scriptName}";
- exit 1;
- }
- else
- echo "Unable to find the script ${scriptName} in ${APP_HOME}/bin";
- exit 1;
- fi;
-
- exit 0;
- fi;
-
- if [ ! -f ${APP_HOME}/scripts/updatePem.sh ]; then
- echo "Unable to find the updatePem script";
- exit 1;
- else
- ${APP_HOME}/scripts/updatePem.sh
- fi;
-
-fi;
-
-mkdir -p /opt/app/aai-resources/logs/gc
-
-if [ -f ${APP_HOME}/resources/aai-resources-swm-vars.sh ]; then
- source ${APP_HOME}/resources/aai-resources-swm-vars.sh;
-fi;
-
-if [ ! -z "${HEAP_SIZE}" ]; then
- MIN_HEAP_SIZE=${HEAP_SIZE};
- MAX_HEAP_SIZE=${HEAP_SIZE};
-fi;
-
-MIN_HEAP_SIZE=${MIN_HEAP_SIZE:-512m};
-MAX_HEAP_SIZE=${MAX_HEAP_SIZE:-1024m};
MAX_METASPACE_SIZE=${MAX_METASPACE_SIZE:-512m};
JAVA_CMD="exec java";
-JVM_OPTS="${PRE_JVM_ARGS} -Xloggc:/opt/app/aai-resources/logs/gc/aai_gc.log";
+JVM_OPTS="${PRE_JVM_ARGS}";
JVM_OPTS="${JVM_OPTS} -XX:HeapDumpPath=/opt/app/aai-resources/logs/ajsc-jetty/heap-dump";
-JVM_OPTS="${JVM_OPTS} -Xms${MIN_HEAP_SIZE}";
-JVM_OPTS="${JVM_OPTS} -Xmx${MAX_HEAP_SIZE}";
+JVM_OPTS="${JVM_OPTS} -XX:MaxRAMPercentage=${MAX_RAM_PERCENTAGE:-60}";
-JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails";
-JVM_OPTS="${JVM_OPTS} -XX:+PrintGCTimeStamps";
JVM_OPTS="${JVM_OPTS} -XX:MaxMetaspaceSize=${MAX_METASPACE_SIZE}";
JVM_OPTS="${JVM_OPTS} -server";
@@ -94,16 +41,12 @@ JVM_OPTS="${JVM_OPTS} -XX:NewSize=512m";
JVM_OPTS="${JVM_OPTS} -XX:MaxNewSize=512m";
JVM_OPTS="${JVM_OPTS} -XX:SurvivorRatio=8";
JVM_OPTS="${JVM_OPTS} -XX:+DisableExplicitGC";
-JVM_OPTS="${JVM_OPTS} -verbose:gc";
-JVM_OPTS="${JVM_OPTS} -XX:+UseParNewGC";
+JVM_OPTS="${JVM_OPTS} -XX:+UseG1GC";
JVM_OPTS="${JVM_OPTS} -XX:+CMSParallelRemarkEnabled";
JVM_OPTS="${JVM_OPTS} -XX:+CMSClassUnloadingEnabled";
-JVM_OPTS="${JVM_OPTS} -XX:+UseConcMarkSweepGC";
JVM_OPTS="${JVM_OPTS} -XX:-UseBiasedLocking";
JVM_OPTS="${JVM_OPTS} -XX:ParallelGCThreads=4";
JVM_OPTS="${JVM_OPTS} -XX:LargePageSizeInBytes=128m";
-JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails";
-JVM_OPTS="${JVM_OPTS} -XX:+PrintGCTimeStamps";
JVM_OPTS="${JVM_OPTS} -Dsun.net.inetaddr.ttl=180";
JVM_OPTS="${JVM_OPTS} -XX:+HeapDumpOnOutOfMemoryError";
JVM_OPTS="${JVM_OPTS} ${POST_JVM_ARGS}";
@@ -118,7 +61,6 @@ JAVA_OPTS="${JAVA_OPTS} -DAAI_CHEF_ENV=${AAI_CHEF_ENV}";
JAVA_OPTS="${JAVA_OPTS} -DSCLD_ENV=${SCLD_ENV}";
JAVA_OPTS="${JAVA_OPTS} -DAFT_ENVIRONMENT=${AFT_ENVIRONMENT}";
JAVA_OPTS="${JAVA_OPTS} -DlrmName=com.att.ajsc.aai-resources";
-JAVA_OPTS="${JAVA_OPTS} -DAAI_BUILD_VERSION=${AAI_BUILD_VERSION}";
JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom";
JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=./resources/logback.xml";
JAVA_OPTS="${JAVA_OPTS} -Dloader.path=$APP_HOME/resources";
diff --git a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java
index 007b0d1..51f5609 100644
--- a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java
+++ b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java
@@ -37,24 +37,17 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
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, DataSourceTransactionManagerAutoConfiguration.class,
- HibernateJpaAutoConfiguration.class})
-// Component Scan provides a way to look for spring beans
-// It only searches beans in the following packages
-// Any method annotated with @Bean annotation or any class
-// with @Component, @Configuration, @Service will be picked up
-@ComponentScan(
- basePackages = {"org.onap.aai.config", "org.onap.aai.web", "org.onap.aai.setup", "org.onap.aai.tasks",
- "org.onap.aai.service", "org.onap.aai.rest", "org.onap.aai.aaf", "org.onap.aai.TenantIsolation",
- "org.onap.aai.aailog", "org.onap.aai.prevalidation"})
+ HibernateJpaAutoConfiguration.class, CassandraDataAutoConfiguration.class, CassandraAutoConfiguration.class})
public class ResourcesApp {
private static final Logger logger = LoggerFactory.getLogger(ResourcesApp.class.getName());
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/NamespaceInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/NamespaceInterceptor.java
new file mode 100644
index 0000000..c97e475
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/NamespaceInterceptor.java
@@ -0,0 +1,128 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.interceptors.pre;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+
+import javax.annotation.Priority;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.ReaderInterceptor;
+import javax.ws.rs.ext.ReaderInterceptorContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.onap.aai.IncreaseNodesTool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * With newer versions of EclipseLink Moxy, the xmlns attribute cannot be included
+ * in the xml structure anymore.
+ * Changes to the model-loader and babel would be required to 'properly' remove
+ * it for the model-distribution.
+ * Since the impact of such a change is hard to judge, this workaround is taken
+ * that is less invasive and with a lower risk of breaking model distribution.
+ *
+ * @deprecated This is only meant as a temporary compatibility layer and will be removed in the future
+ * once all clients have been updated to not include the xmlns attribute.
+ *
+ */
+@Deprecated
+@Component
+@Priority(AAIRequestFilterPriority.REQUEST_MODIFICATION)
+@ConditionalOnProperty(value = "aai.remove-xmlns.enabled", havingValue = "true", matchIfMissing = true)
+public class NamespaceInterceptor implements ReaderInterceptor {
+
+ private static final Logger log = LoggerFactory.getLogger(IncreaseNodesTool.class);
+ private static final String xslStr = String.join("\n",
+ "<xsl:transform xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">",
+ "<xsl:output version=\"1.0\" encoding=\"UTF-8\" indent=\"no\"/>",
+ "<xsl:strip-space elements=\"*\"/>",
+ " <xsl:template match=\"@*|node()\">",
+ " <xsl:element name=\"{local-name()}\">",
+ " <xsl:apply-templates select=\"@*|node()\"/>",
+ " </xsl:element>",
+ " </xsl:template>",
+ " <xsl:template match=\"text()\">",
+ " <xsl:copy/>",
+ " </xsl:template>",
+ "</xsl:transform>");
+
+ @Override
+ public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
+ if(MediaType.APPLICATION_XML.equalsIgnoreCase(context.getMediaType().toString())) {
+ Reader xmlReader = new InputStreamReader(context.getInputStream());
+ try {
+ ByteArrayInputStream inputStream = removeNameSpace(xmlReader);
+ context.setInputStream(inputStream);
+ return context.proceed();
+ } catch (Exception e) {
+ log.error("Could not remove namespace from model payload: " + e.getMessage());
+ return context.proceed();
+ }
+ }
+ return context.proceed();
+ }
+
+ /**
+ * Temporary solution to removing the xmlns attribute from the model payload.
+ * The payload is coming from babel and removing it there would be some larger effort.
+ * As such, this workaround is applied.
+ * Taken from: https://stackoverflow.com/questions/37354605/how-to-remove-xmlns-attribute-from-the-root-element-in-xml-and-java#answer-37357777
+ * @throws Exception
+ */
+ public ByteArrayInputStream removeNameSpace(Reader xmlReader) throws Exception {
+ // Parse XML and Build Document
+ DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ InputSource is = new InputSource();
+ is.setCharacterStream(xmlReader);
+ Document doc = db.parse(is);
+
+ // Parse XSLT and Configure Transformer
+ Source xslt = new StreamSource(new StringReader(xslStr));
+ Transformer tf = TransformerFactory.newInstance().newTransformer(xslt);
+ tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+
+ // Output Result to String
+ DOMSource source = new DOMSource(doc);
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ StreamResult strresult = new StreamResult(outStream);
+ tf.transform(source, strresult);
+
+ return new ByteArrayInputStream(outStream.toByteArray());
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java
index 80741f8..9ca1283 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java
@@ -53,7 +53,7 @@ public class RetiredInterceptor extends AAIContainerFilter implements ContainerR
private String basePath;
- @Autowired
+ @Autowired // remove this
public RetiredInterceptor(RetiredService retiredService, @Value("${schema.uri.base.path}") String basePath) {
this.retiredService = retiredService;
this.basePath = basePath;
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java
index 01cd013..7e1b64e 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java
@@ -49,7 +49,7 @@ public class VersionInterceptor extends AAIContainerFilter implements ContainerR
private final SchemaVersions schemaVersions;
- @Autowired
+ @Autowired // remove this
public VersionInterceptor(SchemaVersions schemaVersions) {
this.schemaVersions = schemaVersions;
allowedVersions =
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java
index 5d68c8a..2ad9ace 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java
@@ -37,7 +37,7 @@ public class VersionLatestInterceptor extends AAIContainerFilter implements Cont
private final SchemaVersions schemaVersions;
- @Autowired
+ @Autowired // remove this
public VersionLatestInterceptor(SchemaVersions schemaVersions) {
this.schemaVersions = schemaVersions;
}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/ExceptionHandler.java b/aai-resources/src/main/java/org/onap/aai/rest/ExceptionHandler.java
index 81c49b9..7af598b 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/ExceptionHandler.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/ExceptionHandler.java
@@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.sun.istack.SAXParseException2;
import java.util.ArrayList;
-import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.WebApplicationException;
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
index 4912a00..689e0b4 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
@@ -3,6 +3,7 @@
* org.onap.aai
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright © 2024 Deutsche Telekom.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +44,9 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.sideeffect.OwnerCheck;
+import org.onap.aai.query.builder.Pageable;
import org.onap.aai.parsers.query.QueryParser;
+import org.onap.aai.query.builder.QueryOptions;
import org.onap.aai.rest.db.DBRequest;
import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.rest.exceptions.AAIInvalidXMLNamespace;
@@ -67,16 +70,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumer.class.getName());
- /**
- *
- * @param content
- * @param versionParam
- * @param uri
- * @param headers
- * @param info
- * @param req
- * @return
- */
@PUT
@Path("/{uri: .+}")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@@ -89,17 +82,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
return this.handleWrites(mediaType, HttpMethod.PUT, content, versionParam, uri, headers, info, roles);
}
- /**
- * Update relationship.
- *
- * @param content the content
- * @param versionParam the version param
- * @param uri the uri
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
@PUT
@Path("/{uri: .+}/relationship-list/relationship")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@@ -164,17 +146,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
return response;
}
- /**
- * Patch.
- *
- * @param content the content
- * @param versionParam the version param
- * @param uri the uri
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
@PATCH
@Path("/{uri: .+}")
@Consumes({"application/merge-patch+json"})
@@ -204,57 +175,43 @@ public class LegacyMoxyConsumer extends RESTAPI {
.build();
}
- /**
- * Gets the legacy.
- *
- * @param content the content
- * @param versionParam the version param
- * @param uri the uri
- * @param depthParam the depth param
- * @param cleanUp the clean up
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the legacy
- */
@GET
@Path("/{uri: .+}")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public Response getLegacy(String content, @DefaultValue("-1") @QueryParam("resultIndex") String resultIndex,
- @DefaultValue("-1") @QueryParam("resultSize") String resultSize, @PathParam("version") String versionParam,
- @PathParam("uri") @Encoded String uri, @DefaultValue("all") @QueryParam("depth") String depthParam,
- @DefaultValue("false") @QueryParam("cleanup") String cleanUp, @Context HttpHeaders headers,
- @Context UriInfo info, @Context HttpServletRequest req) {
+ public Response getLegacy(
+ @PathParam("version") String versionParam,
+ @PathParam("uri") @Encoded String uri,
+ @DefaultValue("-1") @QueryParam("resultIndex") int resultIndex,
+ @DefaultValue("-1") @QueryParam("resultSize") int resultSize,
+ @DefaultValue("true") @QueryParam("includeTotalCount") boolean includeTotalCount,
+ // @DefaultValue("false") @QueryParam("sort") Sort sort,
+ @DefaultValue("all") @QueryParam("depth") String depthParam,
+ @DefaultValue("false") @QueryParam("cleanup") String cleanUp,
+ @Context HttpHeaders headers,
+ @Context UriInfo info,
+ @Context HttpServletRequest req) {
Set<String> roles = getRoles(req.getUserPrincipal(), req.getMethod());
+ Pageable pageable = includeTotalCount == false
+ ? new Pageable(resultIndex -1, resultSize)
+ : new Pageable(resultIndex -1, resultSize).includeTotalCount();
return runner(AAIConstants.AAI_CRUD_TIMEOUT_ENABLED, AAIConstants.AAI_CRUD_TIMEOUT_APP,
AAIConstants.AAI_CRUD_TIMEOUT_LIMIT, headers, info, HttpMethod.GET, new AaiCallable<Response>() {
@Override
public Response process() {
- return getLegacy(content, versionParam, uri, depthParam, cleanUp, headers, info, req,
- new HashSet<String>(), resultIndex, resultSize, roles);
+ return getLegacy(versionParam, uri, depthParam, cleanUp, headers, info, req,
+ new HashSet<String>(), pageable, roles);
}
});
}
/**
* This method exists as a workaround for filtering out undesired query params while routing between REST consumers
- *
- * @param content
- * @param versionParam
- * @param uri
- * @param depthParam
- * @param cleanUp
- * @param headers
- * @param info
- * @param req
- * @param removeQueryParams
- * @return
*/
- public Response getLegacy(String content, String versionParam, String uri, String depthParam, String cleanUp,
+ public Response getLegacy(String versionParam, String uri, String depthParam, String cleanUp,
HttpHeaders headers, UriInfo info, HttpServletRequest req, Set<String> removeQueryParams,
- String resultIndex, String resultSize, Set<String> roles) {
+ Pageable pageable, Set<String> roles) {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
Response response;
@@ -291,12 +248,13 @@ public class LegacyMoxyConsumer extends RESTAPI {
DBRequest request =
new DBRequest.Builder(HttpMethod.GET, uriObject, uriQuery, obj, headers, info, transId).build();
List<DBRequest> requests = Collections.singletonList(request);
- if (hasValidPaginationParams(resultIndex, resultSize)) {
- traversalUriHttpEntry.setPaginationIndex(Integer.parseInt(resultIndex));
- traversalUriHttpEntry.setPaginationBucket(Integer.parseInt(resultSize));
+
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = null;
+ if (hasValidPaginationParams(pageable)) {
+ responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth, roles, true, new QueryOptions(pageable));
+ } else {
+ responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth, roles);
}
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple =
- traversalUriHttpEntry.process(requests, sourceOfTruth, roles);
response = responsesTuple.getValue1().get(0).getValue1();
@@ -319,14 +277,14 @@ public class LegacyMoxyConsumer extends RESTAPI {
return response;
}
- private boolean hasValidPaginationParams(String resultIndex, String resultSize) {
- return resultIndex != null && !"-1".equals(resultIndex) && resultSize != null && !"-1".equals(resultSize);
+ private boolean hasValidPaginationParams(Pageable pageable) {
+ return pageable.getPage() >= 0 && pageable.getPageSize() > 0;
}
private MultivaluedMap<String, String> removeNonFilterableParams(MultivaluedMap<String, String> params) {
String[] toRemove =
- {"depth", "cleanup", "nodes-only", "format", "resultIndex", "resultSize", "skip-related-to"};
+ {"depth", "cleanup", "nodes-only", "format", "resultIndex", "resultSize", "includeTotalCount", "skip-related-to"};
Set<String> toRemoveSet = Arrays.stream(toRemove).collect(Collectors.toSet());
MultivaluedMap<String, String> cleanedParams = new MultivaluedHashMap<>();
@@ -339,17 +297,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
return cleanedParams;
}
- /**
- * Delete.
- *
- * @param versionParam the version param
- * @param uri the uri
- * @param headers the headers
- * @param info the info
- * @param resourceVersion the resource version
- * @param req the req
- * @return the response
- */
@DELETE
@Path("/{uri: .+}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@@ -494,31 +441,30 @@ public class LegacyMoxyConsumer extends RESTAPI {
@Path("/{uri: .+}/relationship-list")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public Response getRelationshipList(@DefaultValue("-1") @QueryParam("resultIndex") String resultIndex,
- @DefaultValue("-1") @QueryParam("resultSize") String resultSize, @PathParam("version") String versionParam,
- @PathParam("uri") @Encoded String uri, @DefaultValue("false") @QueryParam("cleanup") String cleanUp,
- @Context HttpHeaders headers, @Context HttpServletRequest req, @Context UriInfo info) {
+ public Response getRelationshipList(
+ @PathParam("version") String versionParam,
+ @PathParam("uri") @Encoded String uri,
+ @DefaultValue("-1") @QueryParam("resultIndex") int resultIndex,
+ @DefaultValue("-1") @QueryParam("resultSize") int resultSize,
+ @DefaultValue("true") @QueryParam("includeTotalCount") boolean includeTotalCount,
+ @DefaultValue("false") @QueryParam("cleanup") String cleanUp,
+ @Context HttpHeaders headers,
+ @Context HttpServletRequest req,
+ @Context UriInfo info) {
+ Pageable pageable = includeTotalCount == false
+ ? new Pageable(resultIndex -1, resultSize)
+ : new Pageable(resultIndex -1, resultSize).includeTotalCount();
return runner(AAIConstants.AAI_CRUD_TIMEOUT_ENABLED, AAIConstants.AAI_CRUD_TIMEOUT_APP,
AAIConstants.AAI_CRUD_TIMEOUT_LIMIT, headers, info, HttpMethod.GET, new AaiCallable<Response>() {
@Override
public Response process() {
- return getRelationshipList(versionParam, req, uri, cleanUp, headers, info, resultIndex,
- resultSize);
+ return getRelationshipList(versionParam, req, uri, cleanUp, headers, info, pageable);
}
});
}
- /**
- *
- * @param versionParam
- * @param uri
- * @param cleanUp
- * @param headers
- * @param info
- * @return
- */
public Response getRelationshipList(String versionParam, HttpServletRequest req, String uri, String cleanUp,
- HttpHeaders headers, UriInfo info, String resultIndex, String resultSize) {
+ HttpHeaders headers, UriInfo info, Pageable pageable) {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
Response response = null;
@@ -557,13 +503,13 @@ public class LegacyMoxyConsumer extends RESTAPI {
.build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- if (hasValidPaginationParams(resultIndex, resultSize)) {
- traversalUriHttpEntry.setPaginationIndex(Integer.parseInt(resultIndex));
- traversalUriHttpEntry.setPaginationBucket(Integer.parseInt(resultSize));
- }
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple =
- traversalUriHttpEntry.process(requests, sourceOfTruth);
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = null;
+ if (hasValidPaginationParams(pageable)) {
+ responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth, Collections.emptySet(), true, new QueryOptions(pageable));
+ } else {
+ responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth);
+ }
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e) {
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET_RELATIONSHIP, e);
@@ -583,13 +529,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
return response;
}
- /**
- * Validate request.
- *
- * @param info the info
- * @throws AAIException the AAI exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
private void validateRequest(UriInfo info) throws AAIException, UnsupportedEncodingException {
if (!ValidateEncoding.getInstance().validate(info)) {
@@ -597,12 +536,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
}
}
- /**
- * Gets the path.
- *
- * @param info the info
- * @return the path
- */
private String getPath(UriInfo info) {
String path = info.getPath(false);
MultivaluedMap<String, String> map = info.getQueryParameters(false);
@@ -622,18 +555,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
}
- /**
- * Handle writes.
- *
- * @param mediaType the media type
- * @param method the method
- * @param content the content
- * @param versionParam the version param
- * @param uri the uri
- * @param headers the headers
- * @param info the info
- * @return the response
- */
private Response handleWrites(MediaType mediaType, HttpMethod method, String content, String versionParam,
String uri, HttpHeaders headers, UriInfo info, Set<String> roles) {
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java
index 814cea0..1920b37 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java
@@ -20,7 +20,7 @@
package org.onap.aai.rest.bulk.pojos;
-import com.google.gson.*;
+import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
public class Operation {
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java
new file mode 100644
index 0000000..fd5dbcf
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java
@@ -0,0 +1,50 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.util;
+
+import org.onap.aai.tasks.AaiGraphChecker;
+import org.onap.aai.tasks.AaiGraphChecker.CheckerType;
+import org.springframework.boot.actuate.health.Health;
+import org.springframework.boot.actuate.health.HealthIndicator;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+
+import lombok.RequiredArgsConstructor;
+
+@Component
+@RequiredArgsConstructor
+@ConditionalOnProperty(name = "aai.actuator.echo.enabled", havingValue = "true")
+public class EchoHealthIndicator implements HealthIndicator {
+
+ private final AaiGraphChecker aaiGraphChecker;
+
+ @Override
+ public Health health() {
+ return healthy()
+ ? Health.up().build()
+ : Health.down().build();
+ }
+
+ private boolean healthy() {
+ return aaiGraphChecker.isAaiGraphDbAvailable(CheckerType.ACTUAL);
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java
index d4d8d32..0e44a63 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java
@@ -21,7 +21,6 @@
package org.onap.aai.rest.util;
import java.util.ArrayList;
-import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
diff --git a/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java b/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java
index 24004d1..ccbb68e 100644
--- a/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java
+++ b/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java
@@ -24,7 +24,6 @@ import static java.lang.Boolean.parseBoolean;
import static java.util.Comparator.comparingInt;
import com.google.common.collect.Sets;
-import com.sun.jersey.api.client.filter.LoggingFilter;
import java.lang.reflect.AnnotatedElement;
import java.util.Collection;
@@ -35,7 +34,9 @@ import java.util.logging.Logger;
import javax.annotation.Priority;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.ext.ReaderInterceptor;
+import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.onap.aai.rest.BulkAddConsumer;
import org.onap.aai.rest.BulkProcessConsumer;
@@ -47,7 +48,6 @@ import org.onap.aai.rest.bulk.BulkSingleTransactionConsumer;
import org.onap.aai.rest.util.EchoResponse;
import org.onap.logging.filter.base.AuditLogContainerFilter;
import org.reflections.Reflections;
-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;
@@ -81,6 +81,7 @@ public class JerseyConfiguration {
LegacyMoxyConsumer.class, URLFromVertexIdConsumer.class);
resourceConfig.registerClasses(classes);
registerFiltersForClasses(resourceConfig, ContainerRequestFilter.class, ContainerResponseFilter.class,
+ ReaderInterceptor.class,
AuditLogContainerFilter.class);
if (isLoggingEnabled()) {
@@ -118,7 +119,9 @@ public class JerseyConfiguration {
}
private void logRequests(ResourceConfig resourceConfig) {
- resourceConfig.register(new LoggingFilter(log, ENABLE_RESPONSE_LOGGING ? null : 0));
+ if(ENABLE_RESPONSE_LOGGING) {
+ resourceConfig.register(new LoggingFeature(log));
+ }
}
private boolean isLoggingEnabled() {
diff --git a/aai-resources/src/main/resources/application.properties b/aai-resources/src/main/resources/application.properties
index 960db1b..6487dee 100644
--- a/aai-resources/src/main/resources/application.properties
+++ b/aai-resources/src/main/resources/application.properties
@@ -26,7 +26,7 @@ spring.autoconfigure.exclude=\
spring.jersey.application-path=${schema.uri.base.path}
-spring.profiles.active=production,one-way-ssl,kafka
+spring.profiles.active=production,one-way-ssl
#The max number of active threads in this pool
server.jetty.threads.max=200
#The minimum number of threads always kept alive
@@ -43,6 +43,7 @@ server.certs.location=${server.local.startpath}/etc/auth/
server.keystore.name=aai_keystore
server.truststore.name=aai_keystore
server.port=8447
+
server.ssl.enabled=false
server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
server.ssl.key-store=${server.certs.location}${server.keystore.name}
@@ -154,3 +155,9 @@ BOOTSTRAP_SERVERS=localhost:9092
JAAS_CONFIG=""
BUNDLECONFIG_DIR=src/main/resources/
AJSC_HOME=./
+
+# If true, the actuator health check will be overriden
+# to use the AaiGraphChecker check instead
+# this does the same as the /echo endpoint,
+# but doesn't show up in micrometer metrics
+aai.actuator.echo.enabled=false
diff --git a/aai-resources/src/main/scripts/install/addManualData.sh b/aai-resources/src/main/scripts/install/addManualData.sh
index 645f7c8..1003f75 100644
--- a/aai-resources/src/main/scripts/install/addManualData.sh
+++ b/aai-resources/src/main/scripts/install/addManualData.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
###
# ============LICENSE_START=======================================================
@@ -9,9 +9,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/aai-resources/src/test/java/org/onap/aai/AAISetup.java b/aai-resources/src/test/java/org/onap/aai/AAISetup.java
index b510c00..3567187 100644
--- a/aai-resources/src/test/java/org/onap/aai/AAISetup.java
+++ b/aai-resources/src/test/java/org/onap/aai/AAISetup.java
@@ -28,11 +28,8 @@ import java.nio.charset.Charset;
import java.util.Map;
import org.apache.commons.io.IOUtils;
-import org.junit.ClassRule;
-import org.junit.Rule;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.runner.RunWith;
import org.onap.aai.config.ConfigConfiguration;
import org.onap.aai.config.IntrospectionConfig;
import org.onap.aai.config.RestBeanConfig;
@@ -43,22 +40,21 @@ import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.MoxyLoader;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.rest.db.HttpEntry;
+import org.onap.aai.rest.notification.NotificationService;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.setup.AAIConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import org.springframework.test.context.junit4.rules.SpringClassRule;
-import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
@ExtendWith(SpringExtension.class)
-@ContextConfiguration(
+@SpringJUnitConfig(
classes = {ConfigConfiguration.class, AAIConfigTranslator.class, NodeIngestor.class, EdgeIngestor.class,
EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class,
- XmlFormatTransformerConfiguration.class, RestBeanConfig.class})
+ XmlFormatTransformerConfiguration.class, RestBeanConfig.class, LoaderFactory.class, NotificationService.class})
@TestPropertySource(
properties = {"schema.uri.base.path = /aai",
"schema.ingest.file = src/test/resources/application-test.properties"})
@@ -82,12 +78,6 @@ public abstract class AAISetup {
@Autowired
protected SchemaVersions schemaVersions;
- @ClassRule
- public static final SpringClassRule springClassRule = new SpringClassRule();
-
- @Rule
- public final SpringMethodRule springMethodRule = new SpringMethodRule();
-
@BeforeAll
public static void setupBundleconfig() throws Exception {
System.setProperty("AJSC_HOME", "./");
diff --git a/aai-resources/src/test/java/org/onap/aai/config/WebClientConfiguration.java b/aai-resources/src/test/java/org/onap/aai/config/WebClientConfiguration.java
new file mode 100644
index 0000000..e412ded
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/config/WebClientConfiguration.java
@@ -0,0 +1,49 @@
+package org.onap.aai.config;
+
+import java.time.Duration;
+import java.util.Collections;
+
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.context.annotation.Primary;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.reactive.server.WebTestClient;
+
+@TestConfiguration
+public class WebClientConfiguration {
+
+ @Autowired SchemaVersions schemaVersions;
+
+ @Lazy
+ @Bean
+ @Primary
+ WebTestClient webTestClient(@LocalServerPort int port) {
+ return WebTestClient.bindToServer()
+ .baseUrl("http://localhost:" + port + "/aai/" + schemaVersions.getDefaultVersion())
+ .responseTimeout(Duration.ofSeconds(300))
+ .defaultHeaders(headers -> {
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.set("X-FromAppId", "test");
+ headers.set("X-TransactionId", "someTransaction");
+ headers.setBasicAuth("AAI", "AAI");
+ })
+ .build();
+ }
+
+ @Lazy
+ @Bean
+ WebTestClient mgmtClient(@Value("${local.management.port}") int port) {
+ return WebTestClient.bindToServer()
+ .baseUrl("http://localhost:" + port)
+ .responseTimeout(Duration.ofSeconds(300))
+ .defaultHeaders(headers -> {
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ })
+ .build();
+ }
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/entities/Model.java b/aai-resources/src/test/java/org/onap/aai/entities/Model.java
new file mode 100644
index 0000000..d33d2d0
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/entities/Model.java
@@ -0,0 +1,62 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.entities;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Describes the model returned by aai-resources
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class Model {
+
+ @JsonProperty("model-invariant-id")
+ private String modelInvariantId;
+
+ @JsonProperty("model-role")
+ private String modelRole;
+
+ @JsonProperty("model-type")
+ private String modelType;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("model-vers")
+ List<ModelVersion> modelVersions;
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/entities/ModelElement.java b/aai-resources/src/test/java/org/onap/aai/entities/ModelElement.java
new file mode 100644
index 0000000..ae85780
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/entities/ModelElement.java
@@ -0,0 +1,48 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.entities;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ModelElement {
+
+ @JsonProperty("model-element-uuid")
+ private String modelElementUuid;
+
+ @JsonProperty("new-data-del-flag")
+ private String newDataDelFlag;
+
+ @JsonProperty("cardinality")
+ private String cardinality;
+
+ @JsonProperty("model-description")
+ private String modelDescription;
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/entities/ModelVersion.java b/aai-resources/src/test/java/org/onap/aai/entities/ModelVersion.java
new file mode 100644
index 0000000..2e0a68c
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/entities/ModelVersion.java
@@ -0,0 +1,72 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.entities;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ModelVersion {
+
+ @JsonProperty("model-version-id")
+ private String modelVersionId;
+
+ @JsonProperty("model-name")
+ private String modelName;
+
+ @JsonProperty("model-version")
+ private String modelVersion;
+
+ @JsonProperty("distribution-status")
+ private String distributionStatus;
+
+ @JsonProperty("model-description")
+ private String modelDescription;
+
+ @JsonProperty("sdnc-model-name")
+ private String sdncModelName;
+
+ @JsonProperty("sdnc-model-version")
+ private String sdncModelVersion;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("model-elements")
+ List<ModelElement> modelElements;
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/entities/PServer.java b/aai-resources/src/test/java/org/onap/aai/entities/PServer.java
new file mode 100644
index 0000000..988328e
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/entities/PServer.java
@@ -0,0 +1,60 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.entities;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
+
+import lombok.Data;
+
+@Data
+@JsonNaming(PropertyNamingStrategy.KebabCaseStrategy.class)
+public class PServer {
+ String resourceVersion;
+ String hostname;
+ String ptniiEquipName;
+ long numberOfCpus;
+ long diskInGigabytes;
+ long ramInMegabytes;
+ String equipType;
+ String equipVendor;
+ String equipModel;
+ String fqdn;
+ String pserverSelflink;
+ String ipv4OamAddress;
+ String serialNumber;
+ @JsonProperty("ipaddress-v4-loopback-0")
+ String ipaddressV4Loopback0;
+ @JsonProperty("ipaddress-v6-loopback-0")
+ String ipaddressV6Loopback0;
+ String ipaddressV4Aim;
+ String ipaddressV6Aim;
+ String ipaddressV6Oam;
+ String invStatus;
+ String pserverId;
+ String internetTopology;
+ boolean inMaint;
+ String pserverName2;
+ String purpose;
+ String provStatus;
+ String managementOption;
+ String hostProfile;
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/entities/PServerListResponse.java b/aai-resources/src/test/java/org/onap/aai/entities/PServerListResponse.java
new file mode 100644
index 0000000..a08b9ea
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/entities/PServerListResponse.java
@@ -0,0 +1,30 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.entities;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data
+public class PServerListResponse {
+ List<PServer> pserver;
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/it/performance/K6PerformanceTest.java b/aai-resources/src/test/java/org/onap/aai/it/performance/K6PerformanceTest.java
index 8428cb5..f7d1cc6 100644
--- a/aai-resources/src/test/java/org/onap/aai/it/performance/K6PerformanceTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/it/performance/K6PerformanceTest.java
@@ -21,7 +21,7 @@
package org.onap.aai.it.performance;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@@ -36,6 +36,9 @@ import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.AAIGraph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
@@ -48,6 +51,7 @@ import lombok.SneakyThrows;
@Testcontainers
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@EnableAutoConfiguration(exclude={CassandraDataAutoConfiguration.class, CassandraAutoConfiguration.class}) // there is no running cassandra instance for the test
public class K6PerformanceTest {
private static final Logger logger = LoggerFactory.getLogger(ResourcesApp.class.getName());
@@ -56,13 +60,9 @@ public class K6PerformanceTest {
@LocalServerPort
private int port;
-
- private boolean initialized = false;
-
@BeforeEach
public void setup() {
- if (!initialized) {
- initialized = true;
+ if (!AAIGraph.isInit()) {
AAIGraph.getInstance();
long startTime = System.currentTimeMillis();
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
index 9e901ad..adfa433 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
@@ -28,8 +28,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;
-import org.junit.ClassRule;
-import org.junit.Rule;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -41,6 +39,9 @@ import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.util.AAIConfig;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Import;
@@ -49,22 +50,15 @@ 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;
import org.springframework.web.client.RestTemplate;
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ResourcesApp.class)
+@Import(ResourcesTestConfiguration.class)
@TestPropertySource(locations = "classpath:application-test.properties")
@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
-@Import(ResourcesTestConfiguration.class)
+@EnableAutoConfiguration(exclude = {CassandraDataAutoConfiguration.class, CassandraAutoConfiguration.class}) // there is no running cassandra instance for the test
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ResourcesApp.class)
public abstract class AbstractSpringRestTest {
- @ClassRule
- public static final SpringClassRule springClassRule = new SpringClassRule();
-
- @Rule
- public final SpringMethodRule springMethodRule = new SpringMethodRule();
-
@Autowired
protected RestTemplate restTemplate;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java
index e64ecc0..4c2a9f0 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java
@@ -178,8 +178,8 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
when(uriInfo.getPath()).thenReturn(uri);
when(uriInfo.getPath(false)).thenReturn(uri);
- Response response = legacyMoxyConsumer.getLegacy("", "-1", "-1", schemaVersions.getDefaultVersion().toString(),
- uri, "all", "false", httpHeaders, uriInfo, new MockHttpServletRequest("GET", "http://www.test.com"));
+ Response response = legacyMoxyConsumer.getLegacy(schemaVersions.getDefaultVersion().toString(), uri, -1, -1, false,
+ "all", "false", httpHeaders, uriInfo, new MockHttpServletRequest("GET", "http://www.test.com"));
assertNotNull(response, "Response from the legacy moxy consumer returned null");
assertEquals(Response.Status.NOT_FOUND.getStatusCode(),
@@ -199,7 +199,7 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
"Expected to return status created from the response");
queryParameters.add("depth", "10000");
- response = legacyMoxyConsumer.getLegacy("", "-1", "-1", schemaVersions.getDefaultVersion().toString(), uri,
+ response = legacyMoxyConsumer.getLegacy(schemaVersions.getDefaultVersion().toString(), uri, -1, -1, false,
"all", "false", httpHeaders, uriInfo, new MockHttpServletRequest("GET", "http://www.test.com"));
assertNotNull(response, "Response from the legacy moxy consumer returned null");
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
index 68974a3..f734360 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
@@ -37,7 +37,6 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
@@ -73,19 +72,11 @@ public abstract class BulkProcessorTestAbstraction extends AAISetup {
protected String uri;
- private boolean initialized = false;
private static final Logger logger = LoggerFactory.getLogger(BulkProcessorTestAbstraction.class.getName());
- @BeforeAll
- public static void setupRest() {
- // AAIGraph.getInstance();
-
- }
-
@BeforeEach
public void setup() {
- if (!initialized) {
- initialized = true;
+ if (!AAIGraph.isInit()) {
AAIGraph.getInstance();
}
logger.info("Starting the setup for the integration tests of Rest Endpoints");
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
index 5e1142d..b780d90 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
@@ -38,6 +38,10 @@ import org.onap.aai.config.SpringContextAware;
import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Import;
@@ -55,13 +59,16 @@ import org.springframework.web.client.RestTemplate;
* Test REST requests against configuration resource
*/
+@AutoConfigureMetrics
@TestPropertySource(locations = "classpath:application-test.properties")
@ContextConfiguration(initializers = PropertyPasswordConfiguration.class, classes = {SpringContextAware.class})
+@EnableAutoConfiguration(exclude={CassandraDataAutoConfiguration.class, CassandraAutoConfiguration.class}) // there is no running cassandra instance for the test
@Import(ResourcesTestConfiguration.class)
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = {SpringContextAware.class, ResourcesApp.class})
public class ConfigurationTest extends AbstractSpringRestTest {
+
@Autowired
RestTemplate restTemplate;
@@ -88,7 +95,7 @@ public class ConfigurationTest extends AbstractSpringRestTest {
headersGet.add("X-FromAppId", "JUNIT");
headersGet.add("X-TransactionId", "JUNIT");
- headersGet.setBasicAuth("AAI","AAI");
+ headersGet.setBasicAuth("AAI", "AAI");
headersPutPatch = new HttpHeaders();
headersPutPatch.putAll(headersGet);
@@ -108,7 +115,8 @@ public class ConfigurationTest extends AbstractSpringRestTest {
responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntityGet, String.class);
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
- // String putBody = " configuration-id, configuration-type configuration-sub-type";
+ // String putBody = " configuration-id, configuration-type
+ // configuration-sub-type";
String putBody = "{" + "\"configuration-id\": \"" + cid + "\"," + "\"configuration-type\": \"type1\","
+ "\"configuration-sub-type\": \"subtype1\", " + "\"operational-status\": \"example1\", "
+ "\"orchestration-status\": \"example1\", " + "\"configuration-selflink\": \"example1\", "
@@ -167,29 +175,31 @@ public class ConfigurationTest extends AbstractSpringRestTest {
ResponseEntity<String> responseEntity = null;
String responseBody = null;
- // set Accept as text/plain in order to get access of endpoint "/actuator/prometheus"
+ // set Accept as text/plain in order to get access of endpoint
+ // "/actuator/prometheus"
headersGet.set("Accept", "text/plain");
headersGet.setAccept(Arrays.asList(MediaType.TEXT_PLAIN));
httpEntityGet = new HttpEntity<String>(headersGet);
- responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntityGet, String.class);
+ responseEntity = restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntityGet,
+ String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("group_id"));
assertTrue(responseBody.contains("aai_uri"));
- // Set Accept as MediaType.APPLICATION_JSON in order to get access of endpoint "/actuator/info" and
+ // Set Accept as MediaType.APPLICATION_JSON in order to get access of endpoint
+ // "/actuator/info" and
// "/actuator/health"
headersGet.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
httpEntityGet = new HttpEntity<String>(headersGet);
- responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/info", HttpMethod.GET, httpEntityGet, String.class);
+ responseEntity = restTemplate.exchange(actuatorurl + "/actuator/info", HttpMethod.GET, httpEntityGet,
+ String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("aai-resources"));
- responseEntity =
- restTemplate.exchange(actuatorurl + "/actuator/health", HttpMethod.GET, httpEntityGet, String.class);
+ responseEntity = restTemplate.exchange(actuatorurl + "/actuator/health", HttpMethod.GET, httpEntityGet,
+ String.class);
responseBody = (String) responseEntity.getBody();
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertTrue(responseBody.contains("UP"));
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
index 96e7716..b48cdb2 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
@@ -38,7 +38,6 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -74,14 +73,11 @@ public class ExampleConsumerTest extends AAISetup {
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
- @BeforeAll
- public static void setupRest() {
- AAIGraph.getInstance();
-
- }
-
@BeforeEach
public void setup() {
+ if(!AAIGraph.isInit()) {
+ AAIGraph.getInstance();
+ }
logger.info("Starting the setup for the integration tests of Rest Endpoints");
exampleConsumer = new ExampleConsumer();
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
index 0780649..21baedc 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
@@ -27,8 +27,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonMappingException;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
index 1524f69..d88faa5 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2024 Deutsche Telekom.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -20,6 +22,10 @@
package org.onap.aai.rest;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.samePropertyValuesAs;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -28,6 +34,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -42,31 +49,46 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.apache.commons.io.IOUtils;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.hamcrest.Matcher;
+import org.janusgraph.core.JanusGraph;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.onap.aai.AAISetup;
+import org.onap.aai.config.WebClientConfiguration;
+import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.entities.PServer;
+import org.onap.aai.entities.PServerListResponse;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
import org.skyscreamer.jsonassert.JSONAssert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.context.annotation.Import;
import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.test.web.reactive.server.WebTestClient;
-// TODO: Change the following test to use spring boot
-public class LegacyMoxyConsumerTest extends AAISetup {
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@Import(WebClientConfiguration.class)
+public class LegacyMoxyConsumerTest {
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
+ private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
+ protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
static {
VALID_HTTP_STATUS_CODES.add(200);
@@ -74,31 +96,23 @@ public class LegacyMoxyConsumerTest extends AAISetup {
VALID_HTTP_STATUS_CODES.add(204);
}
- private LegacyMoxyConsumer legacyMoxyConsumer;
+ @Autowired WebTestClient webClient;
+ @Autowired SchemaVersions schemaVersions;
- private HttpHeaders httpHeaders;
+ ObjectMapper mapper = new ObjectMapper();
+ private LegacyMoxyConsumer legacyMoxyConsumer;
+ private HttpHeaders httpHeaders;
private UriInfo uriInfo;
-
private MultivaluedMap<String, String> headersMultiMap;
private MultivaluedMap<String, String> queryParameters;
-
private List<String> aaiRequestContextList;
-
private List<MediaType> outputMediaTypes;
- private boolean initialized = false;
private String defaultSchemaVersion;
-
- @BeforeAll
- public static void setupRest() {
- // AAIGraph.getInstance();
- }
-
@BeforeEach
public void setup() {
- if (!initialized) {
- initialized = true;
+ if(!AAIGraph.isInit()) {
AAIGraph.getInstance();
}
logger.info("Starting the setup for the integration tests of Rest Endpoints");
@@ -135,96 +149,90 @@ public class LegacyMoxyConsumerTest extends AAISetup {
Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
-
}
@Test
public void testResponsePutGetDeleteOnResource() throws JSONException, IOException, AAIException {
-
- String uri = getUri();
String payload = getResourcePayload(getObjectName());
-
- assertNotNull(payload, "Introspector returned invalid string when marshalling the object");
- assertNotNull(uri, "Introspector failed to return a valid uri");
-
- if (uri.length() != 0 && uri.charAt(0) == '/') {
- uri = uri.substring(1);
- }
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri);
- Response response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion,
- uri, "all", "false", httpHeaders, uriInfo, mockReqGet);
-
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
-
- MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri);
- response = legacyMoxyConsumer.update(payload, defaultSchemaVersion, uri, httpHeaders,
- uriInfo, mockReq);
-
- int code = response.getStatus();
- if (!VALID_HTTP_STATUS_CODES.contains(code)) {
- logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
- }
-
- assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
-
- queryParameters.add("depth", "10000");
-
- response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
- "10000", "false", httpHeaders, uriInfo, mockReqGet);
-
- code = response.getStatus();
- if (!VALID_HTTP_STATUS_CODES.contains(code)) {
- logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
- }
-
- String pserverEntity = response.getEntity().toString();
- JSONObject pserverJsonbject = new JSONObject(pserverEntity);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
-
- JSONAssert.assertEquals(payload, pserverEntity, false);
-
- String resourceVersion = pserverJsonbject.getString("resource-version");
-
- queryParameters.add("resource-version", resourceVersion);
-
- mockReq = new MockHttpServletRequest("DELETE", uri);
- response = legacyMoxyConsumer.delete(defaultSchemaVersion, uri, httpHeaders, uriInfo,
- "", mockReq);
-
- code = response.getStatus();
- if (!VALID_HTTP_STATUS_CODES.contains(code)) {
- logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
- }
-
- assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
-
- response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
- "all", "false", httpHeaders, uriInfo, mockReqGet);
-
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ PServer expected = mapper.readValue(payload, PServer.class);
+
+ webClient.get()
+ .uri("/cloud-infrastructure/pservers/pserver/pserver-hostname-test?cleanup=false")
+ .exchange()
+ .expectStatus()
+ .isNotFound();
+
+ webClient.put()
+ .uri("/cloud-infrastructure/pservers/pserver/pserver-hostname-test")
+ .bodyValue(payload)
+ .exchange()
+ .expectStatus()
+ .isCreated();
+
+ PServer pserver = webClient.get()
+ .uri("/cloud-infrastructure/pservers/pserver/pserver-hostname-test?cleanup=false&depth=10000")
+ .exchange()
+ .expectStatus()
+ .isOk()
+ .returnResult(PServer.class)
+ .getResponseBody()
+ .blockFirst();
+
+ assertThat(pserver, samePropertyValuesAs(expected, "resourceVersion"));
+
+ String resourceVersion = pserver.getResourceVersion();
+
+ webClient.delete()
+ .uri(uriBuilder -> uriBuilder
+ .path("/cloud-infrastructure/pservers/pserver/pserver-hostname-test")
+ .queryParam("resource-version", resourceVersion)
+ .build())
+ .exchange()
+ .expectStatus()
+ .isNoContent();
+
+ webClient.get()
+ .uri("/cloud-infrastructure/pservers/pserver/pserver-hostname-test?cleanup=false&depth=10000")
+ .exchange()
+ .expectStatus()
+ .isNotFound();
}
@Test
public void testResponseGetOnResourcePaginated() throws JSONException, IOException, AAIException {
-
- String uri = getGetAllPserversURI();
-
- if (uri.length() != 0 && uri.charAt(0) == '/') {
- uri = uri.substring(1);
- }
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri);
- Response response = legacyMoxyConsumer.getLegacy("", "1", "10", defaultSchemaVersion,
- uri, "all", "false", httpHeaders, uriInfo, mockReqGet);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+ JanusGraph graph = AAIGraph.getInstance().getGraph();
+ GraphTraversalSource g = graph.traversal();
+ g.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "hostname1")
+ .property("resource-version", UUID.randomUUID().toString())
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/hostname1")
+ .addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "hostname2")
+ .property("resource-version", UUID.randomUUID().toString())
+ .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/hostname2")
+ .next();
+ g.tx().commit();
+
+ PServerListResponse pservers = webClient.get()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/cloud-infrastructure/pservers")
+ .queryParam("resultIndex", "1")
+ .queryParam("resultSize", "10")
+ .build())
+ .exchange()
+ .expectStatus()
+ .isOk()
+ // TODO: Assert values here once test data is isolated to individual test
+ .expectHeader().exists("total-results")
+ .expectHeader().exists("total-pages")
+ .returnResult(PServerListResponse.class)
+ .getResponseBody()
+ .blockFirst();
+
+ assertTrue(pservers.getPserver().size() > 0);
}
@Test
@@ -330,7 +338,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
mockReq = new MockHttpServletRequest("GET", uri);
- response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
+ response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, uri, -1, -1, false,
"all", "false", httpHeaders, uriInfo, mockReq);
assertNotNull(response, "Response from the legacy moxy consumer returned null");
@@ -372,7 +380,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
mockReq = new MockHttpServletRequest("GET", uri);
- response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
+ response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, uri, -1, -1, false,
"all", "false", httpHeaders, uriInfo, mockReq);
assertNotNull(response, "Response from the legacy moxy consumer returned null");
@@ -408,8 +416,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
when(uriInfo.getPath(false)).thenReturn(uri);
MockHttpServletRequest mockReq = new MockHttpServletRequest("GET", uri);
- Response response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion,
- uri, "all", "false", httpHeaders, uriInfo, mockReq);
+ Response response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, uri, -1, -1,
+ false, "all", "false", httpHeaders, uriInfo, mockReq);
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
mockReq = new MockHttpServletRequest("PUT", uri);
@@ -449,8 +457,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
when(mockRequest.getRequestURL()).thenReturn(new StringBuffer(String.format("https://localhost:8447/aai/%s/", defaultSchemaVersion) + uri));
- Response response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion,
- uri, "all", "false", httpHeaders, uriInfo, mockRequest);
+ Response response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, uri, -1, -1,
+ false, "all", "false", httpHeaders, uriInfo, mockRequest);
assertNotNull(response, "Response from the legacy moxy consumer returned null");
assertEquals(Response.Status.NOT_FOUND.getStatusCode(),
@@ -470,7 +478,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
"Expected to return status created from the response");
queryParameters.add("depth", "10000");
- response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
+ response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, uri, -1, -1, false,
"all", "false", httpHeaders, uriInfo, mockRequest);
assertNotNull(response, "Response from the legacy moxy consumer returned null");
@@ -508,12 +516,12 @@ public class LegacyMoxyConsumerTest extends AAISetup {
}
public String getResourcePayload(String resourceName) throws IOException {
- String rawPayload = getPayload("payloads/resource/" + resourceName + ".json");
+ String rawPayload = IOUtils.toString(this.getClass().getResourceAsStream("/payloads/resource/" + resourceName + ".json"), StandardCharsets.UTF_8);
return String.format(rawPayload, defaultSchemaVersion);
}
public String getRelationshipPayload(String relationshipName) throws IOException {
- String rawPayload = getPayload("payloads/relationship/" + relationshipName + ".json");
+ String rawPayload = IOUtils.toString(this.getClass().getResourceAsStream("/payloads/relationship/" + relationshipName + ".json"), StandardCharsets.UTF_8);
return String.format(rawPayload, defaultSchemaVersion);
}
@@ -585,8 +593,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri);
- Response response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion,
- uri, "all", "false", httpHeaders, uriInfo, mockReqGet);
+ Response response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, uri, -1, -1,
+ false, "all", "false", httpHeaders, uriInfo, mockReqGet);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
}
@@ -605,8 +613,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri);
- Response response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion,
- uri, "all", "false", httpHeaders, uriInfo, mockReqGet);
+ Response response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, uri, -1, -1,
+ false, "all", "false", httpHeaders, uriInfo, mockReqGet);
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
@@ -649,8 +657,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
when(mockRequest.getRequestURL())
.thenReturn(new StringBuffer(String.format("https://localhost:8447/aai/%s/", defaultSchemaVersion) + getRelationshipUri));
- response = legacyMoxyConsumer.getRelationshipList("1", "1", defaultSchemaVersion,
- getRelationshipUri, "false", httpHeaders, mockRequest, uriInfo);
+ response = legacyMoxyConsumer.getRelationshipList(defaultSchemaVersion,
+ getRelationshipUri, 1,1, false, "false", httpHeaders, mockRequest, uriInfo);
code = response.getStatus();
if (!VALID_HTTP_STATUS_CODES.contains(code)) {
@@ -702,8 +710,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
when(mockRequest.getRequestURL())
.thenReturn(new StringBuffer(String.format("https://localhost:8447/aai/%s/", defaultSchemaVersion) + getRelationshipUri));
- response = legacyMoxyConsumer.getRelationshipList("1", "1", defaultSchemaVersion,
- getRelationshipUri, "false", httpHeaders, mockRequest, uriInfo);
+ response = legacyMoxyConsumer.getRelationshipList(defaultSchemaVersion,
+ getRelationshipUri, 1, 1, false, "false", httpHeaders, mockRequest, uriInfo);
queryParameters.remove("format");
code = response.getStatus();
@@ -767,8 +775,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
when(mockRequest.getRequestURL())
.thenReturn(new StringBuffer(String.format("https://localhost:8447/aai/%s/", defaultSchemaVersion) + getRelationshipUri));
Response response =
- legacyMoxyConsumer.getRelationshipList("1", "1", defaultSchemaVersion,
- getRelationshipUri, "false", httpHeaders, mockRequest, uriInfo);
+ legacyMoxyConsumer.getRelationshipList(defaultSchemaVersion,
+ getRelationshipUri, 1, 1, false, "false", httpHeaders, mockRequest, uriInfo);
int code = response.getStatus();
if (!VALID_HTTP_STATUS_CODES.contains(code)) {
@@ -1139,8 +1147,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
private Response getMockResponse(String mockUri) throws IOException, JSONException {
MockHttpServletRequest mockReq = new MockHttpServletRequest("GET", mockUri);
- Response response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion,
- mockUri, "10000", "false", httpHeaders, uriInfo, mockReq);
+ Response response = legacyMoxyConsumer.getLegacy(defaultSchemaVersion, mockUri, -1, -1,
+ false, "10000", "false", httpHeaders, uriInfo, mockReq);
String responseEntity = response.getEntity().toString();
int code = response.getStatus();
if (!VALID_HTTP_STATUS_CODES.contains(code)) {
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java
index 374519e..2177dac 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java
@@ -20,54 +20,155 @@
package org.onap.aai.rest;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.Collections;
-import org.json.JSONObject;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
-import org.onap.aai.rest.AbstractSpringRestTest;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.onap.aai.config.WebClientConfiguration;
+import org.onap.aai.entities.Model;
+import org.onap.aai.entities.ModelVersion;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.context.annotation.Import;
+
import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.util.DefaultUriBuilderFactory;
+import org.springframework.test.web.reactive.server.WebTestClient;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
/**
- * Test designed to imitate model-loader behaviour when distributing models via xml to aai-resources.
- * Similar to test in https://gerrit.onap.org/r/gitweb?p=aai/model-loader.git;a=blob;f=src/test/java/org/onap/aai/modelloader/restclient/TestAaiRestClient.java;h=ebdfcfe45285f14efc2f706caa49f0191b108619;hb=HEAD#l46
+ * Test designed to imitate model-loader behaviour when distributing models via
+ * xml to aai-resources.
+ * Similar to test in
+ * https://gerrit.onap.org/r/gitweb?p=aai/model-loader.git;a=blob;f=src/test/java/org/onap/aai/modelloader/restclient/TestAaiRestClient.java;h=ebdfcfe45285f14efc2f706caa49f0191b108619;hb=HEAD#l46
*/
-public class ModelDistributionTest extends AbstractSpringRestTest {
+@Import(WebClientConfiguration.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+public class ModelDistributionTest {
+
+ ObjectMapper objectMapper = new XmlMapper();
+
+ @Autowired
+ WebTestClient webClient;
+ final String MODEL_FILE = "src/test/resources/payloads/models/network-service.xml";
@Test
+ @Order(1)
public void thatModelsCanBeDistributed() throws Exception {
- final String MODEL_FILE = "src/test/resources/payloads/models/network-service.xml";
- String uri = baseUrl + "/aai/v29/service-design-and-creation/models/model/d821d1aa-8a69-47a4-aa63-3dae1742c47c";
+ String uri = "/aai/v29/service-design-and-creation/models/model/d821d1aa-8a69-47a4-aa63-3dae1742c47c";
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML));
- headers.setContentType(null);
- ResponseEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), String.class);
- assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
+ webClient.get()
+ .uri(uri)
+ .accept(MediaType.APPLICATION_XML)
+ .exchange()
+ .expectStatus()
+ .isNotFound();
String modelPayload = new String(Files.readAllBytes(Paths.get(MODEL_FILE)));
- headers.setContentType(MediaType.APPLICATION_XML);
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
- response = restTemplate.exchange(uri, HttpMethod.PUT, new HttpEntity<>(modelPayload, headers), String.class);
- assertEquals(HttpStatus.CREATED, response.getStatusCode());
-
- headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
- response = restTemplate.exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), String.class);
- assertEquals(HttpStatus.OK, response.getStatusCode());
-
- ObjectMapper mapper = new ObjectMapper();
- String resourceVersion = mapper.readTree(response.getBody()).get("resource-version").asText();
- URI resourceVersionUri = new DefaultUriBuilderFactory(uri.toString()).builder().queryParam("resource-version", resourceVersion).build();
- response = restTemplate.exchange(resourceVersionUri, HttpMethod.DELETE, new HttpEntity<>(headers), String.class);
- assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
+ webClient.put()
+ .uri(uri)
+ .accept(MediaType.APPLICATION_XML)
+ .header("Content-Type", MediaType.APPLICATION_XML_VALUE)
+ .bodyValue(modelPayload)
+ .exchange()
+ .expectStatus()
+ .isCreated();
+
+ String actual = webClient.get()
+ .uri(uri)
+ .accept(MediaType.APPLICATION_XML)
+ .exchange()
+ .expectStatus()
+ .isOk()
+ .returnResult(String.class)
+ .getResponseBody()
+ .blockFirst();
+
+ Model expectedModel = objectMapper.readValue(modelPayload, Model.class);
+ expectedModel.setModelVersions(null); // model versions are not being returned by the endpoint
+ Model actualModel = objectMapper.readValue(actual, Model.class);
+ Assertions.assertThat(expectedModel)
+ .usingRecursiveComparison()
+ .ignoringFields("resourceVersion")
+ .isEqualTo(actualModel);
+
+ webClient.delete()
+ .uri(uriBuilder -> uriBuilder
+ .path(uri)
+ .queryParam("resource-version", actualModel.getResourceVersion()).build())
+ .exchange()
+ .expectStatus()
+ .isNoContent();
+
+ }
+
+ @Test
+ @Order(2)
+ public void thatModelsCanBeRedistributed() throws Exception {
+ final String UPDATE_MODEL_FILE = "src/test/resources/payloads/models/model-version.xml";
+ String modelInvariantId = "d821d1aa-8a69-47a4-aa63-3dae1742c47c";
+ String modelVersionId = "8b713350-90fc-44b1-8c6e-a2b3973aa9d3";
+ String modelUri = "/aai/v29/service-design-and-creation/models/model/" + modelInvariantId;
+ String modelVersionUri = modelUri + "/model-vers/model-ver/" + modelVersionId;
+ webClient.get()
+ .uri(modelUri)
+ .accept(MediaType.APPLICATION_XML)
+ .exchange()
+ .expectStatus()
+ .isNotFound();
+
+ String modelPayload = new String(Files.readAllBytes(Paths.get(MODEL_FILE)));
+ webClient.put()
+ .uri(modelUri)
+ .accept(MediaType.APPLICATION_XML)
+ .header("Content-Type", MediaType.APPLICATION_XML_VALUE)
+ .bodyValue(modelPayload)
+ .exchange()
+ .expectStatus()
+ .isCreated();
+
+ String modelVersionResponse = webClient.get()
+ .uri(modelVersionUri)
+ .accept(MediaType.APPLICATION_XML)
+ .exchange()
+ .expectStatus()
+ .isOk()
+ .returnResult(String.class)
+ .getResponseBody()
+ .blockFirst();
+ ModelVersion modelVersion = objectMapper.readValue(modelVersionResponse, ModelVersion.class);
+ assertNull(modelVersion.getModelElements());
+
+ String updatePayload = new String(Files.readAllBytes(Paths.get(UPDATE_MODEL_FILE)))
+ .replace("resourceVersion", modelVersion.getResourceVersion());
+ webClient.put()
+ .uri(modelVersionUri)
+ .accept(MediaType.APPLICATION_XML)
+ .header("Content-Type", MediaType.APPLICATION_XML_VALUE)
+ .bodyValue(updatePayload)
+ .exchange()
+ .expectStatus()
+ .isOk();
+
+ modelVersionResponse = webClient.get()
+ .uri(modelVersionUri)
+ .accept(MediaType.APPLICATION_XML)
+ .exchange()
+ .expectStatus()
+ .isOk()
+ .returnResult(String.class)
+ .getResponseBody()
+ .blockFirst();
+ modelVersion = objectMapper.readValue(modelVersionResponse, ModelVersion.class);
+ assertEquals("2.0", modelVersion.getModelVersion());
}
}
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
index b04ba21..e97a43a 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
@@ -41,7 +41,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.json.JSONException;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -79,17 +78,10 @@ public class URLFromVertexIdConsumerTest extends AAISetup {
private List<MediaType> outputMediaTypes;
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
- private boolean initialized = false;
-
- @BeforeAll
- public static void setupRest() {
- // AAIGraph.getInstance();
- }
@BeforeEach
public void setup() {
- if (!initialized) {
- initialized = true;
+ if(!AAIGraph.isInit()) {
AAIGraph.getInstance();
}
logger.info("Starting the setup for the integration tests of Rest Endpoints");
@@ -139,8 +131,8 @@ public class URLFromVertexIdConsumerTest extends AAISetup {
when(uriInfo.getPath(false)).thenReturn(uri);
MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri);
- Response response = legacyMoxyConsumer.getLegacy("", "-1", "-1", schemaVersions.getDefaultVersion().toString(),
- uri, "all", "false", httpHeaders, uriInfo, mockReqGet);
+ Response response = legacyMoxyConsumer.getLegacy(schemaVersions.getDefaultVersion().toString(), uri, -1, -1, false,
+ "all", "false", httpHeaders, uriInfo, mockReqGet);
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri);
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
index 0f56348..d0455b1 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
@@ -41,7 +41,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.json.JSONException;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -79,17 +78,10 @@ public class VertexIdConsumerTest extends AAISetup {
private List<MediaType> outputMediaTypes;
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
- private boolean initialized = false;
-
- @BeforeAll
- public static void setupRest() {
- // AAIGraph.getInstance();
- }
@BeforeEach
public void setup() {
- if (!initialized) {
- initialized = true;
+ if(!AAIGraph.isInit()) {
AAIGraph.getInstance();
}
logger.info("Starting the setup for the integration tests of Rest Endpoints");
@@ -139,8 +131,8 @@ public class VertexIdConsumerTest extends AAISetup {
when(uriInfo.getPath(false)).thenReturn(uri);
MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri);
- Response response = legacyMoxyConsumer.getLegacy("", "-1", "-1", schemaVersions.getDefaultVersion().toString(),
- uri, "all", "false", httpHeaders, uriInfo, mockReqGet);
+ Response response = legacyMoxyConsumer.getLegacy(schemaVersions.getDefaultVersion().toString(), uri, -1, -1,
+ false, "all", "false", httpHeaders, uriInfo, mockReqGet);
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri);
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/util/EchoHealthIndicatorTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/EchoHealthIndicatorTest.java
new file mode 100644
index 0000000..f6f7480
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/rest/util/EchoHealthIndicatorTest.java
@@ -0,0 +1,70 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.util;
+
+import static org.mockito.Mockito.when;
+
+import org.junit.jupiter.api.Test;
+import org.onap.aai.config.WebClientConfiguration;
+import org.onap.aai.tasks.AaiGraphChecker;
+import org.onap.aai.tasks.AaiGraphChecker.CheckerType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.context.annotation.Import;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.web.reactive.server.WebTestClient;
+
+@Import(WebClientConfiguration.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@TestPropertySource(properties = "aai.actuator.echo.enabled=true")
+public class EchoHealthIndicatorTest {
+
+ @Autowired
+ @Qualifier("mgmtClient")
+ WebTestClient webClient;
+
+ @MockBean private AaiGraphChecker aaiGraphChecker;
+
+ @Test
+ public void thatActuatorCheckIsHealthy() {
+ when(aaiGraphChecker.isAaiGraphDbAvailable(CheckerType.ACTUAL)).thenReturn(true);
+
+ webClient.get()
+ .uri("/actuator/health")
+ .exchange()
+ .expectStatus()
+ .isOk();
+ }
+
+ @Test
+ public void thatActuatorCheckIsUnhealthy() {
+ when(aaiGraphChecker.isAaiGraphDbAvailable(CheckerType.ACTUAL)).thenReturn(false);
+
+ webClient.get()
+ .uri("/actuator/health")
+ .exchange()
+ .expectStatus()
+ .is5xxServerError();
+ }
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
index b00ae59..3958f46 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
@@ -29,7 +29,7 @@ public class LogFormatToolsTest {
@Test
public void testLogFormatTools() {
- String dateTime = new LogFormatTools().getCurrentDateTime();
+ String dateTime = LogFormatTools.getCurrentDateTime();
assertNotNull(dateTime);
}
}
diff --git a/aai-resources/src/test/resources/application-test.properties b/aai-resources/src/test/resources/application-test.properties
index a4b613c..3fcab50 100644
--- a/aai-resources/src/test/resources/application-test.properties
+++ b/aai-resources/src/test/resources/application-test.properties
@@ -20,7 +20,6 @@ spring.autoconfigure.exclude=\
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\
org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration
-spring.profiles.active=production
#The max number of active threads in this pool
server.tomcat.threads.max=200
#The minimum number of threads always kept alive
@@ -59,7 +58,7 @@ schema.ingest.file=${server.local.startpath}/application.properties
# Schema Version Related Attributes
schema.uri.base.path=/aai
# Lists all of the versions in the schema
-schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29
+schema.version.list=v10,v11,v12,v13,v14,v29
# Specifies from which version should the depth parameter to default to zero
schema.version.depth.start=v10
# Specifies from which version should the related link be displayed in response payload
@@ -77,6 +76,8 @@ schema.translator.list=config
#To expose the Prometheus scraping endpoint in unit test
management.server.port=0
+management.endpoint.metrics.enabled=true
+management.endpoint.prometheus.enabled=true
management.endpoints.enabled-by-default=true
management.endpoints.web.exposure.include=info, health, prometheus
management.metrics.web.server.request.autotime.enabled=false
diff --git a/aai-resources/src/test/resources/it/application-keycloak-test.properties b/aai-resources/src/test/resources/it/application-keycloak-test.properties
index db9b4b4..7a86d1a 100644
--- a/aai-resources/src/test/resources/it/application-keycloak-test.properties
+++ b/aai-resources/src/test/resources/it/application-keycloak-test.properties
@@ -14,4 +14,4 @@ keycloak.bearer-only=true
multi.tenancy.enabled=true
spring.profiles.active=production,keycloak
-schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29
+schema.version.list=v10,v11,v12,v13,v14,v29
diff --git a/aai-resources/src/test/resources/logback.xml b/aai-resources/src/test/resources/logback.xml
index a550336..80050ca 100644
--- a/aai-resources/src/test/resources/logback.xml
+++ b/aai-resources/src/test/resources/logback.xml
@@ -269,7 +269,7 @@
<logger name="org.testcontainers" level="INFO"/>
<logger name="com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire" level="OFF"/>
- <root level="DEBUG">
+ <root level="INFO">
<appender-ref ref="external" />
<appender-ref ref="STDOUT" />
</root>
diff --git a/aai-resources/src/test/resources/payloads/models/model-version.xml b/aai-resources/src/test/resources/payloads/models/model-version.xml
new file mode 100644
index 0000000..130bc68
--- /dev/null
+++ b/aai-resources/src/test/resources/payloads/models/model-version.xml
@@ -0,0 +1,12 @@
+<model-ver xmlns="http://org.onap.aai.inventory/v29">
+ <model-version-id>8b713350-90fc-44b1-8c6e-a2b3973aa9d3</model-version-id>
+ <model-name>test-svc-distribution</model-name>
+ <model-version>2.0</model-version>
+ <resource-version>resourceVersion</resource-version>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>T</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ </model-element>
+ </model-elements>
+ </model-ver>
diff --git a/aai-resources/src/test/resources/payloads/models/network-service.xml b/aai-resources/src/test/resources/payloads/models/network-service.xml
index ee04def..977c186 100644
--- a/aai-resources/src/test/resources/payloads/models/network-service.xml
+++ b/aai-resources/src/test/resources/payloads/models/network-service.xml
@@ -8,19 +8,6 @@
<model-name>test-svc-distribution</model-name>
<model-version>1.0</model-version>
<model-description>test-svc-distribution</model-description>
- <model-elements>
- <model-element>
- <new-data-del-flag>T</new-data-del-flag>
- <cardinality>unbounded</cardinality>
- <model-elements>
- <model-element>
- <new-data-del-flag>T</new-data-del-flag>
- <cardinality>unbounded</cardinality>
- <model-elements/>
- </model-element>
- </model-elements>
- </model-element>
- </model-elements>
</model-ver>
</model-vers>
-</model> \ No newline at end of file
+</model>
diff --git a/onap-java-formatter.xml b/onap-java-formatter.xml
index 1dd9de6..afd15d6 100644
--- a/onap-java-formatter.xml
+++ b/onap-java-formatter.xml
@@ -2,11 +2,11 @@
<profiles version="12">
<profile kind="CodeFormatterProfile" name="onap-java-formatter" version="12">
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
-<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
-<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="11"/>
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="11"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
-<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
+<setting id="org.eclipse.jdt.core.compiler.source" value="11"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="48"/>
diff --git a/pom.xml b/pom.xml
index 8bd1cc1..a333065 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,11 +26,11 @@
<parent>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-parent</artifactId>
- <version>1.14.1</version>
+ <version>1.14.7</version>
</parent>
<groupId>org.onap.aai.resources</groupId>
<artifactId>resources</artifactId>
- <version>1.14.1-SNAPSHOT</version>
+ <version>1.14.7-SNAPSHOT</version>
<name>aai-resources</name>
<packaging>pom</packaging>
<modules>
@@ -48,9 +48,22 @@
<staging.path>/content/repositories/staging/</staging.path>
<!-- GMaven plugin uses this property to figure out the name of the docker tag -->
<aai.project.version>${project.version}</aai.project.version>
- <aai.common.version>1.14.1</aai.common.version>
- <aai.schema.service.version>1.12.4</aai.schema.service.version>
+ <aai.common.version>1.14.7</aai.common.version>
+ <aai.schema.service.version>1.12.5</aai.schema.service.version>
</properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-junit</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
<build>
<pluginManagement>
<plugins>
diff --git a/releases/1.14.3-container-release.yaml b/releases/1.14.3-container-release.yaml
new file mode 100644
index 0000000..4a05bc7
--- /dev/null
+++ b/releases/1.14.3-container-release.yaml
@@ -0,0 +1,7 @@
+distribution_type: container
+container_release_tag: 1.14.3
+project: resources
+ref: 4f5404caa0664bf264223c7a0c5adadb34341bdc
+containers:
+ - name: aai-resources
+ version: 1.14-STAGING-20240701T095657Z
diff --git a/releases/1.14.4-container-release.yaml b/releases/1.14.4-container-release.yaml
new file mode 100644
index 0000000..3a3d8b8
--- /dev/null
+++ b/releases/1.14.4-container-release.yaml
@@ -0,0 +1,7 @@
+distribution_type: container
+container_release_tag: 1.14.4
+project: resources
+ref: ffe39ebf09d514af9fc84e68fb7ebc2f2c4692d2
+containers:
+ - name: aai-resources
+ version: 1.14-STAGING-20240704T134345Z
diff --git a/releases/1.14.5-container-release.yaml b/releases/1.14.5-container-release.yaml
new file mode 100644
index 0000000..369ed42
--- /dev/null
+++ b/releases/1.14.5-container-release.yaml
@@ -0,0 +1,7 @@
+distribution_type: container
+container_release_tag: 1.14.5
+project: resources
+ref: 5484bd86fbec7a912def41cf3fa4f441e92b2b61
+containers:
+ - name: aai-resources
+ version: 1.14-STAGING-20240806T095506Z
diff --git a/releases/1.14.6-container-release.yaml b/releases/1.14.6-container-release.yaml
new file mode 100644
index 0000000..7d0a099
--- /dev/null
+++ b/releases/1.14.6-container-release.yaml
@@ -0,0 +1,7 @@
+distribution_type: container
+container_release_tag: 1.14.6
+project: resources
+ref: c7cb468ab9303db88d27ad96a20b0840a5d58f43
+containers:
+ - name: aai-resources
+ version: 1.14-STAGING-20240815T063226Z
diff --git a/releases/1.14.7-container-release.yaml b/releases/1.14.7-container-release.yaml
new file mode 100644
index 0000000..8614cc8
--- /dev/null
+++ b/releases/1.14.7-container-release.yaml
@@ -0,0 +1,7 @@
+distribution_type: container
+container_release_tag: 1.14.7
+project: resources
+ref: 1a0763c2cfb23de0c690136d8e66df98e3844192
+containers:
+ - name: aai-resources
+ version: 1.14-STAGING-20240919T095903Z
diff --git a/version.properties b/version.properties
index 654a031..e8f490e 100644
--- a/version.properties
+++ b/version.properties
@@ -5,7 +5,7 @@
major_version=1
minor_version=14
-patch_version=1
+patch_version=7
base_version=${major_version}.${minor_version}.${patch_version}