@Test public void greedyPartitionSameTimes() { Collection<TestTime> testData = generateTests(10); Set<TestContainer> containers = createTestContainers(2); PartitionUtil.greedyPartition(testData, containers); containers.forEach(c -> assertEquals(5, c.getTestTimes().size())); }
public static void greedyPartition(Collection<TestTime> testTimes, Set<TestContainer> testContainers) { if(testContainers.isEmpty()) { throw new IllegalArgumentException("Queue must be populated with a partition for each host"); } List<TestTime> sortedList = testTimes.stream() .sorted(Comparator.comparingLong(TestTime::getTime).reversed()) .collect(Collectors.toList()); PriorityQueue<TestContainer> queues = new PriorityQueue<>(testContainers); greedyPartition(sortedList, queues); }
PartitionUtil { public static void greedyPartition(Collection<TestTime> testTimes, Set<TestContainer> testContainers) { if(testContainers.isEmpty()) { throw new IllegalArgumentException("Queue must be populated with a partition for each host"); } List<TestTime> sortedList = testTimes.stream() .sorted(Comparator.comparingLong(TestTime::getTime).reversed()) .collect(Collectors.toList()); PriorityQueue<TestContainer> queues = new PriorityQueue<>(testContainers); greedyPartition(sortedList, queues); } }
PartitionUtil { public static void greedyPartition(Collection<TestTime> testTimes, Set<TestContainer> testContainers) { if(testContainers.isEmpty()) { throw new IllegalArgumentException("Queue must be populated with a partition for each host"); } List<TestTime> sortedList = testTimes.stream() .sorted(Comparator.comparingLong(TestTime::getTime).reversed()) .collect(Collectors.toList()); PriorityQueue<TestContainer> queues = new PriorityQueue<>(testContainers); greedyPartition(sortedList, queues); }  }
PartitionUtil { public static void greedyPartition(Collection<TestTime> testTimes, Set<TestContainer> testContainers) { if(testContainers.isEmpty()) { throw new IllegalArgumentException("Queue must be populated with a partition for each host"); } List<TestTime> sortedList = testTimes.stream() .sorted(Comparator.comparingLong(TestTime::getTime).reversed()) .collect(Collectors.toList()); PriorityQueue<TestContainer> queues = new PriorityQueue<>(testContainers); greedyPartition(sortedList, queues); }  static void greedyPartitionFailuresOnSameHost(Collection<TestTime> testTimes, Set<TestContainer> testContainers); static void greedyPartition(Collection<TestTime> testTimes, Set<TestContainer> testContainers); }
PartitionUtil { public static void greedyPartition(Collection<TestTime> testTimes, Set<TestContainer> testContainers) { if(testContainers.isEmpty()) { throw new IllegalArgumentException("Queue must be populated with a partition for each host"); } List<TestTime> sortedList = testTimes.stream() .sorted(Comparator.comparingLong(TestTime::getTime).reversed()) .collect(Collectors.toList()); PriorityQueue<TestContainer> queues = new PriorityQueue<>(testContainers); greedyPartition(sortedList, queues); }  static void greedyPartitionFailuresOnSameHost(Collection<TestTime> testTimes, Set<TestContainer> testContainers); static void greedyPartition(Collection<TestTime> testTimes, Set<TestContainer> testContainers);  }