Search in sources :

Example 36 with Expression

use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.

the class ExpressionFieldActionTest method testAnd.

@Test
public void testAnd() throws Exception {
    Expression action = new Expression();
    action.setExpression("IF(${0} == ${1} && ${0} == ${2}, 'all same', 'not all same')");
    assertEquals("all same", ExpressionFieldAction.process(action, Arrays.asList("foo", "foo", "foo")));
    assertEquals("all same", ExpressionFieldAction.process(action, Arrays.asList(1, 1, 1)));
    assertEquals("not all same", ExpressionFieldAction.process(action, Arrays.asList("foo", "foo", "fo")));
    assertEquals("not all same", ExpressionFieldAction.process(action, Arrays.asList(1, 1, 2)));
}
Also used : Expression(io.atlasmap.v2.Expression) Test(org.junit.jupiter.api.Test)

Example 37 with Expression

use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.

the class ExpressionFieldActionTest method testMultiply.

@Test
public void testMultiply() throws Exception {
    Expression action = new Expression();
    action.setExpression("${0} * ${1}");
    assertEquals(1000, ExpressionFieldAction.process(action, Arrays.asList(100, 10)));
}
Also used : Expression(io.atlasmap.v2.Expression) Test(org.junit.jupiter.api.Test)

Example 38 with Expression

use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.

the class ExpressionFieldActionTest method testTOLOWER.

@Test
public void testTOLOWER() throws Exception {
    Expression action = new Expression();
    action.setExpression("TOLOWER(${0})");
    assertEquals("qwerty", ExpressionFieldAction.process(action, Arrays.asList("qWeRtY")));
}
Also used : Expression(io.atlasmap.v2.Expression) Test(org.junit.jupiter.api.Test)

Example 39 with Expression

use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.

the class ExpressionFieldActionTest method testEmptyExpression.

@Test
public void testEmptyExpression() throws Exception {
    Expression action = new Expression();
    action.setExpression(null);
    assertEquals(null, ExpressionFieldAction.process(action, null));
    action.setExpression("");
    assertEquals(null, ExpressionFieldAction.process(action, null));
    action.setExpression("   ");
    assertEquals(null, ExpressionFieldAction.process(action, null));
}
Also used : Expression(io.atlasmap.v2.Expression) Test(org.junit.jupiter.api.Test)

Example 40 with Expression

use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.

the class ExpressionFieldActionTest method testIFInteger.

@Test
public void testIFInteger() throws Exception {
    Expression action = new Expression();
    action.setExpression("IF(${0} == 123, 123, 456)");
    assertEquals(123, ExpressionFieldAction.process(action, Arrays.asList(123)));
    assertEquals(456, ExpressionFieldAction.process(action, Arrays.asList(789)));
}
Also used : Expression(io.atlasmap.v2.Expression) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)34 Expression (org.apache.commons.jexl2.Expression)28 Expression (io.atlasmap.v2.Expression)26 JexlContext (org.apache.commons.jexl2.JexlContext)25 JexlEngine (org.apache.commons.jexl2.JexlEngine)22 Field (io.atlasmap.v2.Field)21 FieldGroup (io.atlasmap.v2.FieldGroup)20 MapContext (org.apache.commons.jexl2.MapContext)20 SimpleField (io.atlasmap.v2.SimpleField)16 Test (org.testng.annotations.Test)13 PropertyField (io.atlasmap.v2.PropertyField)9 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Expression (org.eclipse.xtext.resource.bug385636.Expression)7 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)7 Expression (io.atlasmap.expression.Expression)6 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ParseException (io.atlasmap.expression.parser.ParseException)4 Action (io.atlasmap.v2.Action)4 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)4