use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testStrict.
@Test
public void testStrict() {
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
Map<String, Object> vars = Collections.singletonMap("name", "Concord");
Map<String, Object> strict = Collections.singletonMap("name", "Concord!!!");
EvalContext ctx = EvalContextFactory.strict(new SingleFrameContext(vars), strict);
// ---
String str = ee.eval(ctx, "Hello ${name}", String.class);
assertEquals("Hello Concord!!!", str);
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testAllVariables.
@Test
public void testAllVariables() {
String str = "${allVariables()}";
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
// ---
Map<String, Object> vars = new HashMap<>();
vars.put("a", Collections.singletonList("b"));
vars.put("b", "bb");
Map<String, Object> result = ee.evalAsMap(global(vars), str);
assertEquals(vars, result);
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testEval8.
@Test
public void testEval8() {
/*
* x:
* - ${y}
* y: "abc"
*/
Map<Object, Object> input = map("x", Collections.singletonList("${y}"), "y", "abc");
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
Map<String, Object> vars = Collections.emptyMap();
// scope:
// ---
Map<Object, Object> output = ee.evalAsMap(scope(vars), input);
assertThat(output, is(map("x", Collections.singletonList("abc"), "y", "abc")));
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testEval6.
@Test
public void testEval6() {
Map<Object, Object> input = map("x", Collections.singletonList("${y}"), "y", "abc");
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
Map<String, Object> vars = Collections.emptyMap();
// scope:
// ---
Map<Object, Object> output = ee.evalAsMap(scope(vars), input);
assertThat(output, is(map("x", Collections.singletonList("abc"), "y", "abc")));
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testEvalHasVariable.
@Test
public void testEvalHasVariable() {
String str = "${hasVariable('x')}";
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
// ---
boolean result = ee.eval(global(Collections.emptyMap()), str, Boolean.class);
assertFalse(result);
// ---
Map<String, Object> vars = Collections.singletonMap("x", "x-value");
result = ee.eval(global(vars), str, Boolean.class);
assertTrue(result);
}
Aggregations