In your case you have curried function with three args:
def get[T](method: String, additionalHeaders: (String,String)*)
(block: HttpResponse => Try[T]): Future[T] = ???
and calling get
can be presented as:
Function3[String, Seq[(String, String)], HttpResponse => Try[T], Future[T]]
if we will uncurry get
:
trait ServiceWithUncurriedGet {
def uncurriedGet[T]: (String, Seq[(String, String)], HttpResponse => Try[T]) => Future[T] =
new Function3[String, Seq[(String, String)], HttpResponse => Try[T], Future[T]] {
override def apply(v1: String, v2: Seq[(String, String)], v3: HttpResponse => Try[T]): Future[T] =
serviceClient.get(v1, v2: _*)(v3)
}
}
and we can use this service to mock uncurriedGet
as function with 3 args:
val serviceWithUncurriedGetClient = mock[ServiceWithUncurriedGet]
serviceWithUncurriedGetClient.uncurriedGet[String].expects(*, *, *)
to make your code working you need to make conversion from Curried function to UnCurried and pass types (I use String
instead of T
type parameter to simplify):
(
(x: String, y: Seq[(String, String)], f: HttpResponse => Try[String]) =>
serviceClient.get(x, y: _*)(f)
).expects(*, *, *)
It is also needed expand types of arguments to give compiler more information and it will can convert this into function of 3 args.