use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class DataObjectTest method testDataObject.
/**
* DataObject is linked via association with Human Task. Work item should
* obtain this DataObject in parameters.
*/
@Test(timeout = 30000)
public void testDataObject() {
KieSession ksession = createKSession(PROCESS);
IterableProcessEventListener listener = new IterableProcessEventListener();
ksession.addEventListener(listener);
Map<String, Object> params = new HashMap<String, Object>();
Person mojmir = new Person("Mojmir");
params.put("person", mojmir);
JbpmJUnitBaseTestCase.TestWorkItemHandler wih = getTestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", wih);
StartProcessCommand spc = new StartProcessCommand();
spc.setProcessId(PROCESS_ID);
spc.setParameters(params);
ksession.execute(spc);
assertChangedVariable(listener, "person", null, mojmir);
assertProcessStarted(listener, PROCESS_ID);
assertNextNode(listener, "start");
assertTriggered(listener, "userTask");
WorkItem wi = wih.getWorkItem();
assertTrue(wi.getParameters().containsKey("PersonInput"));
Object param = wi.getParameter("PersonInput");
assertTrue(param instanceof Person);
Person userTaskInput = (Person) param;
assertEquals("Mojmir", userTaskInput.getName());
listener.clear();
ksession.getWorkItemManager().completeWorkItem(wi.getId(), null);
assertLeft(listener, "userTask");
assertNextNode(listener, "end");
assertProcessCompleted(listener, PROCESS_ID);
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testSignalStartEvent.
@Test(timeout = 30000)
public void testSignalStartEvent() {
KieSession ksession = createKSession(SIGNAL);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = getCommands().newSignalEvent("start", null);
ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(SIGNAL_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(SIGNAL_ID)).isTrue();
assertProcessStarted(events, SIGNAL_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertNextNode(events, "end");
assertProcessCompleted(events, SIGNAL_ID);
Assertions.assertThat(events.hasNext()).isFalse();
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class ExclusiveGatewayTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
ksession = createKSession(EXCLUSIVE_GATEWAY);
iterableListener = new IterableProcessEventListener();
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class EndEventTest method testNoneEndEvent.
@Test(timeout = 30000)
public void testNoneEndEvent() {
KieSession ksession = createKSession(NONE);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = CommandFactory.newStartProcess(NONE_ID);
ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(NONE_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(NONE_ID)).isTrue();
assertProcessStarted(events, NONE_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertNextNode(events, "end");
assertProcessCompleted(events, NONE_ID);
Assertions.assertThat(events.hasNext()).isFalse();
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class EndEventTest method testCompensateEndEvent.
@BZ("1021631")
@Test(timeout = 30000)
public void testCompensateEndEvent() {
KieSession ksession = createKSession(COMPENSATE);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<ProcessInstance> cmd = getCommands().newStartProcess(COMPENSATE_ID);
ProcessInstance pi = ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(COMPENSATE_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(COMPENSATE_ID)).isTrue();
assertProcessStarted(events, COMPENSATE_ID);
assertNextNode(events, "start");
assertTriggered(events, "subprocess");
assertNextNode(events, "sub-start");
assertTriggered(events, "script");
assertChangedVariable(events, "x", null, 0);
assertLeft(events, "script");
assertNextNode(events, "sub-end");
assertLeft(events, "subprocess");
assertTriggered(events, "end");
assertLeft(events, "compensate-catch");
assertTriggered(events, "compensate");
assertChangedVariable(events, "x", 0, null);
assertLeft(events, "compensate");
Assertions.assertThat(pi.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Aggregations