mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add tests to ensure that pickups/deliveries remain pickups/deliveries
This commit is contained in:
parent
f961fa8971
commit
82713d76d1
1 changed files with 44 additions and 11 deletions
|
|
@ -1,38 +1,41 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package jsprit.core.problem.solution.route;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.driver.DriverImpl.NoDriver;
|
||||
import jsprit.core.problem.job.Delivery;
|
||||
import jsprit.core.problem.job.Pickup;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.route.activity.DeliverService;
|
||||
import jsprit.core.problem.solution.route.activity.PickupService;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class TestVehicleRoute {
|
||||
|
||||
|
|
@ -290,4 +293,34 @@ public class TestVehicleRoute {
|
|||
vRoute.setVehicleAndDepartureTime(new_vehicle, 1500.0);
|
||||
assertEquals(1500.0,vRoute.getDepartureTime(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddingPickup_itShouldBeTreatedAsPickup(){
|
||||
|
||||
Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick").setLocationId("pickLoc").build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId("startLoc").build();
|
||||
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle).addService(pickup).build();
|
||||
|
||||
TourActivity act = route.getActivities().get(0);
|
||||
assertTrue(act.getName().equals("pickup"));
|
||||
System.out.println(act.getName());
|
||||
assertTrue(act instanceof PickupService);
|
||||
assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Pickup);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddingDelivery_itShouldBeTreatedAsDelivery(){
|
||||
|
||||
Delivery delivery = (Delivery) Delivery.Builder.newInstance("delivery").setLocationId("deliveryLoc").build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId("startLoc").build();
|
||||
VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle).addService(delivery).build();
|
||||
|
||||
TourActivity act = route.getActivities().get(0);
|
||||
assertTrue(act.getName().equals("delivery"));
|
||||
System.out.println(act.getName());
|
||||
assertTrue(act instanceof DeliverService);
|
||||
assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Delivery);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue