How to pass async start event in Junit test?

I’m trying to test a process model that has a start event with the flag asynBefore.
When I start the process with

ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(“processKey”);
assertThat(processInstance).isStarted().isNotEnded();
assertThat(processInstance).isWaitingAt(“startBestellung”);

This is all green, but I don’t know how to move on to the first task or job because the processes
waits at the start event which is neither a task nor a job.

Can you give any hints?

Thanks
hlux

1 Like

Hey hlux,

after the process is started a Job is created. So you have to query the job and execute it via the management service.

See following code snipped:

ProcessInstance asyncProc = rule.getRuntimeService().startProcessInstanceByKey("asyncProc");

Job job = rule.getManagementService().createJobQuery().singleResult();
rule.getManagementService().executeJob(job.getId());

assertNull(rule.getRuntimeService().createProcessInstanceQuery().singleResult());

Best regards,

Chris

2 Likes

Hi hlux,

if you use camunda-bpm-assert (https://github.com/camunda/camunda-bpm-assert#get-started-in-3-simple-steps), excute(job()) will do your job.

Cheers, Ingo

3 Likes

you are both right! Thank you very much!

typo in expression:
execute(job())