ResetTweetCallback extends Callback<Tweet> { @Override public void failure(TwitterException exception) { if (cb != null) { cb.failure(exception); } } ResetTweetCallback(BaseTweetView baseTweetView, TweetRepository tweetRepository,
                        Callback<Tweet> cb); @Override void success(Result<Tweet> result); @Override void failure(TwitterException exception);  }
@Test public void testFailure() { final Callback<Tweet> developerCallback = mock(Callback.class); final ResetTweetCallback resetCallback = new ResetTweetCallback(mockTweetView, mockTweetRepository, developerCallback); final TwitterException exception = mock(TwitterException.class); resetCallback.failure(exception); verify(developerCallback).failure(exception); }
@Test public void testFailure_handlesNullCallback() { final Callback<Tweet> developerCallback = mock(Callback.class); final ResetTweetCallback resetCallback = new ResetTweetCallback(mockTweetView, mockTweetRepository, null); final TwitterException exception = mock(TwitterException.class); try { resetCallback.failure(exception); } catch (NullPointerException e) { fail("Should have handled null callback"); } }