Search in sources :

Example 71 with Operand

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());
}
Also used : Operand(com.dexels.navajo.document.Operand) List(java.util.List) Test(org.junit.Test)

Example 72 with Operand

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);
}
Also used : Operand(com.dexels.navajo.document.Operand) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Test(org.junit.Test)

Example 73 with Operand

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);
}
Also used : Operand(com.dexels.navajo.document.Operand) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Test(org.junit.Test)

Example 74 with Operand

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);
}
Also used : ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Message(com.dexels.navajo.document.Message) Selection(com.dexels.navajo.document.Selection) Operand(com.dexels.navajo.document.Operand) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 75 with Operand

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);
}
Also used : Operand(com.dexels.navajo.document.Operand) Test(org.junit.Test)

Aggregations

Operand (com.dexels.navajo.document.Operand)95 Test (org.junit.Test)57 Message (com.dexels.navajo.document.Message)22 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)20 Navajo (com.dexels.navajo.document.Navajo)20 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)15 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)14 ArrayList (java.util.ArrayList)12 Selection (com.dexels.navajo.document.Selection)11 Property (com.dexels.navajo.document.Property)10 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)10 Access (com.dexels.navajo.script.api.Access)10 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)10 NavajoException (com.dexels.navajo.document.NavajoException)9 TipiLink (com.dexels.navajo.expression.api.TipiLink)9 Optional (java.util.Optional)9 FunctionDefinition (com.dexels.navajo.expression.api.FunctionDefinition)8 GiveLongTestFunction (com.dexels.navajo.expression.compiled.GiveLongTestFunction)6 SystemException (com.dexels.navajo.script.api.SystemException)6 List (java.util.List)6