BucketMessageGroups implements MessageGroups<C> { @Override public C get(SimpleString key) { if (buckets == null) { return null; } return buckets[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 testGet() { MessageGroups<String> messageGroups = new BucketMessageGroups<>(2); assertNull(messageGroups.get(toGroupBucketIntKey(1))); messageGroups.put(toGroupBucketIntKey(1), "world"); assertEquals("world", messageGroups.get(toGroupBucketIntKey(1))); messageGroups.put(toGroupBucketIntKey(2), "world2"); assertEquals("world2", messageGroups.get(toGroupBucketIntKey(2))); messageGroups.put(toGroupBucketIntKey(3), "world3"); assertEquals("world3", messageGroups.get(toGroupBucketIntKey(3))); assertEquals("world3", messageGroups.get(toGroupBucketIntKey(1))); assertEquals("world3", messageGroups.get(toGroupBucketIntKey(-1))); assertEquals("world2", messageGroups.get(toGroupBucketIntKey(-2))); }