public static GetQueueUserAclsInfoResponse mergeQueueUserAcls(
      Collection<GetQueueUserAclsInfoResponse> responses) {
    GetQueueUserAclsInfoResponse aclsInfoResponse = Records.newRecord(
        GetQueueUserAclsInfoResponse.class);
    Set<QueueUserACLInfo> queueUserACLInfos = new HashSet<>();
    for (GetQueueUserAclsInfoResponse response : responses) {
      if (response != null && response.getUserAclsInfoList() != null) {
        queueUserACLInfos.addAll(response.getUserAclsInfoList());
      }
    }
    aclsInfoResponse.setUserAclsInfoList(new ArrayList<>(queueUserACLInfos));
    return aclsInfoResponse;
  }
@Test
  public void testMergeQueueUserAclsResponse() {

    List<QueueACL> submitOnlyAcl = new ArrayList<>();
    submitOnlyAcl.add(QueueACL.SUBMIT_APPLICATIONS);

    List<QueueACL> administerOnlyAcl = new ArrayList<>();
    administerOnlyAcl.add(QueueACL.ADMINISTER_QUEUE);

    List<QueueACL> submitAndAdministerAcl = new ArrayList<>();
    submitAndAdministerAcl.add(QueueACL.ADMINISTER_QUEUE);
    submitAndAdministerAcl.add(QueueACL.SUBMIT_APPLICATIONS);

    QueueUserACLInfo queueUserACLInfo1 = QueueUserACLInfo.newInstance(
        "root", submitAndAdministerAcl);

    QueueUserACLInfo queueUserACLInfo2 = QueueUserACLInfo.newInstance(
        "default", submitOnlyAcl);

    QueueUserACLInfo queueUserACLInfo3 = QueueUserACLInfo.newInstance(
        "root", submitAndAdministerAcl);

    QueueUserACLInfo queueUserACLInfo4 = QueueUserACLInfo.newInstance(
        "yarn", administerOnlyAcl);

    List<QueueUserACLInfo> queueUserACLInfoList1 = new ArrayList<>();
    List<QueueUserACLInfo> queueUserACLInfoList2 = new ArrayList<>();

    queueUserACLInfoList1.add(queueUserACLInfo1);
    queueUserACLInfoList1.add(queueUserACLInfo2);
    queueUserACLInfoList2.add(queueUserACLInfo3);
    queueUserACLInfoList2.add(queueUserACLInfo4);

    // normal response
    GetQueueUserAclsInfoResponse response1 = Records.newRecord(
        GetQueueUserAclsInfoResponse.class);
    response1.setUserAclsInfoList(queueUserACLInfoList1);
    GetQueueUserAclsInfoResponse response2 = Records.newRecord(
        GetQueueUserAclsInfoResponse.class);
    response2.setUserAclsInfoList(queueUserACLInfoList2);

    // empty response
    GetQueueUserAclsInfoResponse response3 = Records.newRecord(
        GetQueueUserAclsInfoResponse.class);

    // null response
    GetQueueUserAclsInfoResponse response4 = null;

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

    // expected user acls
    List<QueueUserACLInfo> expectedOutput = new ArrayList<>();
    expectedOutput.add(queueUserACLInfo1);
    expectedOutput.add(queueUserACLInfo2);
    expectedOutput.add(queueUserACLInfo4);

    GetQueueUserAclsInfoResponse response =
        RouterYarnClientUtils.mergeQueueUserAcls(responses);
    Assert.assertTrue(CollectionUtils.isEqualCollection(expectedOutput,
        response.getUserAclsInfoList()));
  }