Search in sources :

Example 71 with StatefulKnowledgeSession

use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.

the class IntermediateEventTest method testSignalBoundaryEventOnSubprocessTakingDifferentPaths.

@Test
public void testSignalBoundaryEventOnSubprocessTakingDifferentPaths() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-SignalBoundaryOnSubProcess.bpmn");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    ProcessInstance processInstance = ksession.startProcess("jbpm.testing.signal");
    assertProcessInstanceActive(processInstance);
    ksession.signalEvent("continue", null, processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    ksession.dispose();
    ksession = createKnowledgeSession(kbase);
    processInstance = ksession.startProcess("jbpm.testing.signal");
    assertProcessInstanceActive(processInstance);
    ksession.signalEvent("forward", null);
    assertProcessInstanceFinished(processInstance, ksession);
    ksession.dispose();
}
Also used : KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 72 with StatefulKnowledgeSession

use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.

the class IntermediateEventTest method testSignalBoundaryEvent.

/*
     * TESTS!
     */
@Test
public void testSignalBoundaryEvent() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-BoundarySignalEventOnTaskbpmn2.bpmn", "BPMN2-IntermediateThrowEventSignal.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance processInstance = ksession.startProcess("BoundarySignalOnTask");
    ProcessInstance processInstance2 = ksession.startProcess("SignalIntermediateEvent");
    assertProcessInstanceFinished(processInstance2, ksession);
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 73 with StatefulKnowledgeSession

use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.

the class IntermediateEventTest method testSignalBetweenProcesses.

@Test
public void testSignalBetweenProcesses() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchSignalSingle.bpmn2", "BPMN2-IntermediateThrowEventSignal.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance processInstance = ksession.startProcess("BPMN2-IntermediateCatchSignalSingle");
    ksession.getWorkItemManager().completeWorkItem(handler.getWorkItem().getId(), null);
    ProcessInstance processInstance2 = ksession.startProcess("SignalIntermediateEvent");
    assertProcessInstanceFinished(processInstance2, ksession);
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 74 with StatefulKnowledgeSession

use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.

the class IntermediateEventTest method testSignalBoundaryEventOnMultiInstanceSubprocess.

@Test
public void testSignalBoundaryEventOnMultiInstanceSubprocess() throws Exception {
    KieBase kbase = createKnowledgeBase("subprocess/BPMN2-MultiInstanceSubprocessWithBoundarySignal.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    Map<String, Object> params = new HashMap<String, Object>();
    List<String> approvers = new ArrayList<String>();
    approvers.add("john");
    approvers.add("john");
    params.put("approvers", approvers);
    ProcessInstance processInstance = ksession.startProcess("boundary-catch-error-event", params);
    assertProcessInstanceActive(processInstance);
    List<WorkItem> workItems = handler.getWorkItems();
    assertThat(workItems).isNotNull();
    assertThat(workItems.size()).isEqualTo(2);
    ksession.signalEvent("Outside", null, processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    ksession.dispose();
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ArrayList(java.util.ArrayList) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test)

Example 75 with StatefulKnowledgeSession

use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.

the class IntermediateEventTest method testSignalIntermediateThrowEventWithTransformation.

@Test
public void testSignalIntermediateThrowEventWithTransformation() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BoundarySignalEventOnTaskbpmn2.bpmn", "BPMN2-IntermediateThrowEventSignalWithTransformation.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "john");
    ProcessInstance processInstance = ksession.startProcess("BoundarySignalOnTask");
    ProcessInstance processInstance2 = ksession.startProcess("SignalIntermediateEvent", params);
    assertProcessInstanceFinished(processInstance2, ksession);
    assertProcessInstanceFinished(processInstance, ksession);
    String var = getProcessVarValue(processInstance, "x");
    assertThat(var).isEqualTo("JOHN");
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Aggregations

StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)114 Test (org.junit.Test)79 KieBase (org.kie.api.KieBase)52 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)40 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)30 ArrayList (java.util.ArrayList)29 CommandBasedStatefulKnowledgeSession (org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession)22 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)20 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)18 HashMap (java.util.HashMap)16 Environment (org.kie.api.runtime.Environment)12 KieSession (org.kie.api.runtime.KieSession)11 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)11 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)10 ClassPathResource (org.drools.core.io.impl.ClassPathResource)9 WorkItem (org.kie.api.runtime.process.WorkItem)9 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)8 TestWorkItemHandler (org.jbpm.persistence.session.objects.TestWorkItemHandler)8 Resource (org.kie.api.io.Resource)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7