@Test public void sendEvents_withRequestInFlightShouldReturnFast() throws Exception { when(mockScribeRequestManager.isAtCapacity()).thenReturn(true); subject.sendEvents(); verify(mockQueue, never()).poll(); verify(mockScribeRequestManager, never()).makeRequest(any(ScribeRequest.ScribeRequestFactory.class), any(ScribeBackoffPolicy.class)); }
@VisibleForTesting void sendEvents() { if (mScribeRequestManager.isAtCapacity()) { return; } final List<BaseEvent> events = dequeueEvents(); if (events.isEmpty()) { return; } mScribeRequestManager.makeRequest( new ScribeRequest.ScribeRequestFactory() { @Override public ScribeRequest createRequest(ScribeRequest.Listener listener) { return new ScribeRequest(SCRIBE_URL, events, mEventSerializer, listener); } }, new ScribeBackoffPolicy() ); }
ScribeEventRecorder implements EventRecorder { @VisibleForTesting void sendEvents() { if (mScribeRequestManager.isAtCapacity()) { return; } final List<BaseEvent> events = dequeueEvents(); if (events.isEmpty()) { return; } mScribeRequestManager.makeRequest( new ScribeRequest.ScribeRequestFactory() { @Override public ScribeRequest createRequest(ScribeRequest.Listener listener) { return new ScribeRequest(SCRIBE_URL, events, mEventSerializer, listener); } }, new ScribeBackoffPolicy() ); } }
ScribeEventRecorder implements EventRecorder { @VisibleForTesting void sendEvents() { if (mScribeRequestManager.isAtCapacity()) { return; } final List<BaseEvent> events = dequeueEvents(); if (events.isEmpty()) { return; } mScribeRequestManager.makeRequest( new ScribeRequest.ScribeRequestFactory() { @Override public ScribeRequest createRequest(ScribeRequest.Listener listener) { return new ScribeRequest(SCRIBE_URL, events, mEventSerializer, listener); } }, new ScribeBackoffPolicy() ); } ScribeEventRecorder(@NonNull Looper looper); @VisibleForTesting  ScribeEventRecorder(@NonNull EventSampler eventSampler,
            @NonNull Queue<BaseEvent> eventQueue,
            @NonNull EventSerializer eventSerializer,
            @NonNull ScribeRequestManager scribeRequestManager,
            @NonNull Handler handler); }
ScribeEventRecorder implements EventRecorder { @VisibleForTesting void sendEvents() { if (mScribeRequestManager.isAtCapacity()) { return; } final List<BaseEvent> events = dequeueEvents(); if (events.isEmpty()) { return; } mScribeRequestManager.makeRequest( new ScribeRequest.ScribeRequestFactory() { @Override public ScribeRequest createRequest(ScribeRequest.Listener listener) { return new ScribeRequest(SCRIBE_URL, events, mEventSerializer, listener); } }, new ScribeBackoffPolicy() ); } 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); }
ScribeEventRecorder implements EventRecorder { @VisibleForTesting void sendEvents() { if (mScribeRequestManager.isAtCapacity()) { return; } final List<BaseEvent> events = dequeueEvents(); if (events.isEmpty()) { return; } mScribeRequestManager.makeRequest( new ScribeRequest.ScribeRequestFactory() { @Override public ScribeRequest createRequest(ScribeRequest.Listener listener) { return new ScribeRequest(SCRIBE_URL, events, mEventSerializer, listener); } }, new ScribeBackoffPolicy() ); } 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);  }