I'm using Groovy with JUnit to test my Java code.
I need to test a method foo() which takes in a java.util.function.Function
public void foo(Function<Foo,Bar> func){
return null;
}
In my normal code I call foo by passing in a method reference of a method bar ie.
foo(mybar::bar)
How can I test this function in Groovy elegantly?
Using:
mybar.&bar
yields a groovy.lang.Closure<...> which is not compatible with java.util.function.Function.
How else can I achieve this?
Coerce the final attempt to
Function, like this: