use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class TestCompiledMoneyExpression method setup.
@Before
public void setup() {
FunctionInterface giveLongFunction = new GiveLongTestFunction();
FunctionDefinition fd = new FunctionDefinition(giveLongFunction.getClass().getName(), "description", "input", "result");
FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("ToLong", fd);
FunctionInterface giveMoneyFunction = new GiveMoneyTestFunction();
fd = new FunctionDefinition(giveMoneyFunction.getClass().getName(), "description", "input", "result");
FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("ToMoney", fd);
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class TestCompiledStringExpression method testSubtractStringAndLong.
@Test(expected = TMLExpressionException.class)
public void testSubtractStringAndLong() {
FunctionInterface giveLongFunction = new GiveLongTestFunction();
FunctionDefinition fd = new FunctionDefinition(giveLongFunction.getClass().getName(), "description", "input", "result");
FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("ToLong", fd);
Expression.evaluate("'bla' - ToLong(10)", null, null, null);
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class TestCompiledLongExpression method testMultiplyWithLongs.
@Test
public void testMultiplyWithLongs() {
FunctionInterface helperFunction = new GiveLongTestFunction();
FunctionDefinition fd = new FunctionDefinition(helperFunction.getClass().getName(), "description", "input", "result");
FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("ToLong", fd);
Operand result;
result = Expression.evaluate("ToLong(3) * ToLong(1)", null, null, null);
Assert.assertEquals(3L, (long) result.value);
result = Expression.evaluate("3 * ToLong(1)", null, null, null);
Assert.assertEquals(3L, (long) result.value);
result = Expression.evaluate("ToLong(3) * 1", null, null, null);
Assert.assertEquals(3L, (long) result.value);
result = Expression.evaluate("3.0 * ToLong(1)", null, null, null);
Assert.assertEquals(3L, (double) result.value, 0.000001);
result = Expression.evaluate("ToLong(3) * 1.0", null, null, null);
Assert.assertEquals(3L, (double) result.value, 0.000001);
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class StandardFunctionsTest method testDateSubtract.
@Test
public void testDateSubtract() {
FunctionInterface fi = fff.getInstance(cl, "DateSubtract");
fi.reset();
fi.insertDateOperand(new Date());
fi.insertDateOperand(new Date());
Object o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Date.class, o.getClass());
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class StandardFunctionsTest method testGetDescription.
@Test
public void testGetDescription() {
FunctionInterface fi = fff.getInstance(cl, "GetDescription");
fi.reset();
fi.setInMessage(createTestNavajo());
Navajo doc = createTestNavajo();
fi.insertPropertyOperand(doc.getProperty("/Single/Selectie"));
Object o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals("", o.toString());
}
Aggregations