@Test
public void testUtilizationOrdering() {

  PriorityUtilizationQueueOrderingPolicy policy =
      new PriorityUtilizationQueueOrderingPolicy(false);
  // Case 1, one queue
  policy.setQueues(mockCSQueues(new String[] { "a" }, new int[] { 0 },
      new float[] { 0.1f }, new float[] {0.2f},  ""));
  verifyOrder(policy, "", new String[] { "a" });
  // Case 2, 2 queues
  policy.setQueues(mockCSQueues(new String[] { "a", "b" }, new int[] { 0, 0 },
      new float[] { 0.1f, 0.0f }, new float[] {0.2f, 0.3f}, ""));
  verifyOrder(policy, "", new String[] { "b", "a" });
  // Case 3, 3 queues
  policy.setQueues(
      mockCSQueues(new String[] { "a", "b", "c" }, new int[] { 0, 0, 0 },
          new float[] { 0.1f, 0.0f, 0.2f }, new float[] {0.2f, 0.3f, 0.4f},
          ""));
  verifyOrder(policy, "", new String[] { "b", "a", "c" });
  // Case 4, 3 queues, ignore priority
  policy.setQueues(
      mockCSQueues(new String[] { "a", "b", "c" }, new int[] { 2, 1, 0 },
          new float[] { 0.1f, 0.0f, 0.2f }, new float[] {0.2f, 0.3f, 0.4f},
          ""));
  verifyOrder(policy, "", new String[] { "b", "a", "c" });
  // Case 5, 3 queues, look at partition (default)
  policy.setQueues(
      mockCSQueues(new String[] { "a", "b", "c" }, new int[] { 2, 1, 0 },
          new float[] { 0.1f, 0.0f, 0.2f }, new float[] {0.2f, 0.3f, 0.4f},
          "x"));
  verifyOrder(policy, "", new String[] { "a", "b", "c" });
  // Case 5, 3 queues, look at partition (x)
  policy.setQueues(
      mockCSQueues(new String[] { "a", "b", "c" }, new int[] { 2, 1, 0 },
          new float[] { 0.1f, 0.0f, 0.2f }, new float[] {0.2f, 0.3f, 0.4f},
          "x"));
  verifyOrder(policy, "x", new String[] { "b", "a", "c" });
  // Case 6, 3 queues, with different accessibility to partition
  List<CSQueue> queues = mockCSQueues(new String[] { "a", "b", "c" }, new int[] { 2, 1, 0 },
      new float[] { 0.1f, 0.0f, 0.2f }, new float[] {0.2f, 0.3f, 0.4f},  "x");
  // a can access "x"
  when(queues.get(0).getAccessibleNodeLabels()).thenReturn(ImmutableSet.of("x", "y"));
  // c can access "x"
  when(queues.get(2).getAccessibleNodeLabels()).thenReturn(ImmutableSet.of("x", "y"));
  policy.setQueues(queues);
  verifyOrder(policy, "x", new String[] { "a", "c", "b" });
}