title: android testing - mockito error org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
body: <p>I try to create test for my presenter, but when I run it, I got this kind of error</p>
  
  <pre><code>org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
  ScalarSynchronousObservable cannot be returned by getContext()
  getContext() should return Context
  </code></pre>
  
  <p>I create my presenter test class like this</p>
  
  <pre><code>public class CreateTalkPresenterTest {
  
      @Mock
      TalkService talkService;
  
      @Mock
      CreateTalkMvpView createTalkMvpView;
  
      CreateTalkPresenter createTalkPresenter;
  
      @Before
      public void setUp() throws Exception {
          MockitoAnnotations.initMocks(this);
          talkService = ServiceFactory.createMapi(createTalkMvpView.getContext(), TalkService.class);
          createTalkPresenter = new CreateTalkPresenter(Schedulers.immediate(), Schedulers.immediate());
          createTalkPresenter.attachView(createTalkMvpView);
      }
  
      @Test
      public void createTalkSuccessfullTest() {
          TalkService.TalkResultModel talkResultModel = MockModel.newTalkResultModel();
  
          when(talkService.createNewTalk(
                  FileUtil.createPartFromString("Lorem Ipsum dolor"),
                  FileUtil.createPartFromString("100"),
                  null,
                  FileUtil.createPartFromString("0")
          )).thenReturn(Observable.just(talkResultModel));
  
          createTalkPresenter.callCreateTalk("Lorem Ipsum dolor", "100", null);
  
          verify(createTalkMvpView).showProgressIndeterminate();
          verify(createTalkMvpView).hideProgressIndeterminate();
          verify(createTalkMvpView).showTalkCreated(talkResultModel.object);
      }
  }
  </code></pre>
  
  <p>and for Mock the result I use this class</p>
  
  <pre><code>public class MockModel {
  
      public static TalkService.TalkResultModel newTalkResultModel(){
          TalkService.TalkResultModel talkResultModel = new TalkService.TalkResultModel();
          talkResultModel.code = 600;
          talkResultModel.message = "Successfully executed!";
          talkResultModel.object = newTalkModel();
  
          return talkResultModel;
      }
  
      public static TalkModel newTalkModel(){
          Random random = new Random();
          String index = String.valueOf(random.nextInt(100));
          TalkModel talkModel = new TalkModel();
          talkModel.id = index;
          talkModel.content = "Lorem Ipsum dolor";
          talkModel.categorytalk = newCategoryTalkModel("Category "+index);
          talkModel.creator = newConsumerModel("User "+index);
          return talkModel;
      }
  
      public static CategoryTalkModel newCategoryTalkModel(String name){
          CategoryTalkModel categoryTalkModel = new CategoryTalkModel();
          categoryTalkModel.id = "100";
          categoryTalkModel.name = name;
          return categoryTalkModel;
      }
  
      public static ConsumerModel newConsumerModel(String name){
          Random random = new Random();
          String index = String.valueOf(random.nextInt(100));
          ConsumerModel consumerModel = new ConsumerModel();
          consumerModel.id = index;
          consumerModel.username = name;
          consumerModel.email = name+"@domain.com";
          consumerModel.fullName = "Fullname "+name;
          return consumerModel;
      }
  }
  </code></pre>
  
  <p>And this is the presenter class that I want to test</p>
  
  <pre><code>public class CreateTalkPresenter implements Presenter&lt;CreateTalkMvpView&gt; {
  
      private CreateTalkMvpView createTalkMvpView;
      private TalkService mApiTalkService;
      private TalkService.TalkResultModel talkResultModel;
      private final Scheduler mainScheduler, ioScheduler;
  
      private Subscription subscription;
  
      public CreateTalkPresenter(Scheduler ioScheduler, Scheduler mainScheduler) {
          this.ioScheduler = ioScheduler;
          this.mainScheduler = mainScheduler;
      }
  
      @Override
      public void attachView(CreateTalkMvpView view) {
          createTalkMvpView = view;
      }
  
      @Override
      public void detachView() {
          createTalkMvpView = null;
          unsubscribe();
      }
  
      private void unsubscribe() {
          if (subscription != null) subscription.unsubscribe();
      }
  
      public void callCreateTalk(String content, String categoryId, String filePath) {
          mApiTalkService = ServiceFactory.createMapi(createTalkMvpView.getContext(), TalkService.class);
  
          unsubscribe();
          createTalkMvpView.showProgressIndeterminate();
          subscription = mApiTalkService.createNewTalk(
                  FileUtil.createPartFromString(content),
                  FileUtil.createPartFromString(categoryId),
                  filePath != null ? FileUtil.prepareFilePart("picture", new File(filePath)) : null,
                  FileUtil.createPartFromString("0"))
                  .observeOn(mainScheduler)
                  .subscribeOn(ioScheduler)
                  .subscribe(new Subscriber&lt;TalkService.TalkResultModel&gt;() {
                      @Override
                      public void onCompleted() {
                          createTalkMvpView.hideProgressIndeterminate();
                          createTalkMvpView.showTalkCreated(talkResultModel.object);
                      }
  
                      @Override
                      public void onError(Throwable e) {
                          createTalkMvpView.hideProgressIndeterminate();
                          WarningUtil.onApiError(createTalkMvpView.getContext(), 0, e.getMessage());
                      }
  
                      @Override
                      public void onNext(TalkService.TalkResultModel talkResultModel) {
                          CreateTalkPresenter.this.talkResultModel = talkResultModel;
                      }
                  });
  
      }
  }
  </code></pre>
  
  <p>I'm using retrofit 2.1.0 and rx android in this case.
  So if someone have any idea, what I'm doing wrong in my code. Please help me</p>
  
  <p>Thanks.</p>