Search in sources :

Example 11 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class Switch method testWithNotEnoughParameters.

@Test
public void testWithNotEnoughParameters() throws Exception {
    FunctionInterface fi = fff.getInstance(cl, "Switch");
    fi.reset();
    Navajo n = createTestNavajo();
    fi.setInMessage(n);
    fi.insertOperand(Expression.evaluate("[/Single/Vuur]", n));
    fi.insertIntegerOperand(20);
    fi.insertIntegerOperand(-20);
    try {
        Object result = fi.evaluate();
    } catch (TMLExpressionException tmle) {
        assertTrue(tmle.getMessage().indexOf("Not enough") != -1);
    }
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Navajo(com.dexels.navajo.document.Navajo) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) Test(org.junit.Test)

Example 12 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class Switch method testIntegerMultipleMissInArrayMessage.

@Test
public void testIntegerMultipleMissInArrayMessage() throws Exception {
    FunctionInterface fi = fff.getInstance(cl, "Switch");
    fi.reset();
    Navajo n = createTestNavajo();
    fi.setInMessage(n);
    fi.insertOperand(Expression.evaluate("[Noot]", n, null, n.getMessage("Aap").getElements().get(0)));
    fi.insertIntegerOperand(20);
    fi.insertIntegerOperand(-20);
    fi.insertIntegerOperand(15);
    fi.insertIntegerOperand(-15);
    fi.insertIntegerOperand(0);
    Object result = fi.evaluate();
    assertNotNull(result);
    assertEquals(result.getClass(), Integer.class);
    assertEquals(Integer.valueOf(0), result);
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 13 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class Switch method testWithOnlyPropertyParameter.

@Test
public void testWithOnlyPropertyParameter() throws Exception {
    FunctionInterface fi = fff.getInstance(cl, "Switch");
    fi.reset();
    Navajo n = createTestNavajo();
    fi.setInMessage(n);
    fi.insertOperand(Expression.evaluate("[/Single/Vuur]", n));
    try {
        Object result = fi.evaluate();
    } catch (TMLExpressionException tmle) {
        assertTrue(tmle.getMessage().indexOf("Not enough") != -1);
    }
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Navajo(com.dexels.navajo.document.Navajo) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) Test(org.junit.Test)

Example 14 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class StandardFunctionsTest method testGetFileExtension.

@Test
public void testGetFileExtension() {
    FunctionInterface fi = fff.getInstance(cl, "GetFileExtension");
    Navajo doc = createTestNavajo();
    fi.setInMessage(doc);
    fi.reset();
    fi.insertOperand(Operand.NULL);
    Object o = fi.evaluateWithTypeChecking();
    assertNull(o);
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 15 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class StandardFunctionsTest method testSumMessage.

@Test
public void testSumMessage() {
    FunctionInterface fi = fff.getInstance(cl, "SumMessage");
    Navajo doc = createTestNavajo();
    fi.setInMessage(doc);
    fi.reset();
    fi.insertMessageOperand(doc.getMessage("Aap"));
    fi.insertStringOperand("Noot");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());
    assertEquals("10", o.toString());
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Aggregations

Navajo (com.dexels.navajo.document.Navajo)258 Message (com.dexels.navajo.document.Message)131 Test (org.junit.Test)109 Property (com.dexels.navajo.document.Property)86 NavajoException (com.dexels.navajo.document.NavajoException)31 Access (com.dexels.navajo.script.api.Access)30 IOException (java.io.IOException)28 StringWriter (java.io.StringWriter)27 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)25 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)22 Selection (com.dexels.navajo.document.Selection)22 Header (com.dexels.navajo.document.Header)20 Operand (com.dexels.navajo.document.Operand)20 InputStream (java.io.InputStream)17 UserException (com.dexels.navajo.script.api.UserException)16 Optional (java.util.Optional)16 FatalException (com.dexels.navajo.script.api.FatalException)14 SystemException (com.dexels.navajo.script.api.SystemException)14 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)13