BucketMessageGroups implements MessageGroups<C> { @Override public C remove(SimpleString key) { if (buckets == null) { return null; } return remove(getBucket(key)); } BucketMessageGroups(int bucketCount); @Override void put(SimpleString key, C consumer); @Override C get(SimpleString key); @Override C remove(SimpleString key); @Override boolean removeIf(Predicate<? super C> filter); @Override void removeAll(); @Override int size(); @Override Map<SimpleString, C> toMap();  }
@Test public void testRemove() { MessageGroups<String> messageGroups = new BucketMessageGroups<>(2); assertNull(messageGroups.remove(toGroupBucketIntKey(1))); messageGroups.put(toGroupBucketIntKey(1), "world"); assertEquals("world", messageGroups.remove(toGroupBucketIntKey(1))); assertNull(messageGroups.remove(toGroupBucketIntKey(1))); messageGroups.put(toGroupBucketIntKey(1), "world1"); messageGroups.put(toGroupBucketIntKey(2), "world2"); messageGroups.put(toGroupBucketIntKey(3), "world3"); messageGroups.put(toGroupBucketIntKey(4), "world4"); messageGroups.put(toGroupBucketIntKey(5), "world5"); assertEquals(2, messageGroups.size()); assertEquals("world5", messageGroups.remove(toGroupBucketIntKey(3))); assertNull(messageGroups.remove(toGroupBucketIntKey(5))); assertEquals(1, messageGroups.size()); assertEquals("world4", messageGroups.remove(toGroupBucketIntKey(4))); assertEquals(0, messageGroups.size()); }