import org.jbpm.ruleflow.instance.RuleFlowProcessInstance;
public class ProcessSplitTest extends JbpmTestCase {
public void testSplitWithProcessInstanceConstraint() {
PackageBuilder builder = new PackageBuilder();
Reader source = new StringReader(
"<process xmlns=\"http://drools.org/drools-5.0/process\"" +
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"" +
" type=\"RuleFlow\" name=\"ruleflow\" id=\"org.jbpm.process-split\" package-name=\"org.jbpm\" >" +
"" +
" <header>" +
" <imports>" +
" <import name=\"org.jbpm.Person\" />" +
" <import name=\"org.jbpm.integrationtests.ProcessSplitTest.ProcessUtils\" />" +
" </imports>" +
" <globals>" +
" <global identifier=\"list\" type=\"java.util.List\" />" +
" </globals>" +
" <variables>\n" +
" <variable name=\"name\" >\n" +
" <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
" </variable>\n" +
" </variables>\n" +
" </header>" +
"" +
" <nodes>" +
" <actionNode id=\"2\" name=\"Action\" >" +
" <action type=\"expression\" dialect=\"mvel\" >insert(kcontext.getProcessInstance());</action>" +
" </actionNode>" +
" <split id=\"4\" name=\"Split\" type=\"2\" >" +
" <constraints>" +
" <constraint toNodeId=\"8\" priority=\"2\" type=\"rule\" dialect=\"mvel\" >eval(true)</constraint>" +
" <constraint toNodeId=\"6\" name=\"constraint\" priority=\"1\" type=\"rule\" dialect=\"mvel\" >processInstance: org.jbpm.ruleflow.instance.RuleFlowProcessInstance()" +
"Person( name == (ProcessUtils.getValue(processInstance, \"name\")) )</constraint>" +
" </constraints>" +
" </split>" +
" <end id=\"8\" name=\"End\" />" +
" <actionNode id=\"6\" name=\"Action\" >" +
" <action type=\"expression\" dialect=\"mvel\" >list.add(kcontext.getProcessInstance().getId());</action>" +
" </actionNode>" +
" <start id=\"1\" name=\"Start\" />" +
" <end id=\"3\" name=\"End\" />" +
" </nodes>" +
" <connections>" +
" <connection from=\"1\" to=\"2\" />" +
" <connection from=\"2\" to=\"4\" />" +
" <connection from=\"4\" to=\"8\" />" +
" <connection from=\"4\" to=\"6\" />" +
" <connection from=\"6\" to=\"3\" />" +
" </connections>" +
"" +
"</process>");
builder.addRuleFlow(source);
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
WorkingMemory workingMemory = ruleBase.newStatefulSession();
List<Long> list = new ArrayList<Long>();
workingMemory.setGlobal("list", list);