Search in sources :

Example 16 with RequirePersistence

use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.

the class ActivityTest method testBusinessRuleTask.

@Test
@RequirePersistence(false)
public void testBusinessRuleTask() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BusinessRuleTask.bpmn2", "BPMN2-BusinessRuleTask.drl");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(new RuleAwareProcessEventLister());
    ProcessInstance processInstance = ksession.startProcess("BPMN2-BusinessRuleTask");
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : KieBase(org.kie.api.KieBase) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) RuleAwareProcessEventLister(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister) Test(org.junit.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Example 17 with RequirePersistence

use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.

the class ActivityTest method testRuleTaskWithFactsWithPersistence.

@Test
@RequirePersistence
public void testRuleTaskWithFactsWithPersistence() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-RuleTaskWithFact.bpmn2", "BPMN2-RuleTask3.drl");
    ksession = createKnowledgeSession(kbase);
    ((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession().addEventListener(new TriggerRulesEventListener(ksession));
    ksession.addEventListener(new DebugAgendaEventListener());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "SomeString");
    ProcessInstance processInstance = ksession.startProcess("RuleTask", params);
    assertProcessInstanceFinished(processInstance, ksession);
    params = new HashMap<String, Object>();
    try {
        processInstance = ksession.startProcess("RuleTask", params);
        fail("Should fail");
    } catch (Exception e) {
        e.printStackTrace();
    }
    params = new HashMap<String, Object>();
    params.put("x", "SomeString");
    processInstance = ksession.startProcess("RuleTask", params);
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : DebugAgendaEventListener(org.kie.api.event.rule.DebugAgendaEventListener) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) TriggerRulesEventListener(org.jbpm.process.instance.event.listeners.TriggerRulesEventListener) WorkflowRuntimeException(org.jbpm.workflow.instance.WorkflowRuntimeException) Test(org.junit.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Example 18 with RequirePersistence

use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.

the class ActivityTest method testBusinessRuleTaskWithPersistence.

@Test
@RequirePersistence(true)
public void testBusinessRuleTaskWithPersistence() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BusinessRuleTask.bpmn2", "BPMN2-BusinessRuleTask.drl");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(new RuleAwareProcessEventLister());
    ProcessInstance processInstance = ksession.startProcess("BPMN2-BusinessRuleTask");
    ksession = restoreSession(ksession, true);
    ksession.addEventListener(new RuleAwareProcessEventLister());
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : KieBase(org.kie.api.KieBase) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) RuleAwareProcessEventLister(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister) Test(org.junit.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Aggregations

RequirePersistence (org.jbpm.bpmn2.test.RequirePersistence)18 Test (org.junit.Test)18 KieBase (org.kie.api.KieBase)18 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)17 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)17 HashMap (java.util.HashMap)9 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)9 DoNothingWorkItemHandler (org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler)6 CommandBasedStatefulKnowledgeSession (org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession)5 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)4 Environment (org.kie.api.runtime.Environment)4 ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)3 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)3 ArrayList (java.util.ArrayList)2 RegistryContext (org.drools.core.command.impl.RegistryContext)2 ProcessPersistenceContext (org.jbpm.persistence.api.ProcessPersistenceContext)2 AuditLogService (org.jbpm.process.audit.AuditLogService)2 JPAAuditLogService (org.jbpm.process.audit.JPAAuditLogService)2 RuleAwareProcessEventLister (org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister)2 WorkflowRuntimeException (org.jbpm.workflow.instance.WorkflowRuntimeException)2