Search in sources :

Example 1 with ComparisonExpression

use of org.apache.activemq.artemis.selector.filter.ComparisonExpression in project activemq-artemis by apache.

the class SelectorParserTest method testParseWithParensAround.

@Test
public void testParseWithParensAround() throws Exception {
    String[] values = { "x = 1 and y = 2", "(x = 1) and (y = 2)", "((x = 1) and (y = 2))" };
    for (int i = 0; i < values.length; i++) {
        String value = values[i];
        info("Parsing: " + value);
        BooleanExpression andExpression = parse(value);
        Assert.assertTrue("Created LogicExpression expression", andExpression instanceof LogicExpression);
        LogicExpression logicExpression = (LogicExpression) andExpression;
        Expression left = logicExpression.getLeft();
        Expression right = logicExpression.getRight();
        Assert.assertTrue("Left is a binary filter", left instanceof ComparisonExpression);
        Assert.assertTrue("Right is a binary filter", right instanceof ComparisonExpression);
        ComparisonExpression leftCompare = (ComparisonExpression) left;
        ComparisonExpression rightCompare = (ComparisonExpression) right;
        assertPropertyExpression("left", leftCompare.getLeft(), "x");
        assertPropertyExpression("right", rightCompare.getLeft(), "y");
    }
}
Also used : ComparisonExpression(org.apache.activemq.artemis.selector.filter.ComparisonExpression) BooleanExpression(org.apache.activemq.artemis.selector.filter.BooleanExpression) Expression(org.apache.activemq.artemis.selector.filter.Expression) LogicExpression(org.apache.activemq.artemis.selector.filter.LogicExpression) ComparisonExpression(org.apache.activemq.artemis.selector.filter.ComparisonExpression) PropertyExpression(org.apache.activemq.artemis.selector.filter.PropertyExpression) XPathExpression(org.apache.activemq.artemis.selector.filter.XPathExpression) BooleanExpression(org.apache.activemq.artemis.selector.filter.BooleanExpression) LogicExpression(org.apache.activemq.artemis.selector.filter.LogicExpression) Test(org.junit.Test)

Aggregations

BooleanExpression (org.apache.activemq.artemis.selector.filter.BooleanExpression)1 ComparisonExpression (org.apache.activemq.artemis.selector.filter.ComparisonExpression)1 Expression (org.apache.activemq.artemis.selector.filter.Expression)1 LogicExpression (org.apache.activemq.artemis.selector.filter.LogicExpression)1 PropertyExpression (org.apache.activemq.artemis.selector.filter.PropertyExpression)1 XPathExpression (org.apache.activemq.artemis.selector.filter.XPathExpression)1 Test (org.junit.Test)1