MoveSelector moveSelector = new ChangeMoveSelector(
new MimicReplayingEntitySelector(recordingEntitySelector),
valueSelector,
false);
QueuedEntityPlacer placer = new QueuedEntityPlacer(recordingEntitySelector, Collections.singletonList(moveSelector));
DefaultSolverScope solverScope = mock(DefaultSolverScope.class);
placer.solvingStarted(solverScope);
AbstractPhaseScope phaseScopeA = mock(AbstractPhaseScope.class);
when(phaseScopeA.getSolverScope()).thenReturn(solverScope);
placer.phaseStarted(phaseScopeA);
Iterator<Placement> placementIterator = placer.iterator();
assertTrue(placementIterator.hasNext());
AbstractStepScope stepScopeA1 = mock(AbstractStepScope.class);
when(stepScopeA1.getPhaseScope()).thenReturn(phaseScopeA);
placer.stepStarted(stepScopeA1);
assertPlacement(placementIterator.next(), "a", "1", "2");
placer.stepEnded(stepScopeA1);
assertTrue(placementIterator.hasNext());
AbstractStepScope stepScopeA2 = mock(AbstractStepScope.class);
when(stepScopeA2.getPhaseScope()).thenReturn(phaseScopeA);
placer.stepStarted(stepScopeA2);
assertPlacement(placementIterator.next(), "b", "1", "2");
placer.stepEnded(stepScopeA2);
assertTrue(placementIterator.hasNext());
AbstractStepScope stepScopeA3 = mock(AbstractStepScope.class);
when(stepScopeA3.getPhaseScope()).thenReturn(phaseScopeA);
placer.stepStarted(stepScopeA3);
assertPlacement(placementIterator.next(), "c", "1", "2");
placer.stepEnded(stepScopeA3);
assertFalse(placementIterator.hasNext());
placer.phaseEnded(phaseScopeA);
AbstractPhaseScope phaseScopeB = mock(AbstractPhaseScope.class);
when(phaseScopeB.getSolverScope()).thenReturn(solverScope);
placer.phaseStarted(phaseScopeB);
placementIterator = placer.iterator();
assertTrue(placementIterator.hasNext());
AbstractStepScope stepScopeB1 = mock(AbstractStepScope.class);
when(stepScopeB1.getPhaseScope()).thenReturn(phaseScopeB);
placer.stepStarted(stepScopeB1);
assertPlacement(placementIterator.next(), "a", "1", "2");
placer.stepEnded(stepScopeB1);
placer.phaseEnded(phaseScopeB);
placer.solvingEnded(solverScope);
verifyPhaseLifecycle(entitySelector, 1, 2, 4);
verifyPhaseLifecycle(valueSelector, 1, 2, 4);
}