use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testExpressionWithinSelection.
@Test
public void testExpressionWithinSelection() throws Exception {
Expression.compileExpressions = true;
Operand o = Expression.evaluate("[name]", testDoc, null, topMessage, testSelection, null);
assertEquals("option1", o.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testTrailingTMLPath.
@Test
public void testTrailingTMLPath() throws Exception {
Expression.compileExpressions = true;
ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
ImmutableMessage inner = ImmutableFactory.empty().with("innerint", 3, "integer");
ImmutableMessage combined = outer.withSubMessage("sub", inner);
Operand o = Expression.evaluateImmutable("[sub/]", null, Optional.of(combined), Optional.empty());
ImmutableMessage s = o.immutableMessageValue();
assertEquals(3, s.value("innerint").get());
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testTrailingTMLPathParam.
@Test
public void testTrailingTMLPathParam() throws Exception {
Expression.compileExpressions = true;
ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
ImmutableMessage inner = ImmutableFactory.empty().with("innerint", 3, "integer");
ImmutableMessage combined = outer.withSubMessage("sub", inner);
Operand o = Expression.evaluateImmutable("[@sub/]", null, Optional.empty(), Optional.of(combined));
ImmutableMessage s = o.immutableMessageValue();
assertEquals(3, s.value("innerint").get());
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class TestCompiledExpression method testIntegerDoubleComparison.
@Test
public void testIntegerDoubleComparison() {
Operand result;
result = Expression.evaluate(" 1 < 1.1 ", null, null, null);
Assert.assertTrue((boolean) result.value);
result = Expression.evaluate(" 1 < 1.0 ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" 1 <= 1.1 ", null, null, null);
Assert.assertTrue((boolean) result.value);
result = Expression.evaluate(" 1 <= 1.0 ", null, null, null);
Assert.assertTrue((boolean) result.value);
result = Expression.evaluate(" 1 > 1.1 ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" 1 > 1.0 ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" 1 >= 1.1 ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" 1 >= 1.0 ", null, null, null);
Assert.assertTrue((boolean) result.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class TestCompiledExpression method testEmptyFunctionCall.
@Test
public void testEmptyFunctionCall() throws ParseException {
FunctionInterface testFunction = new AddTestFunction();
FunctionDefinition fd = new FunctionDefinition(testFunction.getClass().getName(), "blib", "bleb", "blab");
FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("addtest", fd);
String expression = "addtest()";
StringReader sr = new StringReader(expression);
CompiledParser cp = new CompiledParser(sr);
cp.Expression();
List<String> problems = new ArrayList<>();
ContextExpression ss = cp.getJJTree().rootNode().interpretToLambda(problems, sr.toString(), fn -> FunctionClassification.DEFAULT, name -> Optional.empty());
Operand o = ss.apply();
Assert.assertEquals("monkey", o.value);
}
Aggregations