Unit test DMN JUEL Cannot resolve identifier 'execution'

Hi there,
I recently changed my code from using process variables as DMN input to JUEL-expressions. This works just fine in practice but it broke my unit tests with following exception:

org.camunda.bpm.dmn.engine.impl.DmnEvaluationException: DMN-01002 Unable to evaluate expression for language 'JUEL': '${orderDecisionTask.getInputData(execution).status}'
(...)
Caused by: org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'execution'
(...)

The unit test works fine if I don’t use execution as a parameter but I need it to cache the input per execution. Is there anything I need to configure to make the unit test work?

I created a simple example from the template:orderDecision.dmn (3.0 KB)

Hi @wolframS,

the execution object is instantiated by the process engine.

You can write a Unit test deploying the process and the decsion table and start the process directly before the business rule task: https://docs.camunda.org/manual/7.12/user-guide/process-engine/process-instance-modification/#process-instance-modification-in-junit-tests

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

thank you for your answer. Sorry that it wasn’t clear in my question but I already wrote a unit test for the whole process based on the camunda-engine-unittest template. Here is the BPMN: testProcess.bpmn (2.6 KB)

I could upload the whole project later (probably best to github?) if this is necessary to make things clear

Here is my project based on the camunda-engine-unittest:

I hope this helps to make my problem understandable

I’m still struggling with this problem. Is there anyone who might have an idea on how to approach this at least? Or did I describe the problem badly? I very much hope that anyone can help me because it is such a pain for development if so many unit tests are not working.

kind regards
Wolfram

Hi @wolframS,

I cloned your git repo and had a closer look into it.

As the expression is handled in the dmn engine, it seems that this engine is not aware of the execution object that lives in the process engine. And when I try to pass it explicitly with an input mapping, the process engine complains that the object is not serializable.

But why do you want cache something for dmn evaluation?

Wouldn’t it be easier if you cache the values as a process variable (maybe transient) when you evaluate the decision?

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

I’m using the cache to not persist the input values in the database.
Until now I didn’t know about transient process variables but it seems that they exactly fit my needs. So thank you very much for your answer, this will help alot :slight_smile:

kind regards
Wolfram