### Question:
DirectionApiLogic { public BestTransportResult fromToWithDeparture(String origin, String destination, TravelMode mode, ReadableInstant departureTime) { DirectionsRoute[] routes = this.calls.fromToWithDepartureTime(origin, destination, mode, departureTime); if (mode == TravelMode.TRANSIT) { return new BestTransportResult(mode, findBestArrivalTime(routes)); } return new BestTransportResult(mode, findBestRoute(routes)); }  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);  }### Answer:
@Test public void testFromToDepartureCar() { when(this.directionsApiCalls.fromToWithDepartureTime("A", "B", TravelMode.DRIVING, new DateTime(0))) .thenReturn(this.data.carRoutes); BestTransportResult result = this.logic.fromToWithDeparture("A", "B", TravelMode.DRIVING, new DateTime(0)); verify(this.directionsApiCalls).fromToWithDepartureTime("A", "B", TravelMode.DRIVING, new DateTime(0)); assertThat(result.getRoute(), equalTo(this.data.carRoutes[4])); assertThat(result.getMode(), equalTo(TravelMode.DRIVING)); }
@Test public void testFromToDepartureNoRoutes() { when(this.directionsApiCalls.fromToWithDepartureTime("A", "B", TravelMode.DRIVING, new DateTime(0))) .thenReturn(null); BestTransportResult result = this.logic.fromToWithDeparture("A", "B", TravelMode.DRIVING, new DateTime(0)); verify(this.directionsApiCalls).fromToWithDepartureTime("A", "B", TravelMode.DRIVING, new DateTime(0)); assertThat(result.getRoute(), equalTo(null)); assertThat(result.getMode(), equalTo(TravelMode.DRIVING)); }
@Test public void testFromToDepartureTransit() { when(this.directionsApiCalls.fromToWithDepartureTime("A", "B", TravelMode.TRANSIT, new DateTime(0))) .thenReturn(this.data.transportRoutes); BestTransportResult result = this.logic.fromToWithDeparture("A", "B", TravelMode.TRANSIT, new DateTime(0)); verify(this.directionsApiCalls).fromToWithDepartureTime("A", "B", TravelMode.TRANSIT, new DateTime(0)); assertThat(result.getRoute(), equalTo(this.data.transportRoutes[6])); assertThat(result.getMode(), equalTo(TravelMode.TRANSIT)); }
@Test public void testFromToDepartureTransitNoRoutes() { when(this.directionsApiCalls.fromToWithDepartureTime("A", "B", TravelMode.TRANSIT, new DateTime(0))) .thenReturn(null); BestTransportResult result = this.logic.fromToWithDeparture("A", "B", TravelMode.TRANSIT, new DateTime(0)); verify(this.directionsApiCalls).fromToWithDepartureTime("A", "B", TravelMode.TRANSIT, new DateTime(0)); assertThat(result.getRoute(), equalTo(null)); assertThat(result.getMode(), equalTo(TravelMode.TRANSIT)); }