@Test
void putEvents() {

    //keyA has a docRef for both services
    Mockito.when(internalStatisticsConfig.getEnabledDocRefs(Mockito.eq(STAT_KEY_A)))
            .thenReturn(Arrays.asList(DOC_REF_A1, DOC_REF_A2));
    assertThat(internalStatisticsConfig.getEnabledDocRefs(STAT_KEY_A))
            .containsExactly(DOC_REF_A1, DOC_REF_A2);
    //keyB only has a docref for service1
    Mockito.when(internalStatisticsConfig.getEnabledDocRefs(Mockito.eq(STAT_KEY_B)))
            .thenReturn(Arrays.asList(DOC_REF_B1));
    assertThat(internalStatisticsConfig.getEnabledDocRefs(STAT_KEY_B))
            .containsExactly(DOC_REF_B1);
    //service1 supports docRefType1, etc.
    Map<String, InternalStatisticsService> docRefTypeToServiceMap = ImmutableMap.of(
            DOC_REF_TYPE_1, internalStatisticsService1, //i.e. docRefA1 and B1
            DOC_REF_TYPE_2, internalStatisticsService2); //i.e. docRefA2
    MultiServiceInternalStatisticsReceiver facade = new MultiServiceInternalStatisticsReceiver(
            docRefTypeToServiceMap,
            internalStatisticsConfig);
    //fire 6 events at the facade, 3 for each key
    facade.putEvents(Arrays.asList(
            EVENT_A601,
            EVENT_A602,
            EVENT_A603,
            EVENT_B701,
            EVENT_B702,
            EVENT_B703));
    Mockito.verify(internalStatisticsService1, Mockito.times(1))
            .putEvents(argCaptor1.capture());
    assertThat(argCaptor1.getValue().keySet())
            .containsExactlyInAnyOrder(DOC_REF_A1, DOC_REF_B1);
    assertThat(argCaptor1.getValue().get(DOC_REF_A1))
            .containsExactly(EVENT_A601, EVENT_A602, EVENT_A603);
    assertThat(argCaptor1.getValue().get(DOC_REF_B1))
            .containsExactly(EVENT_B701, EVENT_B702, EVENT_B703);
    Mockito.verify(internalStatisticsService2, Mockito.times(1))
            .putEvents(argCaptor2.capture());
    assertThat(argCaptor2.getValue().keySet())
            .containsExactly(DOC_REF_A2);
    assertThat(argCaptor2.getValue().get(DOC_REF_A2))
            .containsExactly(EVENT_A601, EVENT_A602, EVENT_A603);
}