Test of depended DMN in DRD flow

Hi I have a question reqarding test of dmns.

In my case I have a DRD (Decision Requirements Diagram) it consists of 5 DMNs.
DMN_1, DMN_2, DMN_3, DMN_4 and DMN_T.

DMN 1 to 4 are all individual DMNs all linking directly to DMN_T.

I would like to write unit tests for each DMN. DMN_1 to DMN_4 are easy to test since they are individual DMNs.

My problem is how do I test DMN_T. Is there a way to feed DMN_T directly wiht the variables it is depending on. If I should feed the DMN_T test with the variable required by DMN_1 to 4 and would like to test all outcomes, the sampling over these variable would be an almost unmanageable and a error-prone task.

So is where a way to pass the variables directly to DMN_T and making the engine ignore it’s requiredDecision?

Best,
Allan

Hi @AllanT,

I see your point but there is currently no way to evaluate the a decision without evaluating its required decisions.

One idea just came up to my mind:

  • read the DRD with the DMN model API
  • get the decision DMN_T
  • remove the references to the required decisions
  • deploy the modified DRD
  • evaluate the decision DMN_T

Does this help you?

Best regards,
Philipp

Hi @Philipp_Ossler,

Thanks for your quick reply!

In my testcase I use DmnEngineRule to get hold of the dmnEngine and lastly of my decision.

DmnDecision decision = dmnEngine.parseDecision("DMN_T", inputStream);

unfortunately the DmnDecision has no method for manupilating the requiredDecisions.

The DmnDecision only supports the getRequiredDecisions() method.
However, by debugging I found that the collection returned from getRequiredDecisions() actually is the reference to the collection from within DmnDecision and not a clone. So I simply did this:

Collection<DmnDecision> requiredDecisions = decision.getRequiredDecisions();
requiredDecisions.clear();

and it works like a charm.

Thanks for pointing me towards this solution.

Best regards,
Allan

1 Like