Pretty new to Spock. Trying to mock a function that returns a BiFunction unsuccessfully.
The function looks like
public interface myInterface {
Optional<BiFunction<Object, Object, Object>> myAwesomeFunc()
}
Trying to mock like
def mockBiFunction = Mock(BiFunction)
mockMyInterface.myAwesomeFunc >> mockBiFunction
mockBiFunction.apply(*_) >> mockReturnVal
This results in
No signature of method: com.sun.proxy.$Proxy49.apply() is applicable for argument types: (org.spockframework.lang.SpreadWildcard) values: [*_]
Possible solutions: apply(java.lang.Object, java.lang.Object), any(), any(groovy.lang.Closure), every(), tap(groovy.lang.Closure), every(groovy.lang.Closure)
groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy49.apply() is applicable for argument types: (org.spockframework.lang.SpreadWildcard) values: [*_]
Possible solutions: apply(java.lang.Object, java.lang.Object), any(), any(groovy.lang.Closure), every(), tap(groovy.lang.Closure), every(groovy.lang.Closure)
Tried with
mockBiFunction(*_) >> mockReturnVal
That doesn't work either.
Edit: Tried with
mockBiFunction.apply(object1, object2) >> mockReturnVal
This fails with
Cannot invoke method rightShift() on null object
java.lang.NullPointerException: Cannot invoke method rightShift() on null object
When I have mocked it then why is it null ??