@Test
public void testGetQueueInfo() throws Exception {

  ResourceScheduler scheduler = mock(ResourceScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(scheduler, rmContext);
  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
  when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), any(RMApp.class), any(String.class),
      any()))
      .thenReturn(true);
  when(mockAclsManager.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), any(),
      any(ApplicationId.class))).thenReturn(true);
  ClientRMService rmService = new ClientRMService(rmContext, scheduler,
      null, mockAclsManager, mockQueueACLsManager, null);
  GetQueueInfoRequest request = recordFactory
      .newRecordInstance(GetQueueInfoRequest.class);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
  List<ApplicationReport> applications = queueInfo.getQueueInfo()
      .getApplications();
  Assert.assertEquals(2, applications.size());
  Map<String, QueueConfigurations> queueConfigsByPartition =
      queueInfo.getQueueInfo().getQueueConfigurations();
  Assert.assertEquals(1, queueConfigsByPartition.size());
  Assert.assertTrue(queueConfigsByPartition.containsKey("*"));
  QueueConfigurations queueConfigs = queueConfigsByPartition.get("*");
  Assert.assertEquals(0.5f, queueConfigs.getCapacity(), 0.0001f);
  Assert.assertEquals(0.1f, queueConfigs.getAbsoluteCapacity(), 0.0001f);
  Assert.assertEquals(1.0f, queueConfigs.getMaxCapacity(), 0.0001f);
  Assert.assertEquals(1.0f, queueConfigs.getAbsoluteMaxCapacity(), 0.0001f);
  Assert.assertEquals(0.2f, queueConfigs.getMaxAMPercentage(), 0.0001f);
  request.setQueueName("nonexistentqueue");
  request.setIncludeApplications(true);
  // should not throw exception on nonexistent queue
  queueInfo = rmService.getQueueInfo(request);
  // Case where user does not have application access
  ApplicationACLsManager mockAclsManager1 =
      mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager1 =
      mock(QueueACLsManager.class);
  when(mockQueueACLsManager1.checkAccess(any(UserGroupInformation.class),
      any(QueueACL.class), any(RMApp.class), any(String.class),
      any()))
      .thenReturn(false);
  when(mockAclsManager1.checkAccess(any(UserGroupInformation.class),
      any(ApplicationAccessType.class), anyString(),
      any(ApplicationId.class))).thenReturn(false);
  ClientRMService rmService1 = new ClientRMService(rmContext, scheduler,
      null, mockAclsManager1, mockQueueACLsManager1, null);
  request.setQueueName("testqueue");
  request.setIncludeApplications(true);
  GetQueueInfoResponse queueInfo1 = rmService1.getQueueInfo(request);
  List<ApplicationReport> applications1 = queueInfo1.getQueueInfo()
      .getApplications();
  Assert.assertEquals(0, applications1.size());
}