I’ve got a workflow with a section that looks something like this:
I’ve been trying to write some unit tests around how Task1 feeds into Task3; for the purposes of my test I don’t really care much about Task2 except insofar as the process needs to move past the parallel gateway that it feeds into.
I initially tried a test something like this:
val processInstance = rule.processEngine.runtimeService
.createProcessInstanceByKey("Parallel")
.startBeforeActivity("Task1")
//.startAfterTask("Task2")
.execute()
assertThat(processInstance).isWaitingAt("Task1")
complete(task("Task1"), withVariables("task3Items", listOf("task3ItemId")))
assertThat(processInstance).isWaitingAt("Task3")
This gets stuck at the parallel gateway, which I guess makes sense since it never hears anything from the Task2 path. However, when I added in the .startAfterTask("Task2")
line (commented out in the snippet above) I get the error:
Exception while closing command context: Cannot start after activity Task2; activity has no outgoing sequence flow to take
I eventually figured out I could replace that line with .startTransition(...)
on the transition coming out of Task2 and everything works fine, but I sort of wanted to understand the cause of that error. Being able to say startAfterTask("Task2")
seems a little more intuitive so I’m curious why it doesn’t work. Experimenting a little more, it seems like it would work if Task3 weren’t multi-instance?