Update aai-parent in babel to 1.13.3 58/137458/1
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 1 Mar 2024 12:35:53 +0000 (13:35 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 1 Mar 2024 12:36:47 +0000 (13:36 +0100)
- update aai-parent from 1.9.4 to 1.13.3
- update spring-boot from 2.1 to 2.4
- migrate junit 4 to junit 5

Issue-ID: AAI-3791
Change-Id: I849c830f9f0addfb2d4d48d20f038afd401858d2
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
24 files changed:
pom.xml
src/test/java/org/onap/aai/babel/TestApplication.java
src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java
src/test/java/org/onap/aai/babel/TestMicroServiceAuth.java
src/test/java/org/onap/aai/babel/TestMicroServiceAuthCore.java
src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java
src/test/java/org/onap/aai/babel/csar/vnfcatalog/ConfigurationsToBabelArtifactConverterTest.java
src/test/java/org/onap/aai/babel/csar/vnfcatalog/TestVnfVendorImageExtractor.java
src/test/java/org/onap/aai/babel/logging/LogReader.java
src/test/java/org/onap/aai/babel/logging/TestApplicationLogger.java
src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
src/test/java/org/onap/aai/babel/service/TestCsarToXmlConverter.java
src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
src/test/java/org/onap/aai/babel/service/TestInfoService.java
src/test/java/org/onap/aai/babel/service/TestRequestHeaders.java
src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
src/test/java/org/onap/aai/babel/util/TestRequestValidator.java
src/test/java/org/onap/aai/babel/xml/generator/TestAaiArtifactGenerator.java
src/test/java/org/onap/aai/babel/xml/generator/TestModelGenerator.java
src/test/java/org/onap/aai/babel/xml/generator/api/AaiModelGeneratorTest.java
src/test/java/org/onap/aai/babel/xml/generator/model/TestGeneratorUtil.java
src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
src/test/java/org/onap/aai/babel/xml/generator/model/TestVfModule.java
src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java

diff --git a/pom.xml b/pom.xml
index 043824f..01a0268 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
        <parent>
                <groupId>org.onap.aai.aai-common</groupId>
                <artifactId>aai-parent</artifactId>
-               <version>1.9.4</version>
+               <version>1.13.3</version>
        </parent>
 
        <groupId>org.onap.aai</groupId>
                </profile>
        </profiles>
 
-       <dependencies>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-jetty</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-jersey</artifactId>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.springframework.boot</groupId>
-                                       <artifactId>spring-boot-starter-jetty</artifactId>
-                               </exclusion>
-                               <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-web</artifactId>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.springframework.boot</groupId>
-                                       <artifactId>spring-boot-starter-jetty</artifactId>
-                               </exclusion>
-                               <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-aop</artifactId>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.springframework.boot</groupId>
-                                       <artifactId>spring-boot-starter-tomcat</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.aai.logging-service</groupId>
-                       <artifactId>common-logging</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>ch.qos.logback</groupId>
-                       <artifactId>logback-classic</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>ch.qos.logback</groupId>
-                       <artifactId>logback-core</artifactId>
-                       <version>${logback.core.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>commons-codec</groupId>
-                       <artifactId>commons-codec</artifactId>
-                       <version>${commons.codec.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.apache.commons</groupId>
-                       <artifactId>commons-compress</artifactId>
-                       <version>${commons.compress.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.apache.commons</groupId>
-                       <artifactId>commons-lang3</artifactId>
-                       <version>${commons.lang3.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>javax.ws.rs</groupId>
-                       <artifactId>javax.ws.rs-api</artifactId>
-                       <version>${javax.ws.rs.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.codehaus.groovy</groupId>
-                       <artifactId>groovy</artifactId>
-                       <version>${groovy.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.sdc.sdc-tosca</groupId>
-                       <artifactId>sdc-tosca</artifactId>
-                       <version>${sdc.tosca.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.aai</groupId>
-                       <artifactId>rest-client</artifactId>
-               </dependency>
-
-               <!-- Testing -->
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-test</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.onap.sdc.sdc-distribution-client</groupId>
-                       <artifactId>sdc-distribution-client</artifactId>
-                       <version>${sdc.distribution.client.version}</version>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <version>4.12</version>
-                       <scope>test</scope>
-               </dependency>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-jetty</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-jersey</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-starter-jetty</artifactId>
+        </exclusion>
+        <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-web</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-starter-jetty</artifactId>
+        </exclusion>
+        <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-aop</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework.boot</groupId>
+          <artifactId>spring-boot-starter-tomcat</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.onap.aai.logging-service</groupId>
+      <artifactId>common-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+      <version>${logback.core.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>${commons.codec.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-compress</artifactId>
+      <version>${commons.compress.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>${commons.lang3.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.ws.rs</groupId>
+      <artifactId>javax.ws.rs-api</artifactId>
+      <version>${javax.ws.rs.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.groovy</groupId>
+      <artifactId>groovy</artifactId>
+      <version>${groovy.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.onap.sdc.sdc-tosca</groupId>
+      <artifactId>sdc-tosca</artifactId>
+      <version>${sdc.tosca.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.onap.aai</groupId>
+      <artifactId>rest-client</artifactId>
+    </dependency>
+
+    <!-- Testing -->
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.onap.sdc.sdc-distribution-client</groupId>
+      <artifactId>sdc-distribution-client</artifactId>
+      <version>${sdc.distribution.client.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest</artifactId>
+      <version>2.2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <version>5.10.2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
 
                <dependency>
-                       <groupId>xmlunit</groupId>
-                       <artifactId>xmlunit</artifactId>
-                       <version>${xmlunit.version}</version>
+                       <groupId>org.xmlunit</groupId>
+                       <artifactId>xmlunit-legacy</artifactId>
                        <scope>test</scope>
                </dependency>
                <dependency>
index 200b0e2..c8065a2 100644 (file)
 
 package org.onap.aai.babel;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.io.IOException;
 import org.eclipse.jetty.util.security.Password;
 import org.hamcrest.Description;
 import org.hamcrest.TypeSafeMatcher;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.junit.rules.ExpectedException;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContextException;
 
 @SpringBootTest(classes = BabelApplication.class)
 public class TestApplication {
 
-    @Rule
-    public ExpectedException expectedEx = ExpectedException.none();
-
     /**
      * Initialize System Properties.
      */
-    @Before
+    @BeforeEach
     public void init() {
         System.setProperty("APP_HOME", ".");
         System.setProperty("CONFIG_HOME", "src/test/resources");
         System.setProperty("server.ssl.key-store", "src/test/resources/auth/keystore.jks");
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testApplicationStarts() {
-        System.setProperty("KEY_STORE_PASSWORD", "password");
-        BabelApplication.main(new String[] {});
-        BabelApplication.exit();
+        assertDoesNotThrow(() -> {
+            System.setProperty("KEY_STORE_PASSWORD", "password");
+            BabelApplication.main(new String[]{});
+            BabelApplication.exit();
+        });
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testApplicationStartsWithObfuscatedPassword() {
-        System.setProperty("KEY_STORE_PASSWORD", Password.obfuscate("password"));
-        BabelApplication.main(new String[] {});
-        BabelApplication.exit();
+        assertDoesNotThrow(() -> {
+            System.setProperty("KEY_STORE_PASSWORD", Password.obfuscate("password"));
+            BabelApplication.main(new String[]{});
+            BabelApplication.exit();
+        });
     }
 
     @Test
     public void testApplicationWithNullArgs() {
-        System.setProperty("KEY_STORE_PASSWORD", "test");
-        expectedEx.expect(IllegalArgumentException.class);
-        expectedEx.expectMessage("Args must not be null");
-        BabelApplication.main(null);
+        Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+            System.setProperty("KEY_STORE_PASSWORD", "test");
+            BabelApplication.main(null);
+        });
+        assertTrue(exception.getMessage().contains("Args must not be null"));
     }
 
     @Test
     public void testApplicationWithEmptyKeyStorePassword() {
-        System.setProperty("KEY_STORE_PASSWORD", "");
-        expectedEx.expect(IllegalArgumentException.class);
-        expectedEx.expectMessage("roperty KEY_STORE_PASSWORD not set");
-        BabelApplication.main(new String[] {});
+        Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+            System.setProperty("KEY_STORE_PASSWORD", "");
+            BabelApplication.main(new String[]{});
+        });
+        assertTrue(exception.getMessage().contains("roperty KEY_STORE_PASSWORD not set"));
     }
 
     @Test
     public void testApplicationWithNullKeyStorePassword() {
-        System.clearProperty("KEY_STORE_PASSWORD");
-        expectedEx.expect(IllegalArgumentException.class);
-        expectedEx.expectMessage("roperty KEY_STORE_PASSWORD not set");
-        BabelApplication.main(new String[] {});
+        Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+            System.clearProperty("KEY_STORE_PASSWORD");
+            BabelApplication.main(new String[]{});
+        });
+        assertTrue(exception.getMessage().contains("roperty KEY_STORE_PASSWORD not set"));
     }
 
     @Test
     public void testApplicationWithIncorrectKeyStorePassword() {
-        System.setProperty("KEY_STORE_PASSWORD", "test");
-        final CauseMatcher expectedCause = new CauseMatcher(IOException.class, "password was incorrect");
-        expectedEx.expectCause(expectedCause);
-        BabelApplication.main(new String[] {});
+        Throwable exception = assertThrows(ApplicationContextException.class, () -> {
+            System.setProperty("KEY_STORE_PASSWORD", "test");
+            BabelApplication.main(new String[]{});
+        });
     }
 
     /**
@@ -101,31 +110,10 @@ public class TestApplication {
     @Test
     public void testApplicationWithBlankObfuscatedKeyStorePassword() {
         // Note that "OBF:" is correctly deobfuscated and results in an empty string.
-        System.setProperty("KEY_STORE_PASSWORD", "OBF:");
-        final CauseMatcher expectedCause = new CauseMatcher(IOException.class, "password was incorrect");
-        expectedEx.expectCause(expectedCause);
-        BabelApplication.main(new String[] {});
-    }
-
-    private static class CauseMatcher extends TypeSafeMatcher<Throwable> {
-
-        private final Class<? extends Throwable> type;
-        private final String expectedMessage;
-
-        public CauseMatcher(Class<? extends Throwable> type, String expectedMessage) {
-            this.type = type;
-            this.expectedMessage = expectedMessage;
-        }
-
-        @Override
-        protected boolean matchesSafely(Throwable item) {
-            return item.getClass().isAssignableFrom(type) && item.getMessage().contains(expectedMessage);
-        }
-
-        @Override
-        public void describeTo(Description description) {
-            description.appendValue(type).appendText(" and message ").appendValue(expectedMessage);
-        }
+        Throwable exception = assertThrows(ApplicationContextException.class, () -> {
+            System.setProperty("KEY_STORE_PASSWORD", "OBF:");
+            BabelApplication.main(new String[]{});
+        });
     }
 
 }
index 15278e5..19e18de 100644 (file)
 package org.onap.aai.babel;
 
 import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.TimerTask;
-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.auth.AAIAuthException;
 import org.onap.aai.auth.AAIMicroServiceAuth;
@@ -45,25 +46,29 @@ public class TestAuthFileWatcher {
     private TimerTask task;
     private File mockFile = Mockito.mock(File.class);
 
-    @Before
+    @BeforeEach
     public void createTask() {
         task = new AuthFileWatcher(mockFile);
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testOnChangeDoesNotRun() {
-        task.run();
+        assertDoesNotThrow(() -> {
+            task.run();
+        });
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testOnChangeDoesRun() throws IOException, AAIAuthException {
-        System.setProperty("CONFIG_HOME", "src/test/resources");
-        BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
-        babelServiceAuthConfig.setAuthPolicyFile("auth_policy.json");
-        new AAIMicroServiceAuth(babelServiceAuthConfig);
+        assertDoesNotThrow(() -> {
+            System.setProperty("CONFIG_HOME", "src/test/resources");
+            BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
+            babelServiceAuthConfig.setAuthPolicyFile("auth_policy.json");
+            new AAIMicroServiceAuth(babelServiceAuthConfig);
 
-        Mockito.when(mockFile.lastModified()).thenReturn(1000L);
-        task.run();
+            Mockito.when(mockFile.lastModified()).thenReturn(1000L);
+            task.run();
+        });
     }
 
     @Test
index 7375d29..ab28761 100644 (file)
 package org.onap.aai.babel;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -32,9 +34,9 @@ import java.util.concurrent.TimeUnit;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.auth.AAIAuthException;
 import org.onap.aai.auth.AAIMicroServiceAuth;
 import org.onap.aai.auth.AAIMicroServiceAuthCore;
@@ -50,7 +52,7 @@ public class TestMicroServiceAuth {
     private static final String VALID_ADMIN_USER = "cn=common-name, ou=org-unit, o=org, l=location, st=state, c=us";
     private static final String TEST_POLICY_FILE = "auth_policy.json";
 
-    @Before
+    @BeforeEach
     public void setup() {
         System.setProperty("CONFIG_HOME", "src/test/resources");
     }
@@ -76,17 +78,19 @@ public class TestMicroServiceAuth {
      * @throws AAIAuthException
      *             if the Auth policy file cannot be loaded
      */
-    @Test(expected = AAIAuthException.class)
+    @Test
     public void missingPolicyFile() throws AAIAuthException {
-        String defaultFile = AAIMicroServiceAuthCore.getDefaultAuthFileName();
-        try {
-            AAIMicroServiceAuthCore.setDefaultAuthFileName("invalid.default.file");
-            BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
-            babelServiceAuthConfig.setAuthPolicyFile("invalid.file.name");
-            new AAIMicroServiceAuth(babelServiceAuthConfig);
-        } finally {
-            AAIMicroServiceAuthCore.setDefaultAuthFileName(defaultFile);
-        }
+        assertThrows(AAIAuthException.class, () -> {
+            String defaultFile = AAIMicroServiceAuthCore.getDefaultAuthFileName();
+            try {
+                AAIMicroServiceAuthCore.setDefaultAuthFileName("invalid.default.file");
+                BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
+                babelServiceAuthConfig.setAuthPolicyFile("invalid.file.name");
+                new AAIMicroServiceAuth(babelServiceAuthConfig);
+            } finally {
+                AAIMicroServiceAuthCore.setDefaultAuthFileName(defaultFile);
+            }
+        });
     }
 
     /**
@@ -96,17 +100,19 @@ public class TestMicroServiceAuth {
      * @throws AAIAuthException
      *             if the Auth policy file cannot be loaded
      */
-    @Test(expected = AAIAuthException.class)
+    @Test
     public void testNullPolicyFile() throws AAIAuthException {
-        String defaultFile = AAIMicroServiceAuthCore.getDefaultAuthFileName();
-        try {
-            AAIMicroServiceAuthCore.setDefaultAuthFileName("invalid.default.file");
-            BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
-            babelServiceAuthConfig.setAuthPolicyFile(null);
-            new AAIMicroServiceAuth(babelServiceAuthConfig);
-        } finally {
-            AAIMicroServiceAuthCore.setDefaultAuthFileName(defaultFile);
-        }
+        assertThrows(AAIAuthException.class, () -> {
+            String defaultFile = AAIMicroServiceAuthCore.getDefaultAuthFileName();
+            try {
+                AAIMicroServiceAuthCore.setDefaultAuthFileName("invalid.default.file");
+                BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
+                babelServiceAuthConfig.setAuthPolicyFile(null);
+                new AAIMicroServiceAuth(babelServiceAuthConfig);
+            } finally {
+                AAIMicroServiceAuthCore.setDefaultAuthFileName(defaultFile);
+            }
+        });
     }
 
     /**
@@ -126,7 +132,7 @@ public class TestMicroServiceAuth {
         assertThat(file.delete(), is(true));
         try {
             AAIMicroServiceAuthCore.reloadUsers();
-            Assert.fail("Expected an AAIAuthException to be thrown");
+            Assertions.fail("Expected an AAIAuthException to be thrown");
         } catch (AAIAuthException e) {
             assertTrue(true);
         }
@@ -142,12 +148,14 @@ public class TestMicroServiceAuth {
      * @throws IOException
      *             for I/O failures, e.g. when creating the temporary auth policy file
      */
-    @Test(expected = AAIAuthException.class)
+    @Test
     public void testReloadInvalidFile() throws AAIAuthException, JSONException, IOException {
-        File file = createTestPolicyFile();
-        AAIMicroServiceAuthCore.init(file.getAbsolutePath());
-        writeToFile(file, "not valid JSON content");
-        AAIMicroServiceAuthCore.reloadUsers();
+        assertThrows(AAIAuthException.class, () -> {
+            File file = createTestPolicyFile();
+            AAIMicroServiceAuthCore.init(file.getAbsolutePath());
+            writeToFile(file, "not valid JSON content");
+            AAIMicroServiceAuthCore.reloadUsers();
+        });
     }
 
     /**
@@ -179,22 +187,24 @@ public class TestMicroServiceAuth {
      * @throws InterruptedException
      *             if interrupted while sleeping
      */
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void createLocalAuthFileOnChange()
             throws JSONException, AAIAuthException, IOException, InterruptedException {
-        File file = createTestPolicyFile();
+        assertDoesNotThrow(() -> {
+            File file = createTestPolicyFile();
 
-        BabelAuthConfig babelAuthConfig = new BabelAuthConfig();
-        babelAuthConfig.setAuthPolicyFile(file.getAbsolutePath());
-        new AAIMicroServiceAuth(babelAuthConfig);
+            BabelAuthConfig babelAuthConfig = new BabelAuthConfig();
+            babelAuthConfig.setAuthPolicyFile(file.getAbsolutePath());
+            new AAIMicroServiceAuth(babelAuthConfig);
 
-        // Make changes to the temp file
-        writeToFile(file, "");
+            // Make changes to the temp file
+            writeToFile(file, "");
 
-        // Wait for the file to be reloaded
-        TimeUnit.SECONDS.sleep(3);
+            // Wait for the file to be reloaded
+            TimeUnit.SECONDS.sleep(3);
 
-        AAIMicroServiceAuthCore.cleanup();
+            AAIMicroServiceAuthCore.cleanup();
+        });
     }
 
     /**
@@ -219,13 +229,16 @@ public class TestMicroServiceAuth {
      * @throws AAIAuthException
      *             if the Auth Policy cannot be loaded
      */
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void createAuthFromDefaultFileAppHome() throws AAIAuthException {
-        System.clearProperty("CONFIG_HOME");
-        System.setProperty("APP_HOME", "src/test/resources");
-        BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
-        babelServiceAuthConfig.setAuthPolicyFile("non-existent-file");
-        new AAIMicroServiceAuth(babelServiceAuthConfig);
+        assertDoesNotThrow(() -> {
+            System.clearProperty("CONFIG_HOME");
+            System.setProperty("APP_HOME", "src/test/resources");
+            BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
+            babelServiceAuthConfig.setAuthPolicyFile("non-existent-file");
+            new AAIMicroServiceAuth(babelServiceAuthConfig);
+            // The default policy will have been loaded from APP_HOME/appconfig
+        });
         // The default policy will have been loaded from APP_HOME/appconfig
     }
 
index 8fe4508..65c7c03 100644 (file)
@@ -21,7 +21,9 @@
 
 package org.onap.aai.babel;
 
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
 import org.onap.aai.auth.AAIAuthException;
 import org.onap.aai.auth.AAIMicroServiceAuthCore;
 
@@ -37,9 +39,11 @@ public class TestMicroServiceAuthCore {
      * @throws AAIAuthException
      *             when the module has not been initialized
      */
-    @Test(expected = AAIAuthException.class)
+    @Test
     public void testUninitializedModule() throws AAIAuthException {
-        AAIMicroServiceAuthCore.authorize("user", "method:func");
+        assertThrows(AAIAuthException.class, () -> {
+            AAIMicroServiceAuthCore.authorize("user", "method:func");
+        });
     }
 
 }
index 8e9fb3d..68414a8 100644 (file)
 
 package org.onap.aai.babel.csar.extractor;
 
-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.assertDoesNotThrow;
+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;
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.testdata.CsarTest;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 import org.onap.aai.babel.xml.generator.data.Artifact;
@@ -100,33 +101,36 @@ public class YamlExtractorTest {
             CsarTest.NO_YAML_FILES.extractArtifacts();
             fail("An instance of InvalidArchiveException should have been thrown.");
         } catch (Exception e) {
-            assertTrue("An instance of InvalidArchiveException should have been thrown.",
-                    e instanceof InvalidArchiveException);
-            assertEquals("Incorrect message was returned", "No valid YAML files were found in the CSAR file.",
-                    e.getMessage());
+            assertTrue(e instanceof InvalidArchiveException,
+                    "An instance of InvalidArchiveException should have been thrown.");
+            assertEquals("No valid YAML files were found in the CSAR file.",
+                    e.getMessage(),
+                    "Incorrect message was returned");
         }
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testArchiveContainsOnlyTheExpectedYmlFilesFromSdWanService()
             throws IOException, InvalidArchiveException {
-        final List<Artifact> ymlFiles = CsarTest.SD_WAN_CSAR_FILE.extractArtifacts();
-        List<String> payloads = new ArrayList<>();
-        payloads.add("ymlFiles/resource-SdWanTestVsp-template.yml");
-        payloads.add("ymlFiles/resource-SdWanTestVsp-template-interface.yml");
-        payloads.add("ymlFiles/resource-TunnelXconntest-template.yml");
-        payloads.add("ymlFiles/resource-TunnelXconntest-template-interface.yml");
-        payloads.add("ymlFiles/service-SdWanServiceTest-template.yml");
-        payloads.add("ymlFiles/service-SdWanServiceTest-template-interface.yml");
-        payloads.add("ymlFiles/resource-Allotedresource-template.yml");
-        payloads.add("ymlFiles/resource-SdwantestvspNodesDummyServer-template.yml");
-        payloads.add("ymlFiles/nodes.yml");
-        payloads.add("ymlFiles/capabilities.yml");
-        payloads.add("ymlFiles/artifacts.yml");
-        payloads.add("ymlFiles/data.yml");
-        payloads.add("ymlFiles/groups.yml");
-
-        new ArtifactTestUtils().performYmlAsserts(ymlFiles, payloads);
+        assertDoesNotThrow(() -> {
+            final List<Artifact> ymlFiles = CsarTest.SD_WAN_CSAR_FILE.extractArtifacts();
+            List<String> payloads = new ArrayList<>();
+            payloads.add("ymlFiles/resource-SdWanTestVsp-template.yml");
+            payloads.add("ymlFiles/resource-SdWanTestVsp-template-interface.yml");
+            payloads.add("ymlFiles/resource-TunnelXconntest-template.yml");
+            payloads.add("ymlFiles/resource-TunnelXconntest-template-interface.yml");
+            payloads.add("ymlFiles/service-SdWanServiceTest-template.yml");
+            payloads.add("ymlFiles/service-SdWanServiceTest-template-interface.yml");
+            payloads.add("ymlFiles/resource-Allotedresource-template.yml");
+            payloads.add("ymlFiles/resource-SdwantestvspNodesDummyServer-template.yml");
+            payloads.add("ymlFiles/nodes.yml");
+            payloads.add("ymlFiles/capabilities.yml");
+            payloads.add("ymlFiles/artifacts.yml");
+            payloads.add("ymlFiles/data.yml");
+            payloads.add("ymlFiles/groups.yml");
+
+            new ArtifactTestUtils().performYmlAsserts(ymlFiles, payloads);
+        });
     }
 
     /**
index e4ece96..da06387 100644 (file)
@@ -31,7 +31,7 @@ import com.google.gson.reflect.TypeToken;
 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.babel.service.data.BabelArtifact.ArtifactType;
 import org.onap.aai.babel.util.ArtifactTestUtils;
index 7ab8ecd..6ab2ada 100644 (file)
@@ -26,14 +26,15 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import com.google.common.collect.ImmutableMap;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 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.babel.service.data.BabelArtifact.ArtifactType;
 import org.onap.aai.babel.testdata.CsarTest;
@@ -46,24 +47,32 @@ import org.onap.sdc.toscaparser.api.elements.Metadata;
  */
 public class TestVnfVendorImageExtractor {
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void createVendorImageMappingsNullCsarSupplied() throws ToscaToCatalogException, IOException {
-        new VnfVendorImageExtractor().extract(null);
+        assertThrows(NullPointerException.class, () -> {
+            new VnfVendorImageExtractor().extract(null);
+        });
     }
 
-    @Test(expected = ToscaToCatalogException.class)
+    @Test
     public void createVendorImageMappingsEmptyCsarSupplied() throws ToscaToCatalogException, IOException {
-        new VnfVendorImageExtractor().extract(new byte[0]);
+        assertThrows(ToscaToCatalogException.class, () -> {
+            new VnfVendorImageExtractor().extract(new byte[0]);
+        });
     }
 
-    @Test(expected = ToscaToCatalogException.class)
+    @Test
     public void createVendorImageMappingsInvalidCsarFile() throws IOException, ToscaToCatalogException {
-        CsarTest.NO_YAML_FILES.extractVnfVendorImages();
+        assertThrows(ToscaToCatalogException.class, () -> {
+            CsarTest.NO_YAML_FILES.extractVnfVendorImages();
+        });
     }
 
-    @Test(expected = ToscaToCatalogException.class)
+    @Test
     public void createVendorImageMappingsInvalidFile() throws IOException, ToscaToCatalogException {
-        new VnfVendorImageExtractor().extract("not a real file".getBytes());
+        assertThrows(ToscaToCatalogException.class, () -> {
+            new VnfVendorImageExtractor().extract("not a real file".getBytes());
+        });
     }
 
     @Test
@@ -95,13 +104,15 @@ public class TestVnfVendorImageExtractor {
     /**
      * Test that an Exception is created when there are no software versions defined for a VF.
      */
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testBuildVendorImageConfigurations() {
-        SdcToscaHelper helper = new SdcToscaHelper();
-        NodeTemplate vf = helper.addNodeTemplate();
-        vf.setMetaData(new Metadata(ImmutableMap.of("resourceVendor", "vendor")));
-        vf.setSubMappingToscaTemplate(helper.buildMappings());
-        new VnfVendorImageExtractor().buildVendorImageConfigurations(null, vf);
+        assertThrows(IllegalArgumentException.class, () -> {
+            SdcToscaHelper helper = new SdcToscaHelper();
+            NodeTemplate vf = helper.addNodeTemplate();
+            vf.setMetaData(new Metadata(ImmutableMap.of("resourceVendor", "vendor")));
+            vf.setSubMappingToscaTemplate(helper.buildMappings());
+            new VnfVendorImageExtractor().buildVendorImageConfigurations(null, vf);
+        });
     }
 
     @Test
index f18fb6d..e841860 100644 (file)
@@ -34,7 +34,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang3.time.StopWatch;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
 
 public class LogReader {
 
@@ -98,7 +98,7 @@ public class LogReader {
 
         while (!cachedReader.ready()) {
             if (stopwatch.getTime() > TimeUnit.SECONDS.toMillis(30)) {
-                Assert.fail("Test took too long");
+                Assertions.fail("Test took too long");
             }
             // else keep waiting
         }
index 127b77d..e390c8c 100644 (file)
@@ -25,6 +25,7 @@ import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 
 import com.att.eelf.configuration.EELFLogger.Level;
 import com.att.eelf.configuration.EELFManager;
@@ -33,9 +34,10 @@ import java.util.Arrays;
 import javax.servlet.ServletRequest;
 import javax.ws.rs.core.HttpHeaders;
 import org.apache.commons.lang3.time.StopWatch;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.babel.logging.LogHelper.MdcParameter;
 import org.onap.aai.babel.logging.LogHelper.TriConsumer;
@@ -49,10 +51,10 @@ import org.onap.aai.cl.mdc.MdcOverride;
  * This version tests only the error logger at INFO level.
  *
  */
-@Ignore("Test consistently fails in centos and is not critical")
+@Disabled("Test consistently fails in centos and is not critical")
 public class TestApplicationLogger {
 
-    @BeforeClass
+    @BeforeAll
     public static void setupClass() {
         System.setProperty("APP_HOME", ".");
     }
@@ -120,12 +122,14 @@ public class TestApplicationLogger {
     /**
      * Call logAuditError() for code coverage stats.
      */
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void logAuditError() {
-        LogHelper.INSTANCE.logAuditError(new Exception("test"));
-        EELFManager.getInstance().getAuditLogger().setLevel(Level.OFF);
-        LogHelper.INSTANCE.logAuditError(new Exception("test"));
-        EELFManager.getInstance().getAuditLogger().setLevel(Level.INFO);
+        assertDoesNotThrow(() -> {
+            LogHelper.INSTANCE.logAuditError(new Exception("test"));
+            EELFManager.getInstance().getAuditLogger().setLevel(Level.OFF);
+            LogHelper.INSTANCE.logAuditError(new Exception("test"));
+            EELFManager.getInstance().getAuditLogger().setLevel(Level.INFO);
+        });
     }
 
     /**
@@ -198,11 +202,13 @@ public class TestApplicationLogger {
         assertThat("audit message content", str, containsString("foo"));
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void setDefaultContextValue() {
-        LogHelper logger = LogHelper.INSTANCE;
-        logger.setDefaultContextValue("key", "value");
-        logger.setDefaultContextValue(MdcParameter.USER, null);
+        assertDoesNotThrow(() -> {
+            LogHelper logger = LogHelper.INSTANCE;
+            logger.setDefaultContextValue("key", "value");
+            logger.setDefaultContextValue(MdcParameter.USER, null);
+        });
     }
 
     /**
@@ -272,7 +278,7 @@ public class TestApplicationLogger {
     private void callUnsupportedOperationMethod(TriConsumer<Enum<?>, LogFields, String[]> logMethod,
             ApplicationMsgs dummyMsg) {
         logMethod.accept(dummyMsg, new LogFields(), new String[] {""});
-        org.junit.Assert.fail("method should have thrown execption"); // NOSONAR as code not reached
+        Assertions.fail("method should have thrown execption"); // NOSONAR as code not reached
     }
 
     /**
index 3fac6cb..9988076 100644 (file)
@@ -24,6 +24,8 @@ package org.onap.aai.babel.parser;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -31,7 +33,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 import org.onap.aai.babel.util.Resources;
@@ -63,9 +65,11 @@ public class TestArtifactGeneratorToscaParser {
      * @throws IOException
      *             if the file content could not be read successfully
      */
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testMissingMappingsFile() throws IOException {
-        ArtifactGeneratorToscaParser.initToscaMappingsConfiguration("non-existent.file");
+        assertThrows(IllegalArgumentException.class, () -> {
+            ArtifactGeneratorToscaParser.initToscaMappingsConfiguration("non-existent.file");
+        });
     }
 
     /**
@@ -74,10 +78,12 @@ public class TestArtifactGeneratorToscaParser {
      * @throws IOException
      *             if the file content could not be read successfully
      */
-    @Test(expected = IOException.class)
+    @Test
     public void testMissingMappingsContent() throws IOException {
-        String emptyJson = new ArtifactTestUtils().getResourcePath(Resources.EMPTY_TOSCA_MAPPING_CONFIG);
-        ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(emptyJson);
+        assertThrows(IOException.class, () -> {
+            String emptyJson = new ArtifactTestUtils().getResourcePath(Resources.EMPTY_TOSCA_MAPPING_CONFIG);
+            ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(emptyJson);
+        });
     }
 
     /**
@@ -86,10 +92,12 @@ public class TestArtifactGeneratorToscaParser {
      * @throws IOException
      *             if the file content could not be read successfully
      */
-    @Test(expected = IOException.class)
+    @Test
     public void testInvalidMappingsContent() throws IOException {
-        String invalidJson = new ArtifactTestUtils().getResourcePath(Resources.INVALID_TOSCA_MAPPING_CONFIG);
-        ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(invalidJson);
+        assertThrows(IOException.class, () -> {
+            String invalidJson = new ArtifactTestUtils().getResourcePath(Resources.INVALID_TOSCA_MAPPING_CONFIG);
+            ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(invalidJson);
+        });
     }
 
     /**
@@ -98,11 +106,13 @@ public class TestArtifactGeneratorToscaParser {
      * @throws XmlArtifactGenerationException
      *             because the ALLOTTED_RESOURCE lacks a Providing Service
      */
-    @Test(expected = XmlArtifactGenerationException.class)
+    @Test
     public void testMissingProvidingService() throws XmlArtifactGenerationException {
-        List<NodeTemplate> nodeTemplateList = Collections.singletonList(buildNodeTemplate("name", "BlockStorage"));
-        new ArtifactGeneratorToscaParser(null)
-                .processResourceModels(new Resource(WidgetType.valueOf("ALLOTTED_RESOURCE"), true), nodeTemplateList);
+        assertThrows(XmlArtifactGenerationException.class, () -> {
+            List<NodeTemplate> nodeTemplateList = Collections.singletonList(buildNodeTemplate("name", "BlockStorage"));
+            new ArtifactGeneratorToscaParser(null)
+                    .processResourceModels(new Resource(WidgetType.valueOf("ALLOTTED_RESOURCE"), true), nodeTemplateList);
+        });
     }
 
     /**
@@ -113,14 +123,16 @@ public class TestArtifactGeneratorToscaParser {
      * @throws IOException
      *             if the test mappings cannot be loaded
      */
-    @Test(expected = XmlArtifactGenerationException.class)
+    @Test
     public void testAddResourceNotProvidingService() throws XmlArtifactGenerationException, IOException {
-        new ArtifactTestUtils().loadWidgetMappings();
-        List<NodeTemplate> nodeTemplateList = Collections.singletonList(buildNodeTemplate("testCR", "CR"));
+        assertThrows(XmlArtifactGenerationException.class, () -> {
+            new ArtifactTestUtils().loadWidgetMappings();
+            List<NodeTemplate> nodeTemplateList = Collections.singletonList(buildNodeTemplate("testCR", "CR"));
 
-        // Create any Resource to which the CR can be added
-        final Resource dummyResource = new Resource(WidgetType.valueOf("ALLOTTED_RESOURCE"), true);
-        new ArtifactGeneratorToscaParser(null).processResourceModels(dummyResource, nodeTemplateList);
+            // Create any Resource to which the CR can be added
+            final Resource dummyResource = new Resource(WidgetType.valueOf("ALLOTTED_RESOURCE"), true);
+            new ArtifactGeneratorToscaParser(null).processResourceModels(dummyResource, nodeTemplateList);
+        });
     }
 
     /**
@@ -129,11 +141,13 @@ public class TestArtifactGeneratorToscaParser {
      * @throws IOException
      *             if a WidgetMapping is invalid
      */
-    @Test(expected = IOException.class)
+    @Test
     public void testToscaMappingWithoutType() throws IOException {
-        WidgetMapping invalidMapping = new WidgetMapping();
-        invalidMapping.setType(null);
-        WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+        assertThrows(IOException.class, () -> {
+            WidgetMapping invalidMapping = new WidgetMapping();
+            invalidMapping.setType(null);
+            WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+        });
     }
 
     /**
@@ -142,11 +156,13 @@ public class TestArtifactGeneratorToscaParser {
      * @throws IOException
      *             if a WidgetMapping is invalid
      */
-    @Test(expected = IOException.class)
+    @Test
     public void testToscaMappingWithInvalidType() throws IOException {
-        WidgetMapping invalidMapping = new WidgetMapping();
-        invalidMapping.setType("invalid");
-        WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+        assertThrows(IOException.class, () -> {
+            WidgetMapping invalidMapping = new WidgetMapping();
+            invalidMapping.setType("invalid");
+            WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+        });
     }
 
     /**
@@ -155,11 +171,13 @@ public class TestArtifactGeneratorToscaParser {
      * @throws IOException
      *             if a WidgetMapping is invalid
      */
-    @Test(expected = IOException.class)
+    @Test
     public void testToscaMappingWithoutWidget() throws IOException {
-        WidgetMapping invalidMapping = new WidgetMapping();
-        invalidMapping.setWidget(null);
-        WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+        assertThrows(IOException.class, () -> {
+            WidgetMapping invalidMapping = new WidgetMapping();
+            invalidMapping.setWidget(null);
+            WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+        });
     }
 
     /**
@@ -171,18 +189,20 @@ public class TestArtifactGeneratorToscaParser {
      * @throws XmlArtifactGenerationException
      *             if there is no configuration defined for the test resource's widget type
      */
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testAddWidgetToService() throws IOException, XmlArtifactGenerationException {
-        ArtifactTestUtils testUtils = new ArtifactTestUtils();
-        testUtils.loadWidgetMappings();
+        assertDoesNotThrow(() -> {
+            ArtifactTestUtils testUtils = new ArtifactTestUtils();
+            testUtils.loadWidgetMappings();
 
-        Model serviceModel = new Service();
-        Resource resourceModel = new Resource(WidgetType.valueOf("VF"), false);
-        resourceModel.setModelType(ModelType.WIDGET);
+            Model serviceModel = new Service();
+            Resource resourceModel = new Resource(WidgetType.valueOf("VF"), false);
+            resourceModel.setModelType(ModelType.WIDGET);
 
-        ISdcCsarHelper helper = Mockito.mock(ISdcCsarHelper.class);
-        ArtifactGeneratorToscaParser parser = new ArtifactGeneratorToscaParser(helper);
-        parser.addRelatedModel(serviceModel, resourceModel);
+            ISdcCsarHelper helper = Mockito.mock(ISdcCsarHelper.class);
+            ArtifactGeneratorToscaParser parser = new ArtifactGeneratorToscaParser(helper);
+            parser.addRelatedModel(serviceModel, resourceModel);
+        });
     }
 
     /**
index 19eeb22..b3d6999 100644 (file)
@@ -25,7 +25,10 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -35,11 +38,9 @@ import java.util.Map;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.csar.CsarConverterException;
 import org.onap.aai.babel.csar.CsarToXmlConverter;
 import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
@@ -60,44 +61,51 @@ public class TestCsarToXmlConverter {
     // The class to be tested.
     private CsarToXmlConverter converter;
 
-    @Rule
-    public ExpectedException exception = ExpectedException.none();
-
-    @Before
+    @BeforeEach
     public void setup() {
         new ArtifactTestUtils().setGeneratorSystemProperties();
         converter = new CsarToXmlConverter();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         converter = null;
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testNullArtifactSupplied() throws CsarConverterException {
-        converter.generateXmlFromCsar(null, null, null);
+        assertThrows(NullPointerException.class, () -> {
+            converter.generateXmlFromCsar(null, null, null);
+        });
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testMissingName() throws CsarConverterException, IOException {
-        converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), null, null);
+        assertThrows(NullPointerException.class, () -> {
+            converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), null, null);
+        });
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testMissingVersion() throws CsarConverterException, IOException {
-        converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), INCORRECT_CSAR_NAME, null);
+        assertThrows(NullPointerException.class, () -> {
+            converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), INCORRECT_CSAR_NAME, null);
+        });
     }
 
-    @Test(expected = CsarConverterException.class)
+    @Test
     public void testNoPayloadExists() throws CsarConverterException {
-        converter.generateXmlFromCsar(new byte[0], INCORRECT_CSAR_NAME, SERVICE_VERSION);
+        assertThrows(CsarConverterException.class, () -> {
+            converter.generateXmlFromCsar(new byte[0], INCORRECT_CSAR_NAME, SERVICE_VERSION);
+        });
     }
 
-    @Test(expected = CsarConverterException.class)
+    @Test
     public void testCsarFileHasNoYmlFiles() throws CsarConverterException, IOException {
-        converter.generateXmlFromCsar(CsarTest.NO_YAML_FILES.getContent(), CsarTest.NO_YAML_FILES.getName(),
-                SERVICE_VERSION);
+        assertThrows(CsarConverterException.class, () -> {
+            converter.generateXmlFromCsar(CsarTest.NO_YAML_FILES.getContent(), CsarTest.NO_YAML_FILES.getName(),
+                    SERVICE_VERSION);
+        });
     }
 
     /**
@@ -110,21 +118,24 @@ public class TestCsarToXmlConverter {
      */
     @Test
     public void generateXmlFromCsarMappingSystemPropertyNotSet() throws CsarConverterException, IOException {
-        exception.expect(IllegalArgumentException.class);
-        exception.expectMessage("Cannot generate artifacts. System property "
-                + ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE + " not configured");
+        Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
 
-        // Unset the required system property
-        System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE);
-        converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), CsarTest.SD_WAN_CSAR_FILE.getName(),
-                SERVICE_VERSION);
+            // Unset the required system property
+            System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE);
+            converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), CsarTest.SD_WAN_CSAR_FILE.getName(),
+                    SERVICE_VERSION);
+        });
+        assertTrue(exception.getMessage().contains("Cannot generate artifacts. System property "
+                + ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE + " not configured"));
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testServiceMetadataMissing()
             throws IOException, CsarConverterException {
-        converter.generateXmlFromCsar(CsarTest.MISSING_METADATA_CSAR.getContent(),
-                CsarTest.MISSING_METADATA_CSAR.getName(), SERVICE_VERSION);
+        assertDoesNotThrow(() -> {
+            converter.generateXmlFromCsar(CsarTest.MISSING_METADATA_CSAR.getContent(),
+                    CsarTest.MISSING_METADATA_CSAR.getName(), SERVICE_VERSION);
+        });
     }
 
     @Test
index a76b296..5ceca17 100644 (file)
@@ -22,8 +22,8 @@
 package org.onap.aai.babel.service;
 
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
 
 import com.google.gson.Gson;
 import java.io.IOException;
@@ -40,11 +40,8 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.auth.AAIAuthException;
 import org.onap.aai.auth.AAIMicroServiceAuth;
@@ -52,15 +49,13 @@ import org.onap.aai.babel.service.data.BabelRequest;
 import org.onap.aai.babel.testdata.CsarTest;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
 
 /**
  * Direct invocation of the generate artifacts service implementation.
  *
  */
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:/babel-beans.xml"})
+@SpringJUnitConfig(locations = {"classpath:/babel-beans.xml"})
 public class TestGenerateArtifactsServiceImpl {
 
     static {
@@ -70,7 +65,7 @@ public class TestGenerateArtifactsServiceImpl {
     @Inject
     private AAIMicroServiceAuth auth;
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         new ArtifactTestUtils().setGeneratorSystemProperties();
     }
index d481b9a..cd2f3b3 100644 (file)
@@ -22,12 +22,12 @@ package org.onap.aai.babel.service;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.time.Clock;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestInfoService {
 
index 44cc9d4..4828132 100644 (file)
@@ -23,7 +23,7 @@ package org.onap.aai.babel.service;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Arrays;
 import java.util.Collections;
@@ -31,7 +31,7 @@ import java.util.List;
 import java.util.Map.Entry;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedHashMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.onap.aai.babel.request.RequestHeaders;
 
index d1c9f94..2cf221d 100644 (file)
@@ -25,7 +25,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.IOException;
 import java.io.InputStream;
index db7d882..b190070 100644 (file)
  */
 package org.onap.aai.babel.util;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.service.data.BabelRequest;
 
 public class TestRequestValidator {
 
-    @Rule
-    public ExpectedException exception = ExpectedException.none();
-
     @Test
     public void testMissingArtifactNameExceptionThrown() throws Exception {
-        exception.expect(RequestValidationException.class);
-        exception.expectMessage("No artifact name attribute found in the request body.");
+        Throwable exception = assertThrows(RequestValidationException.class, () -> {
 
-        BabelRequest request = new BabelRequest();
-        request.setCsar("UEsDBBQACAgIAGsrz0oAAAAAAAAAAAAAAAAJAAAAY3Nhci5tZXRhC3Z");
-        request.setArtifactVersion("1.0");
-        request.setArtifactName(null);
-        new RequestValidator().validateRequest(request);
+            BabelRequest request = new BabelRequest();
+            request.setCsar("UEsDBBQACAgIAGsrz0oAAAAAAAAAAAAAAAAJAAAAY3Nhci5tZXRhC3Z");
+            request.setArtifactVersion("1.0");
+            request.setArtifactName(null);
+            new RequestValidator().validateRequest(request);
+        });
+        assertTrue(exception.getMessage().contains("No artifact name attribute found in the request body."));
     }
 
     @Test
     public void testMissingArtifactVersionExceptionThrown() throws Exception {
-        exception.expect(RequestValidationException.class);
-        exception.expectMessage("No artifact version attribute found in the request body.");
+        Throwable exception = assertThrows(RequestValidationException.class, () -> {
 
-        BabelRequest request = new BabelRequest();
-        request.setCsar("UEsDBBQACAgIAGsrz0oAAAAAAAAAAAAAAAAJAAAAY3Nhci5tZXRhC3Z");
-        request.setArtifactVersion(null);
-        request.setArtifactName("hello");
-        new RequestValidator().validateRequest(request);
+            BabelRequest request = new BabelRequest();
+            request.setCsar("UEsDBBQACAgIAGsrz0oAAAAAAAAAAAAAAAAJAAAAY3Nhci5tZXRhC3Z");
+            request.setArtifactVersion(null);
+            request.setArtifactName("hello");
+            new RequestValidator().validateRequest(request);
+        });
+        assertTrue(exception.getMessage().contains("No artifact version attribute found in the request body."));
     }
 
     @Test
     public void testMissingCsarFile() throws Exception {
-        exception.expect(RequestValidationException.class);
-        exception.expectMessage("No csar attribute found in the request body.");
+        Throwable exception = assertThrows(RequestValidationException.class, () -> {
 
-        BabelRequest request = new BabelRequest();
-        request.setCsar(null);
-        request.setArtifactVersion("1.0");
-        request.setArtifactName("hello");
-        new RequestValidator().validateRequest(request);
+            BabelRequest request = new BabelRequest();
+            request.setCsar(null);
+            request.setArtifactVersion("1.0");
+            request.setArtifactName("hello");
+            new RequestValidator().validateRequest(request);
+        });
+        assertTrue(exception.getMessage().contains("No csar attribute found in the request body."));
     }
 
 }
index b29d0d7..fc2522f 100644 (file)
@@ -23,13 +23,14 @@ package org.onap.aai.babel.xml.generator;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.csar.extractor.InvalidArchiveException;
 import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
 import org.onap.aai.babel.testdata.CsarTest;
@@ -50,7 +51,7 @@ public class TestAaiArtifactGenerator {
 
     private ArtifactTestUtils testUtils;
 
-    @Before
+    @BeforeEach
     public void setup() {
         testUtils = new ArtifactTestUtils();
         testUtils.setGeneratorSystemProperties();
@@ -84,19 +85,21 @@ public class TestAaiArtifactGenerator {
      * @throws XmlArtifactGenerationException
      *             if the configured widget mappings do not support processed widget type(s)
      */
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testParserWithIncompleteMappings()
             throws SdcToscaParserException, IOException, XmlArtifactGenerationException {
-        testUtils.loadWidgetMappings();
+        assertThrows(IllegalArgumentException.class, () -> {
+            testUtils.loadWidgetMappings();
 
-        AaiArtifactGenerator artifactGenerator = new AaiArtifactGenerator();
-        WidgetType.clearElements(); // Remove all WidgetTypes so that the generator fails
+            AaiArtifactGenerator artifactGenerator = new AaiArtifactGenerator();
+            WidgetType.clearElements(); // Remove all WidgetTypes so that the generator fails
 
-        ISdcCsarHelper csarHelper = SdcToscaParserFactory.getInstance()
-                .getSdcCsarHelper(TestAaiArtifactGenerator.class.getClassLoader()
-                        .getResource(ArtifactTestUtils.CSAR_INPUTS_FOLDER + CsarTest.VNF_VENDOR_CSAR.getName())
-                        .getFile().toString());
-        artifactGenerator.generateAllArtifacts("1.0", csarHelper);
+            ISdcCsarHelper csarHelper = SdcToscaParserFactory.getInstance()
+                    .getSdcCsarHelper(TestAaiArtifactGenerator.class.getClassLoader()
+                            .getResource(ArtifactTestUtils.CSAR_INPUTS_FOLDER + CsarTest.VNF_VENDOR_CSAR.getName())
+                            .getFile().toString());
+            artifactGenerator.generateAllArtifacts("1.0", csarHelper);
+        });
     }
 
     /**
index 43f49a0..680a58a 100644 (file)
 
 package org.onap.aai.babel.xml.generator;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.babel.testdata.CsarTest;
 import org.onap.aai.babel.util.ArtifactTestUtils;
@@ -43,16 +44,18 @@ public class TestModelGenerator {
         System.setProperty("APP_HOME", ".");
     }
 
-    @Before
+    @BeforeEach
     public void setup() {
         new ArtifactTestUtils().setGeneratorSystemProperties();
     }
 
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testDefaultServiceVersion() throws XmlArtifactGenerationException, IOException {
-        Artifact ymlFile = new Artifact(null, null, null, null);
-        new ModelGenerator().generateArtifacts(CsarTest.SD_WAN_CSAR_FILE.getContent(),
-                Collections.singletonList(ymlFile));
+        assertDoesNotThrow(() -> {
+            Artifact ymlFile = new Artifact(null, null, null, null);
+            new ModelGenerator().generateArtifacts(CsarTest.SD_WAN_CSAR_FILE.getContent(),
+                    Collections.singletonList(ymlFile));
+        });
     }
 
     @Test
index 27e158f..6187ab3 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.aai.babel.xml.generator.api;
 
 
 import org.apache.groovy.util.Maps;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
 import org.onap.aai.babel.xml.generator.model.Model;
index 1fc5d13..d4b7fc8 100644 (file)
 
 package org.onap.aai.babel.xml.generator.model;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.util.Base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.xml.generator.data.GeneratorUtil;
 
 public class TestGeneratorUtil {
index 700cf38..93dd443 100644 (file)
@@ -23,11 +23,13 @@ package org.onap.aai.babel.xml.generator.model;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 
 /**
@@ -42,7 +44,7 @@ public class TestModel {
      * @throws IOException
      *             if the mappings configuration cannot be loaded
      */
-    @BeforeClass
+    @BeforeAll
     public static void setup() throws IOException {
         new ArtifactTestUtils().loadWidgetMappings();
     }
@@ -74,18 +76,22 @@ public class TestModel {
     /**
      * Test that there is no exception if processing a Model that has no metadata properties.
      */
-    @Test(expected = Test.None.class /* no exception expected */)
+    @Test
     public void testNullIdentProperties() {
-        createTestModel().populateModelIdentificationInformation(null);
+        assertDoesNotThrow(() -> {
+            createTestModel().populateModelIdentificationInformation(null);
+        });
     }
 
     /**
      * Test that an exception occurs if calling code passes an unsupported Widget Type value to the base implementation
      * of the hasWidgetType() method.
      */
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testUnknownWidgetType() {
-        createTestModel().hasWidgetType(null);
+        assertThrows(IllegalArgumentException.class, () -> {
+            createTestModel().hasWidgetType(null);
+        });
     }
 
     /**
index 88555ee..d752ecd 100644 (file)
@@ -23,15 +23,15 @@ package org.onap.aai.babel.xml.generator.model;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.junit.Assert.assertThat;
 
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
 
@@ -46,7 +46,7 @@ public class TestVfModule {
      * @throws IOException
      *             if the mappings configuration cannot be loaded
      */
-    @BeforeClass
+    @BeforeAll
     public static void setup() throws IOException {
         new ArtifactTestUtils().loadWidgetMappings();
     }
index 35319d6..9a06766 100644 (file)
@@ -23,12 +23,13 @@ package org.onap.aai.babel.xml.generator.model;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
 import java.util.Collections;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
 import org.onap.aai.babel.xml.generator.types.ModelType;
@@ -44,7 +45,7 @@ public class TestWidget {
      * @throws IOException
      *             if the mappings configuration cannot be loaded
      */
-    @BeforeClass
+    @BeforeAll
     public static void setup() throws IOException {
         new ArtifactTestUtils().loadWidgetMappings();
     }
@@ -164,9 +165,11 @@ public class TestWidget {
         assertThat(widgetModel.equals(Widget.createWidget("VSERVER")), is(false));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testGetUnknownWidget() throws XmlArtifactGenerationException {
-        WidgetType.valueOf("invalid-widget-name");
+        assertThrows(IllegalArgumentException.class, () -> {
+            WidgetType.valueOf("invalid-widget-name");
+        });
     }
 
     /**
@@ -175,34 +178,44 @@ public class TestWidget {
      * @throws XmlArtifactGenerationException
      *             if there is no configuration defined for the specified Widget type
      */
-    @Test(expected = XmlArtifactGenerationException.class)
+    @Test
     public void testGetDynamicWidget() throws XmlArtifactGenerationException {
-        Widget.createWidget(new WidgetType(null));
+        assertThrows(XmlArtifactGenerationException.class, () -> {
+            Widget.createWidget(new WidgetType(null));
+        });
     }
 
-    @Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
+    @Test
     public void testAddResourceIsUnsupported() throws XmlArtifactGenerationException {
-        Widget.createWidget("OAM_NETWORK").addResource(null);
+        assertThrows(org.onap.aai.babel.xml.generator.error.IllegalAccessException.class, () -> {
+            Widget.createWidget("OAM_NETWORK").addResource(null);
+        });
     }
 
     // Call Widget methods which are not supported, purely for code coverage.
 
-    @Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
+    @Test
     public void testGetModelNameVersionIdIsUnsupported() throws XmlArtifactGenerationException {
-        Widget widgetModel = Widget.createWidget("OAM_NETWORK");
-        widgetModel.getModelNameVersionId();
+        assertThrows(org.onap.aai.babel.xml.generator.error.IllegalAccessException.class, () -> {
+            Widget widgetModel = Widget.createWidget("OAM_NETWORK");
+            widgetModel.getModelNameVersionId();
+        });
     }
 
-    @Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
+    @Test
     public void testGetModelTypeNameIsUnsupported() throws XmlArtifactGenerationException {
-        Widget widgetModel = Widget.createWidget("OAM_NETWORK");
-        widgetModel.getModelTypeName();
+        assertThrows(org.onap.aai.babel.xml.generator.error.IllegalAccessException.class, () -> {
+            Widget widgetModel = Widget.createWidget("OAM_NETWORK");
+            widgetModel.getModelTypeName();
+        });
     }
 
-    @Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
+    @Test
     public void testGetModelIdIsUnsupported() throws XmlArtifactGenerationException {
-        Widget widgetModel = Widget.createWidget("OAM_NETWORK");
-        widgetModel.getModelId();
+        assertThrows(org.onap.aai.babel.xml.generator.error.IllegalAccessException.class, () -> {
+            Widget widgetModel = Widget.createWidget("OAM_NETWORK");
+            widgetModel.getModelId();
+        });
     }
 
 }