### Question:
Travel2ServiceImpl implements Travel2Service { @Override public Response getRouteByTripId(String tripId, HttpHeaders headers) { TripId tripId1 = new TripId(tripId); Trip trip = repository.findByTripId(tripId1); if (trip == null) { Travel2ServiceImpl.LOGGER.info("[Get Route By Trip ID] Trip Not Found: {}", tripId); return new Response<>(0, "\"[Get Route By Trip ID] Trip Not Found:\" + tripId", null); } else { Route route = getRouteByRouteId(trip.getRouteId(), headers); if (route == null) { return new Response<>(0, "\"[Get Route By Trip ID] Route Not Found:\" + trip.getRouteId()", null); } else { Travel2ServiceImpl.LOGGER.info("[Get Route By Trip ID] Success"); return new Response<>(1, "[Get Route By Trip ID] Success", route); } } }  @Override Response getRouteByTripId(String tripId, HttpHeaders headers); @Override Response getTrainTypeByTripId(String tripId, HttpHeaders headers); @Override Response getTripByRoute(ArrayList<String> routeIds, HttpHeaders headers); @Override Response create(TravelInfo info, 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 testGetRouteByTripId1() { Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(null); Response result = travel2ServiceImpl.getRouteByTripId("K1255", headers); Assert.assertEquals(new Response<>(0, "\"[Get Route By Trip ID] Trip Not Found:\" + tripId", null), result); }
@Test public void testGetRouteByTripId2() { Trip trip = new Trip(); Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(trip); Route route = new Route(); Response response = new Response(1, null, route); ResponseEntity<Response> re = new ResponseEntity<>(response, HttpStatus.OK); Mockito.when(restTemplate.exchange( Mockito.anyString(), Mockito.any(HttpMethod.class), Mockito.any(HttpEntity.class), Mockito.any(Class.class))) .thenReturn(re); Response result = travel2ServiceImpl.getRouteByTripId("K1255", headers); Assert.assertEquals("[Get Route By Trip ID] Success", result.getMsg()); }