I am looking for a way to test a process which contain a task with a java delegate which is extending AbstractBpmnActivityBehavior. This java delegate send a message on a Kafka queue and then waits to resume via the call to the signal method. This works fine. But, i am having a hard time to make a useful junit test for it.
i have read and looked into your Camunda BPM Assertj docs and code here. Have seen that you have made a lot of good work there the last weeks:
Blockquote
ENGINE-16004 Exception while closing command context: Unknown property used in expression: ${createJavaDelegate}. Cause: Cannot resolve identifier ‘createJavaDelegate’
I believe this is because I have wired the java delegate with an expression and not with the java class path. I have done like this in camunda modeller: ${createJavaDelegate}
It works fine when I run the code. But not when I am running junit tests.
Hi. Maybe you have some good hints on how to junit test java delegates that are wired by expression? See that you have made changes to camunda-bpm-mockito lately.
what is ${createJavaDelegate} supposed to be resolved to?
Without knowing more about your process definition this rather looks like a variable that has not been set yet because the activities before the task are not executed now. If that is the case you could manually provide the value for this test case as you already did with .setVariable("createJavaDelegate", whatEverNeedsToGoHere).
If you want to just test the delegate, the way you are working with the DelegateExecutionFake is the right way to go. Do you have problems with that unit test?
For the “complete process” test, it dependes if you use the plain in-memory engine or Spring. In the first case, you are using a MockExpressionManager, meaning that you have to manually register every expression (Mocks.register(“myDelegate”, mock(MyDelegate.class))) so camunda can resolve it. CamundaMockito gives some nice helpers for this, but basically its always registering a String/Instance Pair on the MockExpressionManager.
When doing a spring based process test, you do use the SpringExpressionManager, so every bean available in the spring context could be a candidate for bpmn-expressions. If this fails, check if you configured the context for your test run correctly.