protected FairSchedulerQueueInfoList getChildQueues(FSQueue queue,
                                                      FairScheduler scheduler) {
    // Return null to omit 'childQueues' field from the return value of
    // REST API if it is empty. We omit the field to keep the consistency
    // with CapacitySchedulerQueueInfo, which omits 'queues' field if empty.
    Collection<FSQueue> children = queue.getChildQueues();
    if (children.isEmpty()) {
      return null;
    }
    FairSchedulerQueueInfoList list = new FairSchedulerQueueInfoList();
    for (FSQueue child : children) {
      if (child instanceof FSLeafQueue) {
        list.addToQueueInfoList(
            new FairSchedulerLeafQueueInfo((FSLeafQueue) child, scheduler));
      } else {
        list.addToQueueInfoList(
            new FairSchedulerQueueInfo(child, scheduler));
      }
    }
    return list;
  }
@Test
  public void testEmptyChildQueues() {
    FairSchedulerConfiguration fsConf = new FairSchedulerConfiguration();
    RMContext rmContext = mock(RMContext.class);
    PlacementManager placementManager = new PlacementManager();
    SystemClock clock = SystemClock.getInstance();
    FairScheduler scheduler = mock(FairScheduler.class);
    when(scheduler.getConf()).thenReturn(fsConf);
    when(scheduler.getConfig()).thenReturn(fsConf);
    when(scheduler.getRMContext()).thenReturn(rmContext);
    when(rmContext.getQueuePlacementManager()).thenReturn(placementManager);
    when(scheduler.getClusterResource()).thenReturn(
        Resource.newInstance(1, 1));
    when(scheduler.getResourceCalculator()).thenReturn(
        new DefaultResourceCalculator());
    when(scheduler.getClock()).thenReturn(clock);
    AllocationConfiguration allocConf = new AllocationConfiguration(scheduler);
    when(scheduler.getAllocationConfiguration()).thenReturn(allocConf);
    QueueManager queueManager = new QueueManager(scheduler);
    queueManager.initialize();

    FSQueue testQueue = queueManager.getLeafQueue("test", true);
    FairSchedulerQueueInfo queueInfo =
        new FairSchedulerQueueInfo(testQueue, scheduler);
    Collection<FairSchedulerQueueInfo> childQueues =
        queueInfo.getChildQueues();
    Assert.assertNotNull(childQueues);
    Assert.assertEquals("Child QueueInfo was not empty", 0, childQueues.size());
  }