use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testExpressionWithImmutableParamMessage.
@Test
public void testExpressionWithImmutableParamMessage() throws Exception {
Expression.compileExpressions = true;
Operand o = Expression.evaluate("[@SomeInteger]", testDoc, (MappableTreeNode) null, topMessage, (Message) null, (Selection) null, (TipiLink) null, Collections.emptyMap(), Optional.of(immutableMessage), Optional.of(paramMessage));
assertEquals(4, o.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testExpressionWithImmutableMessage.
@Test
public void testExpressionWithImmutableMessage() throws Exception {
Expression.compileExpressions = true;
Operand o = Expression.evaluate("[SomeInteger]", testDoc, (MappableTreeNode) null, topMessage, (Message) null, (Selection) null, (TipiLink) null, Collections.emptyMap(), Optional.of(immutableMessage), Optional.of(paramMessage));
assertEquals(3, o.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testExpression.
@Test
public void testExpression() throws Exception {
ExpressionEvaluator ee = NavajoFactory.getInstance().getExpressionEvaluator();
Operand o = ee.evaluate("1+1", null, null, null);
assertEquals(2, o.value);
o = ee.evaluate("TODAY + 0#0#2#0#0#0", null, null, null);
System.err.println(o.value);
Navajo testDoc = NavajoFactory.getInstance().createNavajo();
Message m = NavajoFactory.getInstance().createMessage(testDoc, "MyTop");
testDoc.addMessage(m);
Message a = NavajoFactory.getInstance().createMessage(testDoc, "MyArrayMessage", "array");
m.addMessage(a);
for (int i = 0; i < 5; i++) {
Message a1 = NavajoFactory.getInstance().createMessage(testDoc, "MyArrayMessage");
a.addMessage(a1);
Property p = NavajoFactory.getInstance().createProperty(testDoc, "MyProp", "string", "noot" + i, 0, "", "in");
a1.addProperty(p);
Property p2 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp2", "string", "aap" + i, 0, "", "in");
a1.addProperty(p2);
}
o = ee.evaluate("'hallo:' + [/MyTop/MyArrayMessage@MyProp=noot1/MyProp2]", testDoc, null, null);
assertEquals("hallo:aap1", o.value);
o = ee.evaluate("'hallo:' + [/MyTop/MyArrayMessage@2/MyProp2]", testDoc, null, null);
assertEquals("hallo:aap2", o.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testEmptyTML.
@Test
public void testEmptyTML() throws Exception {
Expression.compileExpressions = true;
ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
Operand o = Expression.evaluateImmutable("[]", null, Optional.of(outer), Optional.empty());
ImmutableMessage s = o.immutableMessageValue();
assertEquals(outer, s);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class TestCompiledExpression method testDateComparison.
// Missing date comparison where the right hand operand is not a date
@Test
public void testDateComparison() {
Operand result;
result = Expression.evaluate(" TODAY < ( TODAY + 0#0#1#0#0#0 ) ", null, null, null);
Assert.assertTrue((boolean) result.value);
result = Expression.evaluate(" TODAY < TODAY ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" TODAY <= ( TODAY + 0#0#1#0#0#0 ) ", null, null, null);
Assert.assertTrue((boolean) result.value);
result = Expression.evaluate(" TODAY <= TODAY ", null, null, null);
Assert.assertTrue((boolean) result.value);
result = Expression.evaluate(" TODAY > ( TODAY + 0#0#1#0#0#0 ) ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" TODAY > TODAY ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" TODAY >= ( TODAY + 0#0#1#0#0#0 ) ", null, null, null);
Assert.assertFalse((boolean) result.value);
result = Expression.evaluate(" TODAY >= TODAY ", null, null, null);
Assert.assertTrue((boolean) result.value);
}
Aggregations