title: Mockito thenReturn not working as expected
body: <p>I'm having problem with mockito. I'm mocking a class and then using <code>thenReturn()</code> on on of its method. but seems like something is going wrong. here is the code.</p>
  
  <p>TestCode:</p>
  
  <pre><code> public void getCardsTest() {
      FeatureFragmentPresenterImpl presenter = new FeatureFragmentPresenterImpl();
      GroupFeatureData data = Mockito.mock(GroupFeatureData.class);
  
      FeatureFragmentView view = Mockito.mock(FeatureFragmentView.class);
  
      presenter.init(view, data);
      Observable&lt;Response&lt;ResponseBody&gt;&gt; errorObservable = Observable.error(new IOException());
      assertNotNull(observable);
      Mockito.when(data.getCards(Mockito.anyString(), Mockito.anyString(),
              Mockito.anyInt(), Mockito.anyInt())).
              thenReturn(errorObservable);
  
      presenter.getAllCards(new Contact(new Name("ssd")), -1);     
  }
  </code></pre>
  
  <p>Presenter code :</p>
  
  <pre><code>public void getAllCards(IContact iContact, int lastIndex) {
  
      Observable&lt;Response&lt;ResponseBody&gt;&gt; allCardsResponseObservable = mGroupFeatureData.getCards(path, id, 10, lastIndex);
      allCardsResponseObservable
              .subscribeOn(Schedulers.io()) -------&gt; Test Failing because NPE here
              .observeOn(AndroidSchedulers.mainThread())
              .subscribe(new DisposableObserver&lt;Response&lt;ResponseBody&gt;&gt;() {
                  @Override
                  public void onNext(@NonNull Response&lt;ResponseBody&gt; response) {
  
                  }
  
                  @Override
                  public void onError(@NonNull Throwable e) {
  
                  }
  
                  @Override
                  public void onComplete() {
  
              });
  }
  
    public void init(FeatureFragmentView featureFragmentView,
                    GroupFeatureData groupFeatureData) {
      this.mGroupFeatureData = groupFeatureData;
      this.mFeatureFragmentView = featureFragmentView;
  }
  </code></pre>
  
  <p>Even though i'm mocking response of <code>data.getCards()</code> in Test, In presenter it is throwing NPE whereas it should just operate on mocked Observable that is <code>errorObservable</code>. what is going wrong here?</p>