From 82713d76d1694740b6c640ea590ec87be7e28008 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sat, 20 Sep 2014 10:41:00 +0200 Subject: [PATCH] add tests to ensure that pickups/deliveries remain pickups/deliveries --- .../solution/route/TestVehicleRoute.java | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java index 0dfb034e..6010e8f5 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java @@ -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 . ******************************************************************************/ 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); + + } }