org.kie.internal.runtime.StatefulKnowledgeSession Java Examples
The following examples show how to use
org.kie.internal.runtime.StatefulKnowledgeSession.
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: ConcurrentNodeMemories.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public void resetAllMemories(StatefulKnowledgeSession session) { InternalKnowledgeBase kBase = (InternalKnowledgeBase)session.getKieBase(); for (int i = 0; i < memories.length(); i++) { Memory memory = memories.get(i); if (memory != null) { memory.reset(); SegmentMemory smem = memory.getSegmentMemory(); if (smem != null) { smem.reset(kBase.getSegmentPrototype(smem)); if ( smem.isSegmentLinked() ) { smem.notifyRuleLinkSegment((InternalWorkingMemory)session); } } } } }
Example #2
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@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); }
Example #3
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 #4
Source File: JbpmSerializationHelper.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public static StatefulKnowledgeSession getSerialisedStatefulKnowledgeSession(StatefulKnowledgeSession ksession, ObjectMarshallingStrategy [] strategies, boolean dispose) throws Exception { Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKieBase(), strategies ); final byte [] b1 = serializeKnowledgeSession(marshaller, ksession); StatefulKnowledgeSession ksession2 = deserializeKnowledgeSession(marshaller, b1); final byte[] b2 = serializeKnowledgeSession(marshaller, ksession2); // bytes should be the same. if ( !areByteArraysEqual( b1, b2 ) ) { // throw new IllegalArgumentException( "byte streams for serialisation test are not equal" ); } ((StatefulKnowledgeSessionImpl) ksession2).setGlobalResolver( ((StatefulKnowledgeSessionImpl) ksession).getGlobalResolver() ); if ( dispose ) { ksession.dispose(); } return ksession2; }
Example #5
Source File: StatelessKnowledgeSessionImpl.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public List executeWithResults(Iterable objects, ObjectFilter filter) { List list = new ArrayList(); StatefulKnowledgeSession ksession = newWorkingMemory(); try { for ( Object object : objects ) { ksession.insert( object ); } ksession.fireAllRules(); for (FactHandle fh : ksession.getFactHandles(filter)) { list.add(((InternalFactHandle) fh).getObject()); } } finally { dispose(ksession); } return list; }
Example #6
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 #7
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@Test @Disabled("Transfomer has been disabled") public void testSignalBoundaryEventWithTransformation() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper( "BPMN2-BoundarySignalEventOnTaskWithTransformation.bpmn", "BPMN2-IntermediateThrowEventSignal.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"); }
Example #8
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@Test @Disabled("Transfomer has been disabled") 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"); }
Example #9
Source File: ProcessFactoryTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test @Timeout(10) public void testActionNodeIsDroolsAction() throws Exception { RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.jbpm.process"); factory .name("ActionNodeActionProcess") .version("1") .startNode(1) .name("Start") .done() .endNode(3) .name("End") .done() .actionNode(2) .name("printTextActionNode") .action("java", "System.out.println(\"test print\");", true) .done() .connection(1, 2) .connection(2, 3); RuleFlowProcess process = factory.validate().getProcess(); assertNotNull(process); Resource res = ResourceFactory.newByteArrayResource(XmlBPMNProcessDumper.INSTANCE.dump(process).getBytes()); res.setSourcePath("/tmp/processFactory.bpmn2"); KieBase kbase = createKnowledgeBaseFromResources(res); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); ProcessInstance pi = ksession.startProcess("org.jbpm.process"); assertNotNull(pi); assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState()); ksession.dispose(); }
Example #10
Source File: EndEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testOnEntryExitScript() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-OnEntryExitScriptProcess.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()); }
Example #11
Source File: ProcessFactoryTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testProcessFactory() throws Exception { RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.jbpm.process"); factory // header .name("My process") .packageName("org.jbpm") // nodes .startNode(1) .name("Start") .done() .actionNode(2) .name("Action") .action("java", "System.out.println(\"Action\");") .done() .endNode(3) .name("End") .done() // connections .connection(1, 2) .connection(2, 3); RuleFlowProcess process = factory.validate().getProcess(); Resource res = ResourceFactory.newByteArrayResource(XmlBPMNProcessDumper.INSTANCE.dump(process).getBytes()); res.setSourcePath("/tmp/processFactory.bpmn2"); // source path or target path must be set to be added into kbase KieBase kbase = createKnowledgeBaseFromResources(res); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); ksession.startProcess("org.jbpm.process"); ksession.dispose(); }
Example #12
Source File: ActivityTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testUserTaskWithDataStoreScenario() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-UserTaskWithDataStore.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler()); ksession.startProcess("UserProcess"); // we can't test further as user tasks are asynchronous. }
Example #13
Source File: EndEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testSignalEndWithData() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-EndEventSignalWithData.bpmn2"); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); Map<String, Object> params = new HashMap<String, Object>(); ProcessInstance processInstance = ksession.startProcess("src.simpleEndSignal", params); assertProcessInstanceCompleted(processInstance); }
Example #14
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 #15
Source File: JPAKnowledgeService.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static StatefulKnowledgeSession newStatefulKnowledgeSession(KieBase kbase, KieSessionConfiguration configuration, Environment environment) { return (StatefulKnowledgeSession)getJPAKnowledgeServiceProvider().newKieSession(kbase, configuration, environment); }
Example #16
Source File: EndEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testOnEntryExitScriptDesigner() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-OnEntryExitDesignerScriptProcess.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()); }
Example #17
Source File: EndEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@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()); }
Example #18
Source File: EndEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testOnEntryExitNamespacedScript() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-OnEntryExitNamespacedScriptProcess.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()); }
Example #19
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 #20
Source File: IntermediateEventTest.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@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"); Set<EventDescription<?>> eventDescriptions = processInstance.getEventDescriptions(); assertThat(eventDescriptions) .hasSize(2) .extracting("event").contains("MySignal"); assertThat(eventDescriptions) .extracting("eventType").contains("signal"); assertThat(eventDescriptions) .extracting("processInstanceId").contains(processInstance.getId()); assertThat(eventDescriptions) .filteredOn("eventType", "signal") .hasSize(1) .extracting("properties", Map.class) .anyMatch(m -> m.containsKey("AttachedToID") && m.containsKey("AttachedToName")); ProcessInstance processInstance2 = ksession .startProcess("SignalIntermediateEvent"); assertProcessInstanceFinished(processInstance2, ksession); assertProcessInstanceFinished(processInstance, ksession); }
Example #21
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 #22
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 #23
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 #24
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(); }
Example #25
Source File: JbpmSerializationHelper.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static StatefulKnowledgeSession getSerialisedStatefulKnowledgeSession(StatefulKnowledgeSession ksession, boolean dispose) throws Exception { return getSerialisedStatefulKnowledgeSession( ksession, MarshallerFactory.newSerializeMarshallingStrategy(), dispose ); }
Example #26
Source File: JbpmSerializationHelper.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static StatefulKnowledgeSession getSerialisedStatefulKnowledgeSession(StatefulKnowledgeSession ksession, ObjectMarshallingStrategy strategy, boolean dispose) throws Exception { ObjectMarshallingStrategy [] strategies = new ObjectMarshallingStrategy[] { strategy }; return getSerialisedStatefulKnowledgeSession(ksession, strategies, dispose); }
Example #27
Source File: JbpmSerializationHelper.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static byte [] serializeKnowledgeSession(Marshaller marshaller, StatefulKnowledgeSession ksession) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); marshaller.marshall( bos, ksession ); byte[] ksessionBytes = bos.toByteArray(); bos.close(); return ksessionBytes; }
Example #28
Source File: JbpmSerializationHelper.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static StatefulKnowledgeSession deserializeKnowledgeSession(Marshaller marshaller, byte [] serializedKsession) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream( serializedKsession ); StatefulKnowledgeSession deserializedKsession = (StatefulKnowledgeSession) marshaller.unmarshall( bais, SessionConfiguration.newInstance(), EnvironmentFactory.newEnvironment() ); bais.close(); return deserializedKsession; }
Example #29
Source File: CamelFileTest.java From jbpm-work-items with Apache License 2.0 | 5 votes |
@Test public void testSingleFileProcess() throws IOException { final String testData = "test-data"; HashMap<String, Object> context = setupWithPoolingDataSource("org.jbpm.contrib.camel-workitem"); Environment env = createEnvironment(context); KieBase kbase = createBase(); StatefulKnowledgeSession kieSession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env); kieSession.getWorkItemManager().registerWorkItemHandler("CamelFile", new FileCamelWorkitemHandler()); Map<String, Object> params = new HashMap<String, Object>(); params.put("payloadVar", testData); params.put("pathVar", tempDir.getAbsolutePath()); params.put("fileNameVar", testFile.getName()); ProcessInstance pi = kieSession.startProcess("camelFileProcess", params); ProcessInstance result = kieSession.getProcessInstance(pi.getId()); Assert.assertNull(result); Assert.assertTrue("Expected file does not exist.", testFile.exists()); String resultText = FileUtils.readFileToString(testFile, StandardCharsets.UTF_8); Assert.assertEquals(resultText, testData); }
Example #30
Source File: CamelSqlTest.java From jbpm-work-items with Apache License 2.0 | 5 votes |
@Test public void testSelect() { Environment env = createEnvironment(context); KieBase kbase = createBase(); StatefulKnowledgeSession kieSession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env); kieSession.getWorkItemManager().registerWorkItemHandler("CamelSql", handler); String sqlQuery = "select NAME from TEST"; Map<String, Object> params = new HashMap<String, Object>(); params.put("Query", sqlQuery); params.put("DataSource", "jdbc/testDS1"); WorkflowProcessInstance wpi = (WorkflowProcessInstance) kieSession.startProcess("camelSqlProcess", params); Assert.assertEquals(2, ((RuleFlowProcessInstance) wpi).getVariables().size()); kieSession.dispose(); }