public static ReservationListResponse mergeReservationsList(
      Collection<ReservationListResponse> responses) {
    ReservationListResponse reservationListResponse =
        Records.newRecord(ReservationListResponse.class);
    List<ReservationAllocationState> reservationAllocationStates =
        new ArrayList<>();
    for (ReservationListResponse response : responses) {
      if (response != null && response.getReservationAllocationState() != null) {
        reservationAllocationStates.addAll(
            response.getReservationAllocationState());
      }
    }
    reservationListResponse.setReservationAllocationState(
        reservationAllocationStates);
    return reservationListResponse;
  }
@Test
  public void testMergeReservationsList() {

    // normal response
    ReservationListResponse response1 = createReservationListResponse(
        165348678000L, 165348690000L, 165348678000L, 1L);

    ReservationListResponse response2 = createReservationListResponse(
        165348750000L, 165348768000L, 165348750000L, 1L);

    // empty response
    ReservationListResponse response3 = ReservationListResponse.newInstance(new ArrayList<>());

    // null response
    ReservationListResponse response4 = null;

    List<ReservationListResponse> responses = new ArrayList<>();
    responses.add(response1);
    responses.add(response2);
    responses.add(response3);
    responses.add(response4);

    // expected response
    List<ReservationAllocationState> expectedResponse = new ArrayList<>();
    expectedResponse.addAll(response1.getReservationAllocationState());
    expectedResponse.addAll(response2.getReservationAllocationState());

    ReservationListResponse response =
        RouterYarnClientUtils.mergeReservationsList(responses);
    Assert.assertEquals(expectedResponse, response.getReservationAllocationState());
  }