RouteFollowingVehicle extends Vehicle { protected boolean isTooEarly(Parcel p, TimeLapse time) { final ParcelState parcelState = getPDPModel().getParcelState(p); checkArgument( !parcelState.isTransitionState() && !parcelState.isDelivered(), "Parcel state may not be a transition state nor may it be delivered, " + "it is %s.", parcelState, parcelState.isTransitionState() ? getPDPModel() .getVehicleActionInfo(this).timeNeeded() : null); final boolean isPickup = !parcelState.isPickedUp(); if (isPickup && parcelState == ParcelState.AVAILABLE) { return false; } final Point loc = isPickup ? p.getDto().getPickupLocation() : p .getDeliveryLocation(); final long travelTime = computeTravelTimeTo(loc, time.getTimeUnit()); final long openingTime = isPickup ? p.getPickupTimeWindow().begin() : p .getDeliveryTimeWindow().begin(); final long latestTimeToLeave = openingTime - travelTime; return latestTimeToLeave >= time.getEndTime(); } RouteFollowingVehicle(VehicleDTO dto,
      boolean allowDelayedRouteChanging);  RouteFollowingVehicle(VehicleDTO dto,
      boolean allowDelayedRouteChanging, RouteAdjuster adjuster,
      GeomHeuristic heuristic);  RouteFollowingVehicle(VehicleDTO dto,
      boolean allowDelayedRouteChanging, RouteAdjuster adjuster); boolean isDiversionAllowed(); boolean isDelayedRouteChangingAllowed(); void setRoute(Iterable<? extends Parcel> r); Collection<Parcel> getRoute(); @OverridingMethodsMustInvokeSuper @Override void initRoadPDP(RoadModel pRoadModel, PDPModel pPdpModel); static RouteAdjuster delayAdjuster(); static RouteAdjuster nopAdjuster();  }
@Test public void testIsTooEarly() { assertEquals(minute(2), d.computeTravelTimeTo(new Point(1, 2), SI.MILLI(SI.SECOND))); assertTrue(d.isTooEarly(p1, time(0, 10))); assertTrue(d.isTooEarly(p1, time(minute(2), minute(3)))); assertFalse(d.isTooEarly(p1, time(minute(2) + 1, minute(3) + 1))); assertFalse(d.isTooEarly(p1, time(minute(3), minute(4)))); assertFalse(d.isTooEarly(p1, time(minute(4), minute(5)))); assertFalse(d.isTooEarly(p1, time(minute(10), minute(11)))); assertTrue(d.isTooEarly(p2, time(0, 10))); assertTrue(d.isTooEarly(p2, time(minute(10) + 10, minute(11) + 10))); assertFalse(d.isTooEarly(p2, time(minute(10) + 11, minute(11) + 11))); assertFalse(d.isTooEarly(p2, time(minute(11), minute(12)))); assertFalse(d.isTooEarly(p2, time(minute(12), minute(13)))); assertFalse(d.isTooEarly(p2, time(minute(20), minute(21)))); }
@Test public void isTooEarlyAvailableState() { tick(5, 6); assertFalse(d.isTooEarly(p1, time(2))); }