Java Code Examples for org.kie.internal.runtime.StatefulKnowledgeSession#signalEvent()
The following examples show how to use
org.kie.internal.runtime.StatefulKnowledgeSession#signalEvent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@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(); }
Example 2
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@Test public void testSignalEndWithData() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateThrowEventSignalWithData.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); Map<String, Object> params = new HashMap<String, Object>(); ProcessInstance processInstance = ksession.startProcess("testThrowingSignalEvent", params); assertProcessInstanceActive(processInstance); ksession.signalEvent("mysignal", null, processInstance.getId()); assertProcessInstanceCompleted(processInstance); }
Example 3
Source File: EndEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@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); }
Example 4
Source File: EndEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@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); }
Example 5
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testSignalBoundaryNonEffectiveEvent() throws Exception { final String signal = "signalTest"; final AtomicBoolean eventAfterNodeLeftTriggered = new AtomicBoolean(false); KieBase kbase = createKnowledgeBase( "BPMN2-BoundaryEventWithNonEffectiveSignal.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); TestWorkItemHandler handler = new TestWorkItemHandler(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler); ksession.addEventListener(new DefaultProcessEventListener() { @Override public void afterNodeLeft(ProcessNodeLeftEvent event) { // BoundaryEventNodeInstance if(signal.equals(event.getNodeInstance().getNodeName())) { eventAfterNodeLeftTriggered.set(true); } } }); ProcessInstance processInstance = ksession .startProcess("BoundaryEventWithNonEffectiveSignal"); // outer human work ksession.getWorkItemManager().completeWorkItem( handler.getWorkItem().getId(), null); ksession.signalEvent(signal, signal); // inner human task ksession.getWorkItemManager().completeWorkItem( handler.getWorkItem().getId(), null); assertProcessInstanceFinished(processInstance, ksession); assertThat(eventAfterNodeLeftTriggered.get()).isTrue(); }
Example 6
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@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(); }
Example 7
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testSignalBoundaryEventNoInteruptOnMultiInstanceSubprocess() throws Exception { KieBase kbase = createKnowledgeBase( "subprocess/BPMN2-MultiInstanceSubprocessWithBoundarySignalNoInterupting.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()); assertProcessInstanceActive(processInstance.getId(), ksession); for (WorkItem wi : workItems) { ksession.getWorkItemManager().completeWorkItem(wi.getId(), null); } assertProcessInstanceFinished(processInstance, ksession); ksession.dispose(); }
Example 8
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testErrorBoundaryEventOnMultiInstanceSubprocess() throws Exception { KieBase kbase = createKnowledgeBase( "subprocess/BPMN2-MultiInstanceSubprocessWithBoundaryError.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); Set<EventDescription<?>> eventDescriptions = processInstance.getEventDescriptions(); assertThat(eventDescriptions) .hasSize(3) .extracting("event").contains("workItemCompleted", "Inside", "Error-_D83CFC28-3322-4ABC-A12D-83476B08C7E8-MyError"); assertThat(eventDescriptions) .extracting("eventType").contains("workItem", "signal"); assertThat(eventDescriptions) .extracting("processInstanceId").contains(processInstance.getId()); assertThat(eventDescriptions) .filteredOn("eventType", "signal") .hasSize(2) .extracting("properties", Map.class) .anyMatch(m -> m.containsKey("AttachedToID") && m.containsKey("AttachedToName")); List<WorkItem> workItems = handler.getWorkItems(); assertThat(workItems).isNotNull(); assertThat(workItems.size()).isEqualTo(2); ksession.signalEvent("Inside", null, processInstance.getId()); assertProcessInstanceFinished(processInstance, ksession); ksession.dispose(); }