use of com.cinchapi.ccl.grammar.Symbol 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);
}
use of com.cinchapi.ccl.grammar.Symbol 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);
}
use of com.cinchapi.ccl.grammar.Symbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testGroupSingleBetween.
@Test
public void testGroupSingleBetween() {
String key = TestData.getString();
Operator operator = Operator.BETWEEN;
Object value = TestData.getObject();
Object value1 = TestData.getObject();
Criteria criteria = Criteria.where().key(key).operator(operator).value(value).value(value1).build();
List<Symbol> symbols = Parsing.groupExpressions(criteria.symbols());
ExpressionSymbol exp = (ExpressionSymbol) symbols.get(0);
Assert.assertEquals(1, symbols.size());
Assert.assertEquals(exp.raw().key(), key);
Assert.assertEquals(exp.raw().operator(), operator);
Assert.assertEquals(exp.values().get(0).value(), value);
Assert.assertEquals(exp.values().get(1).value(), value1);
}
use of com.cinchapi.ccl.grammar.Symbol 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);
}
use of com.cinchapi.ccl.grammar.Symbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testGroupSyntaxException.
@Test(expected = SyntaxException.class)
public void testGroupSyntaxException() {
List<Symbol> symbols = Lists.<Symbol>newArrayList(new KeySymbol("foo"), new KeySymbol("bar"));
Parsing.groupExpressions(symbols);
}
Aggregations