use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class LazyExpressionEvaluator method createResolver.
/**
* Based on the original code from {@link StandardELContext#getELResolver()}.
* Creates a {@link ELResolver} instance with "sub-resolvers" in the original order.
*/
private ELResolver createResolver(LazyEvalContext evalContext, ExpressionFactory expressionFactory) {
CompositeELResolver r = new CompositeELResolver();
if (evalContext.scope() != null) {
r.add(new VariableResolver(evalContext.scope()));
}
r.add(new VariableResolver(evalContext.variables()));
if (evalContext.context() != null) {
r.add(new TaskResolver(evalContext.context(), taskProviders));
}
r.add(expressionFactory.getStreamELResolver());
r.add(new StaticFieldELResolver());
r.add(new MapELResolver());
r.add(new MethodAccessorResolver());
r.add(new ResourceBundleELResolver());
r.add(new ListELResolver());
r.add(new ArrayELResolver());
if (evalContext.context() != null) {
r.add(new TaskMethodResolver(evalContext.context()));
}
r.add(new BeanELResolver());
return r;
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class MainTest method setUp.
@BeforeEach
public void setUp() throws IOException {
workDir = Files.createTempDirectory("test");
instanceId = UUID.randomUUID();
Path formsDir = workDir.resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME).resolve(Constants.Files.JOB_STATE_DIR_NAME).resolve(Constants.Files.JOB_FORMS_V2_DIR_NAME);
formService = new FormService(formsDir);
processStatusCallback = mock(ProcessStatusCallback.class);
checkpointService = spy(new TestCheckpointUploader());
testServices = new AbstractModule() {
@Override
protected void configure() {
install(new BaseRunnerModule());
bind(ClassLoader.class).annotatedWith(Names.named("runtime")).toInstance(MainTest.class.getClassLoader());
bind(CheckpointUploader.class).toInstance(checkpointService);
bind(CheckpointService.class).to(DefaultCheckpointService.class);
bind(DependencyManager.class).to(DefaultDependencyManager.class);
bind(DockerService.class).to(DefaultDockerService.class);
bind(FileService.class).to(DefaultFileService.class);
bind(LockService.class).to(DefaultLockService.class);
bind(PersistenceService.class).toInstance(mock(PersistenceService.class));
bind(ProcessStatusCallback.class).toInstance(processStatusCallback);
bind(SecretService.class).to(DefaultSecretService.class);
Multibinder<TaskProvider> taskProviders = Multibinder.newSetBinder(binder(), TaskProvider.class);
taskProviders.addBinding().to(TaskV2Provider.class);
Multibinder<TaskCallListener> taskCallListeners = Multibinder.newSetBinder(binder(), TaskCallListener.class);
taskCallListeners.addBinding().to(TaskCallPolicyChecker.class);
taskCallListeners.addBinding().to(TaskResultListener.class);
Multibinder.newSetBinder(binder(), ExecutionListener.class);
}
};
allLogs = null;
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testEval1.
@Test
public void testEval1() {
/*
* configuration:
* arguments:
* x: ${y}
* z: ${y.y1}
* y:
* y1: ${task(..)}
* y2: "asdasd"
* y3: ${z}
*/
Map<Object, Object> input = map("x", "${y}", "z", "${y.y1}", "y", map("y1", "${in}", "y2", "abc", "y3", "${z}"));
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
Map<String, Object> vars = Collections.singletonMap("in", "task");
// scope -> ok
// ---
Map<Object, Object> output = ee.evalAsMap(scope(vars), input);
Map<Object, Object> y = map("y1", "task", "y2", "abc", "y3", "task");
assertThat(output, is(map("x", y, "z", "task", "y", y)));
// ---
try {
ee.evalAsMap(global(vars), input);
fail("exception expected");
} catch (RuntimeException e) {
assertThat(e.getMessage(), containsString("variable in '${y}'"));
}
// undef -> x = null, z = null, y ...y3 = null
// ---
output = ee.evalAsMap(undefAsNull(global(vars)), input);
y.put("y3", null);
assertThat(output, is(map("x", null, "z", null, "y", y)));
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testEval2.
@Test
public void testEval2() {
Map<Object, Object> input = map("x", "${y}", "y", "${x}");
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
Map<String, Object> vars = Collections.emptyMap();
// ---
try {
ee.evalAsMap(global(vars), input);
fail("exception expected");
} catch (RuntimeException e) {
assertThat(e.getMessage(), containsString("variable in '${y}'"));
}
// ---
try {
ee.evalAsMap(scope(vars), input);
fail("exception expected");
} catch (RuntimeException e) {
assertThat(e.getMessage(), containsString("Key 'x' already in evaluation"));
}
}
use of com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders in project concord by walmartlabs.
the class ExpressionEvaluatorTest method testEvaGlobal.
@Test
public void testEvaGlobal() {
ExpressionEvaluator ee = new DefaultExpressionEvaluator(new TaskProviders());
Map<String, Object> vars = Collections.singletonMap("name", "${Concord}");
// ---
String str = ee.eval(global(vars), "Hello ${name}", String.class);
assertEquals("Hello ${Concord}", str);
}
Aggregations