Search in sources :

Example 11 with ExpressionSymbol

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
}
Also used : PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) Test(org.junit.Test)

Example 12 with ExpressionSymbol

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
}
Also used : PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) Test(org.junit.Test)

Example 13 with ExpressionSymbol

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());
}
Also used : PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) Test(org.junit.Test)

Example 14 with ExpressionSymbol

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));
}
Also used : OperatorSymbol(com.cinchapi.ccl.grammar.OperatorSymbol) KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) ValueSymbol(com.cinchapi.ccl.grammar.ValueSymbol) Test(org.junit.Test)

Example 15 with ExpressionSymbol

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);
}
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) Test(org.junit.Test)

Aggregations

ExpressionSymbol (com.cinchapi.ccl.grammar.ExpressionSymbol)21 Test (org.junit.Test)19 PostfixNotationSymbol (com.cinchapi.ccl.grammar.PostfixNotationSymbol)17 KeySymbol (com.cinchapi.ccl.grammar.KeySymbol)9 Symbol (com.cinchapi.ccl.grammar.Symbol)8 OperatorSymbol (com.cinchapi.ccl.grammar.OperatorSymbol)7 ValueSymbol (com.cinchapi.ccl.grammar.ValueSymbol)7 ParenthesisSymbol (com.cinchapi.ccl.grammar.ParenthesisSymbol)6 Operator (com.cinchapi.concourse.thrift.Operator)6 ConjunctionSymbol (com.cinchapi.ccl.grammar.ConjunctionSymbol)5 NavigationKeySymbol (com.cinchapi.ccl.grammar.NavigationKeySymbol)2 Timestamp (com.cinchapi.concourse.Timestamp)2 TimestampSymbol (com.cinchapi.ccl.grammar.TimestampSymbol)1 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)1 Store (com.cinchapi.concourse.server.storage.Store)1 TObject (com.cinchapi.concourse.thrift.TObject)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1