title: mocking Retrofit response calls with Call not working
body: <p>I'm mocking the response of the APIService. Unfortunately it is not working, I have to send back a Call but I don't understand how. The question is how to send back a Call object. </p>
  
  <pre><code>@RunWith(AndroidJUnit4::class)
  class ApiServiceTest {
  
      @Test
      fun testSomething() {
          val apiService = ApiServiceMock()
          val call = apiService.getStep1User()
          val result = call.execute()
          Assert.assertEquals("SomeUserValue", result.body()!!.getResponse())
      }
  }
  </code></pre>
  
  <p>Here is the mocked service:</p>
  
  <pre><code>class ApiServiceMock : ApiService {
      override fun getStep1User(): Call&lt;UserResponse&gt; {
          // How to return an object of type Call&lt;UserResponse&gt; ?
          val response = "{ \"Response\": \"SomeUserValue\" }"
          val gson = Gson().toJson(response)
          return Response.success(gson)
      }
  }
  </code></pre>
  
  <p>Here is the api interface:</p>
  
  <pre><code>interface ApiService {
  
      @GET("/booky/step1user")
      fun getStep1User(): Call&lt;UserResponse&gt;
  
      companion object {
  
          val interceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
          val client = OkHttpClient.Builder()
                  .addInterceptor(interceptor)
                  .build()
  
          val retrofit = Retrofit.Builder()
                  .baseUrl("http://jimclermonts.nl")
                  .addConverterFactory(MoshiConverterFactory.create().asLenient())
                  .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                  .client(client)
                  .build()
      }
  }
  </code></pre>
  
  <p>build.gradle:</p>
  
  <pre><code>implementation 'com.squareup.retrofit2:retrofit:2.3.0'
  implementation 'com.squareup.retrofit2:converter-moshi:2.3.0'
  implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
  implementation 'com.squareup.okhttp3:okhttp:3.9.0'
  implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
  
  implementation 'com.google.code.gson:gson:2.8.0'
  
  testImplementation "org.mockito:mockito-core:2.12.0"
  testImplementation "com.nhaarman:mockito-kotlin:1.5.0"
  implementation 'org.mockito:mockito-android:2.18.0'
  </code></pre>