I'm using Mockito for JUnit tests. So there is a given class A that is used from the code i want to test:
class A{
public A(){}
public final String a(String x){
return "A.a: " + x;
}
}
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:
class B{
public B(){}
public String b(String x){
return "B.b: " + x;
}
}
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 Mockito.when(A.a(x)).thenReturn(B.b(x));
) but with the same parameter x, without knowing the value of x?
Any help would be appreciated, thank you in advance!