### Question:
AdminTravelServiceImpl implements AdminTravelService { @Override public Response getAllTravels(HttpHeaders headers) { Response<ArrayList<AdminTrip>> result; ArrayList<AdminTrip> trips = new ArrayList<>(); AdminTravelServiceImpl.LOGGER.info("[Admin Travel Service][Get All Travels]"); HttpEntity requestEntity = new HttpEntity(headers); ResponseEntity<Response<ArrayList<AdminTrip>>> re = restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<AdminTrip>>>() { }); result = re.getBody(); if (result.getStatus() == 1) { ArrayList<AdminTrip> adminTrips = result.getData(); AdminTravelServiceImpl.LOGGER.info("[Admin Travel Service][Get Travel From ts-travel-service successfully!]"); trips.addAll(adminTrips); } else { AdminTravelServiceImpl.LOGGER.info("[Admin Travel Service][Get Travel From ts-travel-service fail!]"); } HttpEntity requestEntity2 = new HttpEntity(headers); ResponseEntity<Response<ArrayList<AdminTrip>>> re2 = restTemplate.exchange( "http: HttpMethod.GET, requestEntity2, new ParameterizedTypeReference<Response<ArrayList<AdminTrip>>>() { }); result = re2.getBody(); if (result.getStatus() == 1) { AdminTravelServiceImpl.LOGGER.info("[Admin Travel Service][Get Travel From ts-travel2-service successfully!]"); ArrayList<AdminTrip> adminTrips = result.getData(); trips.addAll(adminTrips); } else { AdminTravelServiceImpl.LOGGER.info("[Admin Travel Service][Get Travel From ts-travel2-service fail!]"); } result.setData(trips); return result; }  @Override Response getAllTravels(HttpHeaders headers); @Override Response addTravel(TravelInfo request, HttpHeaders headers); @Override Response updateTravel(TravelInfo request, HttpHeaders headers); @Override Response deleteTravel(String tripId, HttpHeaders headers);  }### Answer:
@Test public void testGetAllTravels1() { Response<ArrayList<AdminTrip>> response = new Response<>(0, null, null); ResponseEntity<Response<ArrayList<AdminTrip>>> re = new ResponseEntity<>(response, HttpStatus.OK); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<AdminTrip>>>() { })).thenReturn(re); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<AdminTrip>>>() { })).thenReturn(re); Response result = adminTravelServiceImpl.getAllTravels(headers); Assert.assertEquals(new Response<>(0, null, new ArrayList<>()), result); }
@Test public void testGetAllTravels2() { ArrayList<AdminTrip> adminTrips = new ArrayList<>(); adminTrips.add(new AdminTrip()); Response<ArrayList<AdminTrip>> response = new Response<>(1, null, adminTrips); ResponseEntity<Response<ArrayList<AdminTrip>>> re = new ResponseEntity<>(response, HttpStatus.OK); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<AdminTrip>>>() { })).thenReturn(re); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<AdminTrip>>>() { })).thenReturn(re); Response result = adminTravelServiceImpl.getAllTravels(headers); Assert.assertNotNull(result); }