Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Oct 23, 2024
1 parent f3f3ce8 commit f851f1f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/test/java/test/org/fugerit/java/kts/helper/TestEvalKts.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.extern.slf4j.Slf4j;
import org.fugerit.java.core.cfg.ConfigException;
import org.fugerit.java.core.function.SafeFunction;
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.kts.helper.EvalKts;
import org.fugerit.java.kts.helper.EvalKtsWithJsonDataModel;
Expand All @@ -11,24 +12,32 @@

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;

@Slf4j
class TestEvalKts {

private EvalKts evalKts = new EvalKtsWithJsonDataModel();

@Test
void testEvalkts() throws IOException {
private String testWorkerSimpleScript(Function<Reader, Object> evalFun) throws IOException {
try (InputStreamReader reader = new InputStreamReader(ClassHelper.loadFromDefaultClassLoader( "kts/sample-1.kts" ))) {
Object result = evalKts.evalKts( reader );
Object result = evalFun.apply( reader );
String xml = result.toString();
log.info( "xml : \n{}", xml );
Assertions.assertNotNull( xml );
return xml;
}
}

@Test
void testEvalkts() throws IOException {
Assertions.assertNotNull( this.testWorkerSimpleScript( r -> this.evalKts.evalKts( r ) ) );
Assertions.assertNotNull( this.testWorkerSimpleScript( r -> SafeFunction.get( () -> this.evalKts.evalKtsEx( r ) ) ) );
}

@Test
void testEvalktsWithDataModel() throws IOException {
try (InputStreamReader reader = new InputStreamReader(ClassHelper.loadFromDefaultClassLoader( "kts/sample-1-with-data-model.kts" ))) {
Expand Down

0 comments on commit f851f1f

Please sign in to comment.