use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.
the class ExpressionFieldActionTest method testIFIntegerZero.
@Test
public void testIFIntegerZero() throws Exception {
Expression action = new Expression();
action.setExpression("IF(${0} == 0, 0, 1)");
assertEquals(0, ExpressionFieldAction.process(action, Arrays.asList(0)));
assertEquals(1, ExpressionFieldAction.process(action, Arrays.asList(1)));
}
use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.
the class ExpressionFieldActionTest method testGT.
@Test
public void testGT() throws Exception {
Expression action = new Expression();
action.setExpression("IF(${0} > ${1}, ${0}, ${1})");
assertEquals(1000, ExpressionFieldAction.process(action, Arrays.asList(1000, 100)));
assertEquals(10000, ExpressionFieldAction.process(action, Arrays.asList(1000, 10000)));
assertEquals(10, ExpressionFieldAction.process(action, Arrays.asList(10, -10)));
}
use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.
the class ExpressionFieldActionTest method testSubtract.
@Test
public void testSubtract() throws Exception {
Expression action = new Expression();
action.setExpression("${0} - ${1}");
assertEquals(90, ExpressionFieldAction.process(action, Arrays.asList(100, 10)));
}
use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.
the class ExpressionFieldActionTest method testNot.
@Test
public void testNot() throws Exception {
Expression action = new Expression();
action.setExpression("IF(!ISEMPTY(${0}), 'not empty', 'empty')");
assertEquals("not empty", ExpressionFieldAction.process(action, Arrays.asList("foo")));
assertEquals("not empty", ExpressionFieldAction.process(action, Arrays.asList(" ")));
assertEquals("empty", ExpressionFieldAction.process(action, Arrays.asList("")));
assertEquals("empty", ExpressionFieldAction.process(action, Arrays.asList((Object) null)));
}
use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.
the class ExpressionFieldActionTest method testIF.
/*
* functions
*/
@Test
public void testIF() throws Exception {
Expression action = new Expression();
action.setExpression("IF(${0} == ${1}, 'same', 'not same')");
assertEquals("same", ExpressionFieldAction.process(action, Arrays.asList(10, 10)));
assertEquals("not same", ExpressionFieldAction.process(action, Arrays.asList(100, 10)));
}
Aggregations