GraphPartitioner { public void addGroupPartitioner(final String group, final GroupPartitioner groupPartitioner) { if (groupToPartitioner.containsKey(group)) { throw new IllegalArgumentException("Cannot overwrite the groupPartitioner of a group that already exists in groupToPartitioner (group was " + group + ")"); } groupToPartitioner.put(group, groupPartitioner); } GraphPartitioner(); void addGroupPartitioner(final String group, final GroupPartitioner groupPartitioner); void addGroupPartitionerForReversedEdges(final String group, final GroupPartitioner groupPartitioner); GroupPartitioner getGroupPartitioner(final String group); GroupPartitioner getGroupPartitionerForReversedEdges(final String group); Set<String> getGroups(); Set<String> getGroupsForReversedEdges(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode();  }
@Test public void testCannotOverwriteExistingGroupPartitioner() { final String group = "GROUP1"; 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> splitPoints1 = new ArrayList<>(Arrays.asList(key1, key2, key3)); final GroupPartitioner partitioner1 = new GroupPartitioner(group, splitPoints1); final GraphPartitioner graphPartitioner = new GraphPartitioner(); graphPartitioner.addGroupPartitioner(group, partitioner1); final PartitionKey key4 = new PartitionKey(new Object[]{"A", "C", 1000L}); final PartitionKey key5 = new PartitionKey(new Object[]{"A", "Z", 1L}); final PartitionKey key6 = new PartitionKey(new Object[]{"T", "B", 500L}); final List<PartitionKey> splitPoints2 = new ArrayList<>(Arrays.asList(key4, key5, key6)); final GroupPartitioner partitioner2 = new GroupPartitioner(group, splitPoints2); try { graphPartitioner.addGroupPartitioner(group, partitioner2); } catch (final IllegalArgumentException e) { return; } fail("IllegalArgumentException should have been thrown"); }