mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add test
This commit is contained in:
parent
f3037aaed7
commit
2a94626710
1 changed files with 50 additions and 0 deletions
|
|
@ -0,0 +1,50 @@
|
||||||
|
package jsprit.core.algorithm;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import jsprit.core.algorithm.listener.IterationStartsListener;
|
||||||
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
|
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class VehicleRoutingAlgorithmTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSettingIterations_itIsSetCorrectly(){
|
||||||
|
VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(mock(VehicleRoutingProblem.class),
|
||||||
|
mock(SearchStrategyManager.class));
|
||||||
|
algorithm.setNuOfIterations(50);
|
||||||
|
assertEquals(50,algorithm.getNuOfIterations());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CountIterations implements IterationStartsListener {
|
||||||
|
|
||||||
|
private int countIterations = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void informIterationStarts(int i, VehicleRoutingProblem problem,Collection<VehicleRoutingProblemSolution> solutions) {
|
||||||
|
countIterations++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCountIterations() {
|
||||||
|
return countIterations;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSettingIterations_iterAreExecutedCorrectly(){
|
||||||
|
VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(mock(VehicleRoutingProblem.class),
|
||||||
|
mock(SearchStrategyManager.class));
|
||||||
|
algorithm.setNuOfIterations(100);
|
||||||
|
CountIterations counter = new CountIterations();
|
||||||
|
algorithm.addListener(counter);
|
||||||
|
algorithm.searchSolutions();
|
||||||
|
assertEquals(100,counter.getCountIterations());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue