CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
// given
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1")
.listener("complete", stateTransitionCollector)
.createActivity("A")
.listener("terminate", stateTransitionCollector)
.listener("complete", stateTransitionCollector)
.behavior(new TaskWaitState())
.endActivity()
.buildCaseDefinition();
// an active case instance
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// task A as a child of the case instance
CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");