whenever(http.call(any(), any<(Response) -> MyClass>(), any())) .thenAnswer({ inv -> inv.arguments[1] // this is an Object and i need to cast it to (Response) -> MyClass })