Search in sources :

Example 1 with KeySymbol

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

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

the class ConcourseCompilerTest method testToPostfixNotationSimple.

@Test
public void testToPostfixNotationSimple() {
    Criteria criteria = Criteria.where().key("foo").operator(Operator.EQUALS).value("bar").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)).operator(), new OperatorSymbol(Operator.EQUALS));
}
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 3 with KeySymbol

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

Example 4 with KeySymbol

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

the class CriteriaTest method testCannotAddSymbolToBuiltCriteria.

@Test(expected = IllegalStateException.class)
public void testCannotAddSymbolToBuiltCriteria() {
    Criteria criteria = Criteria.where().key("foo").operator(Operator.EQUALS).value("bar").build();
    ((BuiltCriteria) criteria).add(new KeySymbol("baz"));
}
Also used : KeySymbol(com.cinchapi.ccl.grammar.KeySymbol) NavigationKeySymbol(com.cinchapi.ccl.grammar.NavigationKeySymbol) Test(org.junit.Test)

Aggregations

KeySymbol (com.cinchapi.ccl.grammar.KeySymbol)4 Test (org.junit.Test)4 ExpressionSymbol (com.cinchapi.ccl.grammar.ExpressionSymbol)3 OperatorSymbol (com.cinchapi.ccl.grammar.OperatorSymbol)3 PostfixNotationSymbol (com.cinchapi.ccl.grammar.PostfixNotationSymbol)3 ValueSymbol (com.cinchapi.ccl.grammar.ValueSymbol)3 ConjunctionSymbol (com.cinchapi.ccl.grammar.ConjunctionSymbol)1 NavigationKeySymbol (com.cinchapi.ccl.grammar.NavigationKeySymbol)1 ParenthesisSymbol (com.cinchapi.ccl.grammar.ParenthesisSymbol)1 Symbol (com.cinchapi.ccl.grammar.Symbol)1