### Question:
Travel2ServiceImpl implements Travel2Service { @Override public Response delete(String tripId, HttpHeaders headers) { TripId ti = new TripId(tripId); if (repository.findByTripId(ti) != null) { repository.deleteByTripId(ti); return new Response<>(1, "Delete trip:" + tripId + ".", tripId); } else { return new Response<>(0, "Trip " + tripId + " doesn't exist.", null); } }  @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 testDelete1() { Trip trip = new Trip(); Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(trip); Mockito.doNothing().doThrow(new RuntimeException()).when(repository).deleteByTripId(Mockito.any(TripId.class)); Response result = travel2ServiceImpl.delete("trip_id_1", headers); Assert.assertEquals(new Response<>(1, "Delete trip:trip_id_1.", "trip_id_1"), result); }
@Test public void testDelete2() { Mockito.when(repository.findByTripId(Mockito.any(TripId.class))).thenReturn(null); Response result = travel2ServiceImpl.delete("trip_id_1", headers); Assert.assertEquals(new Response<>(0, "Trip trip_id_1 doesn't exist.", null), result); }