Catching event with timer trigger in unit tests

Hi,

In our BPM project, we need the process to wait before performing the next external worker call. The way I implemented this is as follows.
image
However I will need to unit test this, and just following the external worker flow will not work. I have tried looking for the answer in the JobTestHelper documentation, and came across the following (also referenced in another topic on this forum):

Job timer = managementService.createTimerJobQuery().singleResult();
        while (timer == null){
            timer = managementService.createTimerJobQuery().singleResult();
        }
        Job executableJob = managementService.moveTimerToExecutableJob(timer.getId());
        managementService.executeJob(executableJob.getId());

This implementation gives the following error

 HistoricActivityInstanceEntity [...] was updated by another transaction concurrently

my question: is this the correct way to implement the timer in my process, and if so, what is the correct way to implement the timer in my unit tests?

Best regards,
Sebastiaan

Hi Sebastiaan,

One way is to trigger timer as you wrote.
another to move in time (engineConfiguration.getClock()) after the timer due time and wait till the timer is not triggered automatically by engine (allow timer execution)

Regards
Martin