/** Test sorting the list using the comparator. */
 public void testSort() {
   ManagedElementSet<VirtualMachine> elmts = makeDefaultElements();
   VirtualMachineComparator cmp = new VirtualMachineComparator(true, cpuConsumption);
   cmp.appendCriteria(true, nbOfCPUs);
   Collections.sort(elmts, cmp);
   Assert.assertEquals(elmts.get(0).getName(), "VM2");
   Assert.assertEquals(elmts.get(1).getName(), "VM1");
   Assert.assertEquals(elmts.get(2).getName(), "VM3");
   Assert.assertEquals(elmts.get(3).getName(), "VM4");
 }
  /** Test the comparison between non equivalent values. */
  public void testNonEquivalent() {
    ManagedElementSet<VirtualMachine> elmts = makeDefaultElements();
    VirtualMachineComparator cmp = new VirtualMachineComparator(true, cpuConsumption);
    cmp.appendCriteria(true, nbOfCPUs);
    Assert.assertTrue(cmp.compare(elmts.get(0), elmts.get(1)) > 0);

    cmp = new VirtualMachineComparator(false, cpuConsumption);
    cmp.appendCriteria(false, nbOfCPUs);
    Assert.assertTrue(cmp.compare(elmts.get(0), elmts.get(1)) < 0);
  }