action.setData("b=B");
action.setExternalId("ext");
action.setTrackerUri("tracker");
action.setExternalStatus("externalStatus");
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("workflow");
DagELFunctions.configureEvaluator(eval, wf, action);
assertEquals("wfId", eval.evaluate("${wf:id()}", String.class));
assertEquals("name", eval.evaluate("${wf:name()}", String.class));
assertEquals("appPath", eval.evaluate("${wf:appPath()}", String.class));
assertEquals("A", eval.evaluate("${wf:conf('a')}", String.class));
assertEquals("A", eval.evaluate("${a}", String.class));
assertEquals("user", eval.evaluate("${wf:user()}", String.class));
assertEquals("group", eval.evaluate("${wf:group()}", String.class));
assertTrue(eval.evaluate("${wf:callback('XX')}", String.class).contains("id=actionId"));
assertTrue(eval.evaluate("${wf:callback('XX')}", String.class).contains("status=XX"));
assertTrue(eval.evaluate("${wf:callback('XX')}", String.class).contains("status=XX"));
assertEquals(2, (int) eval.evaluate("${wf:run()}", Integer.class));
action.setStatus(WorkflowAction.Status.ERROR);
System.out.println("WorkflowInstance " + wf.getWorkflowInstance().getStatus().toString());
WorkflowInstance wfInstance = wf.getWorkflowInstance();
DagELFunctions.setActionInfo(wfInstance, action);
wf.setWorkflowInstance(wfInstance);
assertEquals("actionName", eval.evaluate("${wf:lastErrorNode()}", String.class));
assertEquals("ec", eval.evaluate("${wf:errorCode('actionName')}", String.class));
assertEquals("em", eval.evaluate("${wf:errorMessage('actionName')}", String.class));
assertEquals("B", eval.evaluate("${wf:actionData('actionName')['b']}", String.class));
String expected = XmlUtils.escapeCharsForXML("{\"b\":\"B\"}");
assertEquals(expected, eval.evaluate("${toJsonStr(wf:actionData('actionName'))}", String.class));
expected = XmlUtils.escapeCharsForXML("b=B");
assertTrue(eval.evaluate("${toPropertiesStr(wf:actionData('actionName'))}", String.class).contains(expected));
conf = new XConfiguration();
conf.set("b", "B");
expected = XmlUtils.escapeCharsForXML(XmlUtils.prettyPrint(conf).toString());
assertTrue(eval.evaluate("${toConfigurationStr(wf:actionData('actionName'))}", String.class).contains(expected));
assertEquals("ext", eval.evaluate("${wf:actionExternalId('actionName')}", String.class));
assertEquals("tracker", eval.evaluate("${wf:actionTrackerUri('actionName')}", String.class));
assertEquals("externalStatus", eval.evaluate("${wf:actionExternalStatus('actionName')}", String.class));
}