use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testListWithMultipleTypes.
@Test
public void testListWithMultipleTypes() throws Exception {
Expression.compileExpressions = true;
Operand o = Expression.evaluate("{1,'a',2+2}", testDoc);
List<Object> res = (List<Object>) o.value;
assertEquals(3, res.size());
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testEmptyTMLJustSlash.
@Test
public void testEmptyTMLJustSlash() 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 ExpressionTest method testImmutableTMLPath.
@Test
public void testImmutableTMLPath() 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/innerint]", null, Optional.of(combined), Optional.empty());
int s = o.integerValue();
assertEquals(3, s);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testSelectionExpressions.
@Test
public void testSelectionExpressions() throws TMLExpressionException, SystemException {
Navajo testDoc = NavajoFactory.getInstance().createNavajo();
Message m = NavajoFactory.getInstance().createMessage(testDoc, "MyTop");
testDoc.addMessage(m);
Property pt = NavajoFactory.getInstance().createProperty(testDoc, "TopProp", "1", "", Property.DIR_IN);
Selection s = NavajoFactory.getInstance().createSelection(testDoc, "option1", "value1", true);
pt.addSelection(s);
m.addProperty(pt);
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);
}
Expression.compileExpressions = true;
Operand o = Expression.evaluate("'hallo:' + [TopProp:name]", testDoc, null, m);
// o = Expression.evaluate(
// "'hallo:' + [out:/MyTop/MyArrayMessage@MyProp=noot1/MyProp2]",
// testDoc);
//
assertEquals("hallo:option1", o.value);
o = Expression.evaluate("[TopProp:value]", testDoc, null, m);
assertEquals("value1", o.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ExpressionTest method testTipiExpression.
@Test
public void testTipiExpression() throws Exception {
Expression.compileExpressions = true;
Operand o = Expression.evaluate("{tipi:/bla}", null, null, null, e -> "chicken", null, Optional.empty());
String s = (String) o.value;
assertEquals("chicken", s);
}
Aggregations