new ConnectionImpl(
subProcessNode, Node.CONNECTION_DEFAULT_TYPE,
endNode, Node.CONNECTION_DEFAULT_TYPE
);
AbstractRuleBase ruleBase = (AbstractRuleBase) RuleBaseFactory.newRuleBase();
ruleBase.addProcess(process);
process = new RuleFlowProcess();
process.setId("org.drools.process.subprocess");
process.setName("SubProcess");
startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
process.addNode(startNode);
endNode = new EndNode();
endNode.setName("EndNode");
endNode.setId(2);
process.addNode(endNode);
ActionNode actionNode = new ActionNode();
actionNode.setName("Action");
DroolsAction action = new DroolsConsequenceAction("java", null);
action.setMetaData("Action", new Action() {
public void execute(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory, ProcessContext context) throws Exception {
System.out.println("Executed action");
executed = true;
}
});
actionNode.setAction(action);
process.addNode(actionNode);
new ConnectionImpl(
startNode, Node.CONNECTION_DEFAULT_TYPE,
actionNode, Node.CONNECTION_DEFAULT_TYPE
);
new ConnectionImpl(
actionNode, Node.CONNECTION_DEFAULT_TYPE,
endNode, Node.CONNECTION_DEFAULT_TYPE
);
ruleBase.addProcess(process);
InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1, ruleBase);
workingMemory.startProcess("org.drools.process.process");
assertTrue(executed);
assertEquals(0, workingMemory.getProcessInstances().size());