<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>
</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>
<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. -->
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;
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;
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;
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<>();
}
public static Path propertiesFile() {
- return Paths.get(configHome, "model-loader.properties");
+ return Path.of(configHome, "model-loader.properties");
}
@Override
*/
package org.onap.aai.modelloader.entity.catalog;
+import java.io.Serial;
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;
*/
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.
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("/")) {
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();
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("/")) {
*/
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.
*/
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.
*/
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.
*/
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);
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()) //
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;
@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);
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;
@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);
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;
*/
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;
* @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;
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;
@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");
@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");
@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");
@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");
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;
@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");
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;
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);
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;
}
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();
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;
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()));
}
}
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;
}
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));
}
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;
@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));
# 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}