Migrate the schema-service from JUnit 4 to JUnit 5 88/139388/3
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 13 Nov 2024 08:58:26 +0000 (09:58 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 13 Nov 2024 10:30:56 +0000 (11:30 +0100)
Issue-ID: AAI-4053
Change-Id: I100c96c9d231f1d5c232886bc00bf3e05cc209b3
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
31 files changed:
aai-annotations/pom.xml
aai-annotations/src/test/java/org/onap/aai/annotations/AnnotationsTest.java
aai-queries/pom.xml
aai-queries/src/test/java/org/onap/aai/queries/AAISetup.java
aai-queries/src/test/java/org/onap/aai/queries/OnapQueryTest.java
aai-queries/src/test/java/org/onap/aai/queries/VnfToEsrSystemInfoQueryTest.java
aai-schema-gen/pom.xml
aai-schema-gen/src/test/java/org/onap/aai/schemagen/GenerateXsdTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSetTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteOperationTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/EdgeDescriptionTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/GetOperationTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/HTMLfromOXMTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodeGetOperationTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXMTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutOperationTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutRelationPathSetTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDElementTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDJavaTypeTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/YAMLfromOXMTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/ApiHttpVerbResponseTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/ApiHttpVerbTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/DefinitionPropertyTest.java
aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/DefinitionTest.java
aai-schema-service/pom.xml
aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
aai-schema/pom.xml
aai-schema/src/test/java/org/onap/aai/schema/ValidateEdgeRulesTest.java
aai-schema/src/test/java/org/onap/aai/schema/ValidateOXMTest.java

index 01f908e..d01c820 100644 (file)
     </properties>
     <dependencies>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-deploy-plugin</artifactId>
             </plugin>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
         </plugins>
     </build>
 
index 9ff262d..508f94e 100644 (file)
 
 package org.onap.aai.annotations;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class AnnotationsTest {
 
-    public AnnotationsTest() {
-    }
-
     @Metadata(
         isKey = false,
         description = "",
index 32906e9..a42c60c 100644 (file)
         <!-- End of NARAD profile -->
     </profiles>
     <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.onap.aai.aai-common</groupId>
             <artifactId>aai-core</artifactId>
                     <groupId>org.onap.aai.aai-common</groupId>
                     <artifactId>aai-aaf-auth</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
             <artifactId>hamcrest-core</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.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
+            <artifactId>mockito-core</artifactId>
+            <version>4.4.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <artifactId>org.eclipse.persistence.moxy</artifactId>
             <version>3.0.0</version>
         </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
index 99d74a1..d538d21 100644 (file)
@@ -20,7 +20,7 @@
 
 package org.onap.aai.queries;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -28,9 +28,8 @@ import java.nio.charset.Charset;
 import java.util.Map;
 
 import org.apache.commons.io.IOUtils;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.onap.aai.config.IntrospectionConfig;
 import org.onap.aai.config.RestBeanConfig;
 import org.onap.aai.config.SpringContextAware;
@@ -48,13 +47,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.rules.SpringClassRule;
-import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 @ContextConfiguration(
     classes = {SchemaLocationsBean.class, SchemaVersions.class, AAIConfigTranslator.class,
         EdgeIngestor.class, EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class,
         IntrospectionConfig.class, RestBeanConfig.class, GremlinServerSingleton.class})
+@ExtendWith(SpringExtension.class)
 @TestPropertySource(
     properties = {"schema.uri.base.path = /aai",
         "schema.ingest.file = src/test/resources/application-test.properties"})
@@ -89,13 +88,7 @@ public abstract class AAISetup {
     @Value("${schema.uri.base.path}")
     protected String basePath;
 
-    @ClassRule
-    public static final SpringClassRule springClassRule = new SpringClassRule();
-
-    @Rule
-    public final SpringMethodRule springMethodRule = new SpringMethodRule();
-
-    @BeforeClass
+    @BeforeAll
     public static void setupBundleconfig() throws Exception {
         System.setProperty("AJSC_HOME", "./");
         System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
@@ -107,7 +100,7 @@ public abstract class AAISetup {
         InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename);
 
         String message = String.format("Unable to find the %s in src/test/resources", filename);
-        assertNotNull(message, inputStream);
+        assertNotNull(inputStream, message);
 
         String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
         return resource;
index 84051b0..21a3312 100644 (file)
@@ -20,8 +20,8 @@
 
 package org.onap.aai.queries;
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
@@ -33,12 +33,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.onap.aai.config.IntrospectionConfig;
@@ -65,25 +62,18 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.rules.SpringClassRule;
-import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
 
-@RunWith(Parameterized.class)
 @ContextConfiguration(
     classes = {SchemaLocationsBean.class, SchemaConfigVersions.class, AAIConfigTranslator.class,
         EdgeIngestor.class, EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class,
         GremlinServerSingleton.class, IntrospectionConfig.class})
+@ExtendWith(SpringExtension.class)
 @TestPropertySource(
     properties = {"schema.uri.base.path = /aai", "schema.source.name = onap",
         "schema.ingest.file = src/test/resources/application-test.properties"})
 public abstract class OnapQueryTest {
 
-    @ClassRule
-    public static final SpringClassRule springClassRule = new SpringClassRule();
-
-    @Rule
-    public final SpringMethodRule springMethodRule = new SpringMethodRule();
-
     protected Logger logger;
     protected Graph graph;
     protected GremlinGroovyShell shell;
@@ -109,17 +99,8 @@ public abstract class OnapQueryTest {
     @Autowired
     protected GremlinServerSingleton gremlinServerSingleton;
 
-    @Parameterized.Parameter(value = 0)
     public SchemaVersion version;
 
-    @Parameterized.Parameters(name = "Version.{0}")
-    public static Collection<Object[]> data() {
-        return Arrays.asList(new Object[][] {{new SchemaVersion("v11")}, {new SchemaVersion("v12")},
-            {new SchemaVersion("v13")}, {new SchemaVersion("v14")}, {new SchemaVersion("v15")},
-            {new SchemaVersion("v16")}, {new SchemaVersion("v17")}, {new SchemaVersion("v18")},
-            {new SchemaVersion("v19")}, {new SchemaVersion("v20")}});
-    }
-
     protected String query;
 
     LinkedHashMap<String, Object> params;
@@ -127,25 +108,24 @@ public abstract class OnapQueryTest {
     @Autowired
     private Environment env;
 
-    @BeforeClass
+    @BeforeAll
     public static void setupBundleconfig() {
         System.setProperty("AJSC_HOME", "./");
         System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws AAIException, NoEdgeRuleFoundException, EdgeRuleNotFoundException,
         AmbiguousRuleChoiceException, IOException {
         System.setProperty("AJSC_HOME", ".");
         System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
         logger = LoggerFactory.getLogger(getClass());
-        MockitoAnnotations.initMocks(this);
+        MockitoAnnotations.openMocks(this);
         graph = TinkerGraph.open();
         gts = graph.traversal();
         createGraph();
         shell = new GremlinGroovyShell();
-        loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, version);
-        setUpQuery();
+
     }
 
     protected void setUpQuery() {
@@ -184,7 +164,7 @@ public abstract class OnapQueryTest {
         // java.lang.AssertionError: Expected all the vertices to be found
         // Expected :[v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
         // Actual :[v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]]
-        assertEquals("Expected all the vertices to be found", nonDuplicateExpectedResult, vertices);
+        assertEquals(nonDuplicateExpectedResult, vertices, "Expected all the vertices to be found");
 
     }
 
@@ -202,4 +182,8 @@ public abstract class OnapQueryTest {
 
     protected abstract void addParam(Map<String, Object> params);
 
+    public void initOnapQueryTest(SchemaVersion version) {
+        this.version = version;
+    }
+
 }
index 373e251..3bd7e04 100644 (file)
 
 package org.onap.aai.queries;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Map;
+import java.util.stream.Stream;
 
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.ModelType;
 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import org.onap.aai.setup.SchemaVersion;
 
 public class VnfToEsrSystemInfoQueryTest extends OnapQueryTest {
     public VnfToEsrSystemInfoQueryTest() {
         super();
     }
 
-    @Test
-    public void run() {
+    public static Stream<Arguments> data() {
+        return Stream.of(
+            Arguments.of(new SchemaVersion("v11")),
+            Arguments.of(new SchemaVersion("v12")),
+            Arguments.of(new SchemaVersion("v13")),
+            Arguments.of(new SchemaVersion("v14")),
+            Arguments.of(new SchemaVersion("v15")),
+            Arguments.of(new SchemaVersion("v16")),
+            Arguments.of(new SchemaVersion("v17")),
+            Arguments.of(new SchemaVersion("v18")),
+            Arguments.of(new SchemaVersion("v19")),
+            Arguments.of(new SchemaVersion("v20"))
+        );
+
+    }
+
+    @ParameterizedTest
+    @MethodSource("data")
+    public void run(SchemaVersion version) {
+        loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, version);
+        setUpQuery();
         super.run();
         assertTrue(true);
     }
index ceb0a86..b7723e7 100644 (file)
             <artifactId>spring-test</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.12</version>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.yaml</groupId>
             <artifactId>snakeyaml</artifactId>
                     <groupId>org.springframework</groupId>
                     <artifactId>spring-webmvc</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
             <version>1.3</version>
             <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.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <version>1.10.19</version>
+            <artifactId>mockito-core</artifactId>
+            <version>4.11.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
index 9b28e3b..c9b8a64 100644 (file)
 package org.onap.aai.schemagen;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.io.BufferedWriter;
 import java.io.FileWriter;
 
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.nodes.NodeIngestor;
 import org.onap.aai.schemagen.genxsd.HTMLfromOXM;
@@ -46,12 +45,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-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(
+@SpringJUnitConfig(
     classes = {SchemaLocationsBean.class, TestUtilConfigTranslatorforBusiness.class,
         EdgeIngestor.class, NodeIngestor.class, SwaggerGenerationConfiguration.class,
         SchemaConfigVersions.class})
@@ -73,7 +70,7 @@ public class GenerateXsdTest {
     @Autowired
     SchemaConfigVersions schemaConfigVersions;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
         XSDElementTest x = new XSDElementTest();
         x.setUp();
@@ -88,7 +85,7 @@ public class GenerateXsdTest {
 
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         // PowerMockito.mockStatic(GenerateXsd.class);
         XSDElementTest x = new XSDElementTest();
index 4729af4..cc8b642 100644 (file)
@@ -22,24 +22,21 @@ package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public class DeleteFootnoteSetTest {
     String targetNode;
     String flavor;
     String result;
     DeleteFootnoteSet footnotes = null;
 
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {
             {"vserver", "(1)",
@@ -57,33 +54,40 @@ public class DeleteFootnoteSetTest {
         return (Arrays.asList(inputs));
     }
 
-    public DeleteFootnoteSetTest(String targetNode, String flavor, String result) {
-        super();
+    public void initDeleteFootnoteSetTest(String targetNode, String flavor, String result) {
         this.targetNode = targetNode;
         this.flavor = flavor;
         this.result = result;
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         footnotes = new DeleteFootnoteSet(this.targetNode);
     }
 
-    @Test
-    public void testDeleteFootnoteSet() {
-        assertThat(footnotes.targetNode, is(this.targetNode));
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testDeleteFootnoteSet(String targetNode, String flavor, String result) {
+        DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
+        assertEquals(targetNode, footnoteSet.targetNode);
+        // initDeleteFootnoteSetTest(targetNode, flavor, result);
+        // assertThat(footnotes.targetNode, is(this.targetNode));
     }
 
-    @Test
-    public void testAdd() {
-        footnotes.add(this.flavor);
-        assertThat(footnotes.footnotes.size(), is(1));
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testAdd(String targetNode, String flavor, String result) {
+        DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
+        footnoteSet.add(flavor);
+        assertEquals(1, footnoteSet.footnotes.size());
     }
 
-    @Test
-    public void testToString() {
-        footnotes.add(this.flavor);
-        assertThat(footnotes.toString(), is(this.result));
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testToString(String targetNode, String flavor, String result) {
+        DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
+        footnoteSet.add(flavor);
+        assertEquals(result, footnoteSet.toString());
     }
 
 }
index 08f5c81..dd9675f 100644 (file)
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public class DeleteOperationTest {
     private String useOpId;
     private String xmlRootElementName;
@@ -41,7 +38,6 @@ public class DeleteOperationTest {
     private String pathParams;
     private String result;
 
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
             "/network/generic-vnfs/generic-vnf/{vnf-id}",
@@ -65,9 +61,8 @@ public class DeleteOperationTest {
         return Arrays.asList(inputs);
     }
 
-    public DeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+    public void initDeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
         String pathParams, String result) {
-        super();
         this.useOpId = useOpId;
         this.xmlRootElementName = xmlRootElementName;
         this.tag = tag;
@@ -76,13 +71,15 @@ public class DeleteOperationTest {
         this.result = result;
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
 
     }
 
-    @Test
-    public void testToString() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+        initDeleteOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
         DeleteOperation delete =
             new DeleteOperation(useOpId, xmlRootElementName, tag, path, pathParams);
         String modResult = delete.toString();
index 046f961..da2e271 100644 (file)
@@ -21,8 +21,8 @@
 package org.onap.aai.schemagen.genxsd;
 
 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.assertTrue;
 
 import com.google.common.collect.Multimap;
 
@@ -35,11 +35,10 @@ import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.edges.EdgeRule;
 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
@@ -49,12 +48,10 @@ import org.onap.aai.setup.SchemaConfigVersions;
 import org.onap.aai.setup.SchemaLocationsBean;
 import org.onap.aai.setup.SchemaVersion;
 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(
+@SpringJUnitConfig(
     classes = {SchemaConfigVersions.class, SchemaLocationsBean.class,
         TestUtilConfigTranslatorforEdges.class, EdgeIngestor.class})
 @TestPropertySource(
@@ -72,7 +69,7 @@ public class EdgeDescriptionTest {
     String toNode = "complex";
     SchemaVersion v10 = new SchemaVersion("v10");
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
         String json = "{" + "  \"rules\": [" + "    {" + "      \"from\": \"availability-zone\","
             + "      \"to\": \"complex\","
@@ -133,13 +130,13 @@ public class EdgeDescriptionTest {
         bw.close();
     }
 
-    @AfterClass
+    @AfterAll
     public static void tearDownAfterClass() throws Exception {
         File edges = new File(EDGEFILENAME);
         edges.delete();
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
 
     }
index aad62ce..5044166 100644 (file)
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Vector;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@RunWith(Parameterized.class)
 public class GetOperationTest {
     private static final Logger logger = LoggerFactory.getLogger("GetOperationTest.class");
     private String useOpId;
@@ -45,7 +42,6 @@ public class GetOperationTest {
     private String pathParams;
     private String result;
 
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
             "/network/generic-vnfs/generic-vnf/{vnf-id}",
@@ -67,9 +63,8 @@ public class GetOperationTest {
         return Arrays.asList(inputs);
     }
 
-    public GetOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+    public void initGetOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
         String pathParams, String result) {
-        super();
         this.useOpId = useOpId;
         this.xmlRootElementName = xmlRootElementName;
         this.tag = tag;
@@ -78,7 +73,7 @@ public class GetOperationTest {
         this.result = result;
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
         String container = "p-interfaces";
         String queryProps[] = {
@@ -91,8 +86,10 @@ public class GetOperationTest {
         GetOperation.addContainerProps(container, containerProps);
     }
 
-    @Test
-    public void testAddContainerProps() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testAddContainerProps(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+        initGetOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
         String container = this.xmlRootElementName;
         String prop = "        - name: " + container
             + "\n          in: query\n          description:\n          required: false\n          type: string";
@@ -106,8 +103,10 @@ public class GetOperationTest {
         assertThat(GetOperation.containers.get(container).get(0), is(prop));
     }
 
-    @Test
-    public void testToString() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+        initGetOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
         GetOperation get = new GetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
         String modResult = get.toString();
         assertThat(modResult, is(this.result));
index 46f90ce..4baf8f0 100644 (file)
@@ -21,7 +21,7 @@
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.BufferedWriter;
 import java.io.File;
@@ -32,10 +32,9 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.nodes.NodeIngestor;
 import org.onap.aai.schemagen.SwaggerGenerationConfiguration;
@@ -47,13 +46,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-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;
 import org.w3c.dom.Element;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(
+@SpringJUnitConfig(
     classes = {SchemaConfigVersions.class, SchemaLocationsBean.class,
         TestUtilConfigTranslatorforBusiness.class, EdgeIngestor.class, NodeIngestor.class,
         SwaggerGenerationConfiguration.class
@@ -73,19 +70,19 @@ public class HTMLfromOXMTest {
     @Autowired
     SchemaConfigVersions schemaConfigVersions;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpContext() throws Exception {
 
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setupBundleconfig() throws Exception {
         System.setProperty("AJSC_HOME", ".");
         System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
         System.setProperty("aai.service.name", SERVICE_NAME);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         setUp(0);
     }
index fc75150..c690ca8 100644 (file)
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Vector;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@RunWith(Parameterized.class)
 public class NodeGetOperationTest {
     private static final Logger logger = LoggerFactory.getLogger("NodeGetOperationTest.class");
     private String useOpId;
@@ -45,7 +42,6 @@ public class NodeGetOperationTest {
     private String pathParams;
     private String result;
 
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
             "/network/generic-vnfs/generic-vnf/{vnf-id}",
@@ -67,9 +63,8 @@ public class NodeGetOperationTest {
         return Arrays.asList(inputs);
     }
 
-    public NodeGetOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+    public void initNodeGetOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
         String pathParams, String result) {
-        super();
         this.useOpId = useOpId;
         this.xmlRootElementName = xmlRootElementName;
         this.tag = tag;
@@ -78,7 +73,7 @@ public class NodeGetOperationTest {
         this.result = result;
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
         String container = "p-interfaces";
         String queryProps[] = {
@@ -91,8 +86,10 @@ public class NodeGetOperationTest {
         NodeGetOperation.addContainerProps(container, containerProps);
     }
 
-    @Test
-    public void testAddContainerProps() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testAddContainerProps(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+        initNodeGetOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
         String container = this.xmlRootElementName;
         String prop = "        - name: " + container
             + "\n          in: query\n          description:\n          required: false\n          type: string";
@@ -109,8 +106,10 @@ public class NodeGetOperationTest {
             NodeGetOperation.containers.get(container).get(0), is(prop));
     }
 
-    @Test
-    public void testToString() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+        initNodeGetOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
         NodeGetOperation get =
             new NodeGetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
         String modResult = get.toString();
index d87bdf7..87e967e 100644 (file)
@@ -21,7 +21,7 @@
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.BufferedWriter;
 import java.io.File;
@@ -32,10 +32,9 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.nodes.NodeIngestor;
 import org.onap.aai.schemagen.SwaggerGenerationConfiguration;
@@ -47,13 +46,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-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;
 import org.w3c.dom.Element;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(
+@SpringJUnitConfig(
     classes = {SchemaConfigVersions.class, SchemaLocationsBean.class,
         TestUtilConfigTranslatorforEdges.class, EdgeIngestor.class, NodeIngestor.class,
         SwaggerGenerationConfiguration.class
@@ -74,7 +71,7 @@ public class NodesYAMLfromOXMTest {
     @Autowired
     SchemaConfigVersions schemaConfigVersions;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
 
         XSDElementTest x = new XSDElementTest();
@@ -90,7 +87,7 @@ public class NodesYAMLfromOXMTest {
 
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
 
         NodeGetOperation.checklist.clear();
index d939a74..3735636 100644 (file)
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.onap.aai.setup.SchemaVersion;
 
-@RunWith(Parameterized.class)
 public class PatchOperationTest {
     private String useOpId;
     private String xmlRootElementName;
@@ -43,7 +40,6 @@ public class PatchOperationTest {
     private String result;
     private static SchemaVersion v = new SchemaVersion("v16");
 
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
             "/network/generic-vnfs/generic-vnf/{vnf-id}",
@@ -67,9 +63,8 @@ public class PatchOperationTest {
         return Arrays.asList(inputs);
     }
 
-    public PatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+    public void initPatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
         String pathParams, String result) {
-        super();
         this.useOpId = useOpId;
         this.xmlRootElementName = xmlRootElementName;
         this.tag = tag;
@@ -78,13 +73,15 @@ public class PatchOperationTest {
         this.result = result;
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
 
     }
 
-    @Test
-    public void testToString() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+        initPatchOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
         PatchOperation patch =
             new PatchOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
         String modResult = patch.toString();
index c5b9408..c2ab69c 100644 (file)
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.onap.aai.setup.SchemaVersion;
 
-@RunWith(Parameterized.class)
 public class PutOperationTest {
     private String useOpId;
     private String xmlRootElementName;
@@ -43,7 +40,6 @@ public class PutOperationTest {
     private String result;
     private static SchemaVersion v = new SchemaVersion("v14");
 
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
             "/network/generic-vnfs/generic-vnf/{vnf-id}",
@@ -69,9 +65,8 @@ public class PutOperationTest {
         return Arrays.asList(inputs);
     }
 
-    public PutOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+    public void initPutOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
         String pathParams, String result) {
-        super();
         this.useOpId = useOpId;
         this.xmlRootElementName = xmlRootElementName;
         this.tag = tag;
@@ -80,13 +75,15 @@ public class PutOperationTest {
         this.result = result;
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
 
     }
 
-    @Test
-    public void testToString() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
+        initPutOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
         PutOperation put =
             new PutOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
         String modResult = put.toString();
index b955f96..637039f 100644 (file)
@@ -22,30 +22,27 @@ package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.schemagen.GenerateXsd;
 import org.onap.aai.setup.SchemaConfigVersions;
 import org.onap.aai.setup.SchemaVersion;
 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 = {SchemaConfigVersions.class, EdgeIngestor.class})
+@SpringJUnitConfig(classes = {SchemaConfigVersions.class, EdgeIngestor.class})
 @TestPropertySource(properties = {"schema.uri.base.path = /aai"})
-@Ignore("This test needs to get major rework done as it is written very poorly")
+@Disabled("This test needs to get major rework done as it is written very poorly")
 public class PutRelationPathSetTest {
     private static final String EDGEFILENAME =
         "src/test/resources/dbedgerules/EdgeDescriptionRules_test.json";
@@ -66,7 +63,7 @@ public class PutRelationPathSetTest {
     @Autowired
     EdgeIngestor edgeIngestor;
 
-    @Before
+    @BeforeEach
     public void setUpBeforeClass() throws Exception {
         v = schemaConfigVersions.getDefaultVersion();
 
@@ -139,7 +136,7 @@ public class PutRelationPathSetTest {
 
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
 
         DeleteOperation.deletePaths.put("/cloud-infrastructure/pservers/pserver/{hostname}",
@@ -167,7 +164,7 @@ public class PutRelationPathSetTest {
         PutRelationPathSet.add(opId, path);
     }
 
-    @AfterClass
+    @AfterAll
     public static void tearDownAfterClass() throws Exception {
         File edges = new File(EDGEFILENAME);
         edges.delete();
index 1442ba9..f2ce481 100644 (file)
@@ -23,11 +23,11 @@ package org.onap.aai.schemagen.genxsd;
 import static org.hamcrest.CoreMatchers.both;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsIn.in;
 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
 import static org.hamcrest.core.Every.everyItem;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.io.StringReader;
@@ -42,10 +42,10 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.commons.lang.StringUtils;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -65,11 +65,11 @@ public class XSDElementTest {
         return testXML;
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         setUp(0);
     }
index e750da2..2938b57 100644 (file)
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.HashMap;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.Element;
 
 public class XSDJavaTypeTest extends XSDElementTest {
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         super.setUp();
     }
index f04b351..7fff5fa 100644 (file)
@@ -21,9 +21,9 @@
 package org.onap.aai.schemagen.genxsd;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.Multimap;
 
@@ -38,10 +38,9 @@ import java.nio.file.Paths;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.edges.EdgeRule;
 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
@@ -55,14 +54,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-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;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(
+@SpringJUnitConfig(
     classes = {SchemaConfigVersions.class, SchemaLocationsBean.class,
         TestUtilConfigTranslatorforBusiness.class, EdgeIngestor.class, NodeIngestor.class,
         SwaggerGenerationConfiguration.class
@@ -90,14 +87,14 @@ public class YAMLfromOXMTest {
     @Autowired
     SchemaConfigVersions schemaConfigVersions;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpBeforeClass() throws Exception {
         System.setProperty("AJSC_HOME", ".");
         System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
         System.setProperty("aai.service.name", SERVICE_NAME);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         XSDElementTest x = new XSDElementTest();
         x.setUp();
@@ -230,7 +227,7 @@ public class YAMLfromOXMTest {
             e.printStackTrace();
         }
         boolean matchFound = fileContent.contains((YAMLRelationshipList()));
-        assertTrue("RelationshipListFormat:\n", matchFound);
+        assertTrue(matchFound, "RelationshipListFormat:\n");
     }
 
     @Test
index 2a39149..b0526e5 100644 (file)
@@ -26,13 +26,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public class ApiHttpVerbResponseTest {
     Api.HttpVerb.Response theResponse = null;
     String responseCode;
@@ -42,7 +39,6 @@ public class ApiHttpVerbResponseTest {
     /**
      * Parameters for the test cases all following same pattern.
      */
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"200", "OK", "Response{responseCode='200', description='OK'}"},
             {"400", "Bad Request", "Response{responseCode='400', description='Bad Request'}"},
@@ -56,8 +52,7 @@ public class ApiHttpVerbResponseTest {
     /**
      * Constructor for the test cases all following same pattern.
      */
-    public ApiHttpVerbResponseTest(String responseCode, String description, String result) {
-        super();
+    public void initApiHttpVerbResponseTest(String responseCode, String description, String result) {
         this.responseCode = responseCode;
         this.description = description;
         this.result = result;
@@ -66,7 +61,7 @@ public class ApiHttpVerbResponseTest {
     /**
      * Initialise the test object.
      */
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         theResponse = new Api.HttpVerb.Response();
     }
@@ -74,8 +69,10 @@ public class ApiHttpVerbResponseTest {
     /**
      * Perform the test on the test object.
      */
-    @Test
-    public void testApiHttpVerbResponse() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testApiHttpVerbResponse(String responseCode, String description, String result) {
+        initApiHttpVerbResponseTest(responseCode, description, result);
         theResponse.setResponseCode(this.responseCode);
         theResponse.setDescription(this.description);
         assertThat(theResponse.toString(), is(this.result));
index c714d82..3f3e804 100644 (file)
@@ -30,13 +30,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public class ApiHttpVerbTest {
     Api.HttpVerb theVerb = null;
     List<String> tags;
@@ -50,7 +47,6 @@ public class ApiHttpVerbTest {
     /**
      * Parameters for the test cases all following same pattern.
      */
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"tag1,tag2", "typeA", "summaryB", "operationC", "consumesD,consumesE",
             "producesF,producesG",
@@ -64,9 +60,8 @@ public class ApiHttpVerbTest {
     /**
      * Constructor for the test cases all following same pattern.
      */
-    public ApiHttpVerbTest(String tags, String type, String summary, String operationId,
+    public void initApiHttpVerbTest(String tags, String type, String summary, String operationId,
         String consumes, String produces, String result) {
-        super();
         this.tags = Arrays.asList(tags.split(","));
         this.type = type;
         this.summary = summary;
@@ -80,7 +75,7 @@ public class ApiHttpVerbTest {
     /**
      * Initialise the test object.
      */
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         theVerb = new Api.HttpVerb();
     }
@@ -88,8 +83,10 @@ public class ApiHttpVerbTest {
     /**
      * Perform the test on the test object.
      */
-    @Test
-    public void testApiHttpVerb() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testApiHttpVerb(String tags, String type, String summary, String operationId, String consumes, String produces, String result) {
+        initApiHttpVerbTest(tags, type, summary, operationId, consumes, produces, result);
         theVerb.setTags(this.tags);
         theVerb.setType(this.type);
         theVerb.setSummary(this.summary);
index fef3344..8b2e46f 100644 (file)
@@ -26,13 +26,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public class DefinitionPropertyTest {
     Definition.Property theProperty = null;
     String propertyName;
@@ -43,7 +40,6 @@ public class DefinitionPropertyTest {
     /**
      * Parameters for the test cases all following same pattern.
      */
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {
             {"name1", "type1", "ref1",
@@ -58,9 +54,8 @@ public class DefinitionPropertyTest {
     /**
      * Constructor for the test cases all following same pattern.
      */
-    public DefinitionPropertyTest(String propertyName, String propertyType,
+    public void initDefinitionPropertyTest(String propertyName, String propertyType,
         String propertyReference, String result) {
-        super();
         this.propertyName = propertyName;
         this.propertyType = propertyType;
         this.propertyReference = propertyReference;
@@ -70,7 +65,7 @@ public class DefinitionPropertyTest {
     /**
      * Initialise the test object.
      */
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         theProperty = new Definition.Property();
     }
@@ -78,8 +73,10 @@ public class DefinitionPropertyTest {
     /**
      * Perform the test on the test object.
      */
-    @Test
-    public void testDefinitionProperty() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testDefinitionProperty(String propertyName, String propertyType, String propertyReference, String result) {
+        initDefinitionPropertyTest(propertyName, propertyType, propertyReference, result);
         theProperty.setPropertyName(this.propertyName);
         theProperty.setPropertyType(this.propertyType);
         theProperty.setPropertyReference(this.propertyReference);
index 98169d8..fe3f8cd 100644 (file)
@@ -28,13 +28,10 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public class DefinitionTest {
     Definition theDefinition = null;
     String definitionName;
@@ -44,7 +41,6 @@ public class DefinitionTest {
     /**
      * Parameters for the test cases all following same pattern.
      */
-    @Parameters
     public static Collection<String[]> testConditions() {
         String inputs[][] = {{"name1", "desc1",
             "Definition{definitionName='name1', definitionDescription='desc1', propertyList=[]}"},
@@ -58,8 +54,7 @@ public class DefinitionTest {
     /**
      * Constructor for the test cases all following same pattern.
      */
-    public DefinitionTest(String definitionName, String definitionDescription, String result) {
-        super();
+    public void initDefinitionTest(String definitionName, String definitionDescription, String result) {
         this.definitionName = definitionName;
         this.definitionDescription = definitionDescription;
         this.result = result;
@@ -68,7 +63,7 @@ public class DefinitionTest {
     /**
      * Initialise the test object.
      */
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         theDefinition = new Definition();
     }
@@ -76,8 +71,10 @@ public class DefinitionTest {
     /**
      * Perform the test on the test object.
      */
-    @Test
-    public void testDefinitionProperty() {
+    @MethodSource("testConditions")
+    @ParameterizedTest
+    public void testDefinitionProperty(String definitionName, String definitionDescription, String result) {
+        initDefinitionTest(definitionName, definitionDescription, result);
         theDefinition.setDefinitionName(this.definitionName);
         theDefinition.setDefinitionDescription(this.definitionDescription);
 
index a5ef621..eaef1e0 100644 (file)
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-access</artifactId>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest-junit</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
         </dependency>
     </dependencies>
     <build>
index c687a58..49c3c33 100644 (file)
 
 package org.onap.aai.schemaservice;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
 
 import java.io.UnsupportedEncodingException;
 import java.util.Base64;
 import java.util.Collections;
 
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.schemaservice.config.PropertyPasswordConfiguration;
 import org.onap.aai.util.AAIConfig;
@@ -45,7 +44,6 @@ import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.web.client.RestTemplate;
 
 @SpringBootTest(
@@ -54,8 +52,6 @@ import org.springframework.web.client.RestTemplate;
 @TestPropertySource(locations = "classpath:application-test.properties")
 @ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
 @Import(SchemaServiceTestConfiguration.class)
-
-@RunWith(SpringRunner.class)
 public class SchemaServiceTest {
 
     private HttpHeaders headers;
@@ -72,14 +68,14 @@ public class SchemaServiceTest {
     @LocalServerPort
     protected int randomPort;
 
-    @BeforeClass
+    @BeforeAll
     public static void setupConfig() throws AAIException {
         System.setProperty("AJSC_HOME", "./");
         System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
         System.out.println("Current directory: " + System.getProperty("user.dir"));
     }
 
-    @Before
+    @BeforeEach
     public void setup() throws AAIException, UnsupportedEncodingException {
 
         AAIConfig.init();
index 938d509..e5a8632 100644 (file)
@@ -38,6 +38,7 @@ import org.springframework.boot.test.context.TestConfiguration;
 import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.core.env.Environment;
+import org.springframework.core.env.Profiles;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.client.ClientHttpResponse;
 import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
@@ -63,7 +64,7 @@ public class SchemaServiceTestConfiguration {
 
         RestTemplate restTemplate = null;
 
-        if (env.acceptsProfiles("one-way-ssl", "two-way-ssl")) {
+        if (env.acceptsProfiles(Profiles.of("one-way-ssl", "two-way-ssl"))) {
             char[] trustStorePassword =
                 env.getProperty("server.ssl.trust-store-password").toCharArray();
             char[] keyStorePassword =
@@ -73,7 +74,7 @@ public class SchemaServiceTestConfiguration {
             String trustStore = env.getProperty("server.ssl.trust-store");
             SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
 
-            if (env.acceptsProfiles("two-way-ssl")) {
+            if (env.acceptsProfiles(Profiles.of("two-way-ssl"))) {
                 sslContextBuilder = sslContextBuilder
                     .loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword);
             }
index a078d38..7588df7 100644 (file)
             <version>${project.version}</version>
         </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.jvnet.jaxb2_commons</groupId>
         <dependency>
             <groupId>com.googlecode.json-simple</groupId>
             <artifactId>json-simple</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>${commons.io.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
index 694f4b9..c09aae2 100644 (file)
@@ -20,7 +20,7 @@
 
 package org.onap.aai.schema;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.File;
 import java.io.FileReader;
@@ -37,7 +37,7 @@ import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.ParseException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class ValidateEdgeRulesTest {
 
index c228e77..60619f1 100644 (file)
@@ -20,8 +20,8 @@
 
 package org.onap.aai.schema;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.*;
 import java.nio.file.Path;
@@ -44,8 +44,8 @@ import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.ParseException;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.*;
 import org.xml.sax.SAXException;
 
@@ -472,7 +472,7 @@ public class ValidateOXMTest {
      * dependentOn relationship matches what is listed in the edge rules.
      *
      */
-    @Ignore
+    @Disabled
     @Test
     public void testSchemaValidationAgainstEdgeRules() throws XPathExpressionException, IOException,
         SAXException, ParserConfigurationException, ParseException {