use of com.blazebit.persistence.parser.predicate.LtPredicate in project blaze-persistence by Blazebit.
the class GeneralParserTest method testNot1.
@Test
public void testNot1() {
GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN NOT(x.a = y.a) OR c.a < 9 AND b - c = 2 THEN 0 ELSE 1 END");
GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new CompoundPredicate(CompoundPredicate.BooleanOperator.OR, new EqPredicate(path("x", "a"), path("y", "a"), true), new CompoundPredicate(CompoundPredicate.BooleanOperator.AND, new LtPredicate(path("c", "a"), _int("9")), new EqPredicate(subtract(path("b"), path("c")), _int("2")))), _int("0"))), _int("1"));
assertEquals(expected, result);
}
use of com.blazebit.persistence.parser.predicate.LtPredicate in project blaze-persistence by Blazebit.
the class LogicOptimizationTest method testOptimizeNegationStructure2.
@Test
public void testOptimizeNegationStructure2() {
Predicate result = parsePredicateOptimized("NOT(NOT(a > b) OR a < x)", false);
Predicate expected = new CompoundPredicate(CompoundPredicate.BooleanOperator.AND, new GtPredicate(path("a"), path("b")), new LtPredicate(path("a"), path("x"), true));
assertEquals(expected, result);
}
use of com.blazebit.persistence.parser.predicate.LtPredicate in project blaze-persistence by Blazebit.
the class LogicOptimizationTest method testOptimizeNegationStructure3.
@Test
public void testOptimizeNegationStructure3() {
Predicate result = parsePredicateOptimized("NOT(NOT(a > b) AND a < x)", false);
Predicate expected = new CompoundPredicate(CompoundPredicate.BooleanOperator.OR, new GtPredicate(path("a"), path("b")), new LtPredicate(path("a"), path("x"), true));
assertEquals(expected, result);
}
use of com.blazebit.persistence.parser.predicate.LtPredicate in project blaze-persistence by Blazebit.
the class GeneralParserTest method testNot3.
@Test
public void testNot3() {
GeneralCaseExpression result = (GeneralCaseExpression) parse("CaSe WHEN NoT(x.a = y.a OR c.a < 9 and b - c = 2) THeN 0 eLsE 1 ENd");
GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(not(new CompoundPredicate(CompoundPredicate.BooleanOperator.OR, new EqPredicate(path("x", "a"), path("y", "a")), new CompoundPredicate(CompoundPredicate.BooleanOperator.AND, new LtPredicate(path("c", "a"), _int("9")), new EqPredicate(subtract(path("b"), path("c")), _int("2"))))), _int("0"))), _int("1"));
assertEquals(expected, result);
}
use of com.blazebit.persistence.parser.predicate.LtPredicate in project blaze-persistence by Blazebit.
the class GeneralParserTest method testCaseWhenAndOr.
@Test
public void testCaseWhenAndOr() {
GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN x.a = y.a OR c.a < 9 AND b - c = 2 THEN 0 ELSE 1 END");
GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new CompoundPredicate(CompoundPredicate.BooleanOperator.OR, new EqPredicate(path("x", "a"), path("y", "a")), new CompoundPredicate(CompoundPredicate.BooleanOperator.AND, new LtPredicate(path("c", "a"), _int("9")), new EqPredicate(subtract(path("b"), path("c")), _int("2")))), _int("0"))), _int("1"));
assertEquals(expected, result);
}
Aggregations