Skip to content

[fj-doc-lib-simpletable] migrate junit4 to junit5 #353 #356

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 26, 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-lib-simpletable/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
Expand Up @@ -19,10 +19,10 @@
import org.fugerit.java.doc.lib.simpletable.model.SimpleCell;
import org.fugerit.java.doc.lib.simpletable.model.SimpleRow;
import org.fugerit.java.doc.lib.simpletable.model.SimpleTable;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestSimpleTable {
class TestSimpleTable {

private void testTable( SimpleTable table, SimpleTableHelper helper ) {
table.addRow( helper.newHeaderRow( "H1", "H2" ) );
Expand All @@ -39,51 +39,51 @@ private void testTable( SimpleTable table, SimpleTableHelper helper ) {
SafeFunction.apply( () -> {
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) {
SimpleTableDocConfig.newConfigLatest().processSimpleTable( table , FreeMarkerHtmlTypeHandler.HANDLER, baos );
Assert.assertTrue( baos.toByteArray().length > 0 );
Assertions.assertTrue( baos.toByteArray().length > 0 );
}
} );
Assert.assertThrows( DocException.class , () -> {
Assertions.assertThrows( DocException.class , () -> {
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) {
SimpleTableDocConfig.newConfigLatest().processSimpleTable( table , new FailTypeHandler(), baos );
Assert.assertTrue( baos.toByteArray().length > 0 );
Assertions.assertTrue( baos.toByteArray().length > 0 );
}
} );
}

@Test
public void testHelper() {
void testHelper() {
Integer defaultBorder = 0;
SimpleTableHelper helper = SimpleTableFacade.newHelper().withDefaultBorderWidth( defaultBorder );
Assert.assertEquals( defaultBorder , helper.getDefaultBorderWidth() );
Assertions.assertEquals( defaultBorder , helper.getDefaultBorderWidth() );
List<Integer> lcw = new ArrayList<Integer>();
Assert.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( lcw ) );
Assert.assertThrows( ConfigRuntimeException.class, () -> helper.newTable() );
Assertions.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( lcw ) );
Assertions.assertThrows( ConfigRuntimeException.class, () -> helper.newTable() );
List<Integer> colWidths = null;
Assert.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( colWidths ) );
Assertions.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( colWidths ) );
Integer[] colWidthsA = null;
Assert.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( colWidthsA ) );
Assertions.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( colWidthsA ) );
Integer[] colWidths50 = { 20, 30 };
Assert.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( colWidths50 ) );
Assertions.assertThrows( ConfigRuntimeException.class, () -> helper.newTable( colWidths50 ) );
// new table ok
Assert.assertNotNull( helper.newTableSingleColumn() );
Assertions.assertNotNull( helper.newTableSingleColumn() );
SimpleTable table = helper.newTable( 50, 50 );
this.testTable(table, helper);
}

@Test
public void testFacade() {
Assert.assertNotNull( SimpleTableFacade.newTable( 100 ) );
Assert.assertNotNull( SimpleTableFacade.newTableSingleColumn() );
void testFacade() {
Assertions.assertNotNull( SimpleTableFacade.newTable( 100 ) );
Assertions.assertNotNull( SimpleTableFacade.newTableSingleColumn() );
List<Integer> colW = new ArrayList<>();
colW.add( 100 );
Assert.assertNotNull( SimpleTableFacade.newTable( colW ) );
Assertions.assertNotNull( SimpleTableFacade.newTable( colW ) );
}

@Test
public void testCell() {
void testCell() {
SimpleCell cell = new SimpleCell( "test", 10 ).bold().bolditalic().italic().left().rigt().underline();
cell.setContent( "aaaa" );
Assert.assertNotNull( SimpleCell.newCell( "bbb" ) );
Assertions.assertNotNull( SimpleCell.newCell( "bbb" ) );
SimpleRow row = new SimpleRow();
row.addCell( "cccc" );
row.setHead( BooleanUtils.BOOLEAN_TRUE );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
import org.fugerit.java.core.cfg.ConfigException;
import org.fugerit.java.doc.freemarker.config.FreeMarkerConfigStep;
import org.fugerit.java.doc.lib.simpletable.SimpleTableDocConfig;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import test.org.fugerit.java.BasicTest;

public class TestSimpleTableConfig extends BasicTest {
class TestSimpleTableConfig extends BasicTest {

@Test
public void newConfigLegacy() {
void newConfigLegacy() {
try {
SimpleTableDocConfig config = SimpleTableDocConfig.newConfig();
Assert.assertNotNull( config );
Assertions.assertNotNull( config );
} catch (ConfigException e) {
this.failEx( e );
}
}

@Test
public void newConfigLatest() {
void newConfigLatest() {
try {
SimpleTableDocConfig config = SimpleTableDocConfig.newConfigLatest();
Assert.assertNotNull( config );
Assertions.assertNotNull( config );
} catch (ConfigException e) {
this.failEx( e );
}
}

@Test
public void newConfigCustom() {
void newConfigCustom() {
try {
SimpleTableDocConfig config = SimpleTableDocConfig.newConfig( FreeMarkerConfigStep.ATT_FREEMARKER_CONFIG_KEY_VERSION_2_3_31 );
Assert.assertNotNull( config );
Assert.assertNotNull( config.getConfig() );
Assertions.assertNotNull( config );
Assertions.assertNotNull( config.getConfig() );
} catch (ConfigException e) {
this.failEx( e );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package test.org.fugerit.java.doc.lib.simpletable;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;

import org.fugerit.java.doc.lib.simpletable.SimpleTableFacade;
import org.fugerit.java.doc.lib.simpletable.SimpleTableHelper;
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 TestSimpleTableHelperColumns {
class TestSimpleTableHelperColumns {

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

Expand All @@ -25,23 +25,23 @@ private boolean test( int columnNumber ) {
size+= current;
}
logger.info( "Total size is {}", size );
assertEquals( "Wrong columns total size", 100 , size );
assertEquals( 100 , size );
return 100 == size;
}

@Test
public void columns_12() {
Assert.assertTrue( this.test( 12 ) );
void columns_12() {
Assertions.assertTrue( this.test( 12 ) );
}

@Test
public void columns_10() {
Assert.assertTrue( this.test( 10 ) );
void columns_10() {
Assertions.assertTrue( this.test( 10 ) );
}

@Test
public void columns_8() {
Assert.assertTrue( this.test( 8 ) );
void columns_8() {
Assertions.assertTrue( this.test( 8 ) );
}

}
Loading