diff options
48 files changed, 1057 insertions, 448 deletions
diff --git a/aai-resources/pom.xml b/aai-resources/pom.xml index b17d12e..0679e26 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.3-SNAPSHOT</version> + <version>1.15.0-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> @@ -75,30 +73,33 @@ <schema.version.namespace.change.start>v12</schema.version.namespace.change.start> <schema.version.edge.label.start>v12</schema.version.edge.label.start> <schema.version.api.default>v29</schema.version.api.default> - <schema.version.list>v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29</schema.version.list> + <schema.version.list>v10,v11,v12,v13,v14,v15,v23,v29</schema.version.list> <schema.uri.base.path>/aai</schema.uri.base.path> <!-- <schema.translator.list>config</schema.translator.list> --> <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> - - <janusgraph.version>0.5.0</janusgraph.version> - <gremlin.version>3.4.13</gremlin.version> + <janusgraph.version>0.6.4</janusgraph.version> + <gremlin.version>3.5.8</gremlin.version> <javax.servlet.version>4.0.1</javax.servlet.version> <keycloak.version>11.0.2</keycloak.version> - <micrometer.version>1.6.6</micrometer.version> <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 --> @@ -107,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> @@ -206,7 +186,7 @@ <properties> <schema.source.name>onap</schema.source.name> <schema.version.namespace.change.start>v12</schema.version.namespace.change.start> - <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> + <schema.version.list>v10,v11,v12,v13,v14,v15,v16,v23,v29</schema.version.list> <schema.ingest.file>${project.basedir}/src/main/resources/application.properties</schema.ingest.file> </properties> </profile> @@ -307,36 +287,37 @@ </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.cloud</groupId> - <artifactId>spring-cloud-starter-sleuth</artifactId> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> - <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-sleuth-zipkin</artifactId> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-jetty</artifactId> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <scope>test</scope> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-starter-sleuth</artifactId> </dependency> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-core</artifactId> - <version>${micrometer.version}</version> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-sleuth-zipkin</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> - <version>${micrometer.version}</version> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-jersey2</artifactId> - <version>${micrometer.version}</version> </dependency> <dependency> <groupId>javax.jms</groupId> @@ -349,16 +330,12 @@ <version>2.1</version> </dependency> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> - </dependency> - <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-impl</artifactId> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> </dependency> <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-core</artifactId> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> </dependency> <dependency> @@ -453,7 +430,8 @@ </dependency> <dependency> <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-junit</artifactId> + <artifactId>hamcrest</artifactId> + <version>2.2</version> <exclusions> <exclusion> <groupId>junit</groupId> @@ -605,6 +583,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> @@ -639,20 +635,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> @@ -724,6 +706,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> @@ -738,9 +726,15 @@ <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> + <version>1.18.34</version> <scope>provided</scope> </dependency> <dependency> @@ -769,13 +763,23 @@ <artifactId>guava</artifactId> <version>25.0-jre</version> </dependency> - <!-- https://docs.datastax.com/en/developer/java-driver/3.5/manual/metrics/index.html#metrics-4-compatibility --> - <!-- remove this for janusgraph >= 0.6.0 --> + <!-- 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>io.dropwizard.metrics</groupId> - <artifactId>metrics-core</artifactId> - <version>3.2.6</version> + <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 c518258..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 @@ -47,7 +47,6 @@ 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.query.builder.Sort; import org.onap.aai.rest.db.DBRequest; import org.onap.aai.rest.db.HttpEntry; import org.onap.aai.rest.exceptions.AAIInvalidXMLNamespace; 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/service/AuthorizationService.java b/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java index 31dd953..0c219a7 100644 --- a/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java +++ b/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java @@ -23,7 +23,7 @@ package org.onap.aai.service; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.Base64; import java.util.HashMap; import java.util.Map; @@ -54,7 +54,7 @@ public class AuthorizationService { String basicAuthFile = getBasicAuthFilePath(); - try (Stream<String> stream = Files.lines(Paths.get(basicAuthFile))) { + try (Stream<String> stream = Files.lines(Path.of(basicAuthFile))) { stream.filter(line -> !line.startsWith("#")).forEach(str -> { byte[] bytes = null; 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..f4eccca 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} @@ -80,7 +81,7 @@ schema.ingest.file=${server.local.startpath}/application.properties 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,v15,v23,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 @@ -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/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 e54c8e5..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(defaultSchemaVersion, uri, -1, -1, - false, "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(defaultSchemaVersion, uri, -1, -1, false, - "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(defaultSchemaVersion, uri, -1, -1, false, - "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(defaultSchemaVersion, uri, 1, 10, true, - "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 @@ -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); } 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..1ba8652 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 java.nio.file.Path; -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"; - - 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()); - - 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()); + String uri = "/aai/v29/service-design-and-creation/models/model/d821d1aa-8a69-47a4-aa63-3dae1742c47c"; + + webClient.get() + .uri(uri) + .accept(MediaType.APPLICATION_XML) + .exchange() + .expectStatus() + .isNotFound(); + + String modelPayload = new String(Files.readAllBytes(Path.of(MODEL_FILE))); + 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(Path.of(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(Path.of(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 2e6d49e..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"); 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 ce9a423..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"); 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"/> @@ -26,17 +26,18 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.3</version> + <version>1.15.0-SNAPSHOT</version> </parent> <groupId>org.onap.aai.resources</groupId> <artifactId>resources</artifactId> - <version>1.14.3-SNAPSHOT</version> + <version>1.15.0-SNAPSHOT</version> <name>aai-resources</name> <packaging>pom</packaging> <modules> <module>aai-resources</module> </modules> <properties> + <maven.compiler.release>11</maven.compiler.release> <!-- Nexus Proxy Properties and Snapshot Locations Ideally this can be overwritten at runtime per internal environment specific values at runtime @@ -48,9 +49,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.3</aai.common.version> - <aai.schema.service.version>1.12.4</aai.schema.service.version> + <aai.common.version>1.15.0-SNAPSHOT</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.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 466ec95..039d36d 100644 --- a/version.properties +++ b/version.properties @@ -4,8 +4,8 @@ # because they are used in Jenkins, whose plug-in doesn't support major_version=1 -minor_version=14 -patch_version=2 +minor_version=15 +patch_version=0 base_version=${major_version}.${minor_version}.${patch_version} |