Search in sources :

Example 1 with FunctionInterface

use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.

the class Switch method testWithPropertyAndSingleValueParameter.

@Test
public void testWithPropertyAndSingleValueParameter() 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(0);
    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 2 with FunctionInterface

use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.

the class Switch method testSingleSimpleMiss.

@Test
public void testSingleSimpleMiss() throws Exception {
    FunctionInterface fi = fff.getInstance(cl, "Switch");
    fi.reset();
    fi.insertIntegerOperand((Integer) Expression.evaluate("20", null).value);
    fi.insertIntegerOperand((Integer) Expression.evaluate("10", null).value);
    fi.insertIntegerOperand((Integer) Expression.evaluate("-10", null).value);
    fi.insertIntegerOperand((Integer) Expression.evaluate("0", null).value);
    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) Test(org.junit.Test)

Example 3 with FunctionInterface

use of com.dexels.navajo.expression.api.FunctionInterface 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 4 with FunctionInterface

use of com.dexels.navajo.expression.api.FunctionInterface 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 5 with FunctionInterface

use of com.dexels.navajo.expression.api.FunctionInterface 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)

Aggregations

FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)161 Test (org.junit.Test)153 Navajo (com.dexels.navajo.document.Navajo)26 FunctionDefinition (com.dexels.navajo.expression.api.FunctionDefinition)20 ArrayList (java.util.ArrayList)16 Date (java.util.Date)16 Operand (com.dexels.navajo.document.Operand)10 GiveLongTestFunction (com.dexels.navajo.expression.compiled.GiveLongTestFunction)10 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)7 CapString (com.dexels.navajo.functions.CapString)7 StringReader (java.io.StringReader)5 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)4 AddTestFunction (com.dexels.navajo.expression.compiled.AddTestFunction)4 Binary (com.dexels.navajo.document.types.Binary)3 CheckInteger (com.dexels.navajo.functions.CheckInteger)3 SimpleDateFormat (java.text.SimpleDateFormat)3 List (java.util.List)3 Message (com.dexels.navajo.document.Message)2 Property (com.dexels.navajo.document.Property)2 ClockTime (com.dexels.navajo.document.types.ClockTime)2