JUnit testing mini process helloworld
This is a simple example of a script task used in the demo. It automatically outputs "Hello World" when the task node is executed"
Open a BPMN2-MinimalProcess.bpmn2 File
For example, when the process starts, the node is automatically executed, and then the output command is executed on the node.
Take a look at the test program
public void testMinimalProcess() throws Exception {KnowledgeBase kbase = createKnowledgeBase("BPMN2-MinimalProcess.bpmn2");StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);ProcessInstance processInstance = ksession.startProcess("Minimal");assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);}
After the execution is complete, assert that the execution result is completed, that is, the completion status is true.
Asserttrue (processinstance. getstate () = processinstance. state_completed );
The result is successfully output in the console.
Loading Process BPMN2-MinimalProcess.bpmn2
Hello World
Indicates that the sample is loaded successfully.
Helloworld for loading sub-processes in JUnit Testing
This is an example of using a sub-process in the demo. The function is the same as the above but the sub-process is used.
The process is as follows:
The Calling procedure is as follows:
public void testCompositeProcessWithDIGraphical() throws Exception {KnowledgeBase kbase = createKnowledgeBase("BPMN2-CompositeProcessWithDIGraphical.bpmn2");StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);ProcessInstance processInstance = ksession.startProcess("Composite");assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);}
After completion, the status is as above and hello World is output in the console.
JUnit test script task
The functions are the same as those of the previous two,
Run
public void testScriptTask() throws Exception {KnowledgeBase kbase = createKnowledgeBase("BPMN2-ScriptTask.bpmn2");StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);ProcessInstance processInstance = ksession.startProcess("ScriptTask");assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);}
Output
Loading Process BPMN2-ScriptTask.bpmn2
Hello World
JUnit test output list
The above functions are provided, but the list is output in the script task.
The content of the Action attribute is as follows:
Running output
Loading Process BPMN2-Import.bpmn2
[1]
JUnit test rule task
There are two files to load this time, one is the BPMN2-RuleTask.bpmn2, the other is the BPMN2-RuleTask.drl, the other is the process file, the other is the rule File
It loads the rule task
And set the rule