TestdataChainedEntity a3 = new TestdataChainedEntity("a3", a2);
TestdataChainedAnchor b0 = new TestdataChainedAnchor("b0");
TestdataChainedEntity b1 = new TestdataChainedEntity("b1", b0);
TestdataChainedSolution solution = new TestdataChainedSolution("solution");
solution.setChainedAnchorList(Arrays.asList(a0, b0));
solution.setChainedEntityList(Arrays.asList(a1, a2, a3, b1));
SolutionDescriptor solutionDescriptor = TestdataChainedSolution.buildSolutionDescriptor();
PlanningEntityDescriptor entityDescriptor = solutionDescriptor.getPlanningEntityDescriptor(
TestdataChainedEntity.class);
PlanningVariableDescriptor variableDescriptor = entityDescriptor.getPlanningVariableDescriptor("chainedObject");
AbstractScoreDirectorFactory scoreDirectorFactory = mock(AbstractScoreDirectorFactory.class);
when(scoreDirectorFactory.getSolutionDescriptor()).thenReturn(solutionDescriptor);
AbstractScoreDirector scoreDirector = new AbstractScoreDirector<AbstractScoreDirectorFactory>(
scoreDirectorFactory) {
public Score calculateScore() {
return DefaultSimpleScore.valueOf(-100);
}
};
TestdataChainedSolution clonedStartingSolution = solution.cloneSolution();
scoreDirector.setWorkingSolution(solution);
assertEquals(a1, scoreDirector.getTrailingEntity(variableDescriptor, a0));
assertEquals(a2, scoreDirector.getTrailingEntity(variableDescriptor, a1));
assertEquals(a3, scoreDirector.getTrailingEntity(variableDescriptor, a2));