use of org.jbpm.test.container.listeners.TrackingAgendaEventListener in project jbpm by kiegroup.
the class ETransactionTest method testRuleFlowGroup.
@Test
public void testRuleFlowGroup() throws Exception {
TrackingAgendaEventListener agenda = new TrackingAgendaEventListener();
RuntimeManager manager = deploymentService.getRuntimeManager(kieJar);
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
engine.getKieSession().addEventListener(agenda);
Long processInstanceId = startProcessInstance(PROCESS_ID);
UserTransaction ut = InitialContext.doLookup(USER_TRANSACTION_NAME);
ut.begin();
processService.signalProcessInstance(processInstanceId, "start", "rfg");
Assertions.assertThat(hasNodeLeft(processInstanceId, "rfg")).isTrue();
ut.rollback();
agenda.clear();
processService.execute(kieJar, new FireAllRulesCommand());
Assertions.assertThat(agenda.isRuleFired("dummyRule")).isFalse();
agenda.clear();
ut = InitialContext.doLookup(USER_TRANSACTION_NAME);
ut.begin();
processService.signalProcessInstance(processInstanceId, "start", "rfg");
ut.commit();
Assertions.assertThat(hasNodeLeft(processInstanceId, "rfg")).isTrue();
processService.execute(kieJar, new FireAllRulesCommand());
processService.signalProcessInstance(processInstanceId, "finish", null);
Assertions.assertThat(agenda.isRuleFired("dummyRule")).isTrue();
Assertions.assertThat(hasProcessInstanceCompleted(processInstanceId)).isTrue();
}
use of org.jbpm.test.container.listeners.TrackingAgendaEventListener 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();
}
Aggregations