@VisibleForTesting
  public void setSizeBasedWeight(boolean sizeBasedWeight) {
   this.sizeBasedWeight = sizeBasedWeight;
  }
@Test
  public void testRemoveEntitiesWithSizeBasedWeightAsCompletedJobs() {
    FairOrderingPolicy<MockSchedulableEntity> policy =
        new FairOrderingPolicy<MockSchedulableEntity>();
    policy.setSizeBasedWeight(true);

    // Add 10 different schedulable entities
    List<MockSchedulableEntity> entities = new ArrayList<>(10);
    for (int i = 1; i <= 10; i++) {
      MockSchedulableEntity r = new MockSchedulableEntity();
      r.setApplicationPriority(Priority.newInstance(i));
      r.setUsed(Resources.createResource(4 * i));
      r.setPending(Resources.createResource(4 * i));
      AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage(
          r.getSchedulingResourceUsage());
      policy.addSchedulableEntity(r);
      entities.add(r);
    }

    // Mark the first 5 entities as completed by setting
    // the resources to 0
    for (int i = 0; i < 5; i++) {
      MockSchedulableEntity r = entities.get(i);
      r.getSchedulingResourceUsage().setCachedUsed(
          CommonNodeLabelsManager.ANY, Resources.createResource(0));
      r.getSchedulingResourceUsage().setCachedPending(
          CommonNodeLabelsManager.ANY, Resources.createResource(0));
      policy.entityRequiresReordering(r);
    }

    policy.reorderScheduleEntities();

    // Remove the first 5 elements
    for (int i = 0; i < 5; i++) {
      policy.removeSchedulableEntity(entities.get(i));
    }

    Assert.assertEquals(5, policy.getNumSchedulableEntities());
  }