GroupPartitioner { public List<Partition> getPartitions() { return this.partitions; } GroupPartitioner(final String group, final List<PartitionKey> splitPoints); String getGroup(); int getPartitionId(final PartitionKey partitionKey); List<Integer> getPartitionIds(final Object[] partialKey); PartitionKey getIthPartitionKey(final int i); List<PartitionKey> getSplitPoints(); List<Partition> getPartitions(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode();  }
@Test public void testGetPartitionsEmptyList() { final GroupPartitioner partitioner = new GroupPartitioner("GROUP", new ArrayList<>()); final List<Partition> partitions = partitioner.getPartitions(); assertEquals(1, partitions.size()); assertEquals(new Partition(0, new NegativeInfinityPartitionKey(), new PositiveInfinityPartitionKey()), partitions.get(0)); }
@Test public void testGetPartitions() { final PartitionKey key1 = new PartitionKey(new Object[]{1L, "B"}); final PartitionKey key2 = new PartitionKey(new Object[]{5L, "A"}); final PartitionKey key3 = new PartitionKey(new Object[]{100L, "Z"}); final List<PartitionKey> splitPoints = new ArrayList<>(Arrays.asList(key1, key2, key3)); final GroupPartitioner partitioner = new GroupPartitioner("GROUP", splitPoints); final List<Partition> partitions = partitioner.getPartitions(); assertEquals(4, partitions.size()); assertEquals(new Partition(0, new NegativeInfinityPartitionKey(), key1), partitions.get(0)); assertEquals(new Partition(1, key1, key2), partitions.get(1)); assertEquals(new Partition(2, key2, key3), partitions.get(2)); assertEquals(new Partition(3, key3, new PositiveInfinityPartitionKey()), partitions.get(3)); }