As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
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.
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) Platform targeted …
Are you using Activiti Community or Alfresco Process Services (enterprise version)?
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!
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.