@Test
public void testContainerOrdering(){

  List<RMContainer> containers = new ArrayList<RMContainer>();
  ApplicationAttemptId appAttId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(TS, 10), 0);
  // create a set of containers
  RMContainer rm1 = mockContainer(appAttId, 5, mock(Resource.class), 3);
  RMContainer rm2 = mockContainer(appAttId, 3, mock(Resource.class), 3);
  RMContainer rm3 = mockContainer(appAttId, 2, mock(Resource.class), 2);
  RMContainer rm4 = mockContainer(appAttId, 1, mock(Resource.class), 2);
  RMContainer rm5 = mockContainer(appAttId, 4, mock(Resource.class), 1);
  // insert them in non-sorted order
  containers.add(rm3);
  containers.add(rm2);
  containers.add(rm1);
  containers.add(rm5);
  containers.add(rm4);
  // sort them
  ProportionalCapacityPreemptionPolicy.sortContainers(containers);
  // verify the "priority"-first, "reverse container-id"-second
  // ordering is enforced correctly
  assert containers.get(0).equals(rm1);
  assert containers.get(1).equals(rm2);
  assert containers.get(2).equals(rm3);
  assert containers.get(3).equals(rm4);
  assert containers.get(4).equals(rm5);
}