PubSub { public void unsubscribeMain(@NonNull Subscriber<T> sub) { synchronized (mainSubs) { if (!mainSubs.remove(sub)) { Log.e(TAG, "Unexpected main listener unsubscribed"); } } }  void post(T obj); void subscribe(@NonNull Subscriber<T> sub); void subscribeMain(@NonNull Subscriber<T> sub); void unsubscribe(@NonNull Subscriber<T> sub); void unsubscribeMain(@NonNull Subscriber<T> sub);  }
@Test public void unsubscribeMain() { final PubSub<String> events = new PubSub<>(); PubSub.Subscriber<String> listener = (msg) -> fail(); events.subscribeMain(listener); events.unsubscribeMain(listener); events.post("BASE"); }