@Test
public void testStartComplexCaseInstance() {
CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1")
.listener("create", stateTransitionCollector)
.createActivity("A1")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new TaskWaitState())
.endActivity()
.createActivity("X1")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new StageActivityBehavior())
.createActivity("A2")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new TaskWaitState())
.endActivity()
.createActivity("B1")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new TaskWaitState())
.endActivity()
.endActivity()
.createActivity("Y")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new StageActivityBehavior())
.createActivity("C")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new TaskWaitState())
.endActivity()
.createActivity("X2")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new StageActivityBehavior())
.createActivity("A3")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new TaskWaitState())
.endActivity()
.createActivity("B2")
.listener("create", stateTransitionCollector)
.listener("enable", stateTransitionCollector)
.listener("manualStart", stateTransitionCollector)
.behavior(new TaskWaitState())
.endActivity()
.endActivity()
.endActivity()
.buildCaseDefinition();
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// expected state transitions after the creation of a case instance:
// () --create(Case1)--> active
// () --create(A1)--> available