### Question:
TravelServiceImpl implements TravelService { @Override public Response create(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, "Create trip:" + ti.toString() + ".", null); } else { return new Response<>(1, "Trip " + info.getTripId().toString() + " already 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 testCreate1() { TravelInfo info = new TravelInfo(); info.setTripId("G"); Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(null); Mockito.when(repository.save(Mockito.any(Trip.class))).thenReturn(null); Response result = travelServiceImpl.create(info, headers); Assert.assertEquals(new Response<>(1, "Create trip:G.", null), result); }
@Test public void testCreate2() { TravelInfo info = new TravelInfo(); info.setTripId("G"); Trip trip = new Trip(); Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(trip); Response result = travelServiceImpl.create(info, headers); Assert.assertEquals(new Response<>(1, "Trip G already exists", null), result); }