// should unconditionally set requestInFlight to false @Test public void testDefaultCallback_failureCallsFinishTimelineRequest() { delegate = new TimelineDelegate<>(mockTimeline); final TimelineStateHolder mockHolder = mock(TimelineStateHolder.class); final TimelineDelegate.DefaultCallback cb = delegate.new DefaultCallback(null, mockHolder); cb.failure((TwitterException) null); verify(mockHolder).finishTimelineRequest(); }
// should unconditionally set requestInFlight to false @Test public void testDefaultCallback_successCallsFinishTimelineRequest() { delegate = new TimelineDelegate<>(mockTimeline); final TimelineStateHolder mockHolder = mock(TimelineStateHolder.class); final TimelineDelegate.DefaultCallback cb = delegate.new DefaultCallback(null, mockHolder); cb.success(null); verify(mockHolder).finishTimelineRequest(); }
@Test public void testDefaultCallback_failureCallsDeveloperCallback() { final Callback<TimelineResult<TestItem>> developerCb = mock(Callback.class); delegate = new TimelineDelegate<>(mockTimeline); final TimelineDelegate.DefaultCallback cb = delegate.new DefaultCallback(developerCb, delegate.timelineStateHolder); cb.failure(TEST_TWITTER_EXCEPTION); verify(developerCb).failure(TEST_TWITTER_EXCEPTION); }
@Test public void testDefaultCallback_successCallsDeveloperCallback() { final Callback<TimelineResult<TestItem>> developerCb = mock(Callback.class); delegate = new TimelineDelegate<>(mockTimeline); final TimelineDelegate.DefaultCallback cb = delegate.new DefaultCallback(developerCb, delegate.timelineStateHolder); cb.success(testResult); verify(developerCb).success(testResult); }
@Test public void testDefaultCallback_failureHandlesNullDeveloperCallback() { delegate = new TimelineDelegate<>(mockTimeline); final TimelineDelegate.DefaultCallback cb = delegate.new DefaultCallback(null, delegate.timelineStateHolder); try { cb.failure(TEST_TWITTER_EXCEPTION); } catch (NullPointerException e) { fail("Should have handled null callback"); } }
@Test public void testDefaultCallback_successHandlesNullDeveloperCallback() { delegate = new TimelineDelegate<>(mockTimeline); final TimelineDelegate.DefaultCallback cb = delegate.new DefaultCallback(null, delegate.timelineStateHolder); try { cb.success(testResult); } catch (NullPointerException e) { fail("Should have handled null callback"); } }