use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testOnEntryExitMixedNamespacedScript.
@Test
public void testOnEntryExitMixedNamespacedScript() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-OnEntryExitMixedNamespacedScriptProcess.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new SystemOutWorkItemHandler());
List<String> myList = new ArrayList<String>();
ksession.setGlobal("list", myList);
ProcessInstance processInstance = ksession.startProcess("OnEntryExitScriptProcess");
assertProcessInstanceCompleted(processInstance);
assertEquals(4, myList.size());
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testTerminateWithinSubprocessEnd.
@Test
public void testTerminateWithinSubprocessEnd() throws Exception {
KieBase kbase = createKnowledgeBase("subprocess/BPMN2-SubprocessWithParallelSpitTerminate.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ProcessInstance processInstance = ksession.startProcess("BPMN2-SubprocessWithParallelSpitTerminate");
ksession.signalEvent("signal1", null, processInstance.getId());
assertProcessInstanceCompleted(processInstance);
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testTerminateEnd.
@Test
public void testTerminateEnd() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-ParallelSpitTerminate.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ProcessInstance processInstance = ksession.startProcess("BPMN2-ParallelSpitTerminate");
ksession.signalEvent("Signal 1", null, processInstance.getId());
assertProcessInstanceCompleted(processInstance);
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testMessageEndVerifyDeploymentId.
@Test
public void testMessageEndVerifyDeploymentId() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-MessageEndEvent.bpmn2");
TestWorkItemHandler handler = new TestWorkItemHandler();
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Send Task", handler);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "MyValue");
ProcessInstance processInstance = ksession.startProcess("MessageEndEvent", params);
assertProcessInstanceCompleted(processInstance);
WorkItem workItem = handler.getWorkItem();
assertNotNull(workItem);
assertTrue(workItem instanceof org.drools.core.process.instance.WorkItem);
long nodeInstanceId = ((org.drools.core.process.instance.WorkItem) workItem).getNodeInstanceId();
long nodeId = ((org.drools.core.process.instance.WorkItem) workItem).getNodeId();
String deploymentId = ((org.drools.core.process.instance.WorkItem) workItem).getDeploymentId();
assertNotNull(nodeId);
assertTrue(nodeId > 0);
assertNotNull(nodeInstanceId);
assertTrue(nodeInstanceId > 0);
assertNull(deploymentId);
// now set deployment id as part of ksession's env
ksession.getEnvironment().set("deploymentId", "testDeploymentId");
processInstance = ksession.startProcess("MessageEndEvent", params);
assertProcessInstanceCompleted(processInstance);
workItem = handler.getWorkItem();
assertNotNull(workItem);
assertTrue(workItem instanceof org.drools.core.process.instance.WorkItem);
nodeInstanceId = ((org.drools.core.process.instance.WorkItem) workItem).getNodeInstanceId();
nodeId = ((org.drools.core.process.instance.WorkItem) workItem).getNodeId();
deploymentId = ((org.drools.core.process.instance.WorkItem) workItem).getDeploymentId();
assertNotNull(nodeId);
assertTrue(nodeId > 0);
assertNotNull(nodeInstanceId);
assertTrue(nodeInstanceId > 0);
assertNotNull(deploymentId);
assertEquals("testDeploymentId", deploymentId);
}
use of org.kie.internal.runtime.StatefulKnowledgeSession in project jbpm by kiegroup.
the class EndEventTest method testErrorEndEventProcess.
@Test
public void testErrorEndEventProcess() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-ErrorEndEvent.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ProcessInstance processInstance = ksession.startProcess("ErrorEndEvent");
assertProcessInstanceAborted(processInstance);
assertEquals("error", ((org.jbpm.process.instance.ProcessInstance) processInstance).getOutcome());
}
Aggregations