Camunda Unit Test job() weirdness

Hi all,

I’ve added asynchronous before to one of my milestone tasks (It is of type intermediateThrowEvent).
I clearly see that the processInstance has a job pending in my test code but I cannot acquire it.

I’m try to run the job as follows;

execute(job());

This tries to fetch the job with following JobQuery (by processId) but it returns no jobs which it very weird as the job pending is for that processInstanceId.

Any help or thoughts are appreciated.

Kr,
Nico

Update;

apparently the 1 job in the processInstance is one that was left of a previous asynchronous before.

Not sure what I should be looking at next…

java.lang.AssertionError: Expecting actual ProcessInstance {id='6', processDefinitionId='productOrderProcess:1:3', businessKey='null'} to be waiting at [WO_PlanInstallation], but it is actually waiting at [MilestoneNotificationApproved].

Hi Nico,

Can you share the test and the process model or simplified version of them?

Cheers,
Thorben

Hi,

The simplified code can be found here.

Kind regards

Hi Nico,

Thanks for providing the code. The intermediate event async milestone is asyncBefore, so another execute(job()); is required to enter the multi-instance subprocess (which then fails but for reasons related to the variables you set).

Cheers,
Thorben

Hmmm indeed. I tried adding this execute(job()) before, but probably too early in the code.

The non-default constructor on ProductDto needed for serialisation is only due to my refactorings.
Anyway it is fixed now. Thank you for having a look!

Kr.
Nico