Search in sources :

Example 6 with PostfixNotationSymbol

use of com.cinchapi.ccl.grammar.PostfixNotationSymbol 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 7 with PostfixNotationSymbol

use of com.cinchapi.ccl.grammar.PostfixNotationSymbol 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 8 with PostfixNotationSymbol

use of com.cinchapi.ccl.grammar.PostfixNotationSymbol 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 9 with PostfixNotationSymbol

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

the class ConcourseCompilerTest method testParseCCLConjuctionsWithAnd.

@Test
public void testParseCCLConjuctionsWithAnd() {
    String ccl = "name = chandresh pancholi on last christmas day && favovite_player != C. Ronaldo during last year";
    Queue<PostfixNotationSymbol> symbols = ConcourseCompiler.get().arrange((ConditionTree) ConcourseCompiler.get().parse(ccl));
    Assert.assertEquals(3, symbols.size());
    for (int i = 0; i < 2; i++) {
        ExpressionSymbol expr = (ExpressionSymbol) symbols.poll();
        Assert.assertTrue(expr.values().get(0).value().toString().contains(" "));
        Assert.assertNotEquals(0, expr.raw().timestamp());
    }
}
Also used : PostfixNotationSymbol(com.cinchapi.ccl.grammar.PostfixNotationSymbol) ExpressionSymbol(com.cinchapi.ccl.grammar.ExpressionSymbol) Test(org.junit.Test)

Example 10 with PostfixNotationSymbol

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

the class ConcourseCompilerTest method testParseCclTimestampPhraseWithoutQuotes.

@Test
public void testParseCclTimestampPhraseWithoutQuotes() {
    String ccl = "name = jeff at 3 seconds ago";
    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)

Aggregations

ExpressionSymbol (com.cinchapi.ccl.grammar.ExpressionSymbol)12 PostfixNotationSymbol (com.cinchapi.ccl.grammar.PostfixNotationSymbol)12 Test (org.junit.Test)12 KeySymbol (com.cinchapi.ccl.grammar.KeySymbol)2 OperatorSymbol (com.cinchapi.ccl.grammar.OperatorSymbol)2 ValueSymbol (com.cinchapi.ccl.grammar.ValueSymbol)2