Search in sources :

Example 1 with ConjunctionSymbol

use of com.cinchapi.ccl.grammar.ConjunctionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testGroupSub.

@Test
public void testGroupSub() {
    String key0 = TestData.getString();
    Operator operator0 = Operator.EQUALS;
    Object value0 = TestData.getObject();
    String key1 = TestData.getString();
    Operator operator1 = Operator.GREATER_THAN;
    Object value1 = TestData.getObject();
    String key2 = TestData.getString();
    Operator operator2 = Operator.LESS_THAN;
    Object value2 = TestData.getObject();
    Criteria criteria = Criteria.where().key(key0).operator(operator0).value(value0).and().group(Criteria.where().key(key1).operator(operator1).value(value1).or().key(key2).operator(operator2).value(value2).build()).build();
    List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
    ExpressionSymbol exp0 = (ExpressionSymbol) symbols.get(0);
    ConjunctionSymbol sym1 = (ConjunctionSymbol) symbols.get(1);
    ParenthesisSymbol sym2 = (ParenthesisSymbol) symbols.get(2);
    ExpressionSymbol exp3 = (ExpressionSymbol) symbols.get(3);
    ConjunctionSymbol sym4 = (ConjunctionSymbol) symbols.get(4);
    ExpressionSymbol exp5 = (ExpressionSymbol) symbols.get(5);
    ParenthesisSymbol sym6 = (ParenthesisSymbol) symbols.get(6);
    Assert.assertEquals(7, symbols.size());
    Assert.assertEquals(exp0.raw().key(), key0);
    Assert.assertEquals(exp0.raw().operator(), operator0);
    Assert.assertEquals(exp0.values().get(0).value(), value0);
    Assert.assertEquals(ConjunctionSymbol.AND, sym1);
    Assert.assertEquals(ParenthesisSymbol.LEFT, sym2);
    Assert.assertEquals(exp3.raw().key(), key1);
    Assert.assertEquals(exp3.raw().operator(), operator1);
    Assert.assertEquals(exp3.values().get(0).value(), value1);
    Assert.assertEquals(ConjunctionSymbol.OR, sym4);
    Assert.assertEquals(exp5.raw().key(), key2);
    Assert.assertEquals(exp5.raw().operator(), operator2);
    Assert.assertEquals(exp5.values().get(0).value(), value2);
    Assert.assertEquals(ParenthesisSymbol.RIGHT, sym6);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) Symbol(com.cinchapi.ccl.grammar.Symbol) OperatorSymbol(com.cinchapi.ccl.grammar.OperatorSymbol) ValueSymbol(com.cinchapi.ccl.grammar.ValueSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) Test(org.junit.Test)

Example 2 with ConjunctionSymbol

use of com.cinchapi.ccl.grammar.ConjunctionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testGroupOr.

@Test
public void testGroupOr() {
    String key0 = TestData.getString();
    Operator operator0 = Operator.EQUALS;
    Object value0 = TestData.getObject();
    String key1 = TestData.getString();
    Operator operator1 = Operator.GREATER_THAN;
    Object value1 = TestData.getObject();
    Criteria criteria = Criteria.where().key(key0).operator(operator0).value(value0).or().key(key1).operator(operator1).value(value1).build();
    List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
    ExpressionSymbol exp0 = (ExpressionSymbol) symbols.get(0);
    ConjunctionSymbol sym = (ConjunctionSymbol) symbols.get(1);
    ExpressionSymbol exp1 = (ExpressionSymbol) symbols.get(2);
    Assert.assertEquals(3, symbols.size());
    Assert.assertEquals(exp0.raw().key(), key0);
    Assert.assertEquals(exp0.raw().operator(), operator0);
    Assert.assertEquals(exp0.values().get(0).value(), value0);
    Assert.assertEquals(sym, ConjunctionSymbol.OR);
    Assert.assertEquals(exp1.raw().key(), key1);
    Assert.assertEquals(exp1.raw().operator(), operator1);
    Assert.assertEquals(exp1.values().get(0).value(), value1);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) Symbol(com.cinchapi.ccl.grammar.Symbol) OperatorSymbol(com.cinchapi.ccl.grammar.OperatorSymbol) ValueSymbol(com.cinchapi.ccl.grammar.ValueSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) Test(org.junit.Test)

Example 3 with ConjunctionSymbol

use of com.cinchapi.ccl.grammar.ConjunctionSymbol in project concourse by cinchapi.

the class ConcourseCompilerTest method testGroupAnd.

@Test
public void testGroupAnd() {
    String key0 = TestData.getString();
    Operator operator0 = Operator.EQUALS;
    Object value0 = TestData.getObject();
    String key1 = TestData.getString();
    Operator operator1 = Operator.GREATER_THAN;
    Object value1 = TestData.getObject();
    Criteria criteria = Criteria.where().key(key0).operator(operator0).value(value0).and().key(key1).operator(operator1).value(value1).build();
    List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
    ExpressionSymbol exp0 = (ExpressionSymbol) symbols.get(0);
    ConjunctionSymbol sym = (ConjunctionSymbol) symbols.get(1);
    ExpressionSymbol exp1 = (ExpressionSymbol) symbols.get(2);
    Assert.assertEquals(3, symbols.size());
    Assert.assertEquals(exp0.raw().key(), key0);
    Assert.assertEquals(exp0.raw().operator(), operator0);
    Assert.assertEquals(exp0.values().get(0).value(), value0);
    Assert.assertEquals(sym, ConjunctionSymbol.AND);
    Assert.assertEquals(exp1.raw().key(), key1);
    Assert.assertEquals(exp1.raw().operator(), operator1);
    Assert.assertEquals(exp1.values().get(0).value(), value1);
}
Also used : Operator(com.cinchapi.concourse.thrift.Operator) KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) Symbol(com.cinchapi.ccl.grammar.Symbol) OperatorSymbol(com.cinchapi.ccl.grammar.OperatorSymbol) ValueSymbol(com.cinchapi.ccl.grammar.ValueSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) ParenthesisSymbol(com.cinchapi.ccl.grammar.ParenthesisSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ConjunctionSymbol(com.cinchapi.ccl.grammar.ConjunctionSymbol) Test(org.junit.Test)

Aggregations

ConjunctionSymbol (com.cinchapi.ccl.grammar.ConjunctionSymbol)3 ExpressionSymbol (com.cinchapi.ccl.grammar.ExpressionSymbol)3 KeySymbol (com.cinchapi.ccl.grammar.KeySymbol)3 OperatorSymbol (com.cinchapi.ccl.grammar.OperatorSymbol)3 ParenthesisSymbol (com.cinchapi.ccl.grammar.ParenthesisSymbol)3 PostfixNotationSymbol (com.cinchapi.ccl.grammar.PostfixNotationSymbol)3 Symbol (com.cinchapi.ccl.grammar.Symbol)3 ValueSymbol (com.cinchapi.ccl.grammar.ValueSymbol)3 Operator (com.cinchapi.concourse.thrift.Operator)3 Test (org.junit.Test)3