Search in sources :

Example 6 with TriggerRulesEventListener

use of org.jbpm.process.instance.event.listeners.TriggerRulesEventListener in project jbpm by kiegroup.

the class TimerCycleOnBinaryPackageTest method testStartTimerCycleFromClasspathDRL.

@Test
@Ignore("beta4 phreak")
public void testStartTimerCycleFromClasspathDRL() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("rules-timer.drl");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    long sessionId = ksession.getIdentifier();
    Environment env = ksession.getEnvironment();
    final List<String> list = new ArrayList<String>();
    ksession.setGlobal("list", list);
    ((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
    ksession.fireAllRules();
    Thread.sleep(5000);
    assertEquals(2, list.size());
    logger.info("dispose");
    ksession.dispose();
    ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
    AuditLoggerFactory.newInstance(Type.JPA, ksession, null);
    final List<String> list2 = new ArrayList<String>();
    ksession.setGlobal("list", list2);
    ((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
    ksession.fireAllRules();
    Thread.sleep(5000);
    assertEquals(3, list2.size());
}
Also used : KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ArrayList(java.util.ArrayList) Environment(org.kie.api.runtime.Environment) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) TriggerRulesEventListener(org.jbpm.process.instance.event.listeners.TriggerRulesEventListener) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TriggerRulesEventListener (org.jbpm.process.instance.event.listeners.TriggerRulesEventListener)6 Test (org.junit.Test)6 KieBase (org.kie.api.KieBase)6 ArrayList (java.util.ArrayList)5 CommandBasedStatefulKnowledgeSession (org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession)5 Environment (org.kie.api.runtime.Environment)4 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)4 HashMap (java.util.HashMap)2 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)2 Ignore (org.junit.Ignore)2 DefaultProcessEventListener (org.kie.api.event.process.DefaultProcessEventListener)2 ProcessStartedEvent (org.kie.api.event.process.ProcessStartedEvent)2 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)2 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)2 Address (org.jbpm.bpmn2.objects.Address)1 Person (org.jbpm.bpmn2.objects.Person)1 RequirePersistence (org.jbpm.bpmn2.test.RequirePersistence)1 WorkflowRuntimeException (org.jbpm.workflow.instance.WorkflowRuntimeException)1 DebugAgendaEventListener (org.kie.api.event.rule.DebugAgendaEventListener)1