Search in sources :

Example 1 with MemberOfPredicate

use of com.blazebit.persistence.parser.predicate.MemberOfPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testMemberOf.

@Test
public void testMemberOf() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN x.a MEMBER OF y.a THEN 0 ELSE 2 END");
    Predicate condition = new MemberOfPredicate(path("x", "a"), path("y", "a"));
    GeneralCaseExpression expectedExpr = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(condition, _int("0"))), _int("2"));
    assertEquals(expectedExpr, result);
}
Also used : MemberOfPredicate(com.blazebit.persistence.parser.predicate.MemberOfPredicate) BetweenPredicate(com.blazebit.persistence.parser.predicate.BetweenPredicate) EqPredicate(com.blazebit.persistence.parser.predicate.EqPredicate) GtPredicate(com.blazebit.persistence.parser.predicate.GtPredicate) LtPredicate(com.blazebit.persistence.parser.predicate.LtPredicate) IsNullPredicate(com.blazebit.persistence.parser.predicate.IsNullPredicate) InPredicate(com.blazebit.persistence.parser.predicate.InPredicate) Predicate(com.blazebit.persistence.parser.predicate.Predicate) CompoundPredicate(com.blazebit.persistence.parser.predicate.CompoundPredicate) LikePredicate(com.blazebit.persistence.parser.predicate.LikePredicate) MemberOfPredicate(com.blazebit.persistence.parser.predicate.MemberOfPredicate) Test(org.junit.Test)

Example 2 with MemberOfPredicate

use of com.blazebit.persistence.parser.predicate.MemberOfPredicate in project blaze-persistence by Blazebit.

the class GeneralParserTest method testCaseWhenSwitchTrue.

@Test
public void testCaseWhenSwitchTrue() {
    GeneralCaseExpression result = (GeneralCaseExpression) parse("CASE WHEN localized[:locale] NOT MEMBER OF supportedLocales THEN true ELSE false END");
    GeneralCaseExpression expected = new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new MemberOfPredicate(path("localized[:locale]"), path("supportedLocales"), true), _boolean(true))), _boolean(false));
    assertEquals(expected, result);
}
Also used : MemberOfPredicate(com.blazebit.persistence.parser.predicate.MemberOfPredicate) Test(org.junit.Test)

Aggregations

MemberOfPredicate (com.blazebit.persistence.parser.predicate.MemberOfPredicate)2 Test (org.junit.Test)2 BetweenPredicate (com.blazebit.persistence.parser.predicate.BetweenPredicate)1 CompoundPredicate (com.blazebit.persistence.parser.predicate.CompoundPredicate)1 EqPredicate (com.blazebit.persistence.parser.predicate.EqPredicate)1 GtPredicate (com.blazebit.persistence.parser.predicate.GtPredicate)1 InPredicate (com.blazebit.persistence.parser.predicate.InPredicate)1 IsNullPredicate (com.blazebit.persistence.parser.predicate.IsNullPredicate)1 LikePredicate (com.blazebit.persistence.parser.predicate.LikePredicate)1 LtPredicate (com.blazebit.persistence.parser.predicate.LtPredicate)1 Predicate (com.blazebit.persistence.parser.predicate.Predicate)1