Search in sources :

Example 16 with FunctionInterface

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

the class StandardFunctionsTest method testURLEncode.

@Test
public void testURLEncode() {
    FunctionInterface fi = fff.getInstance(cl, "URLEncode");
    fi.reset();
    fi.insertStringOperand("10");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(o.getClass(), String.class);
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Test(org.junit.Test)

Example 17 with FunctionInterface

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

Example 18 with FunctionInterface

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

the class StandardFunctionsTest method testGetMimeType.

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

Example 19 with FunctionInterface

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

the class StandardFunctionsTest method testBase64Encode.

@Test
public void testBase64Encode() {
    FunctionInterface fi = fff.getInstance(cl, "Base64Encode");
    fi.reset();
    String data = "tralala";
    fi.insertStringOperand(data);
    String actual = (String) fi.evaluateWithTypeChecking();
    String expected = Base64.encode(data.getBytes());
    // strip newline
    expected = expected.substring(0, expected.length() - 1);
    assertEquals(expected, actual);
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) CapString(com.dexels.navajo.functions.CapString) Test(org.junit.Test)

Example 20 with FunctionInterface

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

the class StandardFunctionsTest method testToInteger.

@Test
public void testToInteger() {
    FunctionInterface fi = fff.getInstance(cl, "ToInteger");
    fi.reset();
    fi.insertStringOperand("10");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals("10", o.toString());
    assertEquals(Integer.class, o.getClass());
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) 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