@Test
public void testDeliver() {
final Vehicle truck = new TestVehicle(new Point(1, 1), 10.0, 1.0);
rm.register(truck);
model.register(truck);
final Parcel pack1 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
rm.register(pack1);
model.register(pack1);
rm.addObjectAtSamePosition(pack1, truck);
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.getDestination(),
TimeLapseFactory.create(0, 3600000 * 3));
assertEquals(pack1.getDestination(), 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 = new TestParcel(new Point(2, 2), 10, 10, 2.0);
rm.register(pack2);
model.register(pack2);
rm.addObjectAtSamePosition(pack2, truck);
assertEquals(ParcelState.AVAILABLE, model.getParcelState(pack2));
assertEquals(VehicleState.IDLE, model.getVehicleState(truck));