Skip to content

Commit 9fc7980

Browse files
committed
more tests and coverage printer
1 parent 27899fb commit 9fc7980

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

buildSrc/src/main/kotlin/whitefox.java-conventions.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
44
plugins {
55
java
66
jacoco
7+
id("com.github.ksoichiro.console.reporter")
78
id("com.palantir.git-version")
89
id("org.openapi.generator")
910
id("com.diffplug.spotless")
@@ -83,6 +84,7 @@ tasks.jacocoTestReport {
8384
files(classDirectories.files.map { fileTree(it) { exclude(classesToExclude) } })
8485
)
8586
doLast {
87+
logger.lifecycle("The coverage is: " + reports.)
8688
logger.lifecycle("The report can be found at: file://" + reports.html.entryPoint)
8789
}
8890

server/core/src/main/java/io/whitefox/core/types/predicates/BaseOp.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ default void validateChildren(List<BaseOp> children) throws PredicateException {
112112
}
113113

114114
for (BaseOp c : children) {
115-
try {
116-
c.validate();
117-
} catch (PredicateException e) {
118-
throw new RuntimeException(e);
119-
}
115+
c.validate();
120116
}
121117
}
122118
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.whitefox.core.types.predicates;
2+
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import io.whitefox.core.types.DateType;
6+
import io.whitefox.core.types.IntegerType;
7+
import java.util.List;
8+
import java.util.Map;
9+
import org.junit.jupiter.api.Test;
10+
11+
public class EvalHelperTest {
12+
13+
@Test
14+
void testLessThan() throws PredicateException {
15+
var evalContext1 = new EvalContext(Map.of("date", "2020-10-10"), Map.of());
16+
var children1 =
17+
List.of(new ColumnOp("date", DateType.DATE), new LiteralOp("2020-10-11", DateType.DATE));
18+
assertTrue(EvalHelper.lessThan(children1, evalContext1));
19+
var evalContext2 = new EvalContext(Map.of("integer", "19"), Map.of());
20+
var children2 = List.of(
21+
new ColumnOp("integer", IntegerType.INTEGER), new LiteralOp("20", IntegerType.INTEGER));
22+
assertTrue(EvalHelper.lessThan(children2, evalContext2));
23+
}
24+
25+
@Test
26+
void testEqual() throws PredicateException {
27+
var evalContext1 = new EvalContext(Map.of("date", "2020-10-11"), Map.of());
28+
var children1 =
29+
List.of(new ColumnOp("date", DateType.DATE), new LiteralOp("2020-10-11", DateType.DATE));
30+
assertTrue(EvalHelper.equal(children1, evalContext1));
31+
var evalContext2 = new EvalContext(Map.of("integer", "20"), Map.of());
32+
var children2 = List.of(
33+
new ColumnOp("integer", IntegerType.INTEGER), new LiteralOp("20", IntegerType.INTEGER));
34+
assertTrue(EvalHelper.equal(children2, evalContext2));
35+
}
36+
}

0 commit comments

Comments
 (0)