RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
WorkingMemory workingMemory = ruleBase.newStatefulSession();
List<String> list = new ArrayList<String>();
workingMemory.setGlobal("list", list);
ProcessInstance processInstance = ( ProcessInstance )
workingMemory.startProcess("org.drools.actions");
assertEquals(3, list.size());
assertEquals("SomeText", list.get(0));
assertEquals("MyActionNode", list.get(1));
assertEquals("MyActionNode", list.get(2));
Iterator<?> iterator = workingMemory.iterateObjects(new ObjectFilter() {
public boolean accept(Object object) {
return object instanceof Message;
}
});
assertTrue(iterator.hasNext());
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}