@Test void export_should_marshal_empty_routing_plan_when_repositories_empty() { when(locationRepository.locations()).thenReturn(Collections.emptyList()); when(vehicleRepository.vehicles()).thenReturn(Collections.emptyList()); demoService.exportDataSet(); RoutingProblem routingProblem = verifyAndCaptureMarshalledProblem(); assertThat(routingProblem.name()).isNotNull(); assertThat(routingProblem.depot()).isEmpty(); assertThat(routingProblem.visits()).isEmpty(); assertThat(routingProblem.vehicles()).isEmpty(); }
public String exportDataSet() { List<Location> visits = new ArrayList<>(locationRepository.locations()); Location depot = visits.isEmpty() ? null : visits.remove(0); List<Vehicle> vehicles = vehicleRepository.vehicles(); return dataSetMarshaller.marshal(new RoutingProblem( "Custom Vehicle Routing instance", vehicles, depot, visits)); }
DemoService { public String exportDataSet() { List<Location> visits = new ArrayList<>(locationRepository.locations()); Location depot = visits.isEmpty() ? null : visits.remove(0); List<Vehicle> vehicles = vehicleRepository.vehicles(); return dataSetMarshaller.marshal(new RoutingProblem( "Custom Vehicle Routing instance", vehicles, depot, visits)); } }
DemoService { public String exportDataSet() { List<Location> visits = new ArrayList<>(locationRepository.locations()); Location depot = visits.isEmpty() ? null : visits.remove(0); List<Vehicle> vehicles = vehicleRepository.vehicles(); return dataSetMarshaller.marshal(new RoutingProblem( "Custom Vehicle Routing instance", vehicles, depot, visits)); } @Autowired  DemoService(
            RoutingProblemList routingProblems,
            LocationService locationService,
            LocationRepository locationRepository,
            VehicleService vehicleService,
            VehicleRepository vehicleRepository,
            DataSetMarshaller dataSetMarshaller); }
DemoService { public String exportDataSet() { List<Location> visits = new ArrayList<>(locationRepository.locations()); Location depot = visits.isEmpty() ? null : visits.remove(0); List<Vehicle> vehicles = vehicleRepository.vehicles(); return dataSetMarshaller.marshal(new RoutingProblem( "Custom Vehicle Routing instance", vehicles, depot, visits)); } @Autowired  DemoService(
            RoutingProblemList routingProblems,
            LocationService locationService,
            LocationRepository locationRepository,
            VehicleService vehicleService,
            VehicleRepository vehicleRepository,
            DataSetMarshaller dataSetMarshaller); Collection<RoutingProblem> demos(); @Async void loadDemo(String name); String exportDataSet(); }
DemoService { public String exportDataSet() { List<Location> visits = new ArrayList<>(locationRepository.locations()); Location depot = visits.isEmpty() ? null : visits.remove(0); List<Vehicle> vehicles = vehicleRepository.vehicles(); return dataSetMarshaller.marshal(new RoutingProblem( "Custom Vehicle Routing instance", vehicles, depot, visits)); } @Autowired  DemoService(
            RoutingProblemList routingProblems,
            LocationService locationService,
            LocationRepository locationRepository,
            VehicleService vehicleService,
            VehicleRepository vehicleRepository,
            DataSetMarshaller dataSetMarshaller); Collection<RoutingProblem> demos(); @Async void loadDemo(String name); String exportDataSet();  }