Skip to content

Commit

Permalink
Test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Aug 19, 2024
1 parent b6fbe80 commit f0e6283
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public void testDocFacade() throws Exception {
DocHandlerFactory.register( new FactoryCatalog() );
Assert.assertFalse( facade.listHandlersForType( SimpleMarkdownBasicTypeHandler.HANDLER.getType() ).isEmpty() );
facade.logHandlersInfo();
// handler not found
// findHandlerRequired
Assert.assertNotNull( facade.findHandlerRequired( DocConfig.TYPE_MD ) );
Assert.assertThrows( ConfigRuntimeException.class, () -> facade.findHandlerRequired( "not-found" ) );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Response document( GenerateInput input) {
} );
}

private void addRow( SimpleTable simpleTableModel, int count, String level, String message ) {
public static void addRow( SimpleTable simpleTableModel, int count, String level, String message ) {
SimpleRow errorRow = new SimpleRow();
if ( count > 0 ) {
errorRow.addCell( String.valueOf( count ) );
Expand Down Expand Up @@ -89,14 +89,14 @@ public Response validate(GenerateInput input) {
DocValidationResult result = parser.validateResult(reader);
int count = 1;
for (String message : result.getErrorList()) {
this.addRow(simpleTableModel, count, "error", message);
addRow(simpleTableModel, count, "error", message);
count++;
}
for (String message : result.getInfoList()) {
this.addRow(simpleTableModel, count, "info", message);
addRow(simpleTableModel, count, "info", message);
count++;
}
this.addRow(simpleTableModel, 0, "result",
addRow(simpleTableModel, 0, "result",
"Document valid? : " + (Result.RESULT_CODE_OK == result.getResultCode()));
SimpleTableDocConfig docConfig = SimpleTableDocConfig.newConfig();
docConfig.processSimpleTable(simpleTableModel, handler, buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.fugerit.java.core.function.SafeFunction;
import org.fugerit.java.core.io.StreamIO;
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.doc.lib.simpletable.SimpleTableFacade;
import org.fugerit.java.doc.lib.simpletable.model.SimpleTable;
import org.fugerit.java.doc.playground.doc.GenerateRest;
import org.junit.Assert;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;
Expand All @@ -16,6 +20,13 @@
@Slf4j
class GenerateRestTest {

@Test
void testAddRow() {
SimpleTable simpleTable = SimpleTableFacade.newTable( 100 );
GenerateRest.addRow( simpleTable, 1, "error", "test" );
Assert.assertEquals( 1, simpleTable.getRows().size() );
}

private byte[] getInput( String path ) {
return SafeFunction.get( () -> {
String json = StreamIO.readString( ClassHelper.loadFromDefaultClassLoader( "request/payload/"+path ) );
Expand Down

0 comments on commit f0e6283

Please sign in to comment.