JUNIT - Is it Possible to dynamically change the Java class in a BPMN model

I am Trying to write a JUNIT which can change the Java class of a service task dynamically. Wanted to know if this is possible.

My requirement is that I just want to log some data instead of running the actual Service in the Java Delegate class.

Or else how do we basically make sure that unit test is covering all the tasks. For eg, if there are around 4 service tasks and I was a Java class to be executed in background instead of my actual Java class.

hi @vishnu_pkv,

Yes, it’s possible to dynamically change the Java class of a Service Task. You can do this with a Delegate Expression which will resolve to an instance of the desired class. Have a look here for more details: https://docs.camunda.org/manual/7.13/reference/bpmn20/tasks/service-task/#calling-java-code.

You can use the method described above. You can also use an Execution listener on each of the Service Tasks where the same idea as above would be applied.

Does this help?



Hi @vishnu_pkv,

you can find more details how to replace the code executed under test here: https://docs.camunda.org/manual/7.13/user-guide/testing/#resolving-beans-without-spring-cdi.

Hope this helps, Ingo

1 Like

Hi Ingo - Thanks. I was able to Mock the service and it is working fine now