@Test(timeout = 60000) public void testCopy() throws Exception { final MockEventListener listener = new MockEventListener(); Subscription subscription = holderRule.getHolder().subscribe(listener); holderRule.assertListenerAdded(listener); final ListenersHolder<MockEventListener> copy = holderRule.getHolder().copy(); assertThat("Holder not copied", copy, is(not(holderRule.getHolder()))); assertThat("Listeners list not copied", copy.getActualListenersList(), not(sameInstance(holderRule.getHolder().getActualListenersList()))); final Collection<MockEventListener> allListenersCopied = copy.getAllListeners(); assertThat("Registered listeners not copied", allListenersCopied, contains(listener)); subscription.unsubscribe(); assertThat("Not removed from copy on unsubscribe.", copy.getAllListeners(), not(contains(listener))); }
public ListenersHolder<T> copy() { return new ListenersHolder<>(this); }
ListenersHolder implements EventSource<T>, EventPublisher { public ListenersHolder<T> copy() { return new ListenersHolder<>(this); } }
ListenersHolder implements EventSource<T>, EventPublisher { public ListenersHolder<T> copy() { return new ListenersHolder<>(this); } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); }
ListenersHolder implements EventSource<T>, EventPublisher { public ListenersHolder<T> copy() { return new ListenersHolder<>(this); } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); @Override Subscription subscribe(final T listener); @Override boolean publishingEnabled(); void dispose(); void invokeListeners(Action1<T> invocationAction); void invokeListeners(Action3<T, Long, TimeUnit> invocationAction, long duration, TimeUnit timeUnit); void invokeListeners(Action4<T, Long, TimeUnit, Throwable> invocationAction, long duration,
                                TimeUnit timeUnit, Throwable throwable); void invokeListeners(Action4<T, Long, TimeUnit, A> invocationAction, long duration,
                                    TimeUnit timeUnit, A arg); void invokeListeners(Action5<T, Long, TimeUnit, Throwable, A> invocationAction, long duration,
                                    TimeUnit timeUnit, Throwable throwable, A arg); void invokeListeners(Action2<T, A> invocationAction, A arg); void invokeListeners(Action3<T, Throwable, A> invocationAction, Throwable throwable, A arg); ListenersHolder<T> copy(); void subscribeAllTo(EventSource<T> lazySource); }
ListenersHolder implements EventSource<T>, EventPublisher { public ListenersHolder<T> copy() { return new ListenersHolder<>(this); } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); @Override Subscription subscribe(final T listener); @Override boolean publishingEnabled(); void dispose(); void invokeListeners(Action1<T> invocationAction); void invokeListeners(Action3<T, Long, TimeUnit> invocationAction, long duration, TimeUnit timeUnit); void invokeListeners(Action4<T, Long, TimeUnit, Throwable> invocationAction, long duration,
                                TimeUnit timeUnit, Throwable throwable); void invokeListeners(Action4<T, Long, TimeUnit, A> invocationAction, long duration,
                                    TimeUnit timeUnit, A arg); void invokeListeners(Action5<T, Long, TimeUnit, Throwable, A> invocationAction, long duration,
                                    TimeUnit timeUnit, Throwable throwable, A arg); void invokeListeners(Action2<T, A> invocationAction, A arg); void invokeListeners(Action3<T, Throwable, A> invocationAction, Throwable throwable, A arg); ListenersHolder<T> copy(); void subscribeAllTo(EventSource<T> lazySource);  }