How to Trigger a Time in a Junit test

992 views
Skip to first unread message

sascha.karch...@gmail.com

unread,
Jun 2, 2014, 5:30:30 AM6/2/14
to camunda-...@googlegroups.com
Hi Folks,

I've modelled a process which uses an Intermediate Catch Event with timer.
The timer's purpose is to pause the process token at that point for 10 minutes which works as expected.

In a Junit test I like to trigger this timer manually so that the process continues.

I'm pretty sure that I've already seen how to do this in a tutorial. But after hours of searching I haven't found it.


Since the process currenty contains only a single timer a first solution which did work for me is this:
Job job = processEngine.getManagementService().createJobQuery().singleResult(); processEngine.getManagementService().executeJob(job.getId());


But I prefer to specify the job more precisely in case the process grows and number of jobs in the process grows.

I'm using Bpmn2 Diagram Editor in Eclipse. In the properties view I can specify various properties of the Timer Event (e.g. "Id", "Nam2", etc.)

Can any of these properties be used in the job query?

Thanks very much for any help.

Daniel Meyer

unread,
Jun 2, 2014, 6:23:59 AM6/2/14
to camunda-...@googlegroups.com, sascha.karch...@gmail.com
Hi Sasha,

With camunda BPM 7.1 we introduced job definitions. You could first query for a job definition and then for all jobs of a given definition:

JobDefinition jobDefinition = managementService.createJobDefinitionQuery().activityIdIn("foo").singleResult();
Job job = managementService.createJobQuery().jobDefinitionId(jobDefinition.getId()).singleResult();

FYI: the camunda-bpm-assert library may also be interesting for you:

Hope this helps,
Daniel Meyer 

Bernd Rücker (camunda)

unread,
Jun 2, 2014, 6:26:09 AM6/2/14
to camunda-...@googlegroups.com, sascha.karch...@gmail.com

Hi Sascha.

 

+1 – I would recommend to use camunda-bpm-assert for testing as it simplifies the test code a lot (and thus makes it much more readable).

 

Cheers

Bernd

Consultant & Evangelist (www.camunda.org/community/team.html)

We are hiring: http://www.camunda.org/community/jobs.html

--
You received this message because you are subscribed to the Google Groups "camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camunda-bpm-users/2f8ec280-4944-422a-a425-b7b97f18ddd2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sascha.karch...@gmail.com

unread,
Jun 2, 2014, 6:50:02 AM6/2/14
to camunda-...@googlegroups.com, sascha.karch...@gmail.com
Hi Bernd,

Thanks for the quick help.
We already use the camunda-bpm-assert.
It makes things really easy.

Martin Schimak

unread,
Jun 2, 2014, 6:57:29 AM6/2/14
to camunda-...@googlegroups.com
Hi all,

Good to know! :-) Please let me also know via issue tracking in case something important is missing from camunda-bpm-assert and/or even better: you want to contribute that missing stuff. And of course you are welcome to star or fork repositories you like!-) 


All the best,
Martin.
--
You received this message because you are subscribed to the Google Groups "camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.

Bernd Rücker (camunda)

unread,
Jun 2, 2014, 6:59:20 AM6/2/14
to camunda-...@googlegroups.com, sascha.karch...@gmail.com
Off topic: Then this is probably the Problem you saw with the engine database tables. Make sure you call the static init method of camunda BPM assert...

von unterwegs gesendet / sent with a mobile device

sascha.karch...@gmail.com

unread,
Jun 2, 2014, 7:15:40 AM6/2/14
to camunda-...@googlegroups.com, sascha.karch...@gmail.com
Hi Daniel,

Thanks very much.
Works great with the camunda-bpm-assert lib.

Reply all
Reply to author
Forward
0 new messages