ResourceMgrDelegate extends YarnClient { public QueueInfo[] getRootQueues() throws IOException, InterruptedException { try { return TypeConverter.fromYarnQueueInfo(client.getRootQueueInfos(), this.conf); } catch (YarnException e) { throw new IOException(e); } } ResourceMgrDelegate(YarnConfiguration conf); TaskTrackerInfo[] getActiveTrackers(); JobStatus[] getAllJobs(); TaskTrackerInfo[] getBlacklistedTrackers(); ClusterMetrics getClusterMetrics(); Text getRMDelegationTokenService(); @SuppressWarnings("rawtypes") Token getDelegationToken(Text renewer); String getFilesystemName(); JobID getNewJobID(); QueueInfo getQueue(String queueName); QueueAclsInfo[] getQueueAclsForCurrentUser(); QueueInfo[] getQueues(); QueueInfo[] getRootQueues(); QueueInfo[] getChildQueues(String parent); String getStagingAreaDir(); String getSystemDir(); long getTaskTrackerExpiryInterval(); void setJobPriority(JobID arg0, String arg1); long getProtocolVersion(String arg0, long arg1); ApplicationId getApplicationId(); @Override YarnClientApplication createApplication(); @Override ApplicationId submitApplication(ApplicationSubmissionContext appContext); @Override void killApplication(ApplicationId applicationId); @Override ApplicationReport getApplicationReport(ApplicationId appId); @Override Token<AMRMTokenIdentifier> getAMRMToken(ApplicationId appId); @Override List<ApplicationReport> getApplications(); @Override List<ApplicationReport> getApplications(Set<String> applicationTypes); @Override List<ApplicationReport> getApplications(
      EnumSet<YarnApplicationState> applicationStates); @Override List<ApplicationReport> getApplications(
      Set<String> applicationTypes,
      EnumSet<YarnApplicationState> applicationStates); @Override YarnClusterMetrics getYarnClusterMetrics(); @Override List<NodeReport> getNodeReports(NodeState... states); @Override org.apache.hadoop.yarn.api.records.Token getRMDelegationToken(
      Text renewer); @Override org.apache.hadoop.yarn.api.records.QueueInfo getQueueInfo(
      String queueName); @Override List<org.apache.hadoop.yarn.api.records.QueueInfo> getAllQueues(); @Override List<org.apache.hadoop.yarn.api.records.QueueInfo> getRootQueueInfos(); @Override List<org.apache.hadoop.yarn.api.records.QueueInfo> getChildQueueInfos(
      String parent); @Override List<QueueUserACLInfo> getQueueAclsInfo(); @Override ApplicationAttemptReport getApplicationAttemptReport(
      ApplicationAttemptId appAttemptId); @Override List<ApplicationAttemptReport> getApplicationAttempts(
      ApplicationId appId); @Override ContainerReport getContainerReport(ContainerId containerId); @Override List<ContainerReport> getContainers(
      ApplicationAttemptId applicationAttemptId); @Override void moveApplicationAcrossQueues(ApplicationId appId, String queue); @Override ReservationSubmissionResponse submitReservation(
      ReservationSubmissionRequest request); @Override ReservationUpdateResponse updateReservation(
      ReservationUpdateRequest request); @Override ReservationDeleteResponse deleteReservation(
      ReservationDeleteRequest request); @Override Map<NodeId, Set<String>> getNodeToLabels(); @Override Set<String> getClusterNodeLabels();  }
@Test public void testGetRootQueues() throws IOException, InterruptedException { final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class); GetQueueInfoResponse response = Mockito.mock(GetQueueInfoResponse.class); org.apache.hadoop.yarn.api.records.QueueInfo queueInfo = Mockito.mock(org.apache.hadoop.yarn.api.records.QueueInfo.class); Mockito.when(response.getQueueInfo()).thenReturn(queueInfo); try { Mockito.when(applicationsManager.getQueueInfo(Mockito.any( GetQueueInfoRequest.class))).thenReturn(response); } catch (YarnException e) { throw new IOException(e); } ResourceMgrDelegate delegate = new ResourceMgrDelegate( new YarnConfiguration()) { @Override protected void serviceStart() throws Exception { Assert.assertTrue(this.client instanceof YarnClientImpl); ((YarnClientImpl) this.client).setRMClient(applicationsManager); } }; delegate.getRootQueues(); ArgumentCaptor<GetQueueInfoRequest> argument = ArgumentCaptor.forClass(GetQueueInfoRequest.class); try { Mockito.verify(applicationsManager).getQueueInfo( argument.capture()); } catch (YarnException e) { throw new IOException(e); } Assert.assertTrue("Children of root queue not requested", argument.getValue().getIncludeChildQueues()); Assert.assertTrue("Request wasn't to recurse through children", argument.getValue().getRecursive()); }