Skip to content

[fj-doc-base-yaml] migrate junit4 to junit5 #322 #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fj-doc-base-yaml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
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 );

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;
Expand All @@ -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 ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
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;

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 );

Expand All @@ -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() ) ) ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

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;

import com.fasterxml.jackson.databind.JsonNode;
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 );

Expand All @@ -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" ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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();
}
} );
Expand All @@ -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 );
Expand Down
Loading