RouteOptimizerImpl implements RouteOptimizer { @Override public void addLocation(Location domainLocation, DistanceMatrixRow distanceMatrixRow) { PlanningLocation location = PlanningLocationFactory.fromDomain( domainLocation, new DistanceMapImpl(distanceMatrixRow)); if (depot == null) { depot = new PlanningDepot(location); publishSolution(); } else { PlanningVisit visit = PlanningVisitFactory.fromLocation(location); visits.add(visit); if (vehicles.isEmpty()) { publishSolution(); } else if (visits.size() == 1) { solverManager.startSolver(SolutionFactory.solutionFromVisits(vehicles, depot, visits)); } else { solverManager.addVisit(visit); } } } @Autowired  RouteOptimizerImpl(SolverManager solverManager, RouteChangedEventPublisher routeChangedEventPublisher); @Override void addLocation(Location domainLocation, DistanceMatrixRow distanceMatrixRow); @Override void removeLocation(Location domainLocation); @Override void addVehicle(Vehicle domainVehicle); @Override void removeVehicle(Vehicle domainVehicle); @Override void changeCapacity(Vehicle domainVehicle); @Override void removeAllLocations(); @Override void removeAllVehicles();  }
@Test void each_location_should_have_a_distance_map_after_it_is_added() { long millis = 8079; routeOptimizer.addLocation(location1, locationId -> Distance.ofMillis(millis)); VehicleRoutingSolution solution = verifyPublishingPreliminarySolution(); assertThat(solution.getDepotList()).hasSize(1); assertThat(solution.getDepotList().get(0).getLocation().distanceTo(fromDomain(location2))).isEqualTo(millis); }