diff --git a/jsprit-io/src/main/java/com/graphhopper/jsprit/io/algorithm/VehicleRoutingAlgorithms.java b/jsprit-io/src/main/java/com/graphhopper/jsprit/io/algorithm/VehicleRoutingAlgorithms.java index 23a73527..e1bee0cd 100644 --- a/jsprit-io/src/main/java/com/graphhopper/jsprit/io/algorithm/VehicleRoutingAlgorithms.java +++ b/jsprit-io/src/main/java/com/graphhopper/jsprit/io/algorithm/VehicleRoutingAlgorithms.java @@ -427,11 +427,11 @@ public class VehicleRoutingAlgorithms { return createAlgo(vrp, algorithmConfig.getXMLConfiguration(), nThreads, null, null); } - public static VehicleRoutingAlgorithm readAndCreateAlgorithm(VehicleRoutingProblem vrp, int nThreads, String configFileName, SolutionCostCalculator solutionCostCalculator) { + public static VehicleRoutingAlgorithm readAndCreateAlgorithm(VehicleRoutingProblem vrp, int nThreads, String configFileName, StateManager stateMan, SolutionCostCalculator solutionCostCalculator) { AlgorithmConfig algorithmConfig = new AlgorithmConfig(); AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig); xmlReader.read(configFileName); - return createAlgo(vrp, algorithmConfig.getXMLConfiguration(), nThreads, null, solutionCostCalculator); + return createAlgo(vrp, algorithmConfig.getXMLConfiguration(), nThreads, stateMan, solutionCostCalculator); } private static class OpenRouteStateVerifier implements StateUpdater, ReverseActivityVisitor { diff --git a/jsprit-io/src/test/java/com/graphhopper/jsprit/io/algorithm/TestAlgorithmReader.java b/jsprit-io/src/test/java/com/graphhopper/jsprit/io/algorithm/TestAlgorithmReader.java index 48209465..17613627 100644 --- a/jsprit-io/src/test/java/com/graphhopper/jsprit/io/algorithm/TestAlgorithmReader.java +++ b/jsprit-io/src/test/java/com/graphhopper/jsprit/io/algorithm/TestAlgorithmReader.java @@ -28,6 +28,7 @@ import com.graphhopper.jsprit.core.algorithm.ruin.RuinStrategy; import com.graphhopper.jsprit.core.algorithm.ruin.listener.RuinListener; import com.graphhopper.jsprit.core.algorithm.selector.SelectBest; import com.graphhopper.jsprit.core.algorithm.selector.SolutionSelector; +import com.graphhopper.jsprit.core.algorithm.state.StateManager; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.job.Job; import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator; @@ -50,6 +51,9 @@ import java.util.Collection; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; public class TestAlgorithmReader { @@ -288,8 +292,17 @@ public class TestAlgorithmReader { @Test public void testWithVehicleRoutingAlgorithm() { SolutionCostCalculator solutionCostCalculator = Mockito.mock(SolutionCostCalculator.class); - VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, 10, getClass().getResource("algorithmConfig_withoutIterations.xml").getFile(), solutionCostCalculator); + StateManager stateMan = Mockito.mock(StateManager.class); + doNothing().when(stateMan).updateLoadStates(); + doNothing().when(stateMan).updateTimeWindowStates(); + doNothing().when(stateMan).updateSkillStates(); + + VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, 10, getClass().getResource("algorithmConfig_withoutIterations.xml").getFile(), stateMan, solutionCostCalculator); vra.getObjectiveFunction().equals(solutionCostCalculator); + + verify(stateMan, times(2)).updateLoadStates(); + verify(stateMan, times(2)).updateTimeWindowStates(); + verify(stateMan, times(2)).updateSkillStates(); }