I want to capture calls to a mock object
public interface Service {
public String stringify(Object o);
}
service = mockery.mock(Service.class);
mockery.allowing(service::stringify).with(42).will(() -> "42");
So inside allowing
I have a Function<Object, String>
Is there any reflecto-magic that will let me find the service from the function created from the method reference?
public WithClause allowing(Function<T,R> f) {
Object myServiceBackAgain = findTargetOf(function);
....
}
I know that the Function will always come from these method references, so I'm happy to down-cast as much as is necessary.
This is not the same question as the related Is it possible to convert method reference to MethodHandle? because, well for a start it isn't the same question, just in a related area. And even if I can get a MethodHandle, I can't get the target from it.