Search in sources :

Example 1 with TaskProviders

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);
}
Also used : TaskProviders(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 2 with TaskProviders

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);
}
Also used : TaskProviders(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 3 with TaskProviders

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")));
}
Also used : TaskProviders(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 4 with TaskProviders

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")));
}
Also used : TaskProviders(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 5 with TaskProviders

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);
}
Also used : TaskProviders(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Aggregations

TaskProviders (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders)18 Test (org.junit.jupiter.api.Test)15 Matchers.containsString (org.hamcrest.Matchers.containsString)14 TaskCallInterceptor (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor)2 TaskException (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskException)2 Frame (com.walmartlabs.concord.svm.Frame)2 AbstractModule (com.google.inject.AbstractModule)1 Multibinder (com.google.inject.multibindings.Multibinder)1 FormService (com.walmartlabs.concord.runtime.common.FormService)1 TaskCall (com.walmartlabs.concord.runtime.v2.model.TaskCall)1 TaskCallOptions (com.walmartlabs.concord.runtime.v2.model.TaskCallOptions)1 DefaultCheckpointService (com.walmartlabs.concord.runtime.v2.runner.checkpoints.DefaultCheckpointService)1 ExpressionEvaluator (com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)1 BeanELResolver (com.walmartlabs.concord.runtime.v2.runner.el.resolvers.BeanELResolver)1 BaseRunnerModule (com.walmartlabs.concord.runtime.v2.runner.guice.BaseRunnerModule)1 LogContext (com.walmartlabs.concord.runtime.v2.runner.logging.LogContext)1 CallContext (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor.CallContext)1 TaskCallListener (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallListener)1 TaskCallPolicyChecker (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallPolicyChecker)1 TaskResultListener (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskResultListener)1