use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testReproGH_113.
@Test
public void testReproGH_113() {
String ccl = "location = \"Atlanta (HQ)\"";
Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
Assert.assertEquals(1, symbols.size());
ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
Assert.assertEquals("Atlanta (HQ)", expr.raw().values().get(0));
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testParseCclValueAndTimestampPhraseWithoutQuotes.
@Test
public void testParseCclValueAndTimestampPhraseWithoutQuotes() {
String ccl = "name = jeff nelson on last christmas day";
Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
Assert.assertEquals("jeff nelson", expr.values().get(0).value());
// this means a
Assert.assertNotEquals(0, expr.raw().timestamp());
// timestamp was
// parsed
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testGroupSingle.
@Test
public void testGroupSingle() {
String key = TestData.getString();
Operator operator = Operator.EQUALS;
Object value = TestData.getObject();
Criteria criteria = Criteria.where().key(key).operator(operator).value(value).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);
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol 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.ExpressionSymbol 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);
}
Aggregations