public void esbToJBpmAndBack() throws Exception
{
SAXReader reader = new SAXReader();
Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
Element element = document.getRootElement();
DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
DefaultElement esbToBpmVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("esbToBpmVars");
String helloWorldTokenScope = "Hello world token scope";
String helloWorldGlobalScope = "Hello world process-instance scope";
TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
Token token = processInstance.getRootToken();
processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
ExecutionContext executionContext = new ExecutionContext(token);
JBpmObjectMapper mapper = new JBpmObjectMapper();
Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
//Setting up return mapping for the callback service.
EsbActionHandler esbActionHandler = new EsbActionHandler();
EPR epr = esbActionHandler.createReplyTo(esbToBpmVars.asXML(), Boolean.FALSE, executionContext);
String esbToBpmXml = epr.getAddr().getExtensionValue(Constants.ESB_TO_BPM_VARS_TAG);
//Obtaining the VariableMap that is going to be set callback command
Map<String,Object> variableMap = mapper.mapFromEsbMessageToJBpmMap(message, esbToBpmVars.asXML());
logger.info(variableMap);
//Let's make sure that what we put in is going to make it roundtrip.
assertEquals(helloWorldTokenScope, variableMap.get("x1"));
assertEquals(helloWorldGlobalScope,variableMap.get("x2"));
}