cancel
Showing results for 
Search instead for 
Did you mean: 

testing serviceTasks in the workflow

lawandco
Champ in-the-making
Champ in-the-making
I think I am missing some functional concepts in what I need to know to properly unit test my activiti workflow.
The workflow is like this:
userTask 1 -> serviceTask 1 -> exclusive gateway 1 -> userTask 2 -> exclusive gateway 2 -> serviceTask 2 -> end
decisions at either exclusive gateway could cause the process to end
the test at userTask 1 executes properly
build output shows the serviceTask 1 class is automatically executed.  serviceTask 1 is designed to make calls to resources that are not functional except in a production environment.  That is all stubbed out so that in the current environment it is always successful.
gateway 1 depends on a variable set by serviceTask 1. 
the test for userTask 2 runs until it performs a task.getName() and finds out the task is at userTask 1 not UserTask 2.
Tests never run in the correct order, which I believe is within the rules.
the first user task completed with activitiRule.getTaskService().complete(task.getId(), variables);
Question.  How does the serviceTask1 show activiti that it has completed successfully?
Question.  Why does the serviceTask 1 class automatically execute, since there is no serviceTask test written for it ( which is because I automatically see it execute )  Must I have a test for the serviceTask1 to make this work?

1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Question. Why does the serviceTask 1 class automatically execute, since there is no serviceTask test written for it ( which is because I automatically see it execute ) Must I have a test for the serviceTask1 to make this work?
Service tasks are executed automatically according to definition (e.g. http://www.activiti.org/userguide/#bpmnJavaServiceTask). It just call the logic when the execution arrives to this task.

Question. How does the serviceTask1 show activiti that it has completed successfully?
There are history tables in which events and execution history is stored. You can reproduce the call from history tables and process definition .


Regards
Martin