Search in sources :

Example 21 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledMoneyExpression method testAddWithMoney.

@Test
public void testAddWithMoney() {
    Operand result;
    result = Expression.evaluate("ToMoney(15) + ToMoney(10)", null, null, null);
    Assert.assertEquals(new Money(25), result.value);
    result = Expression.evaluate("15 + ToMoney(10)", null, null, null);
    Assert.assertEquals(new Money(25), result.value);
    result = Expression.evaluate("ToMoney(15) + 10", null, null, null);
    Assert.assertEquals(new Money(25), result.value);
    result = Expression.evaluate("ToLong(15) + ToMoney(10)", null, null, null);
    Assert.assertEquals(new Money(25), result.value);
    result = Expression.evaluate("ToMoney(15) + ToLong(10)", null, null, null);
    Assert.assertEquals(new Money(25), result.value);
    result = Expression.evaluate("15.0 + ToMoney(10)", null, null, null);
    Assert.assertEquals(new Money(25), result.value);
    result = Expression.evaluate("ToMoney(15) + 10.0", null, null, null);
    Assert.assertEquals(new Money(25), result.value);
}
Also used : Money(com.dexels.navajo.document.types.Money) Operand(com.dexels.navajo.document.Operand) Test(org.junit.Test)

Example 22 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledStringExpression method testAddStringAndDouble.

@Test
public void testAddStringAndDouble() {
    Operand result = Expression.evaluate("'bla' + 10.0", null, null, null);
    assertEquals("bla10.0", result.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) Test(org.junit.Test)

Example 23 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledStringExpression method testAddLongAndString.

@Test
public void testAddLongAndString() {
    FunctionInterface giveLongFunction = new GiveLongTestFunction();
    FunctionDefinition fd = new FunctionDefinition(giveLongFunction.getClass().getName(), "description", "input", "result");
    FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("ToLong", fd);
    Operand result = Expression.evaluate("ToLong(15) + 'bla'", null, null, null);
    assertEquals("15bla", result.value);
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Operand(com.dexels.navajo.document.Operand) FunctionDefinition(com.dexels.navajo.expression.api.FunctionDefinition) GiveLongTestFunction(com.dexels.navajo.expression.compiled.GiveLongTestFunction) Test(org.junit.Test)

Example 24 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledStringExpression method testAddStringAndInteger.

@Test
public void testAddStringAndInteger() {
    Operand result = Expression.evaluate("'bla' + 10", null, null, null);
    assertEquals("bla10", result.value);
}
Also used : Operand(com.dexels.navajo.document.Operand) Test(org.junit.Test)

Example 25 with Operand

use of com.dexels.navajo.document.Operand in project navajo by Dexels.

the class TestCompiledStringExpression method testAddStringAndLong.

@Test
public void testAddStringAndLong() {
    FunctionInterface giveLongFunction = new GiveLongTestFunction();
    FunctionDefinition fd = new FunctionDefinition(giveLongFunction.getClass().getName(), "description", "input", "result");
    FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("ToLong", fd);
    Operand result = Expression.evaluate("'bla' + ToLong(10)", null, null, null);
    assertEquals("bla10", result.value);
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Operand(com.dexels.navajo.document.Operand) FunctionDefinition(com.dexels.navajo.expression.api.FunctionDefinition) GiveLongTestFunction(com.dexels.navajo.expression.compiled.GiveLongTestFunction) Test(org.junit.Test)

Aggregations

Operand (com.dexels.navajo.document.Operand)95 Test (org.junit.Test)57 Message (com.dexels.navajo.document.Message)22 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)20 Navajo (com.dexels.navajo.document.Navajo)20 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)15 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)14 ArrayList (java.util.ArrayList)12 Selection (com.dexels.navajo.document.Selection)11 Property (com.dexels.navajo.document.Property)10 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)10 Access (com.dexels.navajo.script.api.Access)10 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)10 NavajoException (com.dexels.navajo.document.NavajoException)9 TipiLink (com.dexels.navajo.expression.api.TipiLink)9 Optional (java.util.Optional)9 FunctionDefinition (com.dexels.navajo.expression.api.FunctionDefinition)8 GiveLongTestFunction (com.dexels.navajo.expression.compiled.GiveLongTestFunction)6 SystemException (com.dexels.navajo.script.api.SystemException)6 List (java.util.List)6