Test the Decision
We’re now ready to test the decision in its current form.
Deploy the Model
In Camunda Modeler, save your model with Ctrl+S or .
As before, use the to deploy the new model to the running Camunda engine.
You can leave the default values of the pop-up dialog as they are.
Test the Model
Create a new gRPC request by duplicating an earlier one or by adding a new one to the collection from the menu.
Make sure it goes to grpc://localhost:26500 and to the EvaluateDecision method.
|
Give your request a name taken from the Message number shown below, which is 2.1.
Your request could be named something like |
Copy and paste the following message into the Message section of the request’s tab.
{
"decisionId": "order_amount",
"variables": "{ \"warehouse_stock_level\": 132, \"orders\": 20, \"spare_parts_reserve\": 20, \"storage_tier\": \"T1\" }"
}
Hit the Invoke button to execute the request.
If your rules are correct, the response should indicate that 250 items need to be ordered. This is because the current inventory level is 132 - 20 - 20 = 92, the threshold for T1 is 100 items and the order size is 250.
Similarly, the following request should yield an order amount of 50 for T4 items.
Create a new gRPC request by duplicating an earlier one or by adding a new one to the collection from the menu.
Copy and paste the following message into the Message section of the request’s tab.
{
"decisionId": "order_amount",
"variables": "{ \"warehouse_stock_level\": 72, \"orders\": 38, \"spare_parts_reserve\": 5, \"storage_tier\": \"T4\" }"
}
Hit the Invoke button to execute the request.
Edge Cases
Let’s perform another test where the edge case of the threshold for one of the storage tiers is in play. Can you predict what will happen?
{
"decisionId": "order_amount",
"variables": "{ \"warehouse_stock_level\": 60, \"orders\": 5, \"spare_parts_reserve\": 5, \"storage_tier\": \"T3\" }"
}
You’ll get an error in this case.
If it’s not obvious to you why this happens, perhaps the log of the Camunda engine will help you to understand.
If not, read on
Our decision table has four rules currently and a hit policy of Unique. Try to imagine which rules match if the Inventory Level decision returns a value that is equal to or greater than the order threshold for that storage tier.
As you can see, no rules will match.
If no rules match in a decision table with a unique policy, the decision returns an empty or null result.
Let’s improve the decision.