@Test
public void multiVariable() {
EntityDescriptor entityDescriptor = TestdataMultiVarEntity.buildEntityDescriptor();
GenuineVariableDescriptor variableDescriptor = entityDescriptor.getGenuineVariableDescriptor("secondaryValue");
TestdataMultiVarEntity e1 = new TestdataMultiVarEntity("e1");
TestdataMultiVarEntity e2 = new TestdataMultiVarEntity("e2");
TestdataValue p1 = new TestdataValue("p1");
TestdataValue s1 = new TestdataValue("s1");
TestdataValue s2 = new TestdataValue("s2");
TestdataValue s3 = new TestdataValue("s3");
ValueSelector childValueSelector = SelectorTestUtils.mockValueSelector(variableDescriptor,
s1, s2, s3);
ValueSelector valueSelector = new ReinitializeVariableValueSelector(childValueSelector);
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);
e1.setPrimaryValue(p1);
assertAllCodesOfValueSelectorForEntity(valueSelector, e1, "s1", "s2", "s3");
valueSelector.stepEnded(stepScopeA1);
AbstractStepScope stepScopeA2 = mock(AbstractStepScope.class);
when(stepScopeA2.getPhaseScope()).thenReturn(phaseScopeA);
valueSelector.stepStarted(stepScopeA2);
e2.setSecondaryValue(s2);
assertAllCodesOfValueSelectorForEntity(valueSelector, e2);
valueSelector.stepEnded(stepScopeA2);
valueSelector.phaseEnded(phaseScopeA);
AbstractPhaseScope phaseScopeB = mock(AbstractPhaseScope.class);
when(phaseScopeB.getSolverScope()).thenReturn(solverScope);
valueSelector.phaseStarted(phaseScopeB);
AbstractStepScope stepScopeB1 = mock(AbstractStepScope.class);
when(stepScopeB1.getPhaseScope()).thenReturn(phaseScopeB);
valueSelector.stepStarted(stepScopeB1);
e2.setSecondaryValue(null);
assertAllCodesOfValueSelectorForEntity(valueSelector, e2, "s1", "s2", "s3");
valueSelector.stepEnded(stepScopeB1);
AbstractStepScope stepScopeB2 = mock(AbstractStepScope.class);