How to Validate your Enterprise Architect BPMN Models
The BPMN notation is a good way to specify processes, may it be the workflow for a specific task or entire business processes. Such models may grow very large and you can easily lose track of certain details such as model correctness.
Figure 1 shows an example for a BPMN model (using the BPMN 2.0 MDG Technology), a process for resolving problems which are reported via a ticket system.
- Fig 1: BPMN Process example modelled with the Enterprise Architect (example source: OMG).
Do you see the Error?
Maybe you’ve noticed that the final node of the model does not have any incoming control flow edges but instead has an outgoing control flow edge.
Also the Activity ‘Insert issue into product backlog’ is not reachable, because it has no incoming edge. This leads us to the problem that the Enterprise Architect may (only) ensure that every BPMN model is syntactically valid: it prohibits modelling actions which would result in syntactically invalid BPMN models, e.g. a control flow to an element that does not belong to activities, like an Interface.
What the Enterprise Architect does not ensure is semantic correctness.
Formal Validation with OCL
A formal way to validate semantic restrictions on (BPMN) models is to use the Object Constraint Language (OCL) to define constraints the models must fulfill in order to be correct.
In our case we could define the following constraint to ensure that a final node does not have any outgoing control flow edge:
context a:Activity inv:
a.nodes -> forAll(node | not(node.oclIsTypeOf(FlowFinalNode)) or node.outgoing -> isEmpty())
But then an unconnected final node would still be valid and we also do not cover the unreachable activity. With another constraint we can ensure that every node in the model (except for initial nodes) has an incoming edge:
context a:Activity inv:
a.nodes -> forAll(node | node.oclIsTypeOf(InitialNode) or not(node.incoming -> isEmpty()))
Unfortunately, the Enterprise Architect has no feature yet to evaluate any formal constraints like OCL.
To evaluate the constraints on our model we use other tools to load our Enterprise Architect models and run OCL constraints on it.
Semantic Validation of BPMN Models in Eclipse
Once the Enterprise Architect model is loaded with the YAKINDU EA-Bridge, it can be browsed in a simple tree-based editor (as seen in Figure 2), element details are shown in the ‘Properties’ view.
- Fig 2: Our Enterprise Architect model loaded with the YAKINDU EA-Bridge in Eclipse
Now we want to select the activity ‘BPMN 2.0 Business Process View’ and open the OCL Console (open the ‘Console’ View in Eclipse and select the ‘OCL Console’ in the drop-down toolbar icon of the view).
There we can enter our constraints and observe the evaluation result (Figure 3).
Please note that the plain constraint must be entered, the context of our invariants above is the currently selected element in the editor!
- Fig 3: The OCL Console in Eclipse
Once we have run our evaluation and got the result that the model violates the constraints, we can fix our BPMN model and run the OCL evaluation on the corrected model (see Figure 4) again.
- Fig 4: Semantically valid Model, because the Final Node has no outgoing control flow but instead has an incoming control flow.
- Also the Activity ‘Insert issue into product backlog’ has an incoming control flow and is therefore reachable.
This time our constraints evaluate to ‘true’:
To conclude, the usage of additional tools like the YAKINDU EA-Bridge and an OCL Interpreter enables further use cases like validation of BPMN Models by a predefined set of OCL constraints.
There are already projects working on such predefined sets of OCL constraints for BPMN models, for example, ‘OPEN-BPMN-OCL’. The next step would then be to implement automatic model validation.
Try it yourself
Do you want to try it out yourself?
First download the YAKINDU EA-Bridge Trial Eclipse Distribution, which is free to download. Unpack and start it, select a workspace location, and go to ‘Help’ -> ‘Install New Software’. The following dialog should appear. Copy ‘https://download.eclipse.org/modeling/mdt/ocl/updates/releases/latest’ into the field ‘Work with’.
You should now be able to select the ‘OCL’, ‘OCL build’, and ‘OCL tests’ items:
Click ‘Next >’ and finish the installation. Once it is finished, restart Eclipse to complete the installation.
The next thing to do is creating a new 'General Project', this can be done via the ‘File’ Menu:
After creating the project, please download the attached zip file, which contains the BPMN example and an XML file (which defines a slightly adapted version of the BPMN 2.0 MDG Technology). Copy these two files into the newly created project. Finally, change the preferences for the YAKINDU EA-Bridges to look for EA profiles in the same folder (in Eclipse: 'Window' -> 'Preferences' -> 'YAKINDU EA-Bridge' -> 'UML' -> 'Profile Locations').
Once this is done you can start experimenting with the example as shown in the screenshot above.