// an active case instance
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// a case execution associated with Stage X
CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
// an active stage X
stageX.manualStart();
// a case execution associated with Task A
CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
taskA.manualStart();
// a case execution associated with Task B
CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
taskB.manualStart();
// when ////////////////////////////////////////////////////////////////
// terminate task A
taskA.terminate();
// terminate task B
taskB.terminate();
// then ////////////////////////////////////////////////////////////////
List<String> expectedStateTransitions = new ArrayList<String>();
// expected state transitions:
// active --complete(X)--> completed
// active --complete(Case1)--> completed
expectedStateTransitions.add("active --complete(X)--> completed");
expectedStateTransitions.add("active --complete(Case1)--> completed");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// task A is terminated
assertTrue(taskA.isTerminated());
// task B is terminated
assertTrue(taskB.isTerminated());
// stage X is completed
assertTrue(stageX.isCompleted());
// stage X does not contain task A anymore