Upgrade spring boot to 2.6 54/139354/2
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 8 Nov 2024 08:49:07 +0000 (09:49 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Fri, 8 Nov 2024 09:09:22 +0000 (10:09 +0100)
- upgrade spring boot (2.5.15 -> 2.6.15)
- migrate aai-schema-ingest module to JUnit 5

Issue-ID: AAI-4048
Change-Id: I72a59891fdbcdea9b54f6c02aae09fcc7a26947a
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
54 files changed:
aai-annotations/pom.xml
aai-annotations/src/test/java/org/onap/aai/annotations/AnnotationsTest.java
aai-core/pom.xml
aai-failover/pom.xml
aai-parent/pom.xml
aai-rest/src/test/java/org/onap/aai/restclient/RestClientTest.java
aai-schema-abstraction/pom.xml
aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java
aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java
aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java
aai-schema-ingest/pom.xml
aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java
aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java
aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java
aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java
aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java
aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java
aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java
aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java
aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java
aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java
aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java
aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java
aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java
aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java
aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java
aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java
aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java
aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java
aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java
aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java
aai-utils/pom.xml
aai-utils/src/test/java/org/onap/aaiutils/oxm/OxmModelLoaderTest.java

index 19567ef..17d034c 100644 (file)
@@ -38,8 +38,8 @@
     </properties>
     <dependencies>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
index c988ddf..81c5fb5 100644 (file)
 
 package org.onap.aai.annotations;
 
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
 public class AnnotationsTest {
 
     public AnnotationsTest() {
     }
 
+    @Test
     @Metadata(
             isKey = false,
             description = "",
@@ -44,5 +49,6 @@ public class AnnotationsTest {
             maximumDepth = "",
             crossEntityReference = "")
     public void testAnnotation() {
+        assertTrue(true);
     }
 }
index 4ce7f76..41772b9 100644 (file)
@@ -204,10 +204,10 @@ limitations under the License.
                        <version>2.7.14</version>
                </dependency>
                <dependency>
-            <groupId>org.springframework.kafka</groupId>
-            <artifactId>spring-kafka-test</artifactId>
-            <scope>test</scope>
-        </dependency>
+                               <groupId>org.springframework.kafka</groupId>
+                               <artifactId>spring-kafka-test</artifactId>
+                               <scope>test</scope>
+               </dependency>
                <dependency>
                        <groupId>com.googlecode.json-simple</groupId>
                        <artifactId>json-simple</artifactId>
index 4b5f1d7..98526e8 100644 (file)
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-aspects</artifactId>
-            <version>${spring.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.aspectj</groupId>
-            <artifactId>aspectjrt</artifactId>
-            <version>1.9.1</version>
         </dependency>
     </dependencies>
 </project>
index add636e..9ffc037 100644 (file)
@@ -86,9 +86,7 @@ limitations under the License.
         Please don't upgrade to 2.3.0 or above for nexus iq or security scans
         as it could potentially break our code
       -->
-    <spring.boot.version>2.5.15</spring.boot.version>
-    <spring.version>5.3.39</spring.version>
-    <spring.test.version>${spring.version}</spring.test.version>
+    <spring.boot.version>2.6.15</spring.boot.version>
     <json.path.version>2.2.0</json.path.version>
     <json.version>20190722</json.version>
     <junit.version>4.12</junit.version>
@@ -139,13 +137,6 @@ limitations under the License.
         <type>pom</type>
         <scope>import</scope>
       </dependency>
-      <dependency>
-        <groupId>org.springframework</groupId>
-        <artifactId>spring-framework-bom</artifactId>
-        <version>${spring.version}</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
       <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
@@ -496,9 +487,9 @@ limitations under the License.
       </dependency>
 
       <dependency>
-        <groupId>io.swagger</groupId>
+        <groupId>io.swagger.core.v3</groupId>
         <artifactId>swagger-core</artifactId>
-        <version>${io.swagger.version}</version>
+        <version>2.2.25</version>
       </dependency>
 
       <dependency>
@@ -508,9 +499,9 @@ limitations under the License.
       </dependency>
 
       <dependency>
-        <groupId>io.swagger</groupId>
+        <groupId>io.swagger.core.v3</groupId>
         <artifactId>swagger-annotations</artifactId>
-        <version>${io.swagger.version}</version>
+        <version>2.2.25</version>
       </dependency>
 
       <dependency>
index 36b8fb3..bf32e91 100644 (file)
 
 package org.onap.aai.restclient;
 
-public class RestClientTest {
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
 
+public class RestClientTest {
+  @Test
+  public void test() {
+    assertTrue(true);
+  }
 }
index 140db51..8384809 100644 (file)
       <artifactId>rest-client</artifactId>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-junit</artifactId>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
       <artifactId>mockito-core</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-junit-jupiter</artifactId>
+      <version>5.14.2</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
index a4c7546..3fb9871 100644 (file)
 
 package org.onap.aai.schemaif.json;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -39,8 +34,8 @@ import java.util.Set;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.schemaif.SchemaProviderException;
 import org.onap.aai.schemaif.definitions.EdgeSchema;
 import org.onap.aai.schemaif.definitions.PropertySchema;
@@ -59,7 +54,7 @@ public class JsonSchemaProviderTest {
 
     JsonSchemaProviderConfig config = new JsonSchemaProviderConfig();
 
-    @Before
+    @BeforeEach
     public void init() {
         config.setSchemaServiceBaseUrl("https://testurl.com:8443");
         config.setSchemaServiceCertFile("/c/certfile");
@@ -528,66 +523,74 @@ public class JsonSchemaProviderTest {
         }
     }
 
-    @Test(expected = SchemaProviderException.class)
-    public void testSchemaValidateBadEdge() throws SchemaProviderException {
-        SchemaServiceResponse schema;
-
-        try {
-            String testSchema = readFile("src/test/resources/json/badEdgeSchema.json");
-            schema = SchemaServiceResponse.fromJson(testSchema);
-        } catch (Exception ex) {
-            fail();
-            return;
-        }
+    @Test
+    public void testSchemaValidateBadEdge() {
+        assertThrows(SchemaProviderException.class, () -> {
+            SchemaServiceResponse schema;
+
+            try {
+                String testSchema = readFile("src/test/resources/json/badEdgeSchema.json");
+                schema = SchemaServiceResponse.fromJson(testSchema);
+            } catch (Exception ex) {
+                fail();
+                return;
+            }
 
-        schema.getData().validate();
+            schema.getData().validate();
+        });
     }
 
-    @Test(expected = SchemaProviderException.class)
-    public void testSchemaValidateBadVertex() throws SchemaProviderException {
-        SchemaServiceResponse schema;
-
-        try {
-            String testSchema = readFile("src/test/resources/json/badVertexSchema.json");
-            schema = SchemaServiceResponse.fromJson(testSchema);
-        } catch (Exception ex) {
-            fail();
-            return;
-        }
+    @Test
+    public void testSchemaValidateBadVertex() {
+        assertThrows(SchemaProviderException.class, () -> {
+            SchemaServiceResponse schema;
+
+            try {
+                String testSchema = readFile("src/test/resources/json/badVertexSchema.json");
+                schema = SchemaServiceResponse.fromJson(testSchema);
+            } catch (Exception ex) {
+                fail();
+                return;
+            }
 
-        System.out.println("Validate");
-        schema.getData().validate();
-        System.out.println("Validate done");
+            System.out.println("Validate");
+            schema.getData().validate();
+            System.out.println("Validate done");
+        });
     }
 
-    @Test(expected = SchemaProviderException.class)
-    public void testSchemaValidateBadType() throws SchemaProviderException {
-        SchemaServiceResponse schema;
-
-        try {
-            String testSchema = readFile("src/test/resources/json/badTypeSchema.json");
-            schema = SchemaServiceResponse.fromJson(testSchema);
-        } catch (Exception ex) {
-            fail();
-            return;
-        }
+    @Test
+    public void testSchemaValidateBadType() {
+        assertThrows(SchemaProviderException.class, () -> {
+            SchemaServiceResponse schema;
+
+            try {
+                String testSchema = readFile("src/test/resources/json/badTypeSchema.json");
+                schema = SchemaServiceResponse.fromJson(testSchema);
+            } catch (Exception ex) {
+                fail();
+                return;
+            }
 
-        schema.getData().validate();
+            schema.getData().validate();
+        });
     }
 
-    @Test(expected = SchemaProviderException.class)
-    public void testSchemaValidateBadProp() throws SchemaProviderException {
-        SchemaServiceResponse schema;
-
-        try {
-            String testSchema = readFile("src/test/resources/json/badPropSchema.json");
-            schema = SchemaServiceResponse.fromJson(testSchema);
-        } catch (Exception ex) {
-            fail();
-            return;
-        }
+    @Test
+    public void testSchemaValidateBadProp() {
+        assertThrows(SchemaProviderException.class, () -> {
+            SchemaServiceResponse schema;
+
+            try {
+                String testSchema = readFile("src/test/resources/json/badPropSchema.json");
+                schema = SchemaServiceResponse.fromJson(testSchema);
+            } catch (Exception ex) {
+                fail();
+                return;
+            }
 
-        schema.getData().validate();
+            schema.getData().validate();
+        });
     }
 
     static String readFile(String path) throws IOException {
index 222be0e..8d6a744 100644 (file)
 
 package org.onap.aai.schemaif.oxm;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Set;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.aai.schemaif.SchemaProviderException;
 import org.onap.aai.schemaif.definitions.EdgeSchema;
 import org.onap.aai.schemaif.definitions.PropertySchema;
 import org.onap.aai.schemaif.definitions.VertexSchema;
 import org.onap.aai.schemaif.definitions.types.DataType.Type;
 
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class OxmSchemaProviderTest extends OxmSchemaServiceSetup {
 
     @Test
index 08cf880..701d4e1 100644 (file)
@@ -27,11 +27,11 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.nodes.NodeIngestor;
 import org.onap.aai.setup.AAIConfigTranslator;
@@ -40,7 +40,7 @@ import org.onap.aai.setup.SchemaLocationsBean;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.setup.Translator;
 
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class OxmSchemaServiceSetup {
 
     @Mock
@@ -56,7 +56,7 @@ public class OxmSchemaServiceSetup {
     private OxmEdgeRulesLoader edgeLoader;
     private OxmSchemaLoader vertexLoader;
 
-    @Before
+    @BeforeEach
     public void schemaBeanMockSetup() throws Exception {
         schemaVersionList.add(new SchemaVersion("v13"));
 
index cf908b1..bc722c1 100644 (file)
@@ -127,23 +127,22 @@ limitations under the License.
                        <artifactId>spring-boot-test</artifactId>
                        <scope>test</scope>
                </dependency>
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <!-- TODO: Migrate tests to junit 5 and remove this dependency -->
-               <dependency>
-                       <groupId>org.junit.vintage</groupId>
-                       <artifactId>junit-vintage-engine</artifactId>
-                       <scope>test</scope>
-                       <exclusions>
-                                       <exclusion>
-                                                       <groupId>org.hamcrest</groupId>
-                                                       <artifactId>hamcrest-core</artifactId>
-                                       </exclusion>
-                       </exclusions>
-               </dependency>
+  <dependency>
+   <groupId>org.hamcrest</groupId>
+   <artifactId>hamcrest-junit</artifactId>
+   <scope>test</scope>
+   <exclusions>
+    <exclusion>
+     <groupId>junit</groupId>
+     <artifactId>junit</artifactId>
+    </exclusion>
+   </exclusions>
+  </dependency>
+  <dependency>
+   <groupId>org.junit.jupiter</groupId>
+   <artifactId>junit-jupiter</artifactId>
+   <scope>test</scope>
+  </dependency>
                <dependency>
                        <groupId>org.mockito</groupId>
                        <artifactId>mockito-core</artifactId>
index c322216..e2b5e75 100644 (file)
@@ -51,7 +51,6 @@ import org.onap.aai.setup.SchemaVersions;
 import org.onap.aai.setup.Translator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 /**
@@ -76,7 +75,6 @@ public class EdgeIngestor {
 
     private Set<Translator> translators;
 
-    @Autowired
     public EdgeIngestor(Set<Translator> translatorSet) {
         this.translators = translatorSet;
     }
index 15b495a..8db8099 100644 (file)
@@ -52,7 +52,6 @@ import org.onap.aai.setup.SchemaVersions;
 import org.onap.aai.setup.Translator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.PropertySource;
 import org.springframework.stereotype.Component;
 import org.w3c.dom.Document;
@@ -86,7 +85,6 @@ public class NodeIngestor {
      * @param translatorSet
      */
 
-    @Autowired
     public NodeIngestor(Set<Translator> translatorSet) {
         this.translators = translatorSet;
         this.caseFormatStore = new CaseFormatStore();
index 50b9dc2..15587c2 100644 (file)
@@ -33,7 +33,6 @@ import org.apache.commons.io.IOUtils;
 import org.onap.aai.edges.JsonIngestor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * Converts the contents of the schema config file
@@ -46,7 +45,6 @@ public abstract class ConfigTranslator extends Translator {
 
     protected SchemaLocationsBean schemaLocationsBean;
 
-    @Autowired
     public ConfigTranslator(SchemaLocationsBean schemaLocationsBean, SchemaConfigVersions schemaConfigVersions) {
         super(schemaConfigVersions);
         this.schemaLocationsBean = schemaLocationsBean;
index 7308e37..01d8ddd 100644 (file)
@@ -29,7 +29,6 @@ import java.util.Map;
 
 import org.onap.aai.setup.ConfigTranslator;
 import org.onap.aai.setup.SchemaVersion;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 /**
@@ -42,7 +41,6 @@ public class DefaultVersionValidationModule implements VersionValidationModule {
 
     private ConfigTranslator config;
 
-    @Autowired
     public DefaultVersionValidationModule(ConfigTranslator config) {
 
         this.config = config;
index a1e9555..bb9d738 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.onap.aai.validation;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Component;
 
@@ -34,7 +33,6 @@ public class VersionValidator {
     private SchemaErrorStrategy strat;
     private VersionValidationModule verMod;
 
-    @Autowired
     public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
         this.strat = strategy;
         this.verMod = verMod;
index 620bc72..067d329 100644 (file)
@@ -30,7 +30,6 @@ import org.onap.aai.edges.enums.EdgeField;
 import org.onap.aai.setup.ConfigTranslator;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.validation.SchemaErrorStrategy;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +47,6 @@ public class EdgeRuleValidator {
     protected final CousinDefaultingValidationModule defaultsValidator;
     protected final NodeTypesValidationModule typeValidator;
 
-    @Autowired
     public EdgeRuleValidator(ConfigTranslator config, SchemaErrorStrategy strat,
             EdgeFieldsValidationModule fieldValidator, UniqueLabelValidationModule labelValidator,
             SingleContainmentValidationModule containsValidator, CousinDefaultingValidationModule defaultsValidator,
index 0de6624..5b57473 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Set;
 
 import org.onap.aai.nodes.NodeIngestor;
 import org.onap.aai.setup.SchemaVersion;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 /**
@@ -39,7 +38,6 @@ import org.springframework.stereotype.Component;
 public class NodeTypesValidationModule {
     private NodeIngestor ni;
 
-    @Autowired
     public NodeTypesValidationModule(NodeIngestor ni) {
         this.ni = ni;
     }
index 13de671..ab951e4 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Map.Entry;
 import org.onap.aai.setup.ConfigTranslator;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.validation.SchemaErrorStrategy;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Component;
 
@@ -38,7 +37,6 @@ public class NodeValidator {
     private SchemaErrorStrategy strat;
     private DuplicateNodeDefinitionValidationModule dupChecker;
 
-    @Autowired
     public NodeValidator(ConfigTranslator translator, SchemaErrorStrategy strategy,
             DuplicateNodeDefinitionValidationModule dupChecker) {
         this.translator = translator;
index 6f896f8..319d62d 100644 (file)
 
 package org.onap.aai.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.google.common.collect.Multimap;
 
 import java.util.Collection;
 
 import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.EdgesConfiguration;
 import org.onap.aai.edges.enums.AAIDirection;
 import org.onap.aai.edges.enums.MultiplicityRule;
@@ -43,9 +40,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {EdgesConfiguration.class, TestUtilConfigTranslator.class})
 @TestPropertySource(
         properties = {
@@ -58,9 +53,6 @@ public class EdgeIngestorLocalTest {
     @Autowired
     EdgeIngestor edgeIngestor;
 
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     @Test
     public void getRulesTest1() throws EdgeRuleNotFoundException {
         EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
@@ -159,11 +151,12 @@ public class EdgeIngestorLocalTest {
     }
 
     @Test
-    public void getRulesNoneFound() throws EdgeRuleNotFoundException {
-        thrown.expect(EdgeRuleNotFoundException.class);
-        thrown.expectMessage("No rules found for");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").build();
-        edgeIngestor.getRules(q);
+    public void getRulesNoneFound() {
+        Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").build();
+            edgeIngestor.getRules(q);
+        });
+        assertTrue(exception.getMessage().contains("No rules found for"));
     }
 
     @Test
@@ -218,11 +211,12 @@ public class EdgeIngestorLocalTest {
     // }
 
     @Test
-    public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-        thrown.expect(EdgeRuleNotFoundException.class);
-        thrown.expectMessage("No rule found for");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
-        edgeIngestor.getRule(q);
+    public void getRuleNoneFoundTest() {
+        Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
+            edgeIngestor.getRule(q);
+        });
+        assertTrue(exception.getMessage().contains("No rule found for"));
     }
 
     // @Test
@@ -234,19 +228,21 @@ public class EdgeIngestorLocalTest {
     // }
 
     @Test
-    public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-        thrown.expect(AmbiguousRuleChoiceException.class);
-        thrown.expectMessage("Multiple defaults found.");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
-        edgeIngestor.getRule(q);
+    public void getRuleAmbiguousDefaultTest() {
+        Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
+            edgeIngestor.getRule(q);
+        });
+        assertTrue(exception.getMessage().contains("Multiple defaults found."));
     }
 
     @Test
-    public void getRuleNoDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-        thrown.expect(AmbiguousRuleChoiceException.class);
-        thrown.expectMessage("No default found.");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
-        edgeIngestor.getRule(q);
+    public void getRuleNoDefaultTest() {
+        Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
+            edgeIngestor.getRule(q);
+        });
+        assertTrue(exception.getMessage().contains("No default found."));
     }
 
     // @Test
@@ -360,16 +356,16 @@ public class EdgeIngestorLocalTest {
     // }
 
     @Test
-    public void getAllRulesTest() throws EdgeRuleNotFoundException {
-        Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
-        assertTrue(res.size() == 4);
-        assertTrue(res.containsKey("bar|foo"));
-        assertTrue(res.get("bar|foo").size() == 2);
-        assertTrue(res.containsKey("baz|foo"));
-        assertTrue(res.containsKey("foo|quux"));
-
-        thrown.expect(EdgeRuleNotFoundException.class);
-        thrown.expectMessage("No rules found for version v9.");
-        edgeIngestor.getAllRules(new SchemaVersion("v9"));
+    public void getAllRulesTest() {
+        Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+            Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
+            assertTrue(res.size() == 4);
+            assertTrue(res.containsKey("bar|foo"));
+            assertTrue(res.get("bar|foo").size() == 2);
+            assertTrue(res.containsKey("baz|foo"));
+            assertTrue(res.containsKey("foo|quux"));
+            edgeIngestor.getAllRules(new SchemaVersion("v9"));
+        });
+        assertTrue(exception.getMessage().contains("No rules found for version v9."));
     }
 }
index 99693c1..932c9e2 100644 (file)
 
 package org.onap.aai.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.google.common.collect.Multimap;
 
 import java.util.Collection;
 
 import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.EdgesConfiguration;
 import org.onap.aai.edges.enums.AAIDirection;
 import org.onap.aai.edges.enums.MultiplicityRule;
@@ -43,9 +40,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {MockProvider.class, EdgesConfiguration.class})
 @TestPropertySource(
         properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties",
@@ -56,9 +51,6 @@ public class EdgeIngestorTest {
     @Autowired
     EdgeIngestor edgeIngestor;
 
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     @Test
     public void getRulesTest1() throws EdgeRuleNotFoundException {
         EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
@@ -161,11 +153,12 @@ public class EdgeIngestorTest {
     }
 
     @Test
-    public void getRulesNoneFound() throws EdgeRuleNotFoundException {
-        thrown.expect(EdgeRuleNotFoundException.class);
-        thrown.expectMessage("No rules found for");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("bogus-value").build();
-        edgeIngestor.getRules(q);
+    public void getRulesNoneFound() {
+        Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("bogus-value").build();
+            edgeIngestor.getRules(q);
+        });
+        assertTrue(exception.getMessage().contains("No rules found for"));
     }
 
     @Test
@@ -237,35 +230,39 @@ public class EdgeIngestorTest {
     }
 
     @Test
-    public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-        thrown.expect(EdgeRuleNotFoundException.class);
-        thrown.expectMessage("No rule found for");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
-        edgeIngestor.getRule(q);
+    public void getRuleNoneFoundTest() {
+        Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
+            edgeIngestor.getRule(q);
+        });
+        assertTrue(exception.getMessage().contains("No rule found for"));
     }
 
     @Test
-    public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-        thrown.expect(AmbiguousRuleChoiceException.class);
-        thrown.expectMessage("No way to select single rule from these pairs:");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
-        edgeIngestor.getRule(q);
+    public void getRuleTooManyPairsTest() {
+        Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
+            edgeIngestor.getRule(q);
+        });
+        assertTrue(exception.getMessage().contains("No way to select single rule from these pairs:"));
     }
 
     @Test
-    public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-        thrown.expect(AmbiguousRuleChoiceException.class);
-        thrown.expectMessage("Multiple defaults found.");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
-        edgeIngestor.getRule(q);
+    public void getRuleAmbiguousDefaultTest() {
+        Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
+            edgeIngestor.getRule(q);
+        });
+        assertTrue(exception.getMessage().contains("Multiple defaults found."));
     }
 
     @Test
-    public void getRuleNoDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-        thrown.expect(AmbiguousRuleChoiceException.class);
-        thrown.expectMessage("No default found.");
-        EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
-        edgeIngestor.getRule(q);
+    public void getRuleNoDefaultTest() {
+        Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+            EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
+            edgeIngestor.getRule(q);
+        });
+        assertTrue(exception.getMessage().contains("No default found."));
     }
 
     @Test
@@ -382,16 +379,16 @@ public class EdgeIngestorTest {
     }
 
     @Test
-    public void getAllRulesTest() throws EdgeRuleNotFoundException {
-        Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
-        assertTrue(res.size() == 4);
-        assertTrue(res.containsKey("bar|foo"));
-        assertTrue(res.get("bar|foo").size() == 2);
-        assertTrue(res.containsKey("baz|foo"));
-        assertTrue(res.containsKey("foo|quux"));
-
-        thrown.expect(EdgeRuleNotFoundException.class);
-        thrown.expectMessage("No rules found for version v9.");
-        edgeIngestor.getAllRules(new SchemaVersion("v9"));
+    public void getAllRulesTest() {
+        Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+            Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
+            assertTrue(res.size() == 4);
+            assertTrue(res.containsKey("bar|foo"));
+            assertTrue(res.get("bar|foo").size() == 2);
+            assertTrue(res.containsKey("baz|foo"));
+            assertTrue(res.containsKey("foo|quux"));
+            edgeIngestor.getAllRules(new SchemaVersion("v9"));
+        });
+        assertTrue(exception.getMessage().contains("No rules found for version v9."));
     }
 }
index 543ce27..fa7f04c 100644 (file)
 
 package org.onap.aai.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.google.common.collect.Multimap;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.EdgesConfiguration;
 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
 import org.onap.aai.setup.SchemaVersion;
@@ -34,9 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {EdgesConfiguration.class, ConfigTranslatorForWiringTest.class})
 @TestPropertySource(
         properties = {
index c1894f0..3396b93 100644 (file)
@@ -20,7 +20,7 @@
 
 package org.onap.aai.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.jayway.jsonpath.DocumentContext;
 import com.jayway.jsonpath.JsonPath;
@@ -29,8 +29,8 @@ import java.io.InputStream;
 import java.util.List;
 import java.util.Scanner;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.enums.EdgeType;
 
 public class EdgeRuleQueryTest {
@@ -38,7 +38,7 @@ public class EdgeRuleQueryTest {
     private String readStart = "$.rules.[?]";
 
     /* **** DATA SETUP **** */
-    @Before
+    @BeforeEach
     public void setup() {
         InputStream is = getClass().getResourceAsStream("/edgeRules/test.json");
 
index 3fdabfd..798a32f 100644 (file)
 
 package org.onap.aai.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class EdgeRuleTest {
 
index c67be64..66fbcce 100644 (file)
@@ -22,14 +22,14 @@ package org.onap.aai.edges;
 
 import static com.jayway.jsonpath.Criteria.where;
 import static com.jayway.jsonpath.Filter.filter;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.jayway.jsonpath.DocumentContext;
 import com.jayway.jsonpath.Filter;
+import org.junit.jupiter.api.Test;
 
 import java.util.*;
 
-import org.junit.Test;
 import org.onap.aai.setup.SchemaVersion;
 
 public class JsonIngestorTest {
index 4e3d61d..b106310 100644 (file)
@@ -20,9 +20,9 @@
 
 package org.onap.aai.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TypeAlphabetizerTest {
 
index f26e603..90d614b 100644 (file)
@@ -22,7 +22,8 @@ package org.onap.aai.nodes;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -43,10 +44,7 @@ import javax.xml.transform.stream.StreamResult;
 
 import org.eclipse.persistence.dynamic.DynamicEntity;
 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.testutils.TestUtilConfigTranslator;
@@ -55,10 +53,8 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 import org.w3c.dom.Document;
 
-@RunWith(SpringRunner.class)
 @TestPropertySource(
         properties = {
                 "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"})
@@ -68,11 +64,6 @@ import org.w3c.dom.Document;
 
 @SpringBootTest
 public class NodeIngestorLocalTest {
-
-    // set thrown.expect to whatever a specific test needs
-    // this establishes a default of expecting no exceptions to be thrown
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
     @Autowired
     NodeIngestor nodeIngestor;
 
@@ -90,37 +81,37 @@ public class NodeIngestorLocalTest {
 
     @Test
     public void testGetContextForVersion11() {
-        DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
-
-        // should work bc Foo is valid in test_network_v10 schema
-        DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
-
-        foo10.set("fooId", "bar");
-        assertEquals("bar", foo10.get("fooId"));
-
-        // should work bc Bar is valid in test_business_v10 schema
-        DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
-        bar10.set("barId", "bar2");
-        assertEquals("bar2", bar10.get("barId"));
-        XSDOutputResolver outputResolver10 = new XSDOutputResolver();
-        ctx10.generateSchema(outputResolver10);
-
-        DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
-
-        // should work bc Foo.quantity is valid in test_network_v11 schema
-        DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
-        foo11.set("quantity", "12");
-        assertEquals("12", foo11.get("quantity"));
-
-        DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
-        quux11.set("qManagerName", "some guy");
-        assertEquals("some guy", quux11.get("qManagerName"));
-        XSDOutputResolver outputResolver11 = new XSDOutputResolver();
-        ctx11.generateSchema(outputResolver11);
-
-        thrown.expect(IllegalArgumentException.class);
-        // should fail bc Quux not in v10 test schema
-        ctx10.newDynamicEntity("Quux");
+        assertThrows(IllegalArgumentException.class, () -> {
+            DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
+
+            // should work bc Foo is valid in test_network_v10 schema
+            DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
+
+            foo10.set("fooId", "bar");
+            assertEquals("bar", foo10.get("fooId"));
+
+            // should work bc Bar is valid in test_business_v10 schema
+            DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
+            bar10.set("barId", "bar2");
+            assertEquals("bar2", bar10.get("barId"));
+            XSDOutputResolver outputResolver10 = new XSDOutputResolver();
+            ctx10.generateSchema(outputResolver10);
+
+            DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
+
+            // should work bc Foo.quantity is valid in test_network_v11 schema
+            DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
+            foo11.set("quantity", "12");
+            assertEquals("12", foo11.get("quantity"));
+
+            DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
+            quux11.set("qManagerName", "some guy");
+            assertEquals("some guy", quux11.get("qManagerName"));
+            XSDOutputResolver outputResolver11 = new XSDOutputResolver();
+            ctx11.generateSchema(outputResolver11);
+            // should fail bc Quux not in v10 test schema
+            ctx10.newDynamicEntity("Quux");
+        });
     }
 
     @Test
index 053004b..6e62505 100644 (file)
@@ -22,7 +22,8 @@ package org.onap.aai.nodes;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -43,10 +44,7 @@ import javax.xml.transform.stream.StreamResult;
 
 import org.eclipse.persistence.dynamic.DynamicEntity;
 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.restclient.MockProvider;
 import org.onap.aai.setup.SchemaVersion;
@@ -55,10 +53,8 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.w3c.dom.Document;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @TestPropertySource(
         properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties",
                 "spring.main.allow-bean-definition-overriding=true"})
@@ -70,44 +66,39 @@ public class NodeIngestorTest {
     @Autowired
     NodeIngestor nodeIngestor;
 
-    // set thrown.expect to whatever a specific test needs
-    // this establishes a default of expecting no exceptions to be thrown
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     @Test
     public void testGetContextForVersion() {
-        DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
-
-        // should work bc Foo is valid in test_network_v10 schema
-        DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
-
-        foo10.set("fooId", "bar");
-        assertEquals("bar", foo10.get("fooId"));
-
-        // should work bc Bar is valid in test_business_v10 schema
-        DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
-        bar10.set("barId", "bar2");
-        assertEquals("bar2", bar10.get("barId"));
-        XSDOutputResolver outputResolver10 = new XSDOutputResolver();
-        ctx10.generateSchema(outputResolver10);
-
-        DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
-
-        // should work bc Foo.quantity is valid in test_network_v11 schema
-        DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
-        foo11.set("quantity", "12");
-        assertEquals("12", foo11.get("quantity"));
-
-        DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
-        quux11.set("qManagerName", "some guy");
-        assertEquals("some guy", quux11.get("qManagerName"));
-        XSDOutputResolver outputResolver11 = new XSDOutputResolver();
-        ctx11.generateSchema(outputResolver11);
-
-        thrown.expect(IllegalArgumentException.class);
-        // should fail bc Quux not in v10 test schema
-        ctx10.newDynamicEntity("Quux");
+        assertThrows(IllegalArgumentException.class, () -> {
+            DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
+
+            // should work bc Foo is valid in test_network_v10 schema
+            DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
+
+            foo10.set("fooId", "bar");
+            assertEquals("bar", foo10.get("fooId"));
+
+            // should work bc Bar is valid in test_business_v10 schema
+            DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
+            bar10.set("barId", "bar2");
+            assertEquals("bar2", bar10.get("barId"));
+            XSDOutputResolver outputResolver10 = new XSDOutputResolver();
+            ctx10.generateSchema(outputResolver10);
+
+            DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
+
+            // should work bc Foo.quantity is valid in test_network_v11 schema
+            DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
+            foo11.set("quantity", "12");
+            assertEquals("12", foo11.get("quantity"));
+
+            DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
+            quux11.set("qManagerName", "some guy");
+            assertEquals("some guy", quux11.get("qManagerName"));
+            XSDOutputResolver outputResolver11 = new XSDOutputResolver();
+            ctx11.generateSchema(outputResolver11);
+            // should fail bc Quux not in v10 test schema
+            ctx10.newDynamicEntity("Quux");
+        });
     }
 
     @Test
index 7ae0a2c..07631ce 100644 (file)
 
 package org.onap.aai.nodes;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.eclipse.persistence.dynamic.DynamicEntity;
 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
@@ -33,9 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {ConfigTranslatorForWiringTest.class, NodesConfiguration.class})
 @TestPropertySource(
         properties = {
index d2921c7..5ef0ebe 100644 (file)
@@ -21,7 +21,7 @@
 
 package org.onap.aai.restclient;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
 import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
 import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
@@ -124,7 +124,7 @@ public class MockRestClient extends RestClient {
 
         String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
         String message = String.format("Unable to find the %s in src/test/resources", filename);
-        assertNotNull(message, inputStream);
+        assertNotNull(inputStream, message);
 
         JsonObject payload = JsonParser.parseString(result).getAsJsonObject();
         return payload;
index 4b12936..743fe70 100644 (file)
@@ -23,19 +23,16 @@ package org.onap.aai.restclient;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@Ignore
-@RunWith(SpringJUnit4ClassRunner.class)
+@Disabled
 @TestPropertySource(locations = "/schemaService/schema-service-rest.properties")
 @ContextConfiguration(
         classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class,
index 8136ac0..d34ea71 100644 (file)
 
 package org.onap.aai.setup;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
 import java.util.Map;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {SchemaLocationsBean.class, SchemaConfigVersions.class, ConfigTranslatorForWiringTest.class})
 @TestPropertySource(
index 4d7bf69..e4bd1fe 100644 (file)
 
 package org.onap.aai.setup;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {SchemaLocationsBean.class})
+@SpringJUnitConfig(classes = {SchemaLocationsBean.class})
 public class SchemaLocationsBeanDefaultInjectionTest {
     @Autowired
     SchemaLocationsBean bean;
index bfaa917..f4cfef2 100644 (file)
 
 package org.onap.aai.setup;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {SchemaLocationsBean.class})
+@SpringJUnitConfig(classes = {SchemaLocationsBean.class})
 @TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest2.properties"})
 public class SchemaLocationsBeanEnvVarInjectionTest {
     @Autowired
index 78df389..82e7d49 100644 (file)
 
 package org.onap.aai.setup;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:forWiringTests/testContext.xml"})
+@SpringJUnitConfig(locations = {"classpath:forWiringTests/testContext.xml"})
 public class SchemaLocationsBeanXMLSetterTest {
     @Autowired
     SchemaLocationsBean bean;
index 2a5068f..2d4c081 100644 (file)
 
 package org.onap.aai.setup;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
 
-@Ignore("Support of schema ingest via context configuration with prop file is removed as it won't work with spring boot 2")
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:forWiringTests/testUsingPropFileContext.xml"})
+@Disabled("Support of schema ingest via context configuration with prop file is removed as it won't work with spring boot 2")
+@SpringJUnitConfig(locations = {"classpath:forWiringTests/testUsingPropFileContext.xml"})
 public class SchemaLocationsBeanXMLSetterWithPropFileTest {
     @Autowired
     SchemaLocationsBean bean;
index ecc188f..336dd58 100644 (file)
 
 package org.onap.aai.setup;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.restclient.MockProvider;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @TestPropertySource(
         properties = {
                 "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-override-test.properties"})
 @ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class, SchemaConfigVersions.class})
 @SpringBootTest
 public class SchemaVersionsBeanOverrideTest {
-
-    // set thrown.expect to whatever a specific test needs
-    // this establishes a default of expecting no exceptions to be thrown
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
     @Autowired
     SchemaVersionsBean SchemaVersionsBean;
 
index 981be80..322a6b3 100644 (file)
 
 package org.onap.aai.setup;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.restclient.MockProvider;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @TestPropertySource(
         properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties"})
 @ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class})
 @SpringBootTest
 public class SchemaVersionsBeanTest {
-
-    // set thrown.expect to whatever a specific test needs
-    // this establishes a default of expecting no exceptions to be thrown
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
     @Autowired
     SchemaVersionsBean SchemaVersionsBean;
 
index fa6d8ed..0022e15 100644 (file)
@@ -20,9 +20,9 @@
 
 package org.onap.aai.validation;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class CheckEverythingStrategyTest {
 
index 0dc68c4..043e9c7 100644 (file)
@@ -1,4 +1,4 @@
-/** 
+/**
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
 
 package org.onap.aai.validation;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 public class FailFastStrategyTest {
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
 
     @Test
     public void test() {
-        FailFastStrategy strat = new FailFastStrategy();
+        String testError = "hi i'm a problem";
+        Throwable exception = assertThrows(AAISchemaValidationException.class, () -> {
+            FailFastStrategy strat = new FailFastStrategy();
 
-        // simulate no issues found
-        assertTrue(strat.isOK());
-        assertTrue("No errors found.".equals(strat.getErrorMsg()));
+            // simulate no issues found
+            assertTrue(strat.isOK());
+            assertTrue("No errors found.".equals(strat.getErrorMsg()));
 
-        // simulate an issue found
-        String testError = "hi i'm a problem";
-        thrown.expect(AAISchemaValidationException.class);
-        thrown.expectMessage(testError);
-        strat.notifyOnError(testError);
+            // simulate an issue found
+            strat.notifyOnError(testError);
+        });
+        assertTrue(exception.getMessage().contains(testError));
     }
 
 }
index 4c6882c..bcf79d2 100644 (file)
 
 package org.onap.aai.validation;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.testutils.BadNodeConfigForValidationTest;
@@ -31,9 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {NodesConfiguration.class, BadNodeConfigForValidationTest.class, CheckEverythingStrategy.class,
                 DefaultVersionValidationModule.class, VersionValidator.class})
index a74f7ba..f2bb85a 100644 (file)
 
 package org.onap.aai.validation;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.testutils.GoodConfigForValidationTest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
                 DefaultVersionValidationModule.class, VersionValidator.class})
index 58940af..466e4b9 100644 (file)
@@ -20,7 +20,7 @@
 
 package org.onap.aai.validation.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.jayway.jsonpath.DocumentContext;
 
@@ -29,8 +29,8 @@ import java.util.HashMap;
 import java.util.List;
 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.edges.JsonIngestor;
 import org.onap.aai.setup.SchemaVersion;
 
@@ -38,7 +38,7 @@ public class CousinDefaultingValidationModuleTest {
     private static List<DocumentContext> ctxs;
     private static CousinDefaultingValidationModule validator;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() {
         Map<SchemaVersion, List<String>> testRules = new HashMap<>();
         List<String> testFiles = new ArrayList<>();
index a4c70b8..08298f2 100644 (file)
 
 package org.onap.aai.validation.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.enums.EdgeField;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {DefaultEdgeFieldsValidationModule.class})
 @SpringBootTest
 public class DefaultEdgeFieldsValidationModuleTest {
index b1bf314..60c04aa 100644 (file)
 
 package org.onap.aai.validation.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.testutils.BadEdgeConfigForValidationTest;
 import org.onap.aai.validation.CheckEverythingStrategy;
@@ -31,9 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {NodesConfiguration.class, BadEdgeConfigForValidationTest.class, CheckEverythingStrategy.class,
                 DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
index 6094321..53cad53 100644 (file)
 
 package org.onap.aai.validation.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.testutils.GoodConfigForValidationTest;
 import org.onap.aai.validation.CheckEverythingStrategy;
@@ -31,9 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
                 DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
index e80e2fe..191a10d 100644 (file)
 
 package org.onap.aai.validation.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.testutils.TestUtilConfigTranslator;
@@ -34,9 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {NodesConfiguration.class, TestUtilConfigTranslator.class, NodeTypesValidationModule.class})
 @TestPropertySource(
index a704d80..d34772e 100644 (file)
 
 package org.onap.aai.validation.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.jayway.jsonpath.DocumentContext;
 
 import java.util.*;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.JsonIngestor;
 import org.onap.aai.setup.SchemaVersion;
 
@@ -36,7 +36,7 @@ public class SingleContainmentValidationModuleTest {
     private static SingleContainmentValidationModule validator;
     public static final SchemaVersion LATEST = new SchemaVersion("v14");
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() {
         Map<SchemaVersion, List<String>> testRules = new TreeMap<>();
         List<String> testFiles = new ArrayList<>();
index 76e5203..22553b9 100644 (file)
 
 package org.onap.aai.validation.edges;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import com.jayway.jsonpath.DocumentContext;
 
 import java.util.*;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.JsonIngestor;
 import org.onap.aai.setup.SchemaVersion;
 
@@ -36,7 +36,7 @@ public class UniqueLabelValidationModuleTest {
     private static UniqueLabelValidationModule validator;
     public static final SchemaVersion LATEST = new SchemaVersion("v14");
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         Map<SchemaVersion, List<String>> testRules = new TreeMap<>();
         List<String> testFiles = new ArrayList<>();
index 93cb2ab..6995629 100644 (file)
 
 package org.onap.aai.validation.nodes;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.testutils.BadNodeConfigForValidationTest;
 import org.onap.aai.validation.CheckEverythingStrategy;
@@ -32,9 +31,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {BadNodeConfigForValidationTest.class, NodesConfiguration.class, CheckEverythingStrategy.class,
                 DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
index c2e7b7b..aa8aabc 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.onap.aai.validation.nodes;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -32,11 +34,8 @@ import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.nodes.NodeIngestor;
 import org.onap.aai.setup.SchemaVersion;
@@ -45,34 +44,28 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.w3c.dom.Document;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {SchemaIncompleteTranslator.class, NodesConfiguration.class})
 
 @TestPropertySource(
         properties = {
                 "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
 @SpringBootTest
-@Ignore
+@Disabled
 public class NodeValidatorSchemaIncompleteTest {
     @Autowired
     NodeIngestor ni;
 
-    // set thrown.expect to whatever a specific test needs
-    // this establishes a default of expecting no exceptions to be thrown
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     // Throws a NullPointerException because a JavaType is referenced, but not defined
     @Test
-    public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException {
-        thrown.expect(NullPointerException.class);
+    public void testIncompleteCombinedSchema() {
+        assertThrows(NullPointerException.class, () -> {
 
-        // TODO Change for Exception
-        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-        printDocument(ni.getSchema(new SchemaVersion("v12")), buffer);
+            // TODO Change for Exception
+            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+            printDocument(ni.getSchema(new SchemaVersion("v12")), buffer);
+        });
     }
 
     public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException {
index 893dd04..d8a6933 100644 (file)
 
 package org.onap.aai.validation.nodes;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.config.NodesConfiguration;
 import org.onap.aai.testutils.GoodConfigForValidationTest;
 import org.onap.aai.validation.CheckEverythingStrategy;
@@ -31,9 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
                 DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
index f5bc33f..2ce63f6 100644 (file)
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
+  <dependency>
+   <groupId>org.hamcrest</groupId>
+   <artifactId>hamcrest-junit</artifactId>
+   <scope>test</scope>
+   <exclusions>
+    <exclusion>
+     <groupId>junit</groupId>
+     <artifactId>junit</artifactId>
+    </exclusion>
+   </exclusions>
+  </dependency>
+  <dependency>
+   <groupId>org.junit.jupiter</groupId>
+   <artifactId>junit-jupiter</artifactId>
+   <scope>test</scope>
+  </dependency>
         <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-core</artifactId>
index f3b9f62..bcfdbeb 100644 (file)
 
 package org.onap.aaiutils.oxm;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.util.regex.Pattern;
 
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 public class OxmModelLoaderTest {
 
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     @Test
     public void shouldLoadOxmModelsWhichMatchToPattern() throws Exception {
         OxmModelLoader.loadModels("classpath*:test_aai_oxm*.xml", Pattern.compile("test_aai_oxm_(.*).xml"));
 
-        Assert.assertTrue(OxmModelLoader.getVersionContextMap().size() == 2);
-        Assert.assertFalse(OxmModelLoader.getVersionContextMap().containsKey("v7"));
-        Assert.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v8"));
-        Assert.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v9"));
+        Assertions.assertTrue(OxmModelLoader.getVersionContextMap().size() == 2);
+        Assertions.assertFalse(OxmModelLoader.getVersionContextMap().containsKey("v7"));
+        Assertions.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v8"));
+        Assertions.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v9"));
     }
 
     @Test
-    public void shouldReportAnErrorWhenOxmModelsAreNotAvailable() throws Exception {
-        thrown.expect(Exception.class);
-        thrown.expectMessage("Failed to load schema");
+    public void shouldReportAnErrorWhenOxmModelsAreNotAvailable() {
+        Throwable exception = assertThrows(Exception.class, () ->
 
-        OxmModelLoader.loadModels("classpath*:non_existing_aai_oxm*.xml",
-                Pattern.compile("non_existing_aai_oxm_(.*).xml"));
+            OxmModelLoader.loadModels("classpath*:non_existing_aai_oxm*.xml",
+                    Pattern.compile("non_existing_aai_oxm_(.*).xml")));
+        assertTrue(exception.getMessage().contains("Failed to load schema"));
     }
 
 }