title: Mockito when clause not working in kotlin
body: <p>I am trying to use mockito in kotlin. I created the following test:</p>
  
  <pre><code>class HeroesDataSourceTest {
  
      @Mock
      lateinit var heroesRepository: HeroesRepository
      @Mock
      lateinit var params: PageKeyedDataSource.LoadInitialParams&lt;Int&gt;
      @Mock
      lateinit var callback: PageKeyedDataSource.LoadInitialCallback&lt;Int, Heroes.Hero&gt;
  
      val hero = Heroes.Hero(1, "superman", "holasuperman", 1, null, null)
      val results = Arrays.asList(hero)
      val data = Heroes.Data(results)
      val dataResult = Heroes.DataResult(data)
  
      val compositeDisposable = CompositeDisposable()
  
      lateinit var heroesDataSource: HeroesDataSource
      private val heroesPublishSubject = PublishSubject.create&lt;Heroes.DataResult&gt;()
  
      @Before
      fun initTest(){
          MockitoAnnotations.initMocks(this)
  
      }
  
      @Test
      fun testLoadInitialSuccess(){
          `when`(heroesRepository.getHeroes(ArgumentMatchers.anyInt())).thenReturn(heroesPublishSubject.singleOrError())
          heroesDataSource = HeroesDataSource(heroesRepository, compositeDisposable)
          val testObserver = TestObserver&lt;Heroes.DataResult&gt;()
          heroesDataSource.loadInitial(params, callback)
          heroesPublishSubject.onNext(dataResult)
          testObserver.assertComplete()
      }
  
  }
  </code></pre>
  
  <p>But when I execute it in the line <code>when(heroesRepository.getHeroes(ArgumentMatchers.anyInt())).thenReturn(heroesPublishSubject.singleOrError())</code> it just enter to getHeroes method instead of mocking it (and for sure since heroesRepository is not initialized because is mocket the method fails). I use this tons of times in java and it never gave me a single problem. What I have to do in kotlin to mock it properly?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here I put also HeroesRepository class</p>
  
  <pre><code>open class HeroesRepository {
  
      val privateKey = "5009bb73066f50f127907511e70f691cd3f2bb2c"
      val publicKey = "51ef4d355f513641b490a80d32503852"
      val apiDataSource = DataModule.create()
      val pageSize = 20
  
      fun getHeroes(page: Int): Single&lt;Heroes.DataResult&gt; {
          val now = Date().time.toString()
          val hash = generateHash(now + privateKey + publicKey)
          val offset: Int = page * pageSize
          return apiDataSource.getHeroes(now, publicKey, hash, offset, pageSize)
      }
  
      fun generateHash(variable: String): String {
          val md = MessageDigest.getInstance("MD5")
          val digested = md.digest(variable.toByteArray())
          return digested.joinToString("") {
              String.format("%02x", it)
          }
      }
  }
  </code></pre>