### Question:
TravelServiceImpl implements TravelService { @Override public Response getTripAllDetailInfo(TripAllDetailInfo gtdi, HttpHeaders headers) { TripAllDetail gtdr = new TripAllDetail(); TravelServiceImpl.LOGGER.info("[TravelService] [TripAllDetailInfo] TripId: {}", gtdi.getTripId()); Trip trip = repository.findByTripId(new TripId(gtdi.getTripId())); if (trip == null) { gtdr.setTripResponse(null); gtdr.setTrip(null); } else { String startingPlaceName = gtdi.getFrom(); String endPlaceName = gtdi.getTo(); String startingPlaceId = queryForStationId(startingPlaceName, headers); String endPlaceId = queryForStationId(endPlaceName, headers); Route tempRoute = getRouteByRouteId(trip.getRouteId(), headers); TripResponse tripResponse = getTickets(trip, tempRoute, startingPlaceId, endPlaceId, gtdi.getFrom(), gtdi.getTo(), gtdi.getTravelDate(), headers); if (tripResponse == null) { gtdr.setTripResponse(null); gtdr.setTrip(null); } else { gtdr.setTripResponse(tripResponse); gtdr.setTrip(repository.findByTripId(new TripId(gtdi.getTripId()))); } } return new Response<>(1, success, gtdr); }  @Override Response create(TravelInfo info, HttpHeaders headers); @Override Response getRouteByTripId(String tripId, HttpHeaders headers); @Override Response getTrainTypeByTripId(String tripId, HttpHeaders headers); @Override Response getTripByRoute(ArrayList<String> routeIds, HttpHeaders headers); @Override Response retrieve(String tripId, HttpHeaders headers); @Override Response update(TravelInfo info, HttpHeaders headers); @Override Response delete(String tripId, HttpHeaders headers); @Override Response query(TripInfo info, HttpHeaders headers); @Override Response getTripAllDetailInfo(TripAllDetailInfo gtdi, HttpHeaders headers); @Override Response queryAll(HttpHeaders headers); @Override Response adminQueryAll(HttpHeaders headers);  }### Answer:
@Test public void testGetTripAllDetailInfo() { TripAllDetailInfo gtdi = new TripAllDetailInfo(); gtdi.setTripId("Z1255"); gtdi.setFrom("from_station"); gtdi.setTo("to_station"); gtdi.setTravelDate(new Date(System.currentTimeMillis() - 86400000)); Trip trip = new Trip(); trip.setRouteId("route_id"); Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(trip); Response<String> response1 = new Response<>(null, null, ""); ResponseEntity<Response<String>> re1 = new ResponseEntity<>(response1, HttpStatus.OK); Mockito.when(restTemplate.exchange( Mockito.anyString(), Mockito.any(HttpMethod.class), Mockito.any(HttpEntity.class), Mockito.any(ParameterizedTypeReference.class))) .thenReturn(re1); Route route = new Route(); route.setStations(new ArrayList<>()); Response response2 = new Response(1, null, route); ResponseEntity<Response> re2 = new ResponseEntity<>(response2, HttpStatus.OK); Mockito.when(restTemplate.exchange( Mockito.anyString(), Mockito.any(HttpMethod.class), Mockito.any(HttpEntity.class), Mockito.any(Class.class))) .thenReturn(re2); Response result = travelServiceImpl.getTripAllDetailInfo(gtdi, headers); Assert.assertEquals("Success", result.getMsg()); }