DefaultSolverScope solverScope = mock(DefaultSolverScope.class);
when(solverScope.getScoreDirector()).thenReturn(scoreDirector);
subChainSelector.solvingStarted(solverScope);
AbstractPhaseScope phaseScopeA = mock(AbstractPhaseScope.class);
when(phaseScopeA.getSolverScope()).thenReturn(solverScope);
subChainSelector.phaseStarted(phaseScopeA);
AbstractStepScope stepScopeA1 = mock(AbstractStepScope.class);
when(stepScopeA1.getPhaseScope()).thenReturn(phaseScopeA);
subChainSelector.stepStarted(stepScopeA1);
assertAllCodesOfSubChainSelector(subChainSelector,
"[a1]", "[a1, a2]", "[a1, a2, a3]", "[a1, a2, a3, a4]",
"[a2]", "[a2, a3]", "[a2, a3, a4]",
"[a3]", "[a3, a4]",
"[a4]",
"[b1]", "[b1, b2]",
"[b2]");
subChainSelector.stepEnded(stepScopeA1);
a4.setChainedObject(a2);
a3.setChainedObject(b1);
b2.setChainedObject(a3);
AbstractStepScope stepScopeA2 = mock(AbstractStepScope.class);
when(stepScopeA2.getPhaseScope()).thenReturn(phaseScopeA);
subChainSelector.stepStarted(stepScopeA2);
assertAllCodesOfSubChainSelector(subChainSelector,
"[a1]", "[a1, a2]", "[a1, a2, a4]",
"[a2]", "[a2, a4]",
"[a4]",
"[b1]", "[b1, a3]", "[b1, a3, b2]",
"[a3]", "[a3, b2]",
"[b2]");
subChainSelector.stepEnded(stepScopeA2);
subChainSelector.phaseEnded(phaseScopeA);
AbstractPhaseScope phaseScopeB = mock(AbstractPhaseScope.class);
when(phaseScopeB.getSolverScope()).thenReturn(solverScope);
subChainSelector.phaseStarted(phaseScopeB);
AbstractStepScope stepScopeB1 = mock(AbstractStepScope.class);
when(stepScopeB1.getPhaseScope()).thenReturn(phaseScopeB);
subChainSelector.stepStarted(stepScopeB1);