From 434a3e74468d256e6096c6a1497fa38c3d647e2a Mon Sep 17 00:00:00 2001 From: "Matteo Franci a.k.a. Fugerit" Date: Mon, 17 Mar 2025 21:34:18 +0100 Subject: [PATCH] [fj-doc-base-yaml] migrate junit4 to junit5 #322 --- fj-doc-base-yaml/pom.xml | 4 +- .../base/facade/TestDocFacadeSourceYaml.java | 25 ++++++------ .../java/doc/yaml/parse/TestDocXmlToYaml.java | 14 +++---- .../java/doc/yaml/parse/TestDocYamlToXml.java | 10 ++--- .../java/doc/yaml/parse/TestYamlParser.java | 40 +++++++++---------- 5 files changed, 46 insertions(+), 47 deletions(-) diff --git a/fj-doc-base-yaml/pom.xml b/fj-doc-base-yaml/pom.xml index 1d7dab0ee..6c9c0520d 100644 --- a/fj-doc-base-yaml/pom.xml +++ b/fj-doc-base-yaml/pom.xml @@ -52,8 +52,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-api test diff --git a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/base/facade/TestDocFacadeSourceYaml.java b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/base/facade/TestDocFacadeSourceYaml.java index fad4cfd99..6b1eefe80 100644 --- a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/base/facade/TestDocFacadeSourceYaml.java +++ b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/base/facade/TestDocFacadeSourceYaml.java @@ -1,14 +1,13 @@ package test.org.fugerit.java.doc.base.facade; -import static org.junit.Assert.assertEquals; import org.fugerit.java.doc.base.facade.DocFacadeSource; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TestDocFacadeSourceYaml { +class TestDocFacadeSourceYaml { private static final Logger logger = LoggerFactory.getLogger( TestDocFacadeSourceYaml.class ); @@ -16,7 +15,7 @@ private boolean textSupportedParser( boolean expected, int sourceType ) { boolean supported; try { supported = DocFacadeSource.getInstance().isSourceSupported(sourceType); - assertEquals( "Failed doc parser supported check", expected , supported ); + Assertions.assertEquals( expected , supported ); return supported; } catch (Exception e) { String message = "Error : "+e; @@ -26,23 +25,23 @@ private boolean textSupportedParser( boolean expected, int sourceType ) { } @Test - public void testParserXml() { - Assert.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_XML ) ); + void testParserXml() { + Assertions.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_XML ) ); } @Test - public void textParserDefault() { - Assert.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_DEFAULT ) ); + void textParserDefault() { + Assertions.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_DEFAULT ) ); } @Test - public void testParserJson() { - Assert.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_JSON ) ); + void testParserJson() { + Assertions.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_JSON ) ); } @Test - public void testParserYaml() { - Assert.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_YAML ) ); + void testParserYaml() { + Assertions.assertTrue( this.textSupportedParser( true, DocFacadeSource.SOURCE_TYPE_YAML ) ); } } diff --git a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocXmlToYaml.java b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocXmlToYaml.java index c470a994a..ed79b4c81 100644 --- a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocXmlToYaml.java +++ b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocXmlToYaml.java @@ -8,8 +8,8 @@ import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.core.xml.dom.DOMIO; import org.fugerit.java.doc.yaml.parse.DocYamlToXml; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Element; @@ -17,7 +17,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -public class TestDocXmlToYaml { +class TestDocXmlToYaml { private static final Logger logger = LoggerFactory.getLogger( TestDocXmlToYaml.class ); @@ -34,13 +34,13 @@ private boolean worker( String path, DocYamlToXml converter ) { } @Test - public void test01() { - Assert.assertTrue( this.worker( "doc_test_01", new DocYamlToXml() ) ); + void test01() { + Assertions.assertTrue( this.worker( "doc_test_01", new DocYamlToXml() ) ); } @Test - public void test01Alt() { - Assert.assertTrue( this.worker( "doc_test_01", new DocYamlToXml( new ObjectMapper( new YAMLFactory() ) ) ) ); + void test01Alt() { + Assertions.assertTrue( this.worker( "doc_test_01", new DocYamlToXml( new ObjectMapper( new YAMLFactory() ) ) ) ); } } diff --git a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocYamlToXml.java b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocYamlToXml.java index f52b2a382..031bd3338 100644 --- a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocYamlToXml.java +++ b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestDocYamlToXml.java @@ -6,8 +6,8 @@ import org.fugerit.java.core.lang.helpers.ClassHelper; import org.fugerit.java.doc.json.parse.DocXmlToJson; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,7 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -public class TestDocYamlToXml { +class TestDocYamlToXml { private static final Logger logger = LoggerFactory.getLogger( TestDocYamlToXml.class ); @@ -36,8 +36,8 @@ private boolean worker( String path ) { } @Test - public void test01() { - Assert.assertTrue( this.worker( "doc_test_01" ) ); + void test01() { + Assertions.assertTrue( this.worker( "doc_test_01" ) ); } } diff --git a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestYamlParser.java b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestYamlParser.java index 63b09404c..87369b5b0 100644 --- a/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestYamlParser.java +++ b/fj-doc-base-yaml/src/test/java/test/org/fugerit/java/doc/yaml/parse/TestYamlParser.java @@ -16,18 +16,18 @@ import org.fugerit.java.doc.base.typehandler.markdown.SimpleMarkdownExtTypeHandler; import org.fugerit.java.doc.yaml.parse.DocJsonFacade; import org.fugerit.java.doc.yaml.parse.DocYamlParser; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TestYamlParser { +class TestYamlParser { - public static final boolean VALID = true; - public static final boolean NOT_VALID = false; + static final boolean VALID = true; + static final boolean NOT_VALID = false; - public static final boolean NO_EXCEPTION = false; - public static final boolean EXCEPTION = true; + static final boolean NO_EXCEPTION = false; + static final boolean EXCEPTION = true; private static final Logger logger = LoggerFactory.getLogger( TestYamlParser.class ); @@ -49,7 +49,7 @@ private boolean validateWorker( String path, boolean valid, boolean exception, b for ( String error : result.getInfoList() ) { logger.info( "Validation info {}", error ); } - Assert.assertEquals( "Validation result" , valid, result.isResultOk() ); + Assertions.assertEquals( valid, result.isResultOk() ); return result.isResultOk(); } } ); @@ -72,33 +72,33 @@ private boolean parseWorker( String path ) { } @Test - public void testParse01() { - Assert.assertTrue( this.parseWorker( "doc_test_01" ) ); + void testParse01() { + Assertions.assertTrue( this.parseWorker( "doc_test_01" ) ); } @Test - public void testValidateOk01() { - Assert.assertTrue( this.validateWorker( "doc_test_01", VALID, NO_EXCEPTION ) ); + void testValidateOk01() { + Assertions.assertTrue( this.validateWorker( "doc_test_01", VALID, NO_EXCEPTION ) ); } @Test - public void testValidateOk01ParseVersion() { - Assert.assertTrue( this.validateWorker( "doc_test_01", VALID, NO_EXCEPTION, true ) ); + void testValidateOk01ParseVersion() { + Assertions.assertTrue( this.validateWorker( "doc_test_01", VALID, NO_EXCEPTION, true ) ); } @Test - public void testValidateOk02ParseVersion() { - Assert.assertTrue( this.validateWorker( "doc_test_02", VALID, NO_EXCEPTION, true ) ); + void testValidateOk02ParseVersion() { + Assertions.assertTrue( this.validateWorker( "doc_test_02", VALID, NO_EXCEPTION, true ) ); } @Test - public void testValidateKo02() { - Assert.assertFalse( this.validateWorker( "doc_test_02_ko", NOT_VALID, NO_EXCEPTION ) ); + void testValidateKo02() { + Assertions.assertFalse( this.validateWorker( "doc_test_02_ko", NOT_VALID, NO_EXCEPTION ) ); } @Test - public void testFacade() { - Assert.assertNotNull( SafeFunction.get( () -> { + void testFacade() { + Assertions.assertNotNull( SafeFunction.get( () -> { try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( "sample/doc_test_01.yaml" ) ) ) { return DocJsonFacade.parse( reader );