@Test public void testLoadNext() { delegate = new TimelineDelegate<>(mockTimeline); final Callback<TimelineResult<TestItem>> testCb = delegate.new NextCallback(null, delegate.timelineStateHolder); delegate.loadNext(TEST_MIN_POSITION, testCb); verify(mockTimeline).next(TEST_MIN_POSITION, testCb); }
@Test public void testLoadNext_respectsRequestInFlight() { delegate = new TimelineDelegate<>(mockTimeline); delegate.timelineStateHolder.startTimelineRequest(); final Callback<TimelineResult<TestItem>> mockCallback = mock(Callback.class); delegate.loadNext(ANY_POSITION, mockCallback); final ArgumentCaptor<TwitterException> exceptionCaptor = ArgumentCaptor.forClass(TwitterException.class); verifyZeroInteractions(mockTimeline); verify(mockCallback).failure(exceptionCaptor.capture()); assertEquals(exceptionCaptor.getValue().getMessage(), REQUIRED_REQUEST_IN_FLIGHT_ERROR); }
@Test public void testLoadNext_respectsMaxCapacity() { delegate = new TimelineDelegate<>(mockTimeline); TestItem.populateList(delegate.itemList, TimelineDelegate.CAPACITY); final Callback<TimelineResult<TestItem>> mockCallback = mock(Callback.class); delegate.loadNext(ANY_POSITION, mockCallback); final ArgumentCaptor<TwitterException> exceptionCaptor = ArgumentCaptor.forClass(TwitterException.class); verifyZeroInteractions(mockTimeline); verify(mockCallback).failure(exceptionCaptor.capture()); assertEquals(exceptionCaptor.getValue().getMessage(), REQUIRED_MAX_CAPACITY_ERROR); }