@SuppressWarnings("unchecked")
@Test
public void copyOfListenerRegistry() {

    assertNotNull(listenerRegistry);
    Map<String, ListenerRegistry.RegisteredListener<String, String>> listeners = getListeners();
    when(listenerRegistry.getRegisteredListeners()).thenReturn(listeners);
    ListenerRegistry<String, String> copy = ListenerRegistries.copyOf(listenerRegistry, map -> {
        ListenerRegistry<String, String> registry = mock(ListenerRegistry.class);
        when(registry.getRegisteredListeners()).thenReturn(map);
        return registry;
    });
    listeners.clear();
    assertEquals(3, copy.getRegisteredListeners().size());
}