Prev | Next |
BusinessKnowledgeModel & Test Harness
A Business Knowledge Model encapsulate logic without knowing the usage context, it is implemented as a function definition with parameters and a DMN expression as body(Decision table, Boxed Context, Literal Expressions etc).
Because the definition of a Business Knowledge Model is self contained, it is possible to a "Unit Testing" by providing arguments for the parameters. For this reason, a Business Knowledge Model will have a "Input Parameter Values for Simulation" tab in the Expression Window.
Here, we will show some examples available from Model Wizard.
Parameters of a Business Knowledge Model
Context menu on the first row of the Business Knowledge Model and select "Edit Parameters..." to bring up the following dialog.
We can add/delete/modify/change type on parameters.
Test Harness
Decision Table
When a decision table is created for a Business Knowledge Model, we can test this BKM by binding some values:
In this example we provided test values like this:
Click the on the toolbar, we will get the following result:
- The runtime parameter value will take the place of "Allowed Values" in simulation mode.
- Valid rule(s) are highlighted
- Since this decision table's hit policy is P (Priority) the final result is determined by the order of "output values". Since "INELIGIBLE, ELIGIBLE" are the output values and "INELIGIBLE" comes ahead of "ELIGIBLE", rule #3 will be final result and this applicant is "INELIGIBLE".
Boxed Context / Literal Expressions
Similar to Decision table, the Business Knowledge Model implemented as Boxed Expression can be tested as well.
Take the following "Payment" BKM as example,
This BKM will calculate the monthly repayment based interest rate, number of terms, principle amount.
In this example we provided test values like this:
Click the Run button on the toolbar, we will get the following result:
- The runtime parameter and return value will showing with an equal sign "=", following by the runtime value.
In this example, given annual Rate 4% for 30 years, a principle of 300000, the monthly repayment is 1432.25
Note: The DMN Library already has a PMT function defined. This example mainly demonstrate how Literal Expression works and how to test it with a set of arguments.