@Test
public void testUpdateDemand() {

  conf.set(FairSchedulerConfiguration.ASSIGN_MULTIPLE, "false");
  resourceManager = new MockRM(conf);
  resourceManager.start();
  scheduler = (FairScheduler) resourceManager.getResourceScheduler();
  String queueName = "root.queue1";
  FSLeafQueue schedulable = new FSLeafQueue(queueName, scheduler, null);
  schedulable.setMaxShare(new ConfigurableResource(maxResource));
  assertThat(schedulable.getMetrics().getMaxApps()).
      isEqualTo(Integer.MAX_VALUE);
  assertThat(schedulable.getMetrics().getSchedulingPolicy()).isEqualTo(
      SchedulingPolicy.DEFAULT_POLICY.getName());
  FSAppAttempt app = mock(FSAppAttempt.class);
  Mockito.when(app.getDemand()).thenReturn(maxResource);
  Mockito.when(app.getResourceUsage()).thenReturn(Resources.none());
  schedulable.addApp(app, true);
  schedulable.addApp(app, true);
  schedulable.updateDemand();
  assertTrue("Demand is greater than max allowed ",
      Resources.equals(schedulable.getDemand(), maxResource));
}