DMN Module Code Generation & Test
Enterprise Architect also provides a 'Test Module' page, which is a preprocess for integrating DMN with BPMN. The concept is to provide one or more BPMN2.0::DataObject elements, then test if a specified target decision can be evaluated correctly or not.
If any error or exception occurs, you can create an Analyzer Script to debug the code of the DMN Module and Test Client.
After this 'Test Module' process, Enterprise Architect guarantees that the BPMN2.0::DataObject elements work well with the DMN Module.
You then configure BPSim by loading DataObjects and assigning DMN Module decisions to BPSim Properties, which will be further used as conditions on the Sequence Flows outgoing from a Gateway.
Modeling & Simulation
We took the example available from Model Patterns - Ribbon: Simulate | DMN | Apply Perspective | DMN Decision | Decision with BKM
Here is a brief overview of the model:
- Item Definition
- Input Data
- Business Knowledge Model (Decision Table)
- Decision (Invocation)
- Export InputData to a BPMN2.0 DataObject
Activate the 'Configure' page, and click on theon the toolbar.
DMN Module: Code Generation
Activate the 'Generate Module' tab of the DMN Simulation window, select the DMN elements you want to generate to the server, specify the file path and language, then click on the .
(Note: For Java, the path has to match the Package structure.)
- Add the elements to the module, then click on the on the toolbar to open the 'DMN Element Selection' dialog
- Click on the decision you want to generate to the server; in this example we select the decision 'Application risk score'
Note: All the dependencies will be selected automatically.
- Generate the DMN Module; give the Java file a Package name, then click on the Generate button
Note: In this example, the Module Path ends with '\com\sparxsystems\dmn', which matches the Package 'com.sparxsystems.dmn'.
- Click on the to access the 'Test Server' page
DMN Server: Test client
If this page was activated from the 'Generate Server' page, the 'DMN Module' field will be filled automatically with the generated DMN Server's path. Otherwise, click the button to browse for a DMN Server file.
Click theto add one or more BPMN2.0 DataObject(s) to the list, choose a decision from the combo box, then click the on the toolbar.
In the System Output window, this message indicates the DMN Server and BPMN2.0 DataObject can work well with each other to evaluate the selected decision.
Running Test Client for DMN Server...
Result : 133.0
The Running completed successfully.
If there are errors, create an Analyzer script by clicking the toolbar button and fix the issue.
Important: This 'Test Module' step is recommended before integrating DMNServer.java to the Enterprise Architect BPSim Execution Engine.