@Test
public void testListReservationsByTimeIntervalContainingNoReservations() {

  ResourceManager rm = setupResourceManager();
  ClientRMService clientService = rm.getClientRMService();
  Clock clock = new UTCClock();
  long arrival = clock.getTime();
  long duration = 60000;
  long deadline = (long) (arrival + 1.05 * duration);
  ReservationSubmissionRequest sRequest =
      submitReservationTestHelper(clientService, arrival, deadline, duration);
  // List reservations, search by very large start time.
  ReservationListRequest request = ReservationListRequest.newInstance(
      ReservationSystemTestUtil.reservationQ, "", Long.MAX_VALUE, -1, false);
  ReservationListResponse response = null;
  try {
    response = clientService.listReservations(request);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
  // Ensure all reservations are filtered out.
  Assert.assertNotNull(response);
  assertThat(response.getReservationAllocationState()).isEmpty();
  duration = 30000;
  deadline = sRequest.getReservationDefinition().getDeadline();
  // List reservations, search by start time after the reservation
  // end time.
  request = ReservationListRequest.newInstance(
      ReservationSystemTestUtil.reservationQ, "", deadline + duration,
      deadline + 2 * duration, false);
  response = null;
  try {
    response = clientService.listReservations(request);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
  // Ensure all reservations are filtered out.
  Assert.assertNotNull(response);
  assertThat(response.getReservationAllocationState()).isEmpty();
  arrival = clock.getTime();
  // List reservations, search by end time before the reservation start
  // time.
  request = ReservationListRequest.newInstance(
      ReservationSystemTestUtil.reservationQ, "", 0, arrival - duration,
      false);
  response = null;
  try {
    response = clientService.listReservations(request);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
  // Ensure all reservations are filtered out.
  Assert.assertNotNull(response);
  assertThat(response.getReservationAllocationState()).isEmpty();
  // List reservations, search by very small end time.
  request = ReservationListRequest
      .newInstance(ReservationSystemTestUtil.reservationQ, "", 0, 1, false);
  response = null;
  try {
    response = clientService.listReservations(request);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
  // Ensure all reservations are filtered out.
  Assert.assertNotNull(response);
  assertThat(response.getReservationAllocationState()).isEmpty();
  rm.stop();
}