// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
CaseExecutionImpl instance = (CaseExecutionImpl) caseInstance;
// the case instance should be active
assertTrue(instance.isActive());
// the case instance should have three child plan items (A1, X1, Y)
List<CaseExecutionImpl> childPlanItems = instance.getCaseExecutions();
assertEquals(3, childPlanItems.size());
// handle plan item A1 //////////////////////////////////////////////////
CaseExecutionImpl planItemA1 = (CaseExecutionImpl) instance.findCaseExecution("A1");
// case instance should be the parent of A1
assertEquals(caseInstance, planItemA1.getParent());
// A1 should be enabled
assertTrue(planItemA1.isEnabled());
// manual start of A1
planItemA1.manualStart();
// A1 should be active
assertTrue(planItemA1.isActive());
// expected state transitions:
// enabled --manualStart(A1)--> active
expectedStateTransitions.add("enabled --manualStart(A1)--> active");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item X1 ///////////////////////////////////////////////////
CaseExecutionImpl planItemX1 = (CaseExecutionImpl) instance.findCaseExecution("X1");
// case instance should be the parent of X1
assertEquals(caseInstance, planItemX1.getParent());
// X1 should be enabled
assertTrue(planItemX1.isEnabled());
// manual start of X1
planItemX1.manualStart();
// X1 should be active
assertTrue(planItemX1.isActive());
// X1 should have two children
childPlanItems = planItemX1.getCaseExecutions();
assertEquals(2, childPlanItems.size());
// expected state transitions after manual start of X1:
// enabled --manualStart(X1)--> active
// () --create(A2)--> available
// available --enable(A2)--> enabled
// () --create(B1)--> available
// available --enable(B1)--> enabled
expectedStateTransitions.add("enabled --manualStart(X1)--> active");
expectedStateTransitions.add("() --create(A2)--> available");
expectedStateTransitions.add("available --enable(A2)--> enabled");
expectedStateTransitions.add("() --create(B1)--> available");
expectedStateTransitions.add("available --enable(B1)--> enabled");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item A2 ////////////////////////////////////////////////
CaseExecutionImpl planItemA2 = (CaseExecutionImpl) instance.findCaseExecution("A2");
// X1 should be the parent of A2
assertEquals(planItemX1, planItemA2.getParent());
// A2 should be enabled
assertTrue(planItemA2.isEnabled());
// manual start of A2
planItemA2.manualStart();
// A2 should be active
assertTrue(planItemA2.isActive());
// expected state transition after manual start of A2:
// enabled --manualStart(A2)--> active
expectedStateTransitions.add("enabled --manualStart(A2)--> active");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item B1 /////////////////////////////////////////////////
CaseExecutionImpl planItemB1 = (CaseExecutionImpl) instance.findCaseExecution("B1");
// X1 should be the parent of B1
assertEquals(planItemX1, planItemB1.getParent());
// B1 should be enabled
assertTrue(planItemB1.isEnabled());
// manual start of B1
planItemB1.manualStart();
// B1 should be active
assertTrue(planItemB1.isActive());
// expected state transition after manual start of B1:
// enabled --manualStart(B1)--> active
expectedStateTransitions.add("enabled --manualStart(B1)--> active");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item Y ////////////////////////////////////////////////
CaseExecutionImpl planItemY = (CaseExecutionImpl) instance.findCaseExecution("Y");
// case instance should be the parent of Y
assertEquals(caseInstance, planItemY.getParent());
// Y should be enabled
assertTrue(planItemY.isEnabled());
// manual start of Y
planItemY.manualStart();
// Y should be active
assertTrue(planItemY.isActive());
// Y should have two children
childPlanItems = planItemY.getCaseExecutions();
assertEquals(2, childPlanItems.size());
// expected state transitions after manual start of Y:
// enabled --manualStart(Y)--> active
// () --create(C)--> available
// available --enable(C)--> enabled
// () --create(X2)--> available
// available --enable(X2)--> enabled
expectedStateTransitions.add("enabled --manualStart(Y)--> active");
expectedStateTransitions.add("() --create(C)--> available");
expectedStateTransitions.add("available --enable(C)--> enabled");
expectedStateTransitions.add("() --create(X2)--> available");
expectedStateTransitions.add("available --enable(X2)--> enabled");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item C //////////////////////////////////////////////////
CaseExecutionImpl planItemC = (CaseExecutionImpl) instance.findCaseExecution("C");
// Y should be the parent of C
assertEquals(planItemY, planItemC.getParent());
// C should be enabled
assertTrue(planItemC.isEnabled());
// manual start of C
planItemC.manualStart();
// C should be active
assertTrue(planItemC.isActive());
// expected state transition after manual start of C:
// enabled --manualStart(C)--> active
expectedStateTransitions.add("enabled --manualStart(C)--> active");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item X2 ///////////////////////////////////////////
CaseExecutionImpl planItemX2 = (CaseExecutionImpl) instance.findCaseExecution("X2");
// Y should be the parent of X2
assertEquals(planItemY, planItemX2.getParent());
// X2 should be enabled
assertTrue(planItemX2.isEnabled());
// manual start of X2
planItemX2.manualStart();
// X2 should be active
assertTrue(planItemX2.isActive());
// X2 should have two children
childPlanItems = planItemX2.getCaseExecutions();
assertEquals(2, childPlanItems.size());
// expected state transitions after manual start of X2:
// enabled --manualStart(X2)--> active
// () --create(A3)--> available
// available --enable(A3)--> enabled
// () --create(B2)--> available
// available --enable(B2)--> enabled
expectedStateTransitions.add("enabled --manualStart(X2)--> active");
expectedStateTransitions.add("() --create(A3)--> available");
expectedStateTransitions.add("available --enable(A3)--> enabled");
expectedStateTransitions.add("() --create(B2)--> available");
expectedStateTransitions.add("available --enable(B2)--> enabled");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item A3 //////////////////////////////////////////////
CaseExecutionImpl planItemA3 = (CaseExecutionImpl) instance.findCaseExecution("A3");
// A3 should be the parent of X2
assertEquals(planItemX2, planItemA3.getParent());
// A3 should be enabled
assertTrue(planItemA3.isEnabled());
// manual start of A3
planItemA3.manualStart();
// A3 should be active
assertTrue(planItemA3.isActive());
// expected state transition after manual start of A3:
// enabled --manualStart(A3)--> active
expectedStateTransitions.add("enabled --manualStart(A3)--> active");
assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
// clear lists
expectedStateTransitions.clear();
stateTransitionCollector.stateTransitions.clear();
// handle plan item B2 /////////////////////////////////////////////////
CaseExecutionImpl planItemB2 = (CaseExecutionImpl) instance.findCaseExecution("B2");
// B2 should be the parent of X2
assertEquals(planItemX2, planItemB2.getParent());
// B2 should be enabled
assertTrue(planItemB2.isEnabled());
// manual start of B2
planItemB2.manualStart();
// B2 should be active
assertTrue(planItemB2.isActive());
// expected state transition after manual start of B2:
// enabled --manualStart(B2)--> active
expectedStateTransitions.add("enabled --manualStart(B2)--> active");