@Test
public void newImmutableListener() {

    MutableClass id = new MutableClass("id");
    MutableClass listener = new MutableClass("listener");
    ListenerRegistry.RegisteredListener<MutableClass, MutableClass> registeredListener =
            ListenerRegistries.newImmutableRegisteredListener(id, listener, new ListenerRegistries.ImmutableListenerProvider<MutableClass, MutableClass>() {
                @Override
                public MutableClass toImmutableIdentifier(MutableClass mutableClass) {
                    return new MutableClass(mutableClass.a);
                }
                @Override
                public MutableClass toImmutableListener(MutableClass mutableClass) {
                    return new MutableClass(mutableClass.a);
                }
            });
    assertEquals("id", registeredListener.getIdentifier().a);
    assertEquals("listener", registeredListener.getListener().a);
    id.a = "changed";
    listener.a = "changed";
    assertEquals("id", registeredListener.getIdentifier().a);
    assertEquals("listener", registeredListener.getListener().a);
}