MoPubEvents { @VisibleForTesting static EventDispatcher getDispatcher() { EventDispatcher result = sEventDispatcher; if (result == null) { synchronized (MoPubEvents.class) { result = sEventDispatcher; if (result == null) { ArrayList<EventRecorder> recorders = new ArrayList<EventRecorder>(); HandlerThread handlerThread = new HandlerThread("mopub_event_logging"); handlerThread.start(); recorders.add(new ScribeEventRecorder(handlerThread.getLooper())); result = sEventDispatcher = new EventDispatcher(recorders, handlerThread.getLooper()); } } } return result; }  static void log(BaseEvent baseEvent); @VisibleForTesting static void setEventDispatcher(EventDispatcher dispatcher);  }
@Test public void getDispatcher_shouldReturnSingletonEventDispatcherWithScribeEventRecorder() throws Exception { EventDispatcher eventDispatcher = MoPubEvents.getDispatcher(); EventDispatcher eventDispatcher2 = MoPubEvents.getDispatcher(); assertThat(eventDispatcher).isEqualTo(eventDispatcher2); Iterable<EventRecorder> eventRecorderIterable = eventDispatcher.getEventRecorders(); ArrayList<EventRecorder> eventRecorders = new ArrayList<EventRecorder>(); for (EventRecorder recorder : eventRecorderIterable) { eventRecorders.add(recorder); } assertThat(eventRecorders.size()).isEqualTo(1); assertThat(eventRecorders.get(0)).isInstanceOf(ScribeEventRecorder.class); }