ProcessInstance processInstance = ( ProcessInstance )
workingMemory.startProcess("com.sample.ruleflow", map);
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
assertEquals(2, workingMemory.getProcessInstances().size());
for (ProcessInstance p: workingMemory.getProcessInstances()) {
VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
(( ProcessInstance )p).getContextInstance(VariableScope.VARIABLE_SCOPE);
if ("com.sample.ruleflow".equals(p.getProcessId())) {
assertEquals("x-value", variableScopeInstance.getVariable("x"));
} else if ("com.sample.subflow".equals(p.getProcessId())) {
assertEquals("x-value", variableScopeInstance.getVariable("y"));
assertEquals("z-value", variableScopeInstance.getVariable("z"));
assertEquals(7, variableScopeInstance.getVariable("n"));
assertEquals(10, variableScopeInstance.getVariable("o"));
}
}
workingMemory.insert(new Person());
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
assertEquals("z-value", variableScopeInstance.getVariable("x"));
assertEquals(10, variableScopeInstance.getVariable("m"));
assertEquals(0, workingMemory.getProcessInstances().size());
}