@Test
public void testToMap() {

   MessageGroups<String> messageGroups = new BucketMessageGroups<>(2);
   messageGroups.put(toGroupBucketIntKey(1), "world");
   assertEquals(1, messageGroups.toMap().size());
   messageGroups.put(toGroupBucketIntKey(2), "world2");
   assertEquals(2, messageGroups.toMap().size());
   Collection<String> values = messageGroups.toMap().values();
   assertTrue(values.contains("world"));
   assertTrue(values.contains("world2"));
   messageGroups.put(toGroupBucketIntKey(3), "world3");
   messageGroups.put(toGroupBucketIntKey(4), "world4");
   values = messageGroups.toMap().values();
   assertFalse(values.contains("world"));
   assertFalse(values.contains("world2"));
   assertTrue(values.contains("world3"));
   assertTrue(values.contains("world4"));
}