mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
simplify VehicleRoute.Builder by adding .addPickup(Pickup) and .addDelivery(Delivery)
This commit is contained in:
parent
20a898cd25
commit
fe7ad0d316
3 changed files with 76 additions and 76 deletions
|
|
@ -308,6 +308,20 @@ public class TestVehicleRoute {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddingPickup_itShouldBeAdded(){
|
||||
|
||||
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).addPickup(pickup).build();
|
||||
|
||||
TourActivity act = route.getActivities().get(0);
|
||||
assertTrue(act.getName().equals("pickup"));
|
||||
assertTrue(act instanceof PickupService);
|
||||
assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Pickup);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddingDelivery_itShouldBeTreatedAsDelivery(){
|
||||
|
||||
|
|
@ -321,4 +335,18 @@ public class TestVehicleRoute {
|
|||
assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Delivery);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddingDelivery_itShouldBeAdded(){
|
||||
|
||||
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).addDelivery(delivery).build();
|
||||
|
||||
TourActivity act = route.getActivities().get(0);
|
||||
assertTrue(act.getName().equals("delivery"));
|
||||
assertTrue(act instanceof DeliverService);
|
||||
assertTrue(((TourActivity.JobActivity)act).getJob() instanceof Delivery);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue