Migrate Junit4 to Junit5 04/128504/2
authorvasraz <vasyl.razinkov@est.tech>
Tue, 12 Apr 2022 17:44:00 +0000 (18:44 +0100)
committerVasyl Razinkov <vasyl.razinkov@est.tech>
Wed, 13 Apr 2022 09:46:37 +0000 (09:46 +0000)
Remove Junit4 dependency

Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: I9b7965537f55fe479f5e17b6e3ec02f8ff5d93b3
Issue-ID: SDC-3963

19 files changed:
jtosca/pom.xml
jtosca/src/test/java/org/onap/sdc/toscaparser/api/JToscaImportTest.java
jtosca/src/test/java/org/onap/sdc/toscaparser/api/JToscaMetadataParse.java
jtosca/src/test/java/org/onap/sdc/toscaparser/api/elements/CalculatePropertyByPathTest.java
jtosca/src/test/java/org/onap/sdc/toscaparser/api/elements/EntityTypeTest.java
jtosca/src/test/java/org/onap/sdc/toscaparser/api/functions/GetInputTest.java
pom.xml
sdc-tosca/pom.xml
sdc-tosca/src/test/java/org/onap/sdc/impl/CapReqWithSameNamesTest.java
sdc-tosca/src/test/java/org/onap/sdc/impl/GetCvfcWithVfcTest.java
sdc-tosca/src/test/java/org/onap/sdc/impl/GetEntityPortMirroringTest.java
sdc-tosca/src/test/java/org/onap/sdc/impl/GetEntityTest.java
sdc-tosca/src/test/java/org/onap/sdc/impl/GetForwardingPathTest.java
sdc-tosca/src/test/java/org/onap/sdc/impl/GetVfModulesWithMembersTest.java
sdc-tosca/src/test/java/org/onap/sdc/impl/ToscaParserDataTypeTest.java
sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/elements/EntityDetailsFactoryTest.java
sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java
sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/elements/queries/TopologyTemplateQueryTest.java
sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/impl/ToscaParserNodeTemplateMockTest.java

index d897875..0aeffd4 100644 (file)
             <artifactId>junit-jupiter</artifactId>
             <scope>test</scope>
         </dependency>
-        <!-- Enables any legacy JUnit 3 and JUnit 4 tests you may have. Not needed for JUnit 5 tests. -->
-        <dependency>
-            <groupId>org.junit.vintage</groupId>
-            <artifactId>junit-vintage-engine</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <reporting>
index 5876ac7..80faa3a 100644 (file)
  */
 package org.onap.sdc.toscaparser.api;
 
-import org.junit.Test;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.toscaparser.api.common.JToscaException;
 import org.onap.sdc.toscaparser.api.elements.DataType;
 import org.onap.sdc.toscaparser.api.elements.PropertyDef;
@@ -28,25 +45,16 @@ import org.onap.sdc.toscaparser.api.parameters.Annotation;
 import org.onap.sdc.toscaparser.api.parameters.Input;
 import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
 
-import java.io.File;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.*;
-
 public class JToscaImportTest {
 
     @Test
     public void testNoMissingTypeValidationError() throws JToscaException {
         String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
-                .getFile();
+            .getFile();
         File file = new File(fileStr);
         new ToscaTemplate(file.getAbsolutePath(), null, true, null);
         List<String> missingTypeErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
-                .filter(s -> s.contains("JE136")).collect(Collectors.toList());
+            .filter(s -> s.contains("JE136")).collect(Collectors.toList());
         assertEquals(0, missingTypeErrors.size());
     }
 
@@ -55,7 +63,7 @@ public class JToscaImportTest {
         Exception jte = null;
         try {
             String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
-                    .getFile();
+                .getFile();
             File file = new File(fileStr);
             new ToscaTemplate(file.getAbsolutePath(), null, true, null);
         } catch (Exception e) {
@@ -76,7 +84,7 @@ public class JToscaImportTest {
             File file = new File(fileStr);
             new ToscaTemplate(file.getAbsolutePath(), null, true, null);
             List<String> invalidImportErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
-                    .filter(s -> s.contains("JE195")).collect(Collectors.toList());
+                .filter(s -> s.contains("JE195")).collect(Collectors.toList());
             assertEquals(0, invalidImportErrors.size());
         }
     }
@@ -200,7 +208,7 @@ public class JToscaImportTest {
 
     private void validateInputsAnnotations(List<Input> inputs) {
         List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null)
-                .collect(Collectors.toList());
+            .collect(Collectors.toList());
         assertTrue(!inputs.isEmpty());
         inputsWithAnnotations.stream().forEach(i -> validateAnnotations(i));
     }
@@ -213,7 +221,7 @@ public class JToscaImportTest {
         assertEquals(annotation.getType().toLowerCase(), "org.openecomp.annotations.source");
         assertNotNull(annotation.getProperties());
         Optional<Property> source_type = annotation.getProperties().stream()
-                .filter(p -> p.getName().equals("source_type")).findFirst();
+            .filter(p -> p.getName().equals("source_type")).findFirst();
         assertTrue(source_type.isPresent());
         assertEquals(source_type.get().getValue(), "HEAT");
     }
@@ -260,8 +268,10 @@ public class JToscaImportTest {
                 assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST));
                 assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1));
 
-                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1), notNullValue());
-                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2), notNullValue());
+                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1),
+                    notNullValue());
+                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2),
+                    notNullValue());
                 assertThat(toscaTemplate.toString(), containsString(TEST_DATATYPE_TOSTRING));
             }
         }
@@ -300,8 +310,10 @@ public class JToscaImportTest {
                 assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST));
                 assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1));
 
-                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1), notNullValue());
-                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2), notNullValue());
+                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1),
+                    notNullValue());
+                assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2),
+                    notNullValue());
                 assertThat(toscaTemplate.toString(), containsString(TEST_DATATYPE_TOSTRING));
             }
         }
index 2ec41b2..a61fa42 100644 (file)
@@ -23,18 +23,17 @@ package org.onap.sdc.toscaparser.api;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedHashMap;
-
 import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.toscaparser.api.common.JToscaException;
 import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
 import org.onap.sdc.toscaparser.api.utils.JToscaErrorCodes;
@@ -120,7 +119,7 @@ public class JToscaMetadataParse {
 
     private File loadCsar(final String csarFilePath) {
         final URL resourceUrl = JToscaMetadataParse.class.getClassLoader().getResource(csarFilePath);
-        assertNotNull(String.format("Could not load CSAR file '%s'", csarFilePath), resourceUrl);
+        assertNotNull(resourceUrl, String.format("Could not load CSAR file '%s'", csarFilePath));
 
         return new File(resourceUrl.getFile());
     }
index fd84d6e..b1588a0 100644 (file)
@@ -20,8 +20,8 @@
 
 package org.onap.sdc.toscaparser.api.elements;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.toscaparser.api.JToscaImportTest;
 import org.onap.sdc.toscaparser.api.NodeTemplate;
 import org.onap.sdc.toscaparser.api.Property;
@@ -32,13 +32,13 @@ import java.io.File;
 import java.net.URL;
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class CalculatePropertyByPathTest {
     private static ToscaTemplate toscaTemplate;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() throws JToscaException {
         URL scarUrl = JToscaImportTest.class.getClassLoader().getResource("csars/service-NetworkCloudVnfServiceMock-csar.csar");
         if (scarUrl != null) {
index d65de28..bef51ab 100644 (file)
 
 package org.onap.sdc.toscaparser.api.elements;
 
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class EntityTypeTest {
 
@@ -67,7 +67,7 @@ public class EntityTypeTest {
 
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         EntityType.TOSCA_DEF = (LinkedHashMap<String, Object>) origMap;
     }
index 98e5102..bd9c840 100644 (file)
  */
 package org.onap.sdc.toscaparser.api.functions;
 
-import org.junit.Test;
-import org.onap.sdc.toscaparser.api.*;
-import org.onap.sdc.toscaparser.api.common.JToscaException;
-import org.onap.sdc.toscaparser.api.elements.constraints.Schema;
-import org.onap.sdc.toscaparser.api.parameters.Input;
-import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.toscaparser.api.JToscaImportTest;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.onap.sdc.toscaparser.api.common.JToscaException;
+import org.onap.sdc.toscaparser.api.elements.constraints.Schema;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
 
 public class GetInputTest {
 
diff --git a/pom.xml b/pom.xml
index 7e330c8..2a5bcb2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                 <artifactId>junit-jupiter</artifactId>
                 <version>${junitJupiter.version}</version>
             </dependency>
-            <!--JUnit Jupiter Engine to depend on the JUnit4 engine and JUnit 4 API  -->
-            <dependency>
-                <groupId>org.junit.vintage</groupId>
-                <artifactId>junit-vintage-engine</artifactId>
-                <version>${junitJupiter.version}</version>
-            </dependency>
             <dependency>
                 <groupId>org.mockito</groupId>
                 <artifactId>mockito-junit-jupiter</artifactId>
index 18dd63f..4ce2910 100644 (file)
 
         <!-- TEST -->
         <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <version>1.10.19</version>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
             <scope>test</scope>
         </dependency>
+
         <!-- Provides everything you need to write JUnit 5 Jupiter tests. -->
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter</artifactId>
             <scope>test</scope>
         </dependency>
-        <!-- Enables any legacy JUnit 3 and JUnit 4 tests you may have. Not needed for JUnit 5 tests. -->
-        <dependency>
-            <groupId>org.junit.vintage</groupId>
-            <artifactId>junit-vintage-engine</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <reporting>
index 4203293..2a1a8c5 100644 (file)
@@ -20,8 +20,8 @@
 
 package org.onap.sdc.impl;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
@@ -34,13 +34,13 @@ import org.onap.sdc.toscaparser.api.RequirementAssignment;
 import java.net.URL;
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class CapReqWithSameNamesTest {
 
     private static ISdcCsarHelper helper = null;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() {
         try {
             URL resource = GetEntityPortMirroringTest.class.getClassLoader()
index 0fe75e2..b657577 100644 (file)
  * ============LICENSE_END=========================================================
  */
 package org.onap.sdc.impl;
-import org.junit.Test;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
@@ -26,14 +34,9 @@ import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.net.URL;
-import java.util.*;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.assertj.core.api.Assertions.assertThat;
-
 
 public class GetCvfcWithVfcTest {
+
     private static final String SERVICE_WITH_SINGLE_VF_CSAR = "csars/service-JennyVtsbcVlanSvc-csar.csar";
     private static final String SERVICE_WITH_DOUBLE_VF_CSAR = "csars/service-Metaswitch1-csar.csar";
     private static final String ABSTRACT_RTP_MSC = "abstract_rtp_msc";
@@ -45,7 +48,7 @@ public class GetCvfcWithVfcTest {
     private ISdcCsarHelper helper;
     private static Logger log = LoggerFactory.getLogger(GetCvfcWithVfcTest.class.getName());
 
-    public  void setUp(String path) {
+    public void setUp(String path) {
         try {
             URL resource = GetCvfcWithVfcTest.class.getClassLoader().getResource(path);
             if (resource != null) {
@@ -58,7 +61,7 @@ public class GetCvfcWithVfcTest {
     }
 
     @Test
-    public void getCvfcsWithVfcsFromServiceWithSingleVfTest(){
+    public void getCvfcsWithVfcsFromServiceWithSingleVfTest() {
         setUp(SERVICE_WITH_SINGLE_VF_CSAR);
         List<IEntityDetails> entities = helper.getVFModule();
         List<String> actualMembersList = newArrayList();
@@ -69,7 +72,7 @@ public class GetCvfcWithVfcTest {
     }
 
     @Test
-    public void getCvfcsWithVfcsFromVfiSingleVfTest(){
+    public void getCvfcsWithVfcsFromVfiSingleVfTest() {
         setUp(SERVICE_WITH_SINGLE_VF_CSAR);
         List<IEntityDetails> entities = helper.getVFModule("05e77410-a1d8-44fe-8440-b9410c8f98ee");
         List<String> actualMembersList = newArrayList();
@@ -80,7 +83,7 @@ public class GetCvfcWithVfcTest {
     }
 
     @Test
-    public void getCvfcsWithVfcsFromServiceWithDuplicateVfTest(){
+    public void getCvfcsWithVfcsFromServiceWithDuplicateVfTest() {
         setUp(SERVICE_WITH_DOUBLE_VF_CSAR);
         List<IEntityDetails> entities = helper.getVFModule();
         List<String> actualMembersList = newArrayList();
@@ -96,7 +99,7 @@ public class GetCvfcWithVfcTest {
 
 
     @Test
-    public void getCvfcsWithVfcsFromVfiOnServiceWithDuplicateVfTest(){
+    public void getCvfcsWithVfcsFromVfiOnServiceWithDuplicateVfTest() {
         setUp(SERVICE_WITH_DOUBLE_VF_CSAR);
         List<IEntityDetails> entities = helper.getVFModule("2b5f00de-8816-465c-b7bc-c36e26775e1e");
         List<String> actualMembersList = newArrayList();
index 33e130e..3f4e720 100644 (file)
@@ -20,8 +20,8 @@
 
 package org.onap.sdc.impl;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
@@ -38,8 +38,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class GetEntityPortMirroringTest {
 
@@ -47,7 +47,7 @@ public class GetEntityPortMirroringTest {
     private final static String cap1 = "radcomfnvlbavf11_3_3vepdg0.abstract_vlbagentbase_eph_aff.port_mirroring_vlbagentbase_eph_aff_vlbagentbase_eph_aff_int_pktmirror_1_port";
     private static ISdcCsarHelper helper = null;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() {
         try {
             URL resource = GetEntityPortMirroringTest.class.getClassLoader()
index 327ab68..ed889e7 100644 (file)
@@ -20,8 +20,8 @@
 
 package org.onap.sdc.impl;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
@@ -37,15 +37,15 @@ import org.onap.sdc.toscaparser.api.Property;
 import java.net.URL;
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class GetEntityTest {
 
     private static ISdcCsarHelper helper = null;
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() {
         try {
             URL resource = GetEntityTest.class.getClassLoader().getResource("csars/service-JennyVtsbcVlanSvc-csar.csar");
index 6c910e6..70410da 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.onap.sdc.impl;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
index 55bff57..e8151ab 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.onap.sdc.impl;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
index aed9445..142c18b 100644 (file)
@@ -19,8 +19,8 @@
 
 package org.onap.sdc.impl;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
@@ -32,7 +32,7 @@ import java.net.URL;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.core.IsNull.notNullValue;
 
@@ -48,7 +48,7 @@ public class ToscaParserDataTypeTest {
     private static final String TEST_DATATYPE_PROPERTY_TYPE = "type";
     private static final String TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA = "entry_schema";
 
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() {
         try {
             URL resource = GetEntityPortMirroringTest.class.getClassLoader()
index f33e1a7..0d0119f 100644 (file)
 
 package org.onap.sdc.tosca.parser.elements;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.when;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
 import org.onap.sdc.toscaparser.api.Group;
 import org.onap.sdc.toscaparser.api.NodeTemplate;
 import org.onap.sdc.toscaparser.api.Policy;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class EntityDetailsFactoryTest {
 
     @Mock
@@ -112,9 +113,11 @@ public class EntityDetailsFactoryTest {
         assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, null));
     }
 
-    @Test(expected = ClassCastException.class)
+    @Test
     public void createWrongEntityDetails() {
-        EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, group);
+        assertThrows(ClassCastException.class, () -> {
+            EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, group);
+        });
     }
 
 
index df8be5b..afa1c64 100644 (file)
 
 package org.onap.sdc.tosca.parser.elements.queries;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
 import org.onap.sdc.toscaparser.api.elements.Metadata;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.eq;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class EntityQueryTest {
     @Mock
     private Metadata metadata;
index 5a30255..018675a 100644 (file)
 
 package org.onap.sdc.tosca.parser.elements.queries;
 
-import static org.junit.Assert.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.when;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.sdc.tosca.parser.enums.SdcTypes;
 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
 import org.onap.sdc.toscaparser.api.NodeTemplate;
 import org.onap.sdc.toscaparser.api.elements.Metadata;
 
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class TopologyTemplateQueryTest {
 
     @Mock
@@ -42,10 +43,11 @@ public class TopologyTemplateQueryTest {
     @Mock
     private NodeTemplate nodeTemplate;
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void objectIsNotTopologyTemplate() {
-        TopologyTemplateQuery.newBuilder(SdcTypes.CP)
-            .build();
+        assertThrows(IllegalArgumentException.class, () -> {
+            TopologyTemplateQuery.newBuilder(SdcTypes.CP).build();
+        });
     }
 
     @Test
@@ -53,7 +55,6 @@ public class TopologyTemplateQueryTest {
         TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
             .build();
         when(nodeTemplate.getMetaData()).thenReturn(metadata);
-        when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
         when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.SERVICE.getValue());
         assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
     }
@@ -134,7 +135,6 @@ public class TopologyTemplateQueryTest {
             .build();
         when(nodeTemplate.getMetaData()).thenReturn(metadata);
         when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue());
-        when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
         assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
     }
 
index ada63d4..e58d863 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
 package org.onap.sdc.tosca.parser.impl;
 
+
 import org.apache.commons.lang3.StringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.enums.PropertySchemaType;
 import org.onap.sdc.tosca.parser.utils.PropertyUtils;
@@ -37,21 +39,20 @@ import org.onap.sdc.toscaparser.api.elements.Metadata;
 import java.util.LinkedHashMap;
 import java.util.NoSuchElementException;
 
-import static org.junit.Assert.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.when;
 
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class ToscaParserNodeTemplateMockTest {
+
     @Mock
     private NodeTemplate nodeTemplate;
-
     @Mock
     private Metadata metadata;
-
     @Mock
     private ToscaTemplate toscaTemplate;
-
     @Mock
     private Property property;
 
@@ -60,12 +61,13 @@ public class ToscaParserNodeTemplateMockTest {
     private static final String dataTypeD = String.format(".%s.ddd", PropertySchemaType.DATATYPE.getSchemaTypeName());
     private static final String dataTypeR = String.format(".%s.rrr", PropertySchemaType.DATATYPE.getSchemaTypeName());
 
-    @Before
-    public void setUp() {
-        when(property.getType()).thenReturn(dataTypeA);
+    @BeforeEach
+    public void setUp(TestInfo info) {
+        if (!info.getDisplayName().equals("verifyNodeTypeIsNotSupported()")) {
+            when(property.getType()).thenReturn(dataTypeA);
+        }
     }
 
-
     @Test
     public void verifyCorrectPropertyPath() {
         String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
@@ -74,9 +76,9 @@ public class ToscaParserNodeTemplateMockTest {
         LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "q", PropertySchemaType.STRING.getSchemaTypeName());
 
         when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp)
-                .thenReturn(cProp)
-                .thenReturn(dProp);
+            .thenReturn(bProp)
+            .thenReturn(cProp)
+            .thenReturn(dProp);
 
         assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
     }
@@ -86,12 +88,13 @@ public class ToscaParserNodeTemplateMockTest {
         String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
         LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
         LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName());
-        LinkedHashMap<String, Object> dProp = fillDataTypeEntry(PropertySchemaType.MAP.getSchemaTypeName(), "q", PropertySchemaType.STRING.getSchemaTypeName());
+        LinkedHashMap<String, Object> dProp = fillDataTypeEntry(PropertySchemaType.MAP.getSchemaTypeName(), "q",
+            PropertySchemaType.STRING.getSchemaTypeName());
 
         when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp)
-                .thenReturn(cProp)
-                .thenReturn(dProp);
+            .thenReturn(bProp)
+            .thenReturn(cProp)
+            .thenReturn(dProp);
 
         assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
     }
@@ -103,8 +106,8 @@ public class ToscaParserNodeTemplateMockTest {
         LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName());
 
         when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp)
-                .thenReturn(cProp);
+            .thenReturn(bProp)
+            .thenReturn(cProp);
 
         assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
     }
@@ -118,9 +121,9 @@ public class ToscaParserNodeTemplateMockTest {
         LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), dataTypeR);
 
         when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp)
-                .thenReturn(cProp)
-                .thenReturn(dProp);
+            .thenReturn(bProp)
+            .thenReturn(cProp)
+            .thenReturn(dProp);
 
         assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
     }
@@ -130,12 +133,13 @@ public class ToscaParserNodeTemplateMockTest {
         String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "m").split("#");
         LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
         LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD);
-        LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), PropertySchemaType.INTEGER.getSchemaTypeName());
+        LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(),
+            PropertySchemaType.INTEGER.getSchemaTypeName());
 
         when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp)
-                .thenReturn(cProp)
-                .thenReturn(dProp);
+            .thenReturn(bProp)
+            .thenReturn(cProp)
+            .thenReturn(dProp);
 
         assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
     }
@@ -147,33 +151,36 @@ public class ToscaParserNodeTemplateMockTest {
         LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName());
 
         when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp)
-                .thenReturn(dProp);
+            .thenReturn(bProp)
+            .thenReturn(dProp);
 
         assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
     }
 
-    @Test(expected = NoSuchElementException.class)
+    @Test
     public void propertyPathIsRejectedAsLongerThanExpected() {
         String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
         LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
         LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName());
 
         when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp)
-                .thenReturn(dProp);
+            .thenReturn(bProp)
+            .thenReturn(dProp);
 
-        PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property);
+        assertThrows(NoSuchElementException.class, () -> {
+            PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property);
+        });
     }
 
-    @Test(expected = NoSuchElementException.class)
+    @Test
     public void propertyPathIsRejectedAsPropertyIsNotFound() {
         String[] path = String.format("%s#%s", "x", "y").split("#");
         LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "t", dataTypeB);
-        when(nodeTemplate.getCustomDef())
-                .thenReturn(bProp);
+        when(nodeTemplate.getCustomDef()).thenReturn(bProp);
 
-        assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+        assertThrows(NoSuchElementException.class, () -> {
+            assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+        });
     }
 
     @Test
@@ -201,17 +208,16 @@ public class ToscaParserNodeTemplateMockTest {
         PropertySchemaType propertySchemaType = PropertySchemaType.getEnumByValue(type);
 
         if (!StringUtils.isEmpty(entrySchemaType) &&
-                (propertySchemaType.getSchemaTypeComplexity() == PropertySchemaType.PropertySchemaComplexity.Complex)) {
+            (propertySchemaType.getSchemaTypeComplexity() == PropertySchemaType.PropertySchemaComplexity.Complex)) {
             LinkedHashMap<String, Object> entry_schema = new LinkedHashMap<>();
             entry_schema.put(SdcPropertyNames.PROPERTY_NAME_TYPE, entrySchemaType);
             property.put(SdcPropertyNames.PROPERTY_NAME_ENTRY_SCHEMA, entry_schema);
         }
         properties.put(propertyName, property);
-        dataType.put(SdcPropertyNames.PROPERTY_NAME_PROPERTIES,  properties);
+        dataType.put(SdcPropertyNames.PROPERTY_NAME_PROPERTIES, properties);
         dataTypes.put(dataTypeName, dataType);
         return dataTypes;
     }
 
 
-
 }