@Test
public void groupBy()
{

    FastList<String> source = FastList.newListWith("Ted", "Sally", "Mary", "Bob", "Sara");
    Multimap<Character, String> result1 = FJIterate.groupBy(source, StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result2 = FJIterate.groupBy(Collections.synchronizedList(source), StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result3 = FJIterate.groupBy(Collections.synchronizedCollection(source), StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result4 = FJIterate.groupBy(LazyIterate.adapt(source), StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result5 = FJIterate.groupBy(new ArrayList<>(source), StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result6 = FJIterate.groupBy(source.toSet(), StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result7 = FJIterate.groupBy(source.toMap(Functions.getStringPassThru(), Functions.getStringPassThru()), StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result8 = FJIterate.groupBy(source.toBag(), StringFunctions.firstLetter(), 1);
    Multimap<Character, String> result9 = FJIterate.groupBy(source.toImmutable(), StringFunctions.firstLetter(), 1);
    MutableMultimap<Character, String> expected = HashBagMultimap.newMultimap();
    expected.put('T', "Ted");
    expected.put('S', "Sally");
    expected.put('M', "Mary");
    expected.put('B', "Bob");
    expected.put('S', "Sara");
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result1));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result2));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result3));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result4));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result5));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result6));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result7));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result8));
    Assert.assertEquals(expected, HashBagMultimap.newMultimap(result9));
    Verify.assertThrows(IllegalArgumentException.class, new Runnable()
    {
        public void run()
        {
            FJIterate.groupBy(null, null, 1);
        }
    });
}