### Question:
FSLeafQueue extends FSQueue { @Override public void updateDemand() { Resource maxRes = scheduler.getAllocationConfiguration() .getMaxResources(getName()); demand = Resources.createResource(0); for (AppSchedulable sched : runnableAppScheds) { if (Resources.equals(demand, maxRes)) { break; } updateDemandForApp(sched, maxRes); } for (AppSchedulable sched : nonRunnableAppScheds) { if (Resources.equals(demand, maxRes)) { break; } updateDemandForApp(sched, maxRes); } if (LOG.isDebugEnabled()) { LOG.debug("The updated demand for " + getName() + " is " + demand + "; the max is " + maxRes); } } FSLeafQueue(String name, FairScheduler scheduler,
      FSParentQueue parent); void addApp(FSSchedulerApp app, boolean runnable); boolean removeApp(FSSchedulerApp app); Collection<AppSchedulable> getRunnableAppSchedulables(); List<AppSchedulable> getNonRunnableAppSchedulables(); @Override void collectSchedulerApplications(
      Collection<ApplicationAttemptId> apps); @Override void setPolicy(SchedulingPolicy policy); @Override void recomputeShares(); @Override Resource getDemand(); @Override Resource getResourceUsage(); @Override void updateDemand(); @Override Resource assignContainer(FSSchedulerNode node); @Override List<FSQueue> getChildQueues(); @Override List<QueueUserACLInfo> getQueueUserAclInfo(UserGroupInformation user); long getLastTimeAtMinShare(); void setLastTimeAtMinShare(long lastTimeAtMinShare); long getLastTimeAtHalfFairShare(); void setLastTimeAtHalfFairShare(long lastTimeAtHalfFairShare); @Override int getNumRunnableApps(); @Override ActiveUsersManager getActiveUsersManager();  }### Answer:
@Test public void testUpdateDemand() { AppSchedulable app = mock(AppSchedulable.class); Mockito.when(app.getDemand()).thenReturn(maxResource); schedulable.addAppSchedulable(app); schedulable.addAppSchedulable(app); schedulable.updateDemand(); assertTrue("Demand is greater than max allowed ", Resources.equals(schedulable.getDemand(), maxResource)); }