title: Mockito Scala overloaded method value thenReturn with alternatives
body: <p>I am new to Scala and am writing some tests for Play app in Scala. The Play app has already been written in Java.</p>
  <p>I have a RefreshService that has one public method process</p>
  <pre><code>public RefreshResponse process(RefreshRequest request) throws Exception {
      return this.oauthService.token(request.oauthUrl, request.clientId, request.clientSecret, request.refreshToken)
          .thenCompose(oauthToken -&gt; this.processHelper(request.withOAuthToken(oauthToken)))
          .get();
  } 
  </code></pre>
  <p>Where actions are defined in another package as a POJOs</p>
  <p>I have written my tests based on the Scala guides</p>
  <p>When trying to mock this service I used the following code</p>
  <pre><code>var mockRefreshService = mock[RefreshService]
  when(mockRefreshService.process(_: RefreshRequest)) 
      thenReturn (new RefreshResponse)
  </code></pre>
  <p>I get the following compiler error from Scala and cannot figure out how the types can be ambigous</p>
  <blockquote>
  <p>[error] /home/joey/Projects/sntdb/test/controllers/ApiControllerSpec.scala:31: overloaded method value thenReturn with alternatives:</p>
  <p>[error]   (x$1: actions.RefreshRequest =&gt; actions.RefreshResponse,x$2: actions.RefreshRequest =&gt; actions.RefreshResponse*)org.mockito.stubbing.OngoingStubbing[actions.RefreshRequest =&gt; actions.RefreshResponse] </p>
  <p>[error]   (x$1: actions.RefreshRequest =&gt; actions.RefreshResponse)org.mockito.stubbing.OngoingStubbing[actions.RefreshRequest =&gt; actions.RefreshResponse]</p>
  <p>[error]  cannot be applied to (actions.RefreshResponse)</p>
  <p>[error]             when(mockRefreshService.process(_: RefreshRequest)) thenReturn (new RefreshResponse)</p>
  </blockquote>
  <p>If anymore information is needed please let me know. Otherwise if anyone has any ideas it would be appreciated.</p>