SolutionFactory { public static VehicleRoutingSolution solutionFromVisits( List<PlanningVehicle> vehicles, PlanningDepot depot, List<PlanningVisit> visits) { VehicleRoutingSolution solution = new VehicleRoutingSolution(); solution.setVehicleList(new ArrayList<>(vehicles)); solution.setDepotList(new ArrayList<>(1)); if (depot != null) { solution.getDepotList().add(depot); moveAllVehiclesToDepot(vehicles, depot); } solution.setVisitList(new ArrayList<>(visits)); solution.setScore(HardSoftLongScore.ZERO); return solution; } private  SolutionFactory(); static VehicleRoutingSolution emptySolution(); static VehicleRoutingSolution solutionFromVisits(
            List<PlanningVehicle> vehicles,
            PlanningDepot depot,
            List<PlanningVisit> visits);  }
@Test void solution_created_from_vehicles_depot_and_visits_should_be_consistent() { PlanningVehicle vehicle = new PlanningVehicle(); PlanningLocation depotLocation = PlanningLocationFactory.testLocation(1); PlanningDepot depot = new PlanningDepot(depotLocation); PlanningVisit visit = PlanningVisitFactory.testVisit(2); VehicleRoutingSolution solutionWithDepot = SolutionFactory.solutionFromVisits( singletonList(vehicle), depot, singletonList(visit)); assertThat(solutionWithDepot.getVehicleList()).containsExactly(vehicle); assertThat(vehicle.getDepot()).isEqualTo(depot); assertThat(solutionWithDepot.getDepotList()).containsExactly(depot); assertThat(solutionWithDepot.getVisitList()).hasSize(1); assertThat(solutionWithDepot.getVisitList()).containsExactly(visit); assertThat(solutionWithDepot.getVisitList().get(0).getLocation()).isEqualTo(visit.getLocation()); VehicleRoutingSolution solutionWithNoDepot = SolutionFactory.solutionFromVisits( singletonList(vehicle), null, emptyList()); assertThat(solutionWithNoDepot.getDepotList()).isEmpty(); }