Search in sources :

Example 91 with FunctionInterface

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

the class StandardFunctionsTest method testFormatDecimal.

@Test
public void testFormatDecimal() {
    FunctionInterface fi = fff.getInstance(cl, "FormatDecimal");
    fi.reset();
    fi.insertFloatOperand(10.5);
    fi.insertStringOperand("##");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals("10", o.toString());
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Test(org.junit.Test)

Example 92 with FunctionInterface

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

the class Switch method testIntegerMultipleMiss.

@Test
public void testIntegerMultipleMiss() throws Exception {
    FunctionInterface fi = fff.getInstance(cl, "Switch");
    fi.reset();
    Navajo n = createTestNavajo();
    fi.setInMessage(n);
    // Switch('/Single/Vuur', 10, -10, 0). If property /Single/Vuur has value 10 it becomes -10 else it becomes 0.
    fi.insertIntegerOperand((Integer) Expression.evaluate("[/Single/Vuur]", n).value);
    fi.insertIntegerOperand(20);
    fi.insertIntegerOperand(-20);
    fi.insertIntegerOperand(15);
    fi.insertIntegerOperand(-10);
    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 93 with FunctionInterface

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

the class StandardFunctionsTest method testCheckRange.

@Test
public void testCheckRange() {
    FunctionInterface fi = fff.getInstance(cl, "CheckRange");
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(Integer.valueOf(10));
    list.add(Integer.valueOf(10));
    fi.reset();
    fi.setInMessage(createTestNavajo());
    fi.insertListOperand(list);
    fi.insertIntegerOperand(30);
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Boolean.class, o.getClass());
}
Also used : CheckInteger(com.dexels.navajo.functions.CheckInteger) FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 94 with FunctionInterface

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

the class StandardFunctionsTest method testStringPadding.

@Test
public void testStringPadding() {
    FunctionInterface fi = fff.getInstance(cl, "StringPadding");
    fi.reset();
    fi.insertStringOperand("aap");
    fi.insertIntegerOperand(Integer.valueOf(10));
    fi.insertStringOperand("*");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(String.class, o.getClass());
    assertEquals("aap*******", o.toString());
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Test(org.junit.Test)

Example 95 with FunctionInterface

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

the class StandardFunctionsTest method testEuro.

@Test
public void testEuro() {
    DispatcherFactory.createDispatcher(new TestDispatcher(new TestNavajoConfig()));
    FunctionInterface fi = fff.getInstance(cl, "Euro");
    fi.reset();
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
}
Also used : TestNavajoConfig(com.dexels.navajo.server.test.TestNavajoConfig) FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) TestDispatcher(com.dexels.navajo.server.test.TestDispatcher) 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