@Test public void testWehnIHaveToGoNotSupportedTravelMode() { assertThat(this.logic.whenIHaveToGo("A", "B", TravelMode.WALKING, DateTime.now()), equalTo(null)); }
public ReadableInstant whenIHaveToGo(String origin, String destination, TravelMode mode, DateTime arrivalTime) { DirectionsRoute[] routes; DirectionsRoute route; switch (mode) { case DRIVING: case BICYCLING: routes = this.calls.fromToWithDepartureTime(origin, destination, mode, DateTime.now()); route = findBestRoute(routes); if (route != null && route.legs[0].durationInTraffic != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)).getMillis()) { return new DateTime(arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)) .getMillis()); } else if (route != null && route.legs[0].duration != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()) { return new DateTime( arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()); } break; case TRANSIT: routes = this.calls.fromToWithArrivalTime(destination, origin, mode, arrivalTime); if (routes != null && routes[0] != null) { return routes[0].legs[0].departureTime; } break; default: break; } return null; }
DirectionApiLogic { public ReadableInstant whenIHaveToGo(String origin, String destination, TravelMode mode, DateTime arrivalTime) { DirectionsRoute[] routes; DirectionsRoute route; switch (mode) { case DRIVING: case BICYCLING: routes = this.calls.fromToWithDepartureTime(origin, destination, mode, DateTime.now()); route = findBestRoute(routes); if (route != null && route.legs[0].durationInTraffic != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)).getMillis()) { return new DateTime(arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)) .getMillis()); } else if (route != null && route.legs[0].duration != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()) { return new DateTime( arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()); } break; case TRANSIT: routes = this.calls.fromToWithArrivalTime(destination, origin, mode, arrivalTime); if (routes != null && routes[0] != null) { return routes[0].legs[0].departureTime; } break; default: break; } return null; } }
DirectionApiLogic { public ReadableInstant whenIHaveToGo(String origin, String destination, TravelMode mode, DateTime arrivalTime) { DirectionsRoute[] routes; DirectionsRoute route; switch (mode) { case DRIVING: case BICYCLING: routes = this.calls.fromToWithDepartureTime(origin, destination, mode, DateTime.now()); route = findBestRoute(routes); if (route != null && route.legs[0].durationInTraffic != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)).getMillis()) { return new DateTime(arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)) .getMillis()); } else if (route != null && route.legs[0].duration != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()) { return new DateTime( arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()); } break; case TRANSIT: routes = this.calls.fromToWithArrivalTime(destination, origin, mode, arrivalTime); if (routes != null && routes[0] != null) { return routes[0].legs[0].departureTime; } break; default: break; } return null; }  }
DirectionApiLogic { public ReadableInstant whenIHaveToGo(String origin, String destination, TravelMode mode, DateTime arrivalTime) { DirectionsRoute[] routes; DirectionsRoute route; switch (mode) { case DRIVING: case BICYCLING: routes = this.calls.fromToWithDepartureTime(origin, destination, mode, DateTime.now()); route = findBestRoute(routes); if (route != null && route.legs[0].durationInTraffic != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)).getMillis()) { return new DateTime(arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)) .getMillis()); } else if (route != null && route.legs[0].duration != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()) { return new DateTime( arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()); } break; case TRANSIT: routes = this.calls.fromToWithArrivalTime(destination, origin, mode, arrivalTime); if (routes != null && routes[0] != null) { return routes[0].legs[0].departureTime; } break; default: break; } return null; }  BestTransportResult fromTo(String origin, String destination, TravelMode mode); BestTransportResult fromToWithDeparture(String origin, String destination, TravelMode mode,
			ReadableInstant departureTime); ReadableInstant whenIHaveToGo(String origin, String destination, TravelMode mode, DateTime arrivalTime); BestTransportResult getBestTransportInTime(String origin, String destination,
			ReadableInstant departureTime); TravelMode getTravelMode(String mode); }
DirectionApiLogic { public ReadableInstant whenIHaveToGo(String origin, String destination, TravelMode mode, DateTime arrivalTime) { DirectionsRoute[] routes; DirectionsRoute route; switch (mode) { case DRIVING: case BICYCLING: routes = this.calls.fromToWithDepartureTime(origin, destination, mode, DateTime.now()); route = findBestRoute(routes); if (route != null && route.legs[0].durationInTraffic != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)).getMillis()) { return new DateTime(arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].durationInTraffic.inSeconds)) .getMillis()); } else if (route != null && route.legs[0].duration != null && arrivalTime.getMillis() > DateTime.now() .plusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()) { return new DateTime( arrivalTime.minusSeconds(Math.toIntExact(route.legs[0].duration.inSeconds)).getMillis()); } break; case TRANSIT: routes = this.calls.fromToWithArrivalTime(destination, origin, mode, arrivalTime); if (routes != null && routes[0] != null) { return routes[0].legs[0].departureTime; } break; default: break; } return null; }  BestTransportResult fromTo(String origin, String destination, TravelMode mode); BestTransportResult fromToWithDeparture(String origin, String destination, TravelMode mode,
			ReadableInstant departureTime); ReadableInstant whenIHaveToGo(String origin, String destination, TravelMode mode, DateTime arrivalTime); BestTransportResult getBestTransportInTime(String origin, String destination,
			ReadableInstant departureTime); TravelMode getTravelMode(String mode);  }