Skip to content

[fj-doc-base-json] migrate junit4 to junit5 #331 #325

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-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,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,20 @@
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 TestDocFacadeSourceJson {
class TestDocFacadeSourceJson {

private static final Logger logger = LoggerFactory.getLogger( TestDocFacadeSourceJson.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 +24,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.assertFalse( this.textSupportedParser( false, DocFacadeSource.SOURCE_TYPE_YAML ) );
void testParserYaml() {
Assertions.assertFalse( this.textSupportedParser( false, DocFacadeSource.SOURCE_TYPE_YAML ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
import org.fugerit.java.doc.json.ng.DocJsonParserNG;
import org.fugerit.java.doc.json.ng.DocXmlToJsonNG;
import org.fugerit.java.doc.json.parse.DocJsonParser;
import org.junit.Assert;
import org.junit.Test;

import com.fasterxml.jackson.databind.JsonNode;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

@Slf4j
public class TestJsonParserNG {
class TestJsonParserNG {

private boolean parseWorker( String path, String checkInfoKey, String checkinfoValue ) {
return SafeFunction.get( () -> {
Expand All @@ -45,8 +45,8 @@ private boolean parseWorker( String path, String checkInfoKey, String checkinfoV
}

@Test
public void testParse01() {
Assert.assertTrue( this.parseWorker( "doc_test_01_ng", DocInfo.INFO_NAME_MARGINS, "10;10;10;30" ) );
void testParse01() {
Assertions.assertTrue( this.parseWorker( "doc_test_01_ng", DocInfo.INFO_NAME_MARGINS, "10;10;10;30" ) );
}

private boolean worker( String path ) {
Expand All @@ -64,8 +64,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" ) );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.core.xml.dom.DOMIO;
import org.fugerit.java.doc.json.parse.DocJsonToXml;
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;

public class TestDocJsonToXml {
class TestDocJsonToXml {

private static final Logger logger = LoggerFactory.getLogger( TestDocJsonToXml.class );

Expand All @@ -35,13 +35,13 @@ 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" ) );
}

@Test
public void testConvert() {
Assert.assertNotEquals( "" ,
void testConvert() {
Assertions.assertNotEquals( "" ,
SafeFunction.get( () -> {
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( "sample/doc_test_01.json" ) );
StringWriter writer = new StringWriter() ) {
Expand All @@ -53,8 +53,8 @@ public void testConvert() {
}

@Test
public void testFail01() {
Assert.assertThrows( Exception.class , () -> {
void testFail01() {
Assertions.assertThrows( Exception.class , () -> {
DocJsonToXml converter = new DocJsonToXml();
try ( InputStreamReader reader = new InputStreamReader(
ClassHelper.loadFromDefaultClassLoader( "sample/doc_test_fail_01.json" ) ) ) {
Expand All @@ -64,8 +64,8 @@ public void testFail01() {
}

@Test
public void testFail02() {
Assert.assertThrows( Exception.class , () -> {
void testFail02() {
Assertions.assertThrows( Exception.class , () -> {
DocJsonToXml converter = new DocJsonToXml();
try ( InputStreamReader reader = new InputStreamReader(
ClassHelper.loadFromDefaultClassLoader( "sample/doc_test_fail_02.json" ) ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import org.fugerit.java.core.function.SafeFunction;
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;

public class TestDocXmlToJson {
class TestDocXmlToJson {

private static final Logger logger = LoggerFactory.getLogger( TestDocXmlToJson.class );

Expand All @@ -32,8 +32,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 @@ -17,20 +17,20 @@
import org.fugerit.java.doc.json.parse.DocJsonFacade;
import org.fugerit.java.doc.json.parse.DocJsonParser;
import org.fugerit.java.doc.json.parse.DocObjectMapperHelper;
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.ObjectMapper;

public class TestJsonParser {
class TestJsonParser {

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( TestJsonParser.class );

Expand All @@ -52,7 +52,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 @@ -75,38 +75,38 @@ 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 testParse02() {
Assert.assertTrue( this.parseWorker( "doc_test_02" ) );
void testParse02() {
Assertions.assertTrue( this.parseWorker( "doc_test_02" ) );
}

@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(
void testFacade() {
Assertions.assertNotNull(
SafeFunction.get( () -> {
try ( InputStreamReader reader = new InputStreamReader(
ClassHelper.loadFromDefaultClassLoader( "sample/doc_test_01.json" ) ) ) {
Expand All @@ -117,10 +117,10 @@ public void testFacade() {
}

@Test
public void testHelper() {
Assert.assertTrue( DocObjectMapperHelper.isSpecialProperty( DocObjectMapperHelper.PROPERTY_TAG ) );
Assert.assertFalse( DocObjectMapperHelper.isSpecialProperty( "aaa" ) );
Assert.assertNotNull( new DocObjectMapperHelper( new ObjectMapper() ) );
void testHelper() {
Assertions.assertTrue( DocObjectMapperHelper.isSpecialProperty( DocObjectMapperHelper.PROPERTY_TAG ) );
Assertions.assertFalse( DocObjectMapperHelper.isSpecialProperty( "aaa" ) );
Assertions.assertNotNull( new DocObjectMapperHelper( new ObjectMapper() ) );
}

}
Loading