@Test
public void oneMoveSelector() {
MoveSelector moveSelector = SelectorTestUtils.mockMoveSelector(DummyMove.class,
new DummyMove("a1"), new DummyMove("a2"), new DummyMove("b1"));
PooledEntityPlacer placer = new PooledEntityPlacer(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);
assertAllCodesOfIterator(placementIterator.next().iterator(),
"a1", "a2", "b1");
placer.stepEnded(stepScopeA1);
assertTrue(placementIterator.hasNext());
AbstractStepScope stepScopeA2 = mock(AbstractStepScope.class);
when(stepScopeA2.getPhaseScope()).thenReturn(phaseScopeA);
placer.stepStarted(stepScopeA2);
assertAllCodesOfIterator(placementIterator.next().iterator(),
"a1", "a2", "b1");
placer.stepEnded(stepScopeA2);
assertTrue(placementIterator.hasNext());
AbstractStepScope stepScopeA3 = mock(AbstractStepScope.class);
when(stepScopeA3.getPhaseScope()).thenReturn(phaseScopeA);
placer.stepStarted(stepScopeA3);
assertAllCodesOfIterator(placementIterator.next().iterator(),
"a1", "a2", "b1");
placer.stepEnded(stepScopeA3);
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);
assertAllCodesOfIterator(placementIterator.next().iterator(),
"a1", "a2", "b1");
placer.stepEnded(stepScopeB1);
placer.phaseEnded(phaseScopeB);
placer.solvingEnded(solverScope);
verifyPhaseLifecycle(moveSelector, 1, 2, 4);
}