Add expression tests for between operator
@@ -410,6 +410,34 @@ class ExpressionAsStringTest {
);
}
+ @Test
+ void between() {
+ assertExpressional(person.age.between(1, 2).or().age.is(3),
+ "call op=OR",
+ " call op=AND",
+ " call op=GREATER_THAN_OR_EQUAL path=age constant=1",
+ " call op=LESS_THAN_OR_EQUAL path=age constant=2",
+ " call op=EQUAL path=age constant=3"
+ );
+
+ assertExpressional(person.age.is(3).or().age.between(1, 2),
+ "call op=OR",
+ " call op=EQUAL path=age constant=3",
+ " call op=AND",
+ " call op=GREATER_THAN_OR_EQUAL path=age constant=1",
+ " call op=LESS_THAN_OR_EQUAL path=age constant=2"
+ );
+
+ assertExpressional(person.age.is(1).age.between(2, 3),
+ "call op=AND",
+ " call op=EQUAL path=age constant=1",
+ " call op=AND",
+ " call op=GREATER_THAN_OR_EQUAL path=age constant=2",
+ " call op=LESS_THAN_OR_EQUAL path=age constant=3"
+ );
+
+ }
+
private static void assertExpressional(Criterion<?> crit, String ... expectedLines) {
final StringBuilder out = new StringBuilder();
Query query = Criterias.toQuery(crit);
