use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class ConditionalFlowTest method testConditionalFlow.
@Test(timeout = 30000)
public void testConditionalFlow() {
KieSession ksession = createKSession(PROCESS);
IterableProcessEventListener listener = new IterableProcessEventListener();
ksession.addEventListener(listener);
ksession.execute((Command<?>) getCommands().newStartProcess(PROCESS_ID));
assertProcessStarted(listener, PROCESS_ID);
assertNextNode(listener, "start");
assertTriggered(listener, "script");
assertChangedVariable(listener, "x", null, 5);
assertLeft(listener, "script");
assertNextNode(listener, "end1");
assertProcessCompleted(listener, PROCESS_ID);
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class ScriptTaskTest method testScriptTask.
/**
* Object and collection access
*/
@Test(timeout = 30000)
public void testScriptTask() {
KieSession kieSession = createKSession(SCRIPT_TASK);
IterableProcessEventListener ipel = new IterableProcessEventListener();
kieSession.addEventListener(ipel);
Map<String, Object> params = new HashMap<String, Object>();
Person p = new Person("Vandrovec");
params.put("person", p);
List<Person> personList = new ArrayList<Person>();
personList.add(new Person("Birsky"));
personList.add(new Person("Korcasko"));
params.put("personList", personList);
kieSession.execute((Command<?>) getCommands().newStartProcess(SCRIPT_TASK_ID, params));
assertMultipleVariablesChanged(ipel, "person", "personList");
assertProcessStarted(ipel, SCRIPT_TASK_ID);
assertNextNode(ipel, "start");
assertTriggered(ipel, "scriptJava");
assertChangedVariable(ipel, "output", null, "BirskyKorcaskoVandrovec");
assertLeft(ipel, "scriptJava");
assertTriggered(ipel, "scriptMvel");
assertChangedVariable(ipel, "output", "BirskyKorcaskoVandrovec", "VandrovecBirskyKorcasko");
assertLeft(ipel, "scriptMvel");
assertTriggered(ipel, "scriptJavaScript");
assertChangedVariable(ipel, "output", "VandrovecBirskyKorcasko", "JavaScript Node: Vandrovec");
assertLeft(ipel, "scriptJavaScript");
assertNextNode(ipel, "end");
assertProcessCompleted(ipel, SCRIPT_TASK_ID);
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class RuleTaskTest method testRuleTask.
@Test(timeout = 30000)
public void testRuleTask() {
Map<String, ResourceType> res = new HashMap<String, ResourceType>();
res.put(RULE_TASK, ResourceType.BPMN2);
res.put(RULE_TASK_DRL, ResourceType.DRL);
KieSession kieSession = createKSession(res);
List<String> executedRules = new ArrayList<String>();
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(CommandFactory.newSetGlobal("executed", executedRules));
commands.add(CommandFactory.newStartProcess(RULE_TASK_ID));
commands.add(CommandFactory.newFireAllRules());
IterableProcessEventListener listener = new IterableProcessEventListener();
kieSession.addEventListener(listener);
kieSession.execute(CommandFactory.newBatchExecution(commands));
assertProcessStarted(listener, RULE_TASK_ID);
assertNextNode(listener, "start");
assertNextNode(listener, "rules");
assertNextNode(listener, "end");
assertProcessCompleted(listener, RULE_TASK_ID);
assertEquals(3, executedRules.size());
String[] expected = new String[] { "firstRule", "secondRule", "thirdRule" };
for (String expectedRuleName : expected) {
assertTrue(executedRules.contains(expectedRuleName));
}
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class RuleTaskTest method testRuleTaskInsertFact.
@Test(timeout = 30000)
public void testRuleTaskInsertFact() {
Map<String, ResourceType> res = new HashMap<String, ResourceType>();
res.put(RULE_TASK, ResourceType.BPMN2);
res.put(RULE_TASK_DRL, ResourceType.DRL);
KieSession kieSession = createKSession(res);
List<String> executedRules = new ArrayList<String>();
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(CommandFactory.newSetGlobal("executed", executedRules));
commands.add(CommandFactory.newInsert(6));
commands.add(CommandFactory.newStartProcess(RULE_TASK_ID));
commands.add(CommandFactory.newFireAllRules());
IterableProcessEventListener listener = new IterableProcessEventListener();
kieSession.addEventListener(listener);
kieSession.execute(CommandFactory.newBatchExecution(commands));
assertProcessStarted(listener, RULE_TASK_ID);
assertNextNode(listener, "start");
assertNextNode(listener, "rules");
assertNextNode(listener, "end");
assertProcessCompleted(listener, RULE_TASK_ID);
assertEquals(4, executedRules.size());
String[] expected = new String[] { "firstRule", "secondRule", "thirdRule", "fifthRule" };
for (String expectedRuleName : expected) {
assertTrue(executedRules.contains(expectedRuleName));
}
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class EmbeddedSubProcessTest method testProcessWithEmbeddedSubprocess.
@Test(timeout = 30000)
public void testProcessWithEmbeddedSubprocess() {
KieSession kieSession = createKSession(EMBEDDED);
IterableProcessEventListener eventListener = new IterableProcessEventListener();
kieSession.addEventListener(eventListener);
kieSession.execute((Command<?>) getCommands().newStartProcess(EMBEDDED_ID));
assertProcessStarted(eventListener, EMBEDDED_ID);
assertNextNode(eventListener, "start");
assertNextNode(eventListener, "ScriptOuter");
assertTriggered(eventListener, "embedded");
logger.debug("inside embedded subprocess");
assertNextNode(eventListener, "sub-start");
assertNextNode(eventListener, "ScriptInner");
assertNextNode(eventListener, "sub-end");
assertLeft(eventListener, "embedded");
logger.debug("outside embedded subprocess");
assertNextNode(eventListener, "end");
assertProcessCompleted(eventListener, EMBEDDED_ID);
}
Aggregations