Upgrade Java version 17 for AAI modelloader 69/142369/3
authorakshay.khairnar@t-systems.com <akshay.khairnar@t-systems.com>
Mon, 17 Nov 2025 05:27:56 +0000 (06:27 +0100)
committerakshay.khairnar@t-systems.com <akshay.khairnar@t-systems.com>
Mon, 1 Dec 2025 11:15:17 +0000 (12:15 +0100)
- Upgrade java version to 17
- testcase fixes
- Bump up model-loader version 1.15.0

Issue-ID: AAI-4209
Change-Id: If47f1499566d51f93435e11f5b8b7fb65979b85d
Signed-off-by: akshay.khairnar@t-systems.com <akshay.khairnar@t-systems.com>
23 files changed:
pom.xml
src/main/java/org/onap/aai/modelloader/config/BeanConfig.java
src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
src/main/java/org/onap/aai/modelloader/entity/catalog/VnfImageException.java
src/main/java/org/onap/aai/modelloader/entity/model/BabelArtifactParsingException.java
src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java
src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifact.java
src/main/java/org/onap/aai/modelloader/extraction/InvalidArchiveException.java
src/main/java/org/onap/aai/modelloader/notification/DownloadFailureException.java
src/main/java/org/onap/aai/modelloader/notification/ProcessToscaArtifactsException.java
src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientException.java
src/main/java/org/onap/aai/modelloader/util/GizmoTranslator.java
src/test/java/org/onap/aai/modelloader/BabelClientTestConfiguration.java
src/test/java/org/onap/aai/modelloader/DistributionClientTestConfiguration.java
src/test/java/org/onap/aai/modelloader/entity/catalog/TestVnfCatalogArtifactHandler.java
src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactParser.java
src/test/java/org/onap/aai/modelloader/entity/model/TestNamedQueryArtifactParser.java
src/test/java/org/onap/aai/modelloader/notification/DistributionClientIntegrationTest.java
src/test/java/org/onap/aai/modelloader/restclient/TestAaiRestClient.java
src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java
src/test/java/org/onap/aai/modelloader/util/TestGizmoTranslator.java
src/test/java/org/onap/aai/modelloader/util/TestJsonXmlConverter.java
version.properties

diff --git a/pom.xml b/pom.xml
index 518febd..96050a9 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
        <groupId>org.onap.aai.model-loader</groupId>
        <artifactId>model-loader</artifactId>
        <name>aai-model-loader</name>
-       <version>1.14.3-SNAPSHOT</version>
+       <version>1.15.0-SNAPSHOT</version>
 
        <dependencyManagement>
                <dependencies>
@@ -55,6 +55,7 @@
        </dependencyManagement>
 
        <properties>
+               <maven.compiler.release>17</maven.compiler.release>
                <start-class>org.onap.aai.modelloader.service.ModelLoaderApplication</start-class>
                <nexusproxy>https://nexus.onap.org</nexusproxy>
                <docker.location>${basedir}/target</docker.location>
@@ -81,7 +82,7 @@
                <sonar.jacoco.reportMissing.force.zero />
 
                <jacoco.line.coverage.limit>0.75</jacoco.line.coverage.limit>
-               <jacoco.version>0.8.5</jacoco.version>
+               <jacoco.version>0.8.13</jacoco.version>
                <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
                <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
                <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
                <sonar.scanner.version>3.7.0.1746</sonar.scanner.version>
 
                <maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
-               <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
-               <maven-compiler-plugin.source>11</maven-compiler-plugin.source>
-               <maven-compiler-plugin.target>11</maven-compiler-plugin.target>
-               <maven-compiler-plugin.test.source>11</maven-compiler-plugin.test.source>
-               <maven-compiler-plugin.test.target>11</maven-compiler-plugin.test.target>
+               <maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
+               <maven-compiler-plugin.source>17</maven-compiler-plugin.source>
+               <maven-compiler-plugin.target>17</maven-compiler-plugin.target>
+               <maven-compiler-plugin.test.source>17</maven-compiler-plugin.test.source>
+               <maven-compiler-plugin.test.target>17</maven-compiler-plugin.test.target>
        </properties>
 
        <distributionManagement>
                                <artifactId>maven-surefire-plugin</artifactId>
                                <version>3.1.2</version>
                                <configuration>
+                                       <systemPropertyVariables>
+                                       <CONFIG_HOME>${project.basedir}/src/test/resources</CONFIG_HOME>
+                               </systemPropertyVariables>
                                        <!-- Sets the VM argument line used when unit tests are run. -->
                                        <argLine>${surefireArgLine}</argLine>
                                        <!-- Excludes integration tests when unit tests are run. -->
index cc6702b..a4ad48d 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.aai.modelloader.config;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.Properties;
 
 import org.onap.aai.cl.api.Logger;
@@ -48,7 +48,7 @@ public class BeanConfig {
     public Properties configProperties() throws IOException {
         // Load model loader system configuration
         logger.info(ModelLoaderMsgs.LOADING_CONFIGURATION);
-        InputStream configInputStream = Files.newInputStream(Paths.get(configDir, "model-loader.properties"));
+        InputStream configInputStream = Files.newInputStream(Path.of(configDir, "model-loader.properties"));
         Properties configProperties = new Properties();
         configProperties.load(configInputStream);
         return configProperties;
index b01086c..2a6c7e3 100644 (file)
@@ -22,7 +22,6 @@
 package org.onap.aai.modelloader.config;
 
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -76,7 +75,7 @@ public class ModelLoaderConfig implements IConfiguration {
     protected static final String PROP_DEBUG_INGEST_SIMULATOR = PREFIX_DEBUG + "INGEST_SIMULATOR";
     protected static final String FILESEP =
             (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
-    private static String configHome;
+    private static String configHome = System.getProperty("CONFIG_HOME");
     private Properties modelLoaderProperties = null;
     private String certLocation = ".";
     private final List<String> artifactTypes = new ArrayList<>();
@@ -110,7 +109,7 @@ public class ModelLoaderConfig implements IConfiguration {
     }
 
     public static Path propertiesFile() {
-        return Paths.get(configHome, "model-loader.properties");
+        return Path.of(configHome, "model-loader.properties");
     }
 
     @Override
index c116abe..7d8f6de 100644 (file)
@@ -20,6 +20,7 @@
  */
 package org.onap.aai.modelloader.entity.catalog;
 
+import java.io.Serial;
 import java.util.Optional;
 
 /**
@@ -27,7 +28,7 @@ import java.util.Optional;
  */
 class VnfImageException extends Exception {
 
-    private static final long serialVersionUID = 1L;
+    @Serial private static final long serialVersionUID = 1L;
 
     private final String imageId;
     private final transient Optional<Integer> resultCode;
index dfb649c..2cd8da1 100644 (file)
  */
 package org.onap.aai.modelloader.entity.model;
 
+import java.io.Serial;
+
 /**
  * This class represents an exception encountered when parsing an XML model Artifact.
  */
 public class BabelArtifactParsingException extends Exception {
 
-    private static final long serialVersionUID = 1L;
+    @Serial private static final long serialVersionUID = 1L;
 
     /**
      * Constructor for an instance of this exception with just a message.
index 09c12b5..df19434 100644 (file)
@@ -258,7 +258,7 @@ public class ModelArtifact extends AbstractModelArtifact {
 
     private String getModelUrl(AaiProperties aaiProperties) {
         String baseURL = aaiProperties.getBaseUrl().trim();
-        String subURL = String.format(aaiProperties.getModelUrl(), getModelNamespaceVersion()).trim();
+        String subURL = aaiProperties.getModelUrl().formatted(getModelNamespaceVersion()).trim();
         String instance = getModelInvariantId();
 
         if (!baseURL.endsWith("/") && !subURL.startsWith("/")) {
@@ -278,7 +278,7 @@ public class ModelArtifact extends AbstractModelArtifact {
 
     private String getModelVerUrl(AaiProperties aaiProperties) {
         String baseURL = aaiProperties.getBaseUrl().trim();
-        String subURL = String.format(aaiProperties.getModelUrl(), getModelNamespaceVersion()).trim() + getModelInvariantId()
+        String subURL = aaiProperties.getModelUrl().formatted(getModelNamespaceVersion()).trim() + getModelInvariantId()
                 + AAI_MODEL_VER_SUB_URL;
         String instance = getModelVerId();
 
index b2b1e48..34187c7 100644 (file)
@@ -98,7 +98,7 @@ public class NamedQueryArtifact extends AbstractModelArtifact {
 
     private String getNamedQueryUrl(AaiProperties aaiProperties) {
         String baseURL = aaiProperties.getBaseUrl().trim();
-        String subURL = String.format(aaiProperties.getNamedQueryUrl(), getModelNamespaceVersion()).trim();
+        String subURL = aaiProperties.getNamedQueryUrl().formatted(getModelNamespaceVersion()).trim();
         String instance = this.getNamedQueryUuid();
 
         if (!baseURL.endsWith("/") && !subURL.startsWith("/")) {
index 36581df..f51928f 100644 (file)
  */
 package org.onap.aai.modelloader.extraction;
 
+import java.io.Serial;
+
 /**
  * This class represents an exception encountered when processing an archive in memory.
  */
 public class InvalidArchiveException extends Exception {
 
-    private static final long serialVersionUID = 1L;
+    @Serial private static final long serialVersionUID = 1L;
 
     /**
      * Constructor for an instance of this exception with just a message.
index d39330f..b0472d2 100644 (file)
  */
 package org.onap.aai.modelloader.notification;
 
+import java.io.Serial;
+
 /**
  * Failure to download a distribution.
  */
 class DownloadFailureException extends Exception {
 
-    private static final long serialVersionUID = 1L;
+    @Serial private static final long serialVersionUID = 1L;
 
     /**
      * Constructor for an instance of this exception with just a message.
index 0d082c1..c0c70ff 100644 (file)
  */
 package org.onap.aai.modelloader.notification;
 
+import java.io.Serial;
+
 public class ProcessToscaArtifactsException extends Exception {
 
-    private static final long serialVersionUID = 1L;
+    @Serial private static final long serialVersionUID = 1L;
 
     /**
      * Constructor for an instance of this exception with just a message.
index 0ce8037..e1131a5 100644 (file)
  */
 package org.onap.aai.modelloader.restclient;
 
+import java.io.Serial;
+
 public class BabelServiceClientException extends Exception {
 
     /**
      * Babel Service Client Exception.
      */
-    private static final long serialVersionUID = 1L;
+    @Serial private static final long serialVersionUID = 1L;
 
     public BabelServiceClientException(String message) {
         super(message);
index 1b03933..e9657ba 100644 (file)
@@ -206,7 +206,7 @@ public class GizmoTranslator {
         Optional<String> parentVersion = Optional.empty();
 
         Node parentNode = node.getParentNode();
-        while (parentNode != null && !parentVersion.isPresent()) {
+        while (parentNode != null && parentVersion.isEmpty()) {
             if (getNodeType(parentNode) == NodeType.VERTEX) {
                 NodeList childNodes = ((Element) parentNode).getElementsByTagName("*");
                 parentVersion = IntStream.range(0, childNodes.getLength()) //
index 363b92c..6233e43 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.aai.modelloader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.Properties;
 
 import org.springframework.beans.factory.annotation.Value;
@@ -42,7 +42,7 @@ public class BabelClientTestConfiguration {
   @Bean(name = "testProperties")
   public Properties configProperties() throws IOException {
     // Load model loader system configuration
-    InputStream configInputStream = Files.newInputStream(Paths.get(configDir, "model-loader.properties"));
+    InputStream configInputStream = Files.newInputStream(Path.of(configDir, "model-loader.properties"));
     Properties configProperties = new Properties();
     configProperties.load(configInputStream);
 
index b716c1a..7dbd2e2 100644 (file)
@@ -29,7 +29,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -62,7 +62,7 @@ public class DistributionClientTestConfiguration {
   @Bean(name = "testProperties")
   Properties configProperties() throws IOException {
     // Load model loader system configuration
-    InputStream configInputStream = Files.newInputStream(Paths.get(configDir, "model-loader.properties"));
+    InputStream configInputStream = Files.newInputStream(Path.of(configDir, "model-loader.properties"));
     Properties configProperties = new Properties();
     configProperties.load(configInputStream);
 
index 840acb0..edd9004 100644 (file)
@@ -30,7 +30,7 @@ import static org.mockito.Mockito.when;
 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.ArrayList;
 import java.util.List;
 
@@ -132,7 +132,7 @@ public class TestVnfCatalogArtifactHandler {
      */
     private List<Artifact> createVnfCatalogArtifact() throws IOException, UnsupportedEncodingException {
         String examplePath = "src/test/resources/imagedataexample.json";
-        byte[] encoded = Files.readAllBytes(Paths.get(examplePath));
+        byte[] encoded = Files.readAllBytes(Path.of(examplePath));
         List<Artifact> artifacts = new ArrayList<Artifact>();
         artifacts.add(new VnfCatalogArtifact(new String(encoded, "utf-8")));
         return artifacts;
@@ -146,7 +146,7 @@ public class TestVnfCatalogArtifactHandler {
      * @throws UnsupportedEncodingException
      */
     private List<Artifact> createVnfCatalogXmlArtifact() throws IOException, UnsupportedEncodingException {
-        byte[] encoded = Files.readAllBytes(Paths.get("src/test/resources/xmlFiles/fortigate.xml"));
+        byte[] encoded = Files.readAllBytes(Path.of("src/test/resources/xmlFiles/fortigate.xml"));
         List<Artifact> artifacts = new ArrayList<Artifact>();
         artifacts.add(new VnfCatalogArtifact(ArtifactType.VNF_CATALOG_XML, new String(encoded, "utf-8")));
         return artifacts;
index fc0556f..da4e326 100644 (file)
@@ -27,7 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase;
 
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.List;
 
 import org.junit.jupiter.api.Test;
@@ -43,7 +43,7 @@ public class TestModelArtifactParser {
 
     @Test
     public void testParseModelFileNoDeps() throws Exception {
-        String fileString = new String(Files.readAllBytes(Paths.get(MODEL_FILE)));
+        String fileString = new String(Files.readAllBytes(Path.of(MODEL_FILE)));
 
         ModelArtifactParser parser = new ModelArtifactParser();
         List<Artifact> modelList = parser.parse(fileString, "test-artifact");
@@ -62,7 +62,7 @@ public class TestModelArtifactParser {
 
     @Test
     public void testParseModelFileDeps() throws Exception {
-        String fileString = new String(Files.readAllBytes(Paths.get(MODEL_FILE_SERVICE)));
+        String fileString = new String(Files.readAllBytes(Path.of(MODEL_FILE_SERVICE)));
 
         ModelArtifactParser parser = new ModelArtifactParser();
         List<Artifact> modelList = parser.parse(fileString, "test-artifact");
@@ -83,7 +83,7 @@ public class TestModelArtifactParser {
 
     @Test
     public void testParseModelFileInvalidArtifact() throws Exception {
-        String fileString = new String(Files.readAllBytes(Paths.get(MODEL_FILE_INVALID)));
+        String fileString = new String(Files.readAllBytes(Path.of(MODEL_FILE_INVALID)));
 
         ModelArtifactParser parser = new ModelArtifactParser();
         List<Artifact> modelList = parser.parse(fileString, "test-artifact");
@@ -93,7 +93,7 @@ public class TestModelArtifactParser {
 
     @Test
     public void testParseModelFileIncompleteArtifact() throws Exception {
-        String fileString = new String(Files.readAllBytes(Paths.get(MODEL_FILE_INCOMPLETE)));
+        String fileString = new String(Files.readAllBytes(Path.of(MODEL_FILE_INCOMPLETE)));
 
         ModelArtifactParser parser = new ModelArtifactParser();
         List<Artifact> modelList = parser.parse(fileString, "test-artifact");
index 9ea900f..fe7538e 100644 (file)
@@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.List;
 
 import org.junit.jupiter.api.Test;
@@ -41,7 +41,7 @@ public class TestNamedQueryArtifactParser {
     @Test
     public void testParseNamedQuery() throws Exception {
         try {
-            String fileString = new String(Files.readAllBytes(Paths.get(MODEL_FILE)));
+            String fileString = new String(Files.readAllBytes(Path.of(MODEL_FILE)));
 
             NamedQueryArtifactParser parser = new NamedQueryArtifactParser();
             List<Artifact> modelList = parser.parse(fileString, "test-artifact");
index 916f740..9c59bba 100644 (file)
@@ -25,7 +25,7 @@ import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.verify;
 
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -77,7 +77,7 @@ public class DistributionClientIntegrationTest {
   void thatCallbackIsCalled() {
     Thread.sleep(10000);
     String distributionJson = "src/test/resources/messages/distribution.json";
-    String message = Files.readString(Paths.get(distributionJson));
+    String message = Files.readString(Path.of(distributionJson));
 
     kafkaTemplate.send(topic, message);
 
index 191e032..03e207b 100644 (file)
@@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
@@ -113,16 +113,16 @@ public class TestAaiRestClient {
     }
 
     static String readFile(String path) throws IOException {
-        byte[] encoded = Files.readAllBytes(Paths.get(path));
+        byte[] encoded = Files.readAllBytes(Path.of(path));
         return new String(encoded);
     }
 
     private String getUrl(ModelArtifact model, AaiProperties aaiProperties) {
         String subUrl;
         if (model.getType().equals(ArtifactType.MODEL)) {
-            subUrl = String.format(aaiProperties.getModelUrl(), model.getModelNamespaceVersion()).trim();
+            subUrl = aaiProperties.getModelUrl().formatted(model.getModelNamespaceVersion()).trim();
         } else {
-            subUrl = String.format(aaiProperties.getNamedQueryUrl(), model.getModelNamespaceVersion()).trim();
+            subUrl = aaiProperties.getNamedQueryUrl().formatted(model.getModelNamespaceVersion()).trim();
         }
 
         String baseUrl = aaiProperties.getBaseUrl().trim();
index d82bff0..30008af 100644 (file)
@@ -27,7 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.Base64;
 import java.util.List;
 
@@ -96,6 +96,6 @@ public class TestBabelServiceClient {
 
 
     private byte[] readBytesFromFile(String resourceFile) throws IOException, URISyntaxException {
-        return Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(resourceFile).toURI()));
+        return Files.readAllBytes(Path.of(ClassLoader.getSystemResource(resourceFile).toURI()));
     }
 }
index c1a862a..fd02b6d 100644 (file)
@@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 
 import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.gizmo.GizmoBulkPayload;
@@ -66,7 +66,7 @@ public class TestGizmoTranslator {
     }
 
     private GizmoBulkPayload createBulkRequest(String filePath) throws IOException {
-        final String xmlPayload = new String(Files.readAllBytes(Paths.get(filePath)));
+        final String xmlPayload = new String(Files.readAllBytes(Path.of(filePath)));
         return GizmoBulkPayload.fromJson(GizmoTranslator.translate(xmlPayload));
     }
 
index ec66a59..f6e87a2 100644 (file)
@@ -25,7 +25,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.ByteArrayInputStream;
 import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -51,9 +51,9 @@ public class TestJsonXmlConverter {
 
     @Test
     public void testConversion() throws Exception {
-        byte[] encoded = Files.readAllBytes(Paths.get(XML_MODEL_FILE));
+        byte[] encoded = Files.readAllBytes(Path.of(XML_MODEL_FILE));
         assertThat(JsonXmlConverter.isValidJson(new String(encoded)), is(false));
-        encoded = Files.readAllBytes(Paths.get(JSON_MODEL_FILE));
+        encoded = Files.readAllBytes(Path.of(JSON_MODEL_FILE));
         String originalJson = new String(encoded);
 
         assertThat(JsonXmlConverter.isValidJson(originalJson), is(true));
index 3601758..5b2605c 100644 (file)
@@ -24,8 +24,8 @@
 # because they are used in Jenkins, whose plug-in doesn't support
 
 major=1
-minor=14
-patch=3
+minor=15
+patch=0
 
 base_version=${major}.${minor}.${patch}