test_class.file: optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/websocket/PortableRoutingPlanFactoryTest.java
test_class.identifier: PortableRoutingPlanFactoryTest
test_case.body: @Test
      void portable_routing_plan_with_two_routes() {
          // arrange
          final Coordinates coordinates1 = Coordinates.valueOf(0.0, 0.1);
          final Coordinates coordinates2 = Coordinates.valueOf(2.0, -0.2);
          final Coordinates coordinates3 = Coordinates.valueOf(3.3, -3.3);
          final Coordinates checkpoint12 = Coordinates.valueOf(12, 12);
          final Coordinates checkpoint21 = Coordinates.valueOf(21, 21);
          final Coordinates checkpoint13 = Coordinates.valueOf(13, 13);
          final Coordinates checkpoint31 = Coordinates.valueOf(31, 31);
          List<Coordinates> segment12 = asList(coordinates1, checkpoint12, coordinates2);
          List<Coordinates> segment21 = asList(coordinates2, checkpoint21, coordinates1);
          List<Coordinates> segment13 = asList(coordinates1, checkpoint13, coordinates3);
          List<Coordinates> segment31 = asList(coordinates3, checkpoint31, coordinates1);
  
          final Location location1 = new Location(1, coordinates1);
          final Location location2 = new Location(2, coordinates2);
          final Location location3 = new Location(3, coordinates3);
          final Distance distance = Distance.ofMillis(5);
  
          final Vehicle vehicle1 = VehicleFactory.createVehicle(1, "Vehicle 1", 100);
          final Vehicle vehicle2 = VehicleFactory.createVehicle(2, "Vehicle 2", 200);
  
          RouteWithTrack route1 = new RouteWithTrack(
                  new Route(vehicle1, location1, singletonList(location2)),
                  asList(segment12, segment21));
          RouteWithTrack route2 = new RouteWithTrack(
                  new Route(vehicle2, location1, singletonList(location3)),
                  asList(segment13, segment31));
  
          RoutingPlan routingPlan = new RoutingPlan(
                  distance,
                  asList(vehicle1, vehicle2),
                  location1,
                  asList(location2, location3),
                  asList(route1, route2));
  
          // act
          PortableRoutingPlan portableRoutingPlan = PortableRoutingPlanFactory.fromRoutingPlan(routingPlan);
  
          // assert
          // -- plan.distance
          assertThat(portableRoutingPlan.getDistance()).isEqualTo(PortableDistance.fromDistance(distance));
          // -- plan.depot
          assertThat(portableRoutingPlan.getDepot()).isEqualTo(PortableLocation.fromLocation(location1));
          // -- plan.visits
          assertThat(portableRoutingPlan.getVisits()).containsExactlyInAnyOrder(
                  PortableLocation.fromLocation(location2),
                  PortableLocation.fromLocation(location3));
          // -- plan.routes
          assertThat(portableRoutingPlan.getRoutes()).hasSize(2);
          // -- plan.vehicles
          assertThat(portableRoutingPlan.getVehicles()).containsExactlyInAnyOrder(
                  PortableVehicle.fromVehicle(vehicle1),
                  PortableVehicle.fromVehicle(vehicle2));
  
          // -- plan.routes[1]
          PortableRoute portableRoute1 = portableRoutingPlan.getRoutes().get(0);
  
          assertThat(portableRoute1.getVehicle()).isEqualTo(PortableVehicle.fromVehicle(vehicle1));
          assertThat(portableRoute1.getDepot()).isEqualTo(PortableLocation.fromLocation(location1));
          assertThat(portableRoute1.getVisits()).containsExactly(
                  PortableLocation.fromLocation(location2));
          assertThat(portableRoute1.getTrack()).hasSize(2);
          assertThat(portableRoute1.getTrack().get(0)).containsExactly(
                  PortableCoordinates.fromCoordinates(location1.coordinates()),
                  PortableCoordinates.fromCoordinates(checkpoint12),
                  PortableCoordinates.fromCoordinates(location2.coordinates()));
          assertThat(portableRoute1.getTrack().get(1)).containsExactly(
                  PortableCoordinates.fromCoordinates(location2.coordinates()),
                  PortableCoordinates.fromCoordinates(checkpoint21),
                  PortableCoordinates.fromCoordinates(location1.coordinates()));
  
          // -- plan.routes[2]
          PortableRoute portableRoute2 = portableRoutingPlan.getRoutes().get(1);
  
          assertThat(portableRoute2.getVehicle()).isEqualTo(PortableVehicle.fromVehicle(vehicle2));
          assertThat(portableRoute2.getDepot()).isEqualTo(PortableLocation.fromLocation(location1));
          assertThat(portableRoute2.getVisits()).containsExactly(
                  PortableLocation.fromLocation(location3));
          assertThat(portableRoute2.getTrack()).hasSize(2);
          assertThat(portableRoute2.getTrack().get(0)).containsExactly(
                  PortableCoordinates.fromCoordinates(location1.coordinates()),
                  PortableCoordinates.fromCoordinates(checkpoint13),
                  PortableCoordinates.fromCoordinates(location3.coordinates()));
          assertThat(portableRoute2.getTrack().get(1)).containsExactly(
                  PortableCoordinates.fromCoordinates(location3.coordinates()),
                  PortableCoordinates.fromCoordinates(checkpoint31),
                  PortableCoordinates.fromCoordinates(location1.coordinates()));
      }
test_case.class_method_signature: PortableRoutingPlanFactoryTest.portable_routing_plan_with_two_routes()
test_case.full_signature: @Test void portable_routing_plan_with_two_routes()
test_case.identifier: portable_routing_plan_with_two_routes
test_case.invocations: valueOf valueOf valueOf valueOf valueOf valueOf valueOf asList asList asList asList ofMillis createVehicle createVehicle singletonList asList singletonList asList asList asList asList fromRoutingPlan isEqualTo assertThat getDistance fromDistance isEqualTo assertThat getDepot fromLocation containsExactlyInAnyOrder assertThat getVisits fromLocation fromLocation hasSize assertThat getRoutes containsExactlyInAnyOrder assertThat getVehicles fromVehicle fromVehicle get getRoutes isEqualTo assertThat getVehicle fromVehicle isEqualTo assertThat getDepot fromLocation containsExactly assertThat getVisits fromLocation hasSize assertThat getTrack containsExactly assertThat get getTrack fromCoordinates coordinates fromCoordinates fromCoordinates coordinates containsExactly assertThat get getTrack fromCoordinates coordinates fromCoordinates fromCoordinates coordinates get getRoutes isEqualTo assertThat getVehicle fromVehicle isEqualTo assertThat getDepot fromLocation containsExactly assertThat getVisits fromLocation hasSize assertThat getTrack containsExactly assertThat get getTrack fromCoordinates coordinates fromCoordinates fromCoordinates coordinates containsExactly assertThat get getTrack fromCoordinates coordinates fromCoordinates fromCoordinates coordinates
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void portable_routing_plan_with_two_routes()
focal_class.file: optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/websocket/PortableRoutingPlanFactory.java
focal_class.identifier: PortableRoutingPlanFactory
focal_class.class_method_signature: PortableRoutingPlanFactory.PortableRoutingPlanFactory()
focal_class.full_signature: private  PortableRoutingPlanFactory()
focal_class.identifier: PortableRoutingPlanFactory
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  PortableRoutingPlanFactory()
focal_class.class_method_signature: PortableRoutingPlanFactory.fromRoutingPlan(RoutingPlan routingPlan)
focal_class.full_signature: static PortableRoutingPlan fromRoutingPlan(RoutingPlan routingPlan)
focal_class.identifier: fromRoutingPlan
focal_class.modifiers: static
focal_class.parameters: (RoutingPlan routingPlan)
focal_class.return: PortableRoutingPlan
focal_class.signature: PortableRoutingPlan fromRoutingPlan(RoutingPlan routingPlan)
focal_class.class_method_signature: PortableRoutingPlanFactory.portableTrack(List<List<Coordinates>> track)
focal_class.full_signature: private static List<List<PortableCoordinates>> portableTrack(List<List<Coordinates>> track)
focal_class.identifier: portableTrack
focal_class.modifiers: private static
focal_class.parameters: (List<List<Coordinates>> track)
focal_class.return: List<List<PortableCoordinates>>
focal_class.signature: List<List<PortableCoordinates>> portableTrack(List<List<Coordinates>> track)
focal_class.class_method_signature: PortableRoutingPlanFactory.portableVisits(List<Location> visits)
focal_class.full_signature: private static List<PortableLocation> portableVisits(List<Location> visits)
focal_class.identifier: portableVisits
focal_class.modifiers: private static
focal_class.parameters: (List<Location> visits)
focal_class.return: List<PortableLocation>
focal_class.signature: List<PortableLocation> portableVisits(List<Location> visits)
focal_class.class_method_signature: PortableRoutingPlanFactory.portableVehicles(List<Vehicle> vehicles)
focal_class.full_signature: private static List<PortableVehicle> portableVehicles(List<Vehicle> vehicles)
focal_class.identifier: portableVehicles
focal_class.modifiers: private static
focal_class.parameters: (List<Vehicle> vehicles)
focal_class.return: List<PortableVehicle>
focal_class.signature: List<PortableVehicle> portableVehicles(List<Vehicle> vehicles)
focal_method.body: static PortableRoutingPlan fromRoutingPlan(RoutingPlan routingPlan) {
          PortableDistance distance = PortableDistance.fromDistance(routingPlan.distance());
          List<PortableVehicle> vehicles = portableVehicles(routingPlan.vehicles());
          PortableLocation depot = routingPlan.depot().map(PortableLocation::fromLocation).orElse(null);
          List<PortableLocation> visits = portableVisits(routingPlan.visits());
          List<PortableRoute> routes = routingPlan.routes().stream()
                  .map(routeWithTrack -> new PortableRoute(
                          PortableVehicle.fromVehicle(routeWithTrack.vehicle()),
                          depot,
                          portableVisits(routeWithTrack.visits()),
                          portableTrack(routeWithTrack.track())))
                  .collect(toList());
          return new PortableRoutingPlan(distance, vehicles, depot, visits, routes);
      }
focal_method.class_method_signature: PortableRoutingPlanFactory.fromRoutingPlan(RoutingPlan routingPlan)
focal_method.full_signature: static PortableRoutingPlan fromRoutingPlan(RoutingPlan routingPlan)
focal_method.identifier: fromRoutingPlan
focal_method.invocations: fromDistance distance portableVehicles vehicles orElse map depot portableVisits visits collect map stream routes fromVehicle vehicle portableVisits visits portableTrack track toList
focal_method.modifiers: static
focal_method.parameters: (RoutingPlan routingPlan)
focal_method.return: PortableRoutingPlan
focal_method.signature: PortableRoutingPlan fromRoutingPlan(RoutingPlan routingPlan)