@Test
public void testGetListMapKeyValueMapper()
{

    DataElementGroupSet groupSetA = new DataElementGroupSet( "GroupSetA" );
    DataElementGroupSet groupSetB = new DataElementGroupSet( "GroupSetB" );
    DataElementGroupSet groupSetC = new DataElementGroupSet( "GroupSetC" );
    DataElementGroupSet groupSetZ = new DataElementGroupSet( "GroupSetZ" );
    
    DataElementGroup groupA = new DataElementGroup( "GroupA" );
    DataElementGroup groupB = new DataElementGroup( "GroupB" );
    DataElementGroup groupC = new DataElementGroup( "GroupC" );
    DataElementGroup groupD = new DataElementGroup( "GroupD" );
    DataElementGroup groupE = new DataElementGroup( "GroupE" );
    DataElementGroup groupF = new DataElementGroup( "GroupF" );
    
    groupA.getGroupSets().add( groupSetA );
    groupB.getGroupSets().add( groupSetB );
    groupC.getGroupSets().add( groupSetC );
    groupD.getGroupSets().add( groupSetA );
    groupE.getGroupSets().add( groupSetB );
    groupF.getGroupSets().add( groupSetA );
    
    List<DataElementGroup> groups = Lists.newArrayList( groupA, groupB, groupC, groupD, groupE, groupF );
                    
    ListMap<DataElementGroupSet, Long> map = ListMap.getListMap( groups, group -> group.getGroupSets().iterator().next(), group -> group.getId() );
    
    assertEquals( Lists.newArrayList( groupA.getId(), groupD.getId(), groupF.getId() ), map.get( groupSetA ) );
    assertEquals( Lists.newArrayList( groupB.getId(), groupE.getId() ), map.get( groupSetB ) );
    assertEquals( Lists.newArrayList( groupC.getId() ), map.get( groupSetC ) );
    assertNull( map.get( groupSetZ ) );
}