04-17-2018 10:03 AM
Hi,
I need to write a testcase to test an asynchronous process mocking some of the service tasks in it. I am able to mock by extending from ActivitiTestCase class but the process doesnt wait until all jobs are done. And I am able to test async process with the help of PluggableActivitiTestCase class but in this case, I am unable to mock a service task. Not sure how to test my scenario. Your inputs are highly appreciated. Thanks in advance.
Regards,
Durga Prasad.
04-20-2018 08:36 AM
If there are async jobs/tasks in the process, you may need to query for jobs via the management service and complete the jobs in your test case for it to move to the next step. There are plenty of examples in the activiti repo under unit test cases. GitHub - Activiti/Activiti: Activiti is a light-weight workflow and Business Process Management (BPM...
04-20-2018 09:57 AM
04-20-2018 10:08 AM
Are you using Activiti Community or Alfresco Process Services (enterprise version)?
04-20-2018 10:12 AM
If enterprise, I have an example in this blog where I am using org.mockito.Mockito to mock some classes. You could take a similar approach even with community version, but I don't have an example handy!
04-23-2018 08:06 AM
Hi,
You will need to follow the below steps to be able to mock the service tasks of an async process.
1) Create a custom class to extend AbstractActivitiTestCase class and add mock support to it. You may refer to ActivitiTestCase class on how it was done.
2) Extend PluggableActivitiTestCase and modify it to extend from the above created custom class.
3) In your test case, extend from your CustomPluggableActivitiTestCase class.
Explore our Alfresco products with the links below. Use labels to filter content by product module.