I want to mock Java 8 Function in spock groovy
below is my transformer interface
interface Transformer {
String doSomething();
Integer performTest();
Function<List<Test>, String> findSuccess();
}
want to mock this Function in service
transformer.findSuccess().apply(tests); // service class code
Please help me on this
I am using groovy 2.5 and I have added below in my test case. it's working
def function = {
"1234"
} as Function<List<Test>, String>
1 * transformer.findSuccess() >> function