Update model-loader to spring-boot 2.4 37/137437/1
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 28 Feb 2024 13:39:51 +0000 (14:39 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 28 Feb 2024 13:39:51 +0000 (14:39 +0100)
- update spring boot from 2.3.12 to 2.4.13 release
- migrate JUnit 4 to JUnit 5
- bump version to 1.13.5

Issue-ID: AAI-3788
Change-Id: I280dd09194dfb4c9810c01933fdd18ea7f3d03a9
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
28 files changed:
pom.xml
src/main/resources/application.properties
src/test/java/org/onap/aai/modelloader/TestModelLoaderApplication.java
src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
src/test/java/org/onap/aai/modelloader/csar/extractor/VnfCatalogExtractorTest.java
src/test/java/org/onap/aai/modelloader/entity/catalog/TestVnfCatalogArtifactHandler.java
src/test/java/org/onap/aai/modelloader/entity/catalog/TestVnfImageException.java
src/test/java/org/onap/aai/modelloader/entity/model/ModelSorterTest.java
src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.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/extraction/TestArtifactInfoExtractor.java
src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java
src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java
src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java
src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java
src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java
src/test/java/org/onap/aai/modelloader/notification/TestNotificationDataImpl.java
src/test/java/org/onap/aai/modelloader/notification/TestNotificationPublisher.java
src/test/java/org/onap/aai/modelloader/restclient/TestAaiRestClient.java
src/test/java/org/onap/aai/modelloader/restclient/TestAaiServiceClient.java
src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java
src/test/java/org/onap/aai/modelloader/service/TestArtifactInfoImpl.java
src/test/java/org/onap/aai/modelloader/service/TestModelLoaderService.java
src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.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 27978bb..a311908 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.12.0-SNAPSHOT</version>
+       <version>1.13.5-SNAPSHOT</version>
 
        <dependencyManagement>
                <dependencies>
@@ -51,7 +51,7 @@
                <start-class>org.onap.aai.modelloader.service.ModelLoaderApplication</start-class>
                <nexusproxy>https://nexus.onap.org</nexusproxy>
                <docker.location>${basedir}/target</docker.location>
-               <spring-boot.version>2.3.12.RELEASE</spring-boot.version>
+               <spring-boot.version>2.4.13</spring-boot.version>
                <apache.commons-text.version>1.10.0</apache.commons-text.version>
                <commons-compress.version>1.22</commons-compress.version>
                <hamcrest-all.version>1.3</hamcrest-all.version>
                <dependency>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-classic</artifactId>
-                       <version>${logback.version}</version><!--$NO-MVN-MAN-VER$ -->
+                       <version>${logback.version}</version>
+                       <!--$NO-MVN-MAN-VER$ -->
                </dependency>
                <dependency>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-core</artifactId>
-                       <version>${logback.version}</version><!--$NO-MVN-MAN-VER$ -->
+                       <version>${logback.version}</version>
+                       <!--$NO-MVN-MAN-VER$ -->
                </dependency>
                <dependency>
                        <groupId>org.onap.sdc.sdc-distribution-client</groupId>
                <dependency>
                        <groupId>org.json</groupId>
                        <artifactId>json</artifactId>
-                       <version>20131018</version><!--$NO-MVN-MAN-VER$ -->
+                       <version>20131018</version>
+                       <!--$NO-MVN-MAN-VER$ -->
                </dependency>
                <dependency>
                        <groupId>org.eclipse.jetty</groupId>
                </dependency>
 
                <!-- Test dependencies -->
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <scope>test</scope>
-               </dependency>
                <dependency>
                        <groupId>org.hamcrest</groupId>
                        <artifactId>hamcrest-all</artifactId>
                        <version>${hamcrest-all.version}</version>
                        <scope>test</scope>
                </dependency>
+               <dependency>
+                       <groupId>org.junit.jupiter</groupId>
+                       <artifactId>junit-jupiter</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.junit.jupiter</groupId>
+                       <artifactId>junit-jupiter-api</artifactId>
+                       <scope>test</scope>
+               </dependency>
                <dependency>
                        <groupId>org.mockito</groupId>
                        <artifactId>mockito-core</artifactId>
index 4ea6f0a..7273277 100644 (file)
@@ -12,9 +12,9 @@ server.port=9500
 #server.ssl.keyStoreType=
 #server.ssl.keyAlias=
 
-server.tomcat.max-threads=200
+server.tomcat.threads.max=200
 # The minimum number of threads always kept alive
-server.tomcat.min-spare-threads=25
+server.tomcat.threads.min-spare=25
 
 # Spring Boot logging
 logging.config=${logback.configurationFile}
index 0387f2d..cd39066 100644 (file)
@@ -20,9 +20,9 @@
  */
 package org.onap.aai.modelloader;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for ModelLoaderApplication class.
index e19b1e2..87fbd6a 100644 (file)
@@ -20,8 +20,8 @@
  */
 package org.onap.aai.modelloader.config;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -29,7 +29,7 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Properties;
 import org.eclipse.jetty.util.security.Password;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.restclient.AaiRestClient;
 import org.onap.sdc.utils.ArtifactTypeEnum;
 
@@ -157,13 +157,13 @@ public class TestModelLoaderConfig {
         ModelLoaderConfig config = new ModelLoaderConfig(props, null);
         AaiRestClient aaiClient = new AaiRestClient(config);
 
-        assertFalse("Empty AAI Password should result in no basic authentication", aaiClient.useBasicAuth());
+        assertFalse(aaiClient.useBasicAuth(), "Empty AAI Password should result in no basic authentication");
 
         props.load(new FileInputStream("src/test/resources/model-loader-no-auth-password.properties"));
         config = new ModelLoaderConfig(props, null);
         aaiClient = new AaiRestClient(config);
 
-        assertFalse("No AAI Password should result in no basic authentication", aaiClient.useBasicAuth());
+        assertFalse(aaiClient.useBasicAuth(), "No AAI Password should result in no basic authentication");
     }
 
     @Test
index 043edc3..b3335fc 100644 (file)
@@ -22,8 +22,8 @@ package org.onap.aai.modelloader.csar.extractor;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
@@ -32,7 +32,7 @@ import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.entity.ArtifactType;
 import org.onap.aai.modelloader.extraction.InvalidArchiveException;
@@ -86,8 +86,8 @@ public class VnfCatalogExtractorTest {
         List<Artifact> vnfcArtifacts = new VnfCatalogExtractor().extract(
                 new ArtifactTestUtils().loadResource("compressedArtifacts/noVnfcFilesArchive.csar"),
                 "noVnfcFilesArchive.csar");
-        assertTrue("No VNFC files should have been extracted, but " + vnfcArtifacts.size() + " were found.",
-                vnfcArtifacts.isEmpty());
+        assertTrue(vnfcArtifacts.isEmpty(),
+                "No VNFC files should have been extracted, but " + vnfcArtifacts.size() + " were found.");
     }
 
     @Test
index d4a0020..8145599 100644 (file)
@@ -23,7 +23,7 @@ package org.onap.aai.modelloader.entity.catalog;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -38,7 +38,7 @@ import java.util.Properties;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
index 88c1941..793ed9a 100644 (file)
@@ -24,7 +24,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for NotificationDataImpl class.
index 86985d8..0c79dc5 100644 (file)
@@ -26,13 +26,14 @@ import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.isEmptyString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 
 public class ModelSorterTest {
@@ -129,12 +130,14 @@ public class ModelSorterTest {
         assertThat(new ModelSorter().sort(Arrays.asList(nq1, nq2, artifact)), is(expected));
     }
 
-    @Test(expected = BabelArtifactParsingException.class)
+    @Test
     public void circularDependency() throws BabelArtifactParsingException {
-        List<Artifact> modelList = new ArrayList<Artifact>();
-        modelList.add(buildTestModel("aaaa", "1111", "bbbb|1111"));
-        modelList.add(buildTestModel("bbbb", "1111", "aaaa|1111"));
-        new ModelSorter().sort(modelList);
+        assertThrows(BabelArtifactParsingException.class, () -> {
+            List<Artifact> modelList = new ArrayList<Artifact>();
+            modelList.add(buildTestModel("aaaa", "1111", "bbbb|1111"));
+            modelList.add(buildTestModel("bbbb", "1111", "aaaa|1111"));
+            new ModelSorter().sort(modelList);
+        });
     }
 
     private ModelArtifact buildTestModel() {
index 3418a6b..fac50cb 100644 (file)
@@ -23,7 +23,7 @@ package org.onap.aai.modelloader.entity.model;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -34,8 +34,8 @@ import java.util.List;
 
 import javax.ws.rs.core.Response;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
@@ -55,7 +55,7 @@ public class TestModelArtifactHandler {
     @Mock
     private AaiRestClient aaiClient;
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         MockitoAnnotations.initMocks(this);
     }
index 9b90aa2..fc0556f 100644 (file)
@@ -30,7 +30,7 @@ import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.springframework.util.CollectionUtils;
 
index 8eebd06..9ea900f 100644 (file)
@@ -23,15 +23,15 @@ package org.onap.aai.modelloader.entity.model;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.isEmptyString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+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.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 
 public class TestNamedQueryArtifactParser {
index 3bfb2a5..142b3c0 100644 (file)
@@ -20,8 +20,8 @@
  */
 package org.onap.aai.modelloader.extraction;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getEmptyNotificationData;
 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getNotificationDataWithOneResource;
 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getNotificationDataWithOneService;
@@ -29,9 +29,9 @@ import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.ge
 
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.fixture.ArtifactInfoBuilder;
 import org.onap.aai.modelloader.fixture.MockNotificationDataImpl;
 import org.onap.sdc.api.notification.IArtifactInfo;
@@ -44,12 +44,12 @@ public class TestArtifactInfoExtractor {
 
     private ArtifactInfoExtractor extractor;
 
-    @Before
+    @BeforeEach
     public void setup() {
         extractor = new ArtifactInfoExtractor();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         extractor = null;
     }
@@ -60,7 +60,7 @@ public class TestArtifactInfoExtractor {
     }
 
     private void doEmptyArtifactsTest(INotificationData notificationData) {
-        assertTrue("The list returned should have been empty", extractor.extract(notificationData).isEmpty());
+        assertTrue(extractor.extract(notificationData).isEmpty(), "The list returned should have been empty");
     }
 
     @Test
@@ -79,8 +79,8 @@ public class TestArtifactInfoExtractor {
 
         List<IArtifactInfo> artifacts = extractor.extract(getNotificationDataWithOneService());
 
-        assertEquals("One artifact should have been returned", 1, artifacts.size());
-        assertEquals("The actual artifact did not match the expected one", expected, artifacts.get(0));
+        assertEquals(1, artifacts.size(), "One artifact should have been returned");
+        assertEquals(expected, artifacts.get(0), "The actual artifact did not match the expected one");
     }
 
     @Test
@@ -90,8 +90,8 @@ public class TestArtifactInfoExtractor {
 
         List<IArtifactInfo> artifacts = extractor.extract(getNotificationDataWithOneResource());
 
-        assertEquals("One artifact should have been returned", 1, artifacts.size());
-        assertEquals("The actual artifact did not match the expected one", expectedArtifacts, artifacts);
+        assertEquals(1, artifacts.size(), "One artifact should have been returned");
+        assertEquals(expectedArtifacts, artifacts, "The actual artifact did not match the expected one");
     }
 
     @Test
@@ -102,7 +102,7 @@ public class TestArtifactInfoExtractor {
 
         List<IArtifactInfo> artifacts = extractor.extract(getNotificationDataWithOneServiceAndResources());
 
-        assertEquals("Two artifact should have been returned", 2, artifacts.size());
-        assertEquals("The actual artifact did not match the expected one", expectedArtifacts, artifacts);
+        assertEquals(2, artifacts.size(), "Two artifact should have been returned");
+        assertEquals(expectedArtifacts, artifacts, "The actual artifact did not match the expected one");
     }
 }
index 3710d62..1b8f33b 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.aai.modelloader.notification;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
@@ -34,8 +34,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
@@ -71,7 +71,7 @@ public class ArtifactDownloadManagerVnfcTest {
     private BabelServiceClientFactory mockClientFactory;
     private VnfCatalogExtractor mockVnfCatalogExtractor;
 
-    @Before
+    @BeforeEach
     public void setup() throws Exception {
         mockBabelClient = mock(BabelServiceClient.class);
         mockDistributionClient = mock(IDistributionClient.class);
@@ -107,7 +107,7 @@ public class ArtifactDownloadManagerVnfcTest {
         assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
                 is(true));
 
-        assertEquals("There should have been some catalog files", 2, catalogFiles.size());
+        assertEquals(2, catalogFiles.size(), "There should have been some catalog files");
     }
 
     @Test
@@ -125,7 +125,7 @@ public class ArtifactDownloadManagerVnfcTest {
         assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
                 is(true));
 
-        assertEquals("There should have been some catalog files", 3, catalogFiles.size());
+        assertEquals(3, catalogFiles.size(), "There should have been some catalog files");
     }
 
     @Test
@@ -143,7 +143,7 @@ public class ArtifactDownloadManagerVnfcTest {
         assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), modelArtifacts, catalogFiles),
                 is(true));
 
-        assertEquals("There should not have been any catalog files", 0, catalogFiles.size());
+        assertEquals(0, catalogFiles.size(), "There should not have been any catalog files");
     }
 
     @Test
index a63710e..2cac3c9 100644 (file)
@@ -34,9 +34,9 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
@@ -66,7 +66,7 @@ public class TestArtifactDeploymentManager {
     private ModelArtifactHandler mockModelArtifactHandler;
     private VnfCatalogArtifactHandler mockVnfCatalogArtifactHandler;
 
-    @Before
+    @BeforeEach
     public void setup() throws IOException {
         configProperties = new Properties();
         configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE));
@@ -80,7 +80,7 @@ public class TestArtifactDeploymentManager {
         ReflectionTestUtils.setField(manager, "vnfCatalogArtifactHandler", mockVnfCatalogArtifactHandler);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         configProperties = null;
         mockModelArtifactHandler = null;
index 3d1cf15..561791b 100644 (file)
@@ -41,9 +41,9 @@ import java.util.List;
 import java.util.Properties;
 
 import org.hamcrest.collection.IsEmptyCollection;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
@@ -74,7 +74,7 @@ public class TestArtifactDownloadManager {
     private BabelArtifactConverter mockBabelArtifactConverter;
     private BabelServiceClientFactory mockClientFactory;
 
-    @Before
+    @BeforeEach
     public void setup() throws Exception {
         mockBabelClient = mock(BabelServiceClient.class);
         mockDistributionClient = mock(IDistributionClient.class);
@@ -92,7 +92,7 @@ public class TestArtifactDownloadManager {
         ReflectionTestUtils.setField(downloadManager, "babelArtifactConverter", mockBabelArtifactConverter);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         downloadManager = null;
         mockDistributionClient = null;
index 2a04ec5..1d81513 100644 (file)
  */
 package org.onap.aai.modelloader.notification;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.entity.ArtifactType;
@@ -42,30 +44,34 @@ import org.onap.sdc.api.notification.INotificationData;
  */
 public class TestBabelArtifactConverter {
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void convert_nullToscaFiles() throws BabelArtifactParsingException {
-        new BabelArtifactConverter().convertToModel(null);
-        fail("An instance of ArtifactGenerationException should have been thrown");
+        assertThrows(NullPointerException.class, () -> {
+            new BabelArtifactConverter().convertToModel(null);
+            fail("An instance of ArtifactGenerationException should have been thrown");
+        });
     }
 
     @Test
     public void testEmptyToscaFiles() throws BabelArtifactParsingException {
-        assertTrue("Nothing should have been returned",
-                new BabelArtifactConverter().convertToModel(new ArrayList<>()).isEmpty());
+        assertTrue(new BabelArtifactConverter().convertToModel(new ArrayList<>()).isEmpty(),
+                "Nothing should have been returned");
     }
 
-    @Test(expected = BabelArtifactParsingException.class)
+    @Test
     public void testInvalidXml() throws IOException, BabelArtifactParsingException {
-        byte[] problemXml =
-                "<model xmlns=\"http://org.openecomp.aai.inventory/v10\"><rubbish>This is some xml that should cause the model artifact parser to throw an erorr</rubbish></model>"
-                        .getBytes();
+        assertThrows(BabelArtifactParsingException.class, () -> {
+            byte[] problemXml =
+                    "<model xmlns=\"http://org.openecomp.aai.inventory/v10\"><rubbish>This is some xml that should cause the model artifact parser to throw an erorr</rubbish></model>"
+                            .getBytes();
 
-        INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
+            INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
 
-        List<BabelArtifact> toscaArtifacts = setupTest(problemXml, data);
+            List<BabelArtifact> toscaArtifacts = setupTest(problemXml, data);
 
-        new BabelArtifactConverter().convertToModel(toscaArtifacts);
-        fail("An instance of ModelArtifactParsingException should have been thrown");
+            new BabelArtifactConverter().convertToModel(toscaArtifacts);
+            fail("An instance of ModelArtifactParsingException should have been thrown");
+        });
     }
 
     private List<BabelArtifact> setupTest(byte[] xml, INotificationData data) throws IOException {
@@ -88,7 +94,7 @@ public class TestBabelArtifactConverter {
 
         List<Artifact> modelArtifacts = new BabelArtifactConverter().convertToModel(toscaArtifacts);
 
-        assertEquals("There should have been 1 artifact", 1, modelArtifacts.size());
+        assertEquals(1, modelArtifacts.size(), "There should have been 1 artifact");
         assertEquals(new String(xml), modelArtifacts.get(0).getPayload());
         assertEquals(ArtifactType.MODEL, modelArtifacts.get(0).getType());
     }
index 8c4ffed..d9245d9 100644 (file)
@@ -29,9 +29,9 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Properties;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
@@ -57,7 +57,7 @@ public class TestEventCallback {
     private IDistributionClient mockDistributionClient;
     private NotificationPublisher mockNotificationPublisher;
 
-    @Before
+    @BeforeEach
     public void setup() throws IOException {
         configProperties = new Properties();
         configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE));
@@ -75,7 +75,7 @@ public class TestEventCallback {
         ReflectionTestUtils.setField(eventCallback, "notificationPublisher", mockNotificationPublisher);
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         config = null;
         configProperties = null;
index d7441ec..4d6858a 100644 (file)
@@ -25,7 +25,7 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for NotificationDataImpl class
index 253fc17..edf50a8 100644 (file)
  */
 package org.onap.aai.modelloader.notification;
 
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.when;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.onap.sdc.api.IDistributionClient;
@@ -61,7 +61,7 @@ public class TestNotificationPublisher {
         System.setProperty("CONFIG_HOME", "src/test/resources");
     }
 
-    @Before
+    @BeforeEach
     public void setupMocks() {
         MockitoAnnotations.initMocks(this);
         when(client.getConfiguration()).thenReturn(config);
index ebdfcfe..37b7e12 100644 (file)
@@ -20,7 +20,7 @@
  */
 package org.onap.aai.modelloader.restclient;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.File;
 import java.io.IOException;
index c5da065..fd65383 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.aai.modelloader.restclient;
 
 import static javax.servlet.http.HttpServletResponse.SC_OK;
 import static org.apache.commons.io.IOUtils.write;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -37,9 +37,9 @@ import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.AbstractHandler;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 
 /**
@@ -51,7 +51,7 @@ public class TestAaiServiceClient {
     private Server server;
     private AaiRestClient aaiClient;
 
-    @Before
+    @BeforeEach
     public void startJetty() throws Exception {
         server = new Server(8080);
         server.setHandler(getMockHandler());
@@ -63,7 +63,7 @@ public class TestAaiServiceClient {
         aaiClient = new AaiRestClient(config);
     }
 
-    @After
+    @AfterEach
     public void stopJetty() throws Exception {
         server.stop();
     }
index 51c5642..c653244 100644 (file)
@@ -43,9 +43,9 @@ import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.AbstractHandler;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 import org.onap.aai.modelloader.service.HttpsBabelServiceClientFactory;
@@ -61,7 +61,7 @@ public class TestBabelServiceClient {
     private Server server;
     private String responseBody;
 
-    @Before
+    @BeforeEach
     public void startJetty() throws Exception {
         List<BabelArtifact> response = new ArrayList<>();
         response.add(new BabelArtifact("", null, ""));
@@ -74,7 +74,7 @@ public class TestBabelServiceClient {
         server.start();
     }
 
-    @After
+    @AfterEach
     public void stopJetty() throws Exception {
         server.stop();
     }
index a791b46..d1d46f0 100644 (file)
@@ -27,7 +27,7 @@ import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.empty;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for NotificationDataImpl class
index 1a55580..f926d8e 100644 (file)
@@ -22,27 +22,24 @@ package org.onap.aai.modelloader.service;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.util.Base64;
 
 import javax.ws.rs.core.Response;
 
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.util.ArtifactTestUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 
 /**
  * Tests for the ModelLoaderService class.
  *
  */
-@RunWith(SpringRunner.class)
 @SpringBootTest(classes = {ModelLoaderService.class, MockBabelServiceClientFactory.class})
 @TestPropertySource(properties = {"CONFIG_HOME=src/test/resources",})
 public class TestModelLoaderService {
@@ -50,7 +47,7 @@ public class TestModelLoaderService {
     @Autowired
     private ModelLoaderService service;
 
-    @After
+    @AfterEach
     public void shutdown() {
         service.preShutdownOperations();
     }
index 976acbc..6a01bfc 100644 (file)
@@ -28,20 +28,17 @@ import java.util.Base64;
 
 import javax.ws.rs.core.Response;
 
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.util.ArtifactTestUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 
 /**
  * Tests for the ModelLoaderService class.
  *
  */
-@RunWith(SpringRunner.class)
 @SpringBootTest(classes = {ModelLoaderService.class, HttpsBabelServiceClientFactory.class})
 @TestPropertySource(properties = {"CONFIG_HOME=src/test/resources",})
 public class TestModelLoaderServiceWithSdc {
@@ -49,7 +46,7 @@ public class TestModelLoaderServiceWithSdc {
     @Autowired
     private ModelLoaderService service;
 
-    @After
+    @AfterEach
     public void shutdown() {
         service.preShutdownOperations();
     }
index 1746e05..c1a862a 100644 (file)
@@ -23,19 +23,22 @@ package org.onap.aai.modelloader.util;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.modelloader.gizmo.GizmoBulkPayload;
 
 public class TestGizmoTranslator {
 
-    @Test(expected = IOException.class)
+    @Test
     public void translateInvalidXml() throws IOException {
-        GizmoTranslator.translate("not valid XML");
+        assertThrows(IOException.class, () -> {
+            GizmoTranslator.translate("not valid XML");
+        });
     }
 
     @Test
index 116e1e5..ec66a59 100644 (file)
@@ -30,7 +30,7 @@ import java.nio.file.Paths;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
index 78f179d..76cb5aa 100644 (file)
@@ -24,8 +24,8 @@
 # because they are used in Jenkins, whose plug-in doesn't support
 
 major=1
-minor=12
-patch=0
+minor=13
+patch=5
 
 base_version=${major}.${minor}.${patch}