### Question:
BestTransportResult { public String routeToShortString() { if (this.route != null && this.route.legs != null && this.route.legs[0] != null) { DirectionsLeg leg = this.route.legs[0]; StringBuilder builder = new StringBuilder(); switch (this.mode) { case DRIVING: if (leg.durationInTraffic != null) { return builder.append(THE_ROUTE_IS).append(leg.distance.humanReadable).append(LONG_AND_NEED) .append(leg.durationInTraffic.humanReadable).append(" time in traffic").toString(); } return builder.append(THE_ROUTE_IS).append(leg.distance.humanReadable).append(LONG_AND_NEED) .append(leg.duration.humanReadable).append(" time").toString(); case TRANSIT: int i = 0; while (leg.steps[i].transitDetails == null) { i++; } if (i > 0) { return builder.append("You should go at ").append(leg.departureTime.toString(TIME_FORMAT)) .append(". departure time of the first public transport is ") .append(leg.steps[i].transitDetails.departureTime.toString(TIME_FORMAT)) .append(" at the station ").append(leg.steps[i].transitDetails.departureStop.name) .append(" with line ").append(leg.steps[i].transitDetails.line.shortName).append(" to ") .append(leg.steps[i].transitDetails.headsign).append(". The arrival time is ") .append(leg.arrivalTime.toString(TIME_FORMAT)).toString(); } return builder.append("Departure is ").append(leg.departureTime.toString(TIME_FORMAT)).append(" at ") .append(leg.steps[i].transitDetails.departureStop.name).append(" with line ") .append(leg.steps[i].transitDetails.line.shortName).append(" to ") .append(leg.steps[i].transitDetails.headsign).append(", arrival time is ") .append(leg.arrivalTime.toString(TIME_FORMAT)).toString(); case BICYCLING: return builder.append(THE_ROUTE_IS).append(leg.distance.humanReadable).append(LONG_AND_NEED) .append(leg.duration.humanReadable).append(" time").toString(); default: break; } } return "No route found"; } BestTransportResult();  BestTransportResult(TravelMode mode, DirectionsRoute route); TravelMode getMode(); DirectionsRoute getRoute(); String routeToLongString(); String routeToShortString(); WidgetRouteInfo routeToWidgetInfo(String mapsStaticAPIKey); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testRoutToShortStringCar() { this.bestResult = new BestTransportResult(TravelMode.DRIVING, this.data.carRoutes[0]); assertThat(this.bestResult.routeToShortString(), equalTo("The route is 2 km long and you will need 5 min time in traffic")); }
@Test public void testRoutToShortStringCarwithoutTraffic() { this.bestResult = new BestTransportResult(TravelMode.DRIVING, this.data.carRoutes[1]); assertThat(this.bestResult.routeToShortString(), equalTo("The route is 2 km long and you will need 5 min time")); }
@Test public void testRoutToShortStringBike() { this.bestResult = new BestTransportResult(TravelMode.BICYCLING, this.data.bicycleRoutes[0]); assertThat(this.bestResult.routeToShortString(), equalTo("The route is 2 km long and you will need 5 min time")); }