TestdataValue val1 = new TestdataValue("1");
TestdataValue val2 = new TestdataValue("2");
TestdataValue val3 = new TestdataValue("3");
TestdataValue val4 = new TestdataValue("4");
final TestdataEntity a = new TestdataEntity("a", val1);
final TestdataEntity b = new TestdataEntity("b", val2);
final TestdataEntity c = new TestdataEntity("c", val3);
final TestdataEntity d = new TestdataEntity("d", val2);
final TestdataEntity e = new TestdataEntity("e", val3);
final TestdataEntity f = new TestdataEntity("f", val3);
EntitySelector entitySelector = SelectorTestUtils.mockEntitySelector(TestdataEntity.class,
a, b, c, d, e, f);
PlanningVariableDescriptor variableDescriptor = SelectorTestUtils.mockVariableDescriptor(
entitySelector.getEntityDescriptor(), "value");
for (final TestdataEntity entity : Arrays.asList(a, b, c, d, e, f)) {
when(variableDescriptor.getValue(entity)).thenAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) throws Throwable {
return entity.getValue();
}
});
}
SameValuePillarSelector pillarSelector = new SameValuePillarSelector(
entitySelector, Arrays.asList(variableDescriptor), false);
DefaultSolverScope solverScope = mock(DefaultSolverScope.class);
pillarSelector.solvingStarted(solverScope);
AbstractSolverPhaseScope phaseScopeA = mock(AbstractSolverPhaseScope.class);
when(phaseScopeA.getSolverScope()).thenReturn(solverScope);
pillarSelector.phaseStarted(phaseScopeA);
AbstractStepScope stepScopeA1 = mock(AbstractStepScope.class);
when(stepScopeA1.getPhaseScope()).thenReturn(phaseScopeA);
pillarSelector.stepStarted(stepScopeA1);
runAssertsOriginal1(pillarSelector);
pillarSelector.stepEnded(stepScopeA1);
b.setValue(val3);
f.setValue(val4);
AbstractStepScope stepScopeA2 = mock(AbstractStepScope.class);
when(stepScopeA2.getPhaseScope()).thenReturn(phaseScopeA);
pillarSelector.stepStarted(stepScopeA2);
runAssertsOriginal2(pillarSelector);