PDPModel extends AbstractModel<PDPObject> implements TickListener { public abstract void deliver(Vehicle vehicle, Parcel parcel, TimeLapse time);  @Override final boolean register(PDPObject object); abstract ImmutableSet<Parcel> getContents(Container container); abstract double getContentsSize(Container container); abstract double getContainerCapacity(Container container); abstract void pickup(Vehicle vehicle, Parcel parcel, TimeLapse time); abstract void drop(Vehicle vehicle, Parcel parcel, TimeLapse time); abstract void deliver(Vehicle vehicle, Parcel parcel, TimeLapse time); abstract void addParcelIn(Container container, Parcel parcel); abstract Collection<Parcel> getParcels(ParcelState state); abstract Collection<Parcel> getParcels(ParcelState... states); abstract Set<Vehicle> getVehicles(); abstract ParcelState getParcelState(Parcel parcel); abstract VehicleState getVehicleState(Vehicle vehicle); abstract PDPModel.VehicleParcelActionInfo getVehicleActionInfo(
      Vehicle vehicle); abstract EventAPI getEventAPI(); abstract boolean containerContains(Container container, Parcel parcel); abstract TimeWindowPolicy getTimeWindowPolicy(); abstract void service(Vehicle vehicle, Parcel parcel, TimeLapse time);  }
@Test public void testDeliver() { final Vehicle truck = new TestVehicle(VehicleDTO.builder() .startPosition(new Point(1, 1)) .capacity(10) .build()); rm.register(truck); model.register(truck); final Parcel pack1 = Parcel.builder(new Point(1, 1), new Point(2, 2)) .pickupDuration(10) .deliveryDuration(10) .neededCapacity(2d) .build(); rm.register(pack1); model.register(pack1); assertTrue(rm.equalPosition(truck, pack1)); assertEquals(ParcelState.AVAILABLE, model.getParcelState(pack1)); assertEquals(VehicleState.IDLE, model.getVehicleState(truck)); assertEquals(newHashSet(pack1), model.getParcels(ParcelState.AVAILABLE)); model.pickup(truck, pack1, TimeLapseFactory.create(0, 100)); assertEquals(ParcelState.IN_CARGO, model.getParcelState(pack1)); assertEquals(VehicleState.IDLE, model.getVehicleState(truck)); assertTrue(model.getParcels(ParcelState.AVAILABLE).isEmpty()); rm.moveTo(truck, pack1.getDeliveryLocation(), TimeLapseFactory.create(0, 3600000 * 3)); assertEquals(pack1.getDeliveryLocation(), rm.getPosition(truck)); model.deliver(truck, pack1, TimeLapseFactory.create(0, 8)); assertEquals(ParcelState.DELIVERING, model.getParcelState(pack1)); assertEquals(VehicleState.DELIVERING, model.getVehicleState(truck)); final TimeLapse tl = TimeLapseFactory.create(0, 10); model.continuePreviousActions(truck, tl); assertEquals(ParcelState.DELIVERED, model.getParcelState(pack1)); assertEquals(VehicleState.IDLE, model.getVehicleState(truck)); assertEquals(8, tl.getTimeLeft()); final Parcel pack2 = Parcel.builder(new Point(2, 2), new Point(2, 2)) .pickupDuration(10) .deliveryDuration(10) .neededCapacity(2d) .build(); rm.register(pack2); model.register(pack2); assertEquals(ParcelState.AVAILABLE, model.getParcelState(pack2)); assertEquals(VehicleState.IDLE, model.getVehicleState(truck)); assertEquals(newHashSet(pack2), model.getParcels(ParcelState.AVAILABLE)); model.pickup(truck, pack2, TimeLapseFactory.create(0, 10)); assertEquals(ParcelState.IN_CARGO, model.getParcelState(pack2)); assertEquals(VehicleState.IDLE, model.getVehicleState(truck)); assertTrue(model.getParcels(ParcelState.AVAILABLE).isEmpty()); model.deliver(truck, pack2, TimeLapseFactory.create(0, 10)); assertEquals(ParcelState.DELIVERED, model.getParcelState(pack2)); assertEquals(VehicleState.IDLE, model.getVehicleState(truck)); }
@Test(expected = IllegalArgumentException.class) public void testDeliverFail1() { model.deliver(new TestVehicle(), null, TimeLapseFactory.create(0, 1)); }