### Question:
TravelServiceImpl implements TravelService { @Override public Response update(TravelInfo info, HttpHeaders headers) { TripId ti = new TripId(info.getTripId()); if (repository.findByTripId(ti) != null) { Trip trip = new Trip(ti, info.getTrainTypeId(), info.getStartingStationId(), info.getStationsId(), info.getTerminalStationId(), info.getStartingTime(), info.getEndTime()); trip.setRouteId(info.getRouteId()); repository.save(trip); return new Response<>(1, "Update trip:" + ti.toString(), trip); } else { return new Response<>(1, "Trip" + info.getTripId().toString() + "doesn 't exists", null); } }  @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 testUpdate1() { TravelInfo info = new TravelInfo(); info.setTripId("G"); Trip trip = new Trip(); Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(trip); Mockito.when(repository.save(Mockito.any(Trip.class))).thenReturn(null); Response result = travelServiceImpl.update(info, headers); Assert.assertEquals("Update trip:G", result.getMsg()); }
@Test public void testUpdate2() { TravelInfo info = new TravelInfo(); info.setTripId("G"); Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(null); Response result = travelServiceImpl.update(info, headers); Assert.assertEquals(new Response<>(1, "TripGdoesn 't exists", null), result); }