Search in sources :

Example 6 with ExpressionCache

use of com.dexels.navajo.parser.compiled.api.ExpressionCache in project navajo by Dexels.

the class TestCompiledExpression method testFunctionEvaluation.

@Test
public void testFunctionEvaluation() {
    List<String> problems = new ArrayList<>();
    ExpressionCache ce = ExpressionCache.getInstance();
    String embeddedExpression = "StringFunction('matches','aaa', '.*[-]+7[0-9][A-z]*$' ))";
    ContextExpression cemb = ce.parse(problems, embeddedExpression, name -> FunctionClassification.DEFAULT);
    System.err.println("Problems: " + problems);
    Assert.assertEquals(0, problems.size());
    Operand result = cemb.apply(input, Optional.empty(), Optional.empty());
    System.err.println("Result: " + result.type + " value: " + result.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) ContextExpression(com.dexels.navajo.expression.api.ContextExpression) ArrayList(java.util.ArrayList) ExpressionCache(com.dexels.navajo.parser.compiled.api.ExpressionCache) Test(org.junit.Test)

Example 7 with ExpressionCache

use of com.dexels.navajo.parser.compiled.api.ExpressionCache in project navajo by Dexels.

the class TestCompiledExpression method testForall.

@Test
public void testForall() throws TMLExpressionException {
    List<String> problems = new ArrayList<>();
    ExpressionCache ce = ExpressionCache.getInstance();
    // String extBackup ="FORALL( '/TestArrayMessageMessage', `! ?[Delete] OR ! [Delete] OR [/__globals__/ApplicationInstance] != 'TENANT' OR ! StringFunction( 'matches', [ChargeCodeId], '.*[-]+7[0-9][A-z]*$' )` )";
    String ext = "FORALL( '/Msg', `!StringFunction( 'matches', [ChargeCodeId], '.*[-]+7[0-9][A-z]*$' )` )";
    // String expression = "FORALL( '/Charges' , `! ?[Delete] OR ! [Delete]  OR [/__globals__/ApplicationInstance] != 'SOMETENANT' OR [SomeProperty] == 'SOMESTRING' `)";
    // ce.parse(problems, expression, mode, allowLiteralResolve)
    ContextExpression cx = ce.parse(problems, ext, name -> FunctionClassification.DEFAULT);
    System.err.println("Problems: " + problems);
    Assert.assertEquals(0, problems.size());
    Operand result = cx.apply(input, Optional.empty(), Optional.empty());
    System.err.println("Result: " + result.type + " value: " + result.value);
// Operand result = Expression.evaluate(expression, testDoc,null,topMessage);
}
Also used : Operand(com.dexels.navajo.document.Operand) ContextExpression(com.dexels.navajo.expression.api.ContextExpression) ArrayList(java.util.ArrayList) ExpressionCache(com.dexels.navajo.parser.compiled.api.ExpressionCache) Test(org.junit.Test)

Aggregations

ContextExpression (com.dexels.navajo.expression.api.ContextExpression)7 ExpressionCache (com.dexels.navajo.parser.compiled.api.ExpressionCache)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Operand (com.dexels.navajo.document.Operand)2