Hi all,
I’m tring to write some bpmn unit test with the lib camunda-bpm-assert.
I am facing a problem to inject listener defined in bpmn
I got the exception
Caused by: java.lang.NoSuchMethodException: XXXListener.init()
How can I configure the test process engine to use mocks ?
Regards
Hello @sfaxianovic ,
in case you are using expressions or delegate expressions to bind your beans, in your process engine configuration, you will have to set the expression manager to MockExpressionManager:
<bean id="processEngineConfiguration"
class="org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
...
<property name="expressionManager">
<bean
class="org.camunda.bpm.engine.test.mock.MockExpressionManager" />
</property>
This will work as provided here as XML or in a programmatic process engine configuration as well.
Then, you can register your mocks in the test class as:
Mocks.register("myListener", new MyFancyListener());
If you are using the className to bind your Bean, please configure your ArtifactFactory
to suit your needs.
Anyway, the above provided way is usually the easier one.
I hope this helps
Jonathan