title: Mockito: when Method A.a is called then execute B.b
body: <p>I'm using Mockito for JUnit tests.
  So there is a given class A that is used from the code i want to test:</p>
  
  <pre><code>class A{
  
      public A(){}
  
      public final String a(String x){
          return "A.a: " + x;
      }
  
  }
  </code></pre>
  
  <p>and i want to replace the Method call A.a with another method call with the same arguments and same type of return value. As you can see, its not possible to override the method a by extending the class as it is final. So what i have now is another class B with the method B.b:</p>
  
  <pre><code>class B{
  
      public B(){}
  
      public String b(String x){
          return "B.b: " + x;
      }
  
  }
  </code></pre>
  
  <p>Now i want to make sure every time when A.a is called from the code, the return value of B.b is used instead. Is there a possibility to achieve this with Mockito (something like <code>Mockito.when(A.a(x)).thenReturn(B.b(x));</code> ) but with the same parameter x, without knowing the value of x?</p>
  
  <p>Any help would be appreciated, thank you in advance!</p>