public class InitializedValueSelectorTest {
@Test
public void originalSelectionNullable() {
EntityDescriptor entityDescriptor = TestdataNullableEntity.buildEntityDescriptor();
TestdataNullableEntity e1 = new TestdataNullableEntity("e1");
// This variable is unable to have entity's as values, but it's an interesting nullable test anyway
GenuineVariableDescriptor variableDescriptor = entityDescriptor.getGenuineVariableDescriptor("value");
TestdataValue v1 = new TestdataValue("v1");
TestdataValue v2 = null;
TestdataValue v3 = new TestdataValue("v3");
ValueSelector childValueSelector = SelectorTestUtils.mockValueSelector(variableDescriptor,
v1, v2, v3);
ValueSelector valueSelector = new InitializedValueSelector(childValueSelector);
verify(childValueSelector, times(1)).isNeverEnding();
DefaultSolverScope solverScope = mock(DefaultSolverScope.class);
valueSelector.solvingStarted(solverScope);
AbstractPhaseScope phaseScopeA = mock(AbstractPhaseScope.class);
when(phaseScopeA.getSolverScope()).thenReturn(solverScope);
valueSelector.phaseStarted(phaseScopeA);
AbstractStepScope stepScopeA1 = mock(AbstractStepScope.class);
when(stepScopeA1.getPhaseScope()).thenReturn(phaseScopeA);
valueSelector.stepStarted(stepScopeA1);
assertAllCodesOfValueSelectorForEntity(valueSelector, e1, PlannerAssert.DO_NOT_ASSERT_SIZE, "v1", null, "v3");
e1.setValue(v1);
valueSelector.stepEnded(stepScopeA1);
valueSelector.phaseEnded(phaseScopeA);
valueSelector.solvingEnded(solverScope);