((InternalWorkingMemory) session).getProcessRuntime().signalEvent("MyEvent", "MyValue");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
}
public void testInternalNodeSignalCompositeEvent() {
PackageBuilder builder = new PackageBuilder();
Reader source = new StringReader(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<process xmlns=\"http://drools.org/drools-5.0/process\"\n" +
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
" xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" +
" type=\"RuleFlow\" name=\"flow\" id=\"org.drools.event\" package-name=\"org.drools\" version=\"1\" >\n" +
"\n" +
" <header>\n" +
" <variables>\n" +
" <variable name=\"MyVar\" >\n" +
" <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n" +
" <value>SomeText</value>\n" +
" </variable>\n" +
" </variables>\n" +
" </header>\n" +
"\n" +
" <nodes>\n" +
" <start id=\"1\" name=\"Start\" />\n" +
" <composite id=\"2\" name=\"CompositeNode\" >\n" +
" <nodes>\n" +
" <actionNode id=\"1\" name=\"Signal Event\" >\n" +
" <action type=\"expression\" dialect=\"java\" >context.getProcessInstance().signalEvent(\"MyEvent\", \"MyValue\");</action>\n" +
" </actionNode>\n" +
" <eventNode id=\"2\" name=\"Event\" variableName=\"MyVar\" >\n" +
" <eventFilters>\n" +
" <eventFilter type=\"eventType\" eventType=\"MyEvent\" />\n" +
" </eventFilters>\n" +
" </eventNode>\n" +
" <join id=\"3\" name=\"Join\" type=\"1\" />\n" +
" </nodes>\n" +
" <connections>\n" +
" <connection from=\"1\" to=\"3\" />\n" +
" <connection from=\"2\" to=\"3\" />\n" +
" </connections>\n" +
" <in-ports>\n" +
" <in-port type=\"DROOLS_DEFAULT\" nodeId=\"1\" nodeInType=\"DROOLS_DEFAULT\" />\n" +
" </in-ports>\n" +
" <out-ports>\n" +
" <out-port type=\"DROOLS_DEFAULT\" nodeId=\"3\" nodeOutType=\"DROOLS_DEFAULT\" />\n" +
" </out-ports>\n" +
" </composite>\n" +
" <end id=\"3\" name=\"End\" />\n" +
" </nodes>\n" +
"\n" +
" <connections>\n" +
" <connection from=\"1\" to=\"2\" />\n" +
" <connection from=\"2\" to=\"3\" />\n" +
" </connections>\n" +
"\n" +
"</process>");
builder.addRuleFlow(source);
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
WorkingMemory workingMemory = ruleBase.newStatefulSession();
ProcessInstance processInstance =
workingMemory.startProcess("org.drools.event");