ScribeEventRecorder implements EventRecorder { @VisibleForTesting void scheduleNextPoll() { if (mPollHandler.hasMessages(0) || mEventQueue.isEmpty()) { return; } mPollHandler.postDelayed(mPollingRunnable, POLLING_PERIOD_MS); } ScribeEventRecorder(@NonNull Looper looper); @VisibleForTesting  ScribeEventRecorder(@NonNull EventSampler eventSampler,
            @NonNull Queue<BaseEvent> eventQueue,
            @NonNull EventSerializer eventSerializer,
            @NonNull ScribeRequestManager scribeRequestManager,
            @NonNull Handler handler); @Override void record(@NonNull BaseEvent baseEvent);  }
@Test public void scheduleNextPoll_shouldPostDelayedPollingRunnable() throws Exception { when(mockHandler.hasMessages(0)).thenReturn(false); when(mockQueue.isEmpty()).thenReturn(false); subject.scheduleNextPoll(); verify(mockHandler).postDelayed(any(ScribeEventRecorder.PollingRunnable.class), eq(Long.valueOf(120000))); }
@Test public void scheduleNextPoll_withPollScheduled_shouldNotPostDelayedPollingRunnable() throws Exception { when(mockHandler.hasMessages(0)).thenReturn(true); when(mockQueue.isEmpty()).thenReturn(false); subject.scheduleNextPoll(); verify(mockHandler, never()).postDelayed(any(ScribeEventRecorder.PollingRunnable.class), anyLong()); }
@Test public void scheduleNextPoll_withEmptyRequestQueue_shouldNotPostDelayedPollingRunnable() throws Exception { when(mockHandler.hasMessages(0)).thenReturn(false); when(mockQueue.isEmpty()).thenReturn(true); subject.scheduleNextPoll(); verify(mockHandler, never()).postDelayed(any(ScribeEventRecorder.PollingRunnable.class), anyLong()); }