use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testParseCclTimestampBasicPhrase.
@Test
public void testParseCclTimestampBasicPhrase() {
String ccl = "name = jeff at \"now\"";
Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
// 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 testParseCclTimestampNumericPhrase.
@Test
public void testParseCclTimestampNumericPhrase() {
String ccl = "name = jeff at \"" + Time.now() + "\"";
Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
// 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 testParseCclValueWithoutQuotes.
@Test
public void testParseCclValueWithoutQuotes() {
String ccl = "name = jeff nelson";
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());
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol in project concourse by cinchapi.
the class ConcourseCompilerTest method testToPostfixNotationSimpleBetween.
@Test
public void testToPostfixNotationSimpleBetween() {
Criteria criteria = Criteria.where().key("foo").operator(Operator.BETWEEN).value("bar").value("baz").build();
Queue<PostfixNotationSymbol> pfn = Parsing.toPostfixNotation(criteria.symbols());
Assert.assertEquals(pfn.size(), 1);
Assert.assertEquals(((ExpressionSymbol) Iterables.getOnlyElement(pfn)).key(), new KeySymbol("foo"));
Assert.assertEquals(((ExpressionSymbol) Iterables.getOnlyElement(pfn)).values().get(0), new ValueSymbol("bar"));
Assert.assertEquals(((ExpressionSymbol) Iterables.getOnlyElement(pfn)).values().get(1), new ValueSymbol("baz"));
Assert.assertEquals(((ExpressionSymbol) Iterables.getOnlyElement(pfn)).operator(), new OperatorSymbol(Operator.BETWEEN));
}
use of com.cinchapi.ccl.grammar.ExpressionSymbol 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);
}
Aggregations