Search in sources :

Example 21 with FunctionInterface

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

the class StandardFunctionsTest method testEvaluateExpression.

@Test
public void testEvaluateExpression() {
    DispatcherFactory.createDispatcher(new TestDispatcher(new TestNavajoConfig()));
    FunctionInterface fi = fff.getInstance(cl, "EvaluateExpression");
    fi.reset();
    Navajo doc = createTestNavajo();
    Header h = NavajoFactory.getInstance().createHeader(doc, "aap", "noot", "mies", -1);
    doc.addHeader(h);
    fi.setInMessage(doc);
    fi.insertStringOperand("true");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
}
Also used : TestNavajoConfig(com.dexels.navajo.server.test.TestNavajoConfig) FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Header(com.dexels.navajo.document.Header) TestDispatcher(com.dexels.navajo.server.test.TestDispatcher) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 22 with FunctionInterface

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

the class TestAbsFunction method testAbsWithDouble.

@Test
public void testAbsWithDouble() {
    FunctionInterface fi = fff.getInstance(cl, "Abs");
    fi.reset();
    fi.insertFloatOperand(-10.0D);
    Object result = fi.evaluateWithTypeChecking();
    assertEquals(Double.class, result.getClass());
    assertEquals(10, ((Double) result).intValue());
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Test(org.junit.Test)

Example 23 with FunctionInterface

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

the class TestAbsFunction method testAbsWithLong.

@Test
public void testAbsWithLong() {
    FunctionInterface fi = fff.getInstance(cl, "Abs");
    fi.reset();
    fi.insertLongOperand(-10L);
    Object result = fi.evaluateWithTypeChecking();
    assertEquals(Long.class, result.getClass());
    assertEquals(10L, ((Long) result).longValue());
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Test(org.junit.Test)

Example 24 with FunctionInterface

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

the class TestAbsFunction method testAbsWithNoParameters.

@Test(expected = TMLExpressionException.class)
public void testAbsWithNoParameters() {
    FunctionInterface fi = fff.getInstance(cl, "Abs");
    fi.reset();
    fi.evaluateWithTypeChecking();
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Test(org.junit.Test)

Example 25 with FunctionInterface

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

the class StandardFunctionsTest method testGetLogoImage.

@Test
public void testGetLogoImage() {
    FunctionInterface fi = fff.getInstance(cl, "GetLogoImage");
    Navajo doc = createTestNavajo();
    fi.setInMessage(doc);
    fi.reset();
    fi.insertStringOperand("Logo");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Binary.class, o.getClass());
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Navajo(com.dexels.navajo.document.Navajo) 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