Before you can start writing execution scenario's, you need a
ProcessDefinition
. The easiest way to get a
ProcessDefinition
object is by parsing xml. If you
have code completion, type ProcessDefinition.parse
and activate code completion. Then you get the various parsing methods.
There are basically 3 ways to write xml that can be parsed to a
ProcessDefinition
object:
A process archive is a zip file that contains the process xml
in a file called processdefinition.xml
. The jBPM
process designer reads and writes process archives. For example:
... static ProcessDefinition auctionProcess = ProcessDefinition.parseParResource("org/jbpm/tdd/auction.par"); ...
In other situations, you might want to write the
processdefinition.xml file by hand and later package the zip file
with e.g. an ant script. In that case, you can use the
JpdlXmlReader
... static ProcessDefinition auctionProcess = ProcessDefinition.parseXmlResource("org/jbpm/tdd/auction.xml"); ...
The simplest option is to parse the xml in the unit test inline from a plain String.
... static ProcessDefinition auctionProcess = ProcessDefinition.parseXmlString( "<process-definition>" + " <start-state name='start'>" + " <transition to='auction'/>" + " </start-state>" + " <state name='auction'>" + " <transition to='end'/>" + " </state>" + " <end-state name='end'/>" + "</process-definition>"); ...