@Test
public void testIterators() {

  OrderingPolicy<MockSchedulableEntity> schedOrder =
   new FairOrderingPolicy<MockSchedulableEntity>();
  MockSchedulableEntity msp1 = new MockSchedulableEntity();
  MockSchedulableEntity msp2 = new MockSchedulableEntity();
  MockSchedulableEntity msp3 = new MockSchedulableEntity();
  msp1.setId("1");
  msp2.setId("2");
  msp3.setId("3");
  msp1.setUsed(Resources.createResource(3));
  msp2.setUsed(Resources.createResource(2));
  msp3.setUsed(Resources.createResource(1));
  AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage(
    msp1.getSchedulingResourceUsage());
  AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage(
    msp2.getSchedulingResourceUsage());
  AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage(
    msp2.getSchedulingResourceUsage());
  schedOrder.addSchedulableEntity(msp1);
  schedOrder.addSchedulableEntity(msp2);
  schedOrder.addSchedulableEntity(msp3);
  //Assignment, least to greatest consumption
  checkIds(schedOrder.getAssignmentIterator(
      IteratorSelector.EMPTY_ITERATOR_SELECTOR),
      new String[]{"3", "2", "1"});
  //Preemption, greatest to least
  checkIds(schedOrder.getPreemptionIterator(), new String[]{"1", "2", "3"});
  //Change value without inform, should see no change
  msp2.setUsed(Resources.createResource(6));
  checkIds(schedOrder.getAssignmentIterator(
      IteratorSelector.EMPTY_ITERATOR_SELECTOR),
      new String[]{"3", "2", "1"});
  checkIds(schedOrder.getPreemptionIterator(), new String[]{"1", "2", "3"});
  //Do inform, will reorder
  schedOrder.containerAllocated(msp2, null);
  checkIds(schedOrder.getAssignmentIterator(
      IteratorSelector.EMPTY_ITERATOR_SELECTOR),
      new String[]{"3", "1", "2"});
  checkIds(schedOrder.getPreemptionIterator(), new String[]{"2", "1", "3"});
}