### Question:
DirectionApiLogic { public BestTransportResult fromTo(String origin, String destination, TravelMode mode) { DirectionsRoute[] routes = this.calls.fromTo(origin, destination, mode); 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 testFromToCar() { when(this.directionsApiCalls.fromTo("A", "B", TravelMode.DRIVING)).thenReturn(this.data.carRoutes); BestTransportResult result = this.logic.fromTo("A", "B", TravelMode.DRIVING); verify(this.directionsApiCalls).fromTo("A", "B", TravelMode.DRIVING); assertThat(result.getRoute(), equalTo(this.data.carRoutes[4])); assertThat(result.getMode(), equalTo(TravelMode.DRIVING)); }
@Test public void testFromToNoRoutes() { when(this.directionsApiCalls.fromTo("A", "B", TravelMode.DRIVING)).thenReturn(null); BestTransportResult result = this.logic.fromTo("A", "B", TravelMode.DRIVING); verify(this.directionsApiCalls).fromTo("A", "B", TravelMode.DRIVING); assertThat(result.getRoute(), equalTo(null)); assertThat(result.getMode(), equalTo(TravelMode.DRIVING)); }
@Test public void testFromToTransit() { when(this.directionsApiCalls.fromTo("A", "B", TravelMode.TRANSIT)).thenReturn(this.data.transportRoutes); BestTransportResult result = this.logic.fromTo("A", "B", TravelMode.TRANSIT); verify(this.directionsApiCalls).fromTo("A", "B", TravelMode.TRANSIT); assertThat(result.getRoute(), equalTo(this.data.transportRoutes[6])); assertThat(result.getMode(), equalTo(TravelMode.TRANSIT)); }
@Test public void testFromToTransitNoRoutes() { when(this.directionsApiCalls.fromTo("A", "B", TravelMode.TRANSIT)).thenReturn(null); BestTransportResult result = this.logic.fromTo("A", "B", TravelMode.TRANSIT); verify(this.directionsApiCalls).fromTo("A", "B", TravelMode.TRANSIT); assertThat(result.getRoute(), equalTo(null)); assertThat(result.getMode(), equalTo(TravelMode.TRANSIT)); }