use of org.jbpm.test.container.listeners.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testRuleflowGroup.
@Test
public void testRuleflowGroup() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener();
TrackingAgendaEventListener agenda = new TrackingAgendaEventListener();
KieSession ksession = createJPASession(getKnowledgeBase());
ksession.addEventListener(process);
ksession.addEventListener(agenda);
long processId = ksession.startProcess(LocalTransactions.PROCESS_TRANSACTIONS).getId();
UserTransaction ut = getUserTransaction();
ut.begin();
ksession.signalEvent("start", "rfg", processId);
Assertions.assertThat(process.wasNodeLeft("rfg")).isTrue();
ut.rollback();
Thread.sleep(600);
process.clear();
agenda.clear();
ksession = reloadSession(ksession);
ksession.addEventListener(process);
ksession.addEventListener(agenda);
ksession.fireAllRules();
Assertions.assertThat(agenda.isRuleFired("dummyRule")).isFalse();
agenda.clear();
process.clear();
ut = getUserTransaction();
ut.begin();
ksession.signalEvent("start", "rfg", processId);
Thread.sleep(1000);
ut.commit();
Assertions.assertThat(process.wasNodeLeft("rfg")).isTrue();
ksession.fireAllRules();
ksession.signalEvent("finish", null, processId);
Thread.sleep(1000);
Assertions.assertThat(agenda.isRuleFired("dummyRule")).isTrue();
Assertions.assertThat(process.wasProcessCompleted(LocalTransactions.PROCESS_TRANSACTIONS)).isTrue();
}
use of org.jbpm.test.container.listeners.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testForloop.
@Test
public void testForloop() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener();
KieSession ksession = createJPASession(getKnowledgeBase());
ksession.addEventListener(process);
Map<String, Object> params = new HashMap<String, Object>();
params.put("collection", Arrays.asList("hello world", "25", "false", "1234567891011121314151617181920", ""));
long processId = ksession.startProcess(LocalTransactions.PROCESS_TRANSACTIONS, params).getId();
UserTransaction ut = getUserTransaction();
ut.begin();
ksession.signalEvent("start", "forloop", processId);
Thread.sleep(1000);
Assertions.assertThat(process.wasNodeLeft("forloop")).isTrue();
ut.rollback();
process.clear();
ksession = reloadSession(ksession);
ksession.addEventListener(process);
ut = getUserTransaction();
ut.begin();
ksession.signalEvent("start", "forloop", processId);
ut.commit();
Thread.sleep(5000);
Assertions.assertThat(process.wasNodeLeft("forloop")).isTrue();
Assertions.assertThat(process.wasNodeLeft("Multiple Instances")).isTrue();
Assertions.assertThat(process.wasProcessCompleted(LocalTransactions.PROCESS_TRANSACTIONS)).isFalse();
}
use of org.jbpm.test.container.listeners.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testEmbedded.
@Test
public void testEmbedded() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener();
KieSession ksession = createJPASession(getKnowledgeBase());
ksession.addEventListener(process);
long processId = ksession.startProcess(LocalTransactions.PROCESS_TRANSACTIONS).getId();
UserTransaction ut = getUserTransaction();
ut.begin();
ksession.signalEvent("start", "embedded", processId);
Thread.sleep(1000);
Assertions.assertThat(process.wasNodeLeft("embedded")).isTrue();
ut.rollback();
process.clear();
ksession = reloadSession(ksession);
ksession.addEventListener(process);
ut = getUserTransaction();
ut.begin();
ksession.signalEvent("start", "embedded", processId);
ut.commit();
Thread.sleep(5000);
Assertions.assertThat(process.wasNodeLeft("embedded")).isTrue();
Assertions.assertThat(process.wasProcessCompleted(LocalTransactions.PROCESS_TRANSACTIONS)).isFalse();
}
Aggregations