title: Local unit test while using Call<T> object in Retrofit
body: <p>I have following unitTest :</p>
  
  <pre><code>@Test
      fun loadMovieTrailer() {
          val video = Video("id", "name", "site",
                  "videoId", 20, "type")
  
          val observableResponse =
                  Observable.just(MovieApi.VideoWrapper(Lists.newArrayList(video)))
          `when`(movieApi.trailers(anyString())).thenReturn(observableResponse)
  
  
          with(viewModel) {
              assertFalse(isTrailersVisible.get())
  
              showTrailers(movie)
  
              assertTrue(isTrailersVisible.get())
              assertFalse(trailers.isEmpty())
              assertTrue(trailers.size == 1)
          }
      }
  </code></pre>
  
  <p>And this is <code>movieApi.trailers</code> retrofit api method : </p>
  
  <pre><code>@GET("3/movie/{movieId}/videos")
      fun trailers(@Path("movieId") movieId: String): Observable&lt;VideoWrapper&gt;
  </code></pre>
  
  <p>I have another method in MovieApi which I want to write a test for :</p>
  
  <pre><code>@GET("3/discover/movie?language=en&amp;sort_by=popularity.desc")
      fun popularMovies(@Query("page") page: Int): Call&lt;MovieWrapper&gt;
  </code></pre>
  
  <p>As you see it returns <code>Call&lt;T&gt;</code> object instead of <code>Observable</code>. How can I have a replacement for following part in test method ?</p>
  
  <pre><code>Observable.just(MovieApi.VideoWrapper(Lists.newArrayList(video)))
              `when`(movieApi.trailers(anyString())).thenReturn(observableResponse)
  </code></pre>
  
  <p>Full sample code can be found at : <a href="https://github.com/Ali-Rezaei/TMDb-Paging" rel="nofollow noreferrer">https://github.com/Ali-Rezaei/TMDb-Paging</a></p>