Package org.apache.camel

Examples of org.apache.camel.Predicate


    public Predicate in(Object... values) {
        List<Predicate> predicates = new ArrayList<Predicate>();
        for (Object value : values) {
            Expression right = asExpression(value);
            right = ExpressionBuilder.convertToExpression(right, expression);
            Predicate predicate = onNewPredicate(PredicateBuilder.isEqualTo(expression, right));
            predicates.add(predicate);
        }
        return in(predicates.toArray(new Predicate[predicates.size()]));
    }
View Full Code Here


    public void testSimpleEq() throws Exception {
        exchange.getIn().setBody("foo");

        SimplePredicateParser parser = new SimplePredicateParser("${body} == 'foo'");
        Predicate pre = parser.parsePredicate();

        assertTrue(pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleEqNumeric() throws Exception {
        exchange.getIn().setBody(123);

        SimplePredicateParser parser = new SimplePredicateParser("${body} == 123");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleEqFunctionFunction() throws Exception {
        exchange.getIn().setBody(122);
        exchange.getIn().setHeader("val", 122);

        SimplePredicateParser parser = new SimplePredicateParser("${body} == ${header.val}");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleEqFunctionNumeric() throws Exception {
        exchange.getIn().setBody(122);

        SimplePredicateParser parser = new SimplePredicateParser("${body} == 122");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleGtFunctionNumeric() throws Exception {
        exchange.getIn().setBody(122);

        SimplePredicateParser parser = new SimplePredicateParser("${body} > 120");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleUnaryInc() throws Exception {
        exchange.getIn().setBody(122);

        SimplePredicateParser parser = new SimplePredicateParser("${body}++ == 123");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleUnaryDec() throws Exception {
        exchange.getIn().setBody(122);

        SimplePredicateParser parser = new SimplePredicateParser("${body}-- == 121");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleEqFunctionBoolean() throws Exception {
        exchange.getIn().setBody("Hello");
        exchange.getIn().setHeader("high", true);

        SimplePredicateParser parser = new SimplePredicateParser("${header.high} == true");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

    public void testSimpleEqFunctionBooleanSpaces() throws Exception {
        exchange.getIn().setBody("Hello");
        exchange.getIn().setHeader("high", true);

        SimplePredicateParser parser = new SimplePredicateParser("${header.high}   ==     true");
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.Predicate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.