trouble with overloaded method...?

20 views
Skip to first unread message

Anthony Kerz

unread,
Sep 25, 2015, 10:08:33 AM9/25/15
to specs2-users

i’ve been getting beat up attempting to match on an overloaded method.

i’m new to scala and specs2, so that is likely one factor ;)

so i have a mock of this SchedulerDriver class

and i’m trying to verify the content of the arguments that are being
passed to the signature of this launchTasks method:

http://mesos.apache.org/api/latest/java/org/apache/mesos/SchedulerDriver.html#launchTasks(java.util.Collection,%20java.util.Collection)

i have tried the answers style like so:

      val mockSchedulerDriver = mock[SchedulerDriver]
      mockSchedulerDriver.launchTasks(haveInterface[Collection[OfferID]], haveInterface[Collection[TaskInfo]]) answers { i => System.out.println(s"i=$i") }

and get

ambiguous reference to overloaded definition, both method launchTasks in trait SchedulerDriver of type (x$1: org.apache.mesos.Protos.OfferID, x$2: java.util.Collection[org.apache.mesos.Protos.TaskInfo])org.apache.mesos.Protos.Status and method launchTasks in trait SchedulerDriver of type (x$1: java.util.Collection[org.apache.mesos.Protos.OfferID], x$2: java.util.Collection[org.apache.mesos.Protos.TaskInfo])org.apache.mesos.Protos.Status match argument types (org.specs2.matcher.Matcher[Any],org.specs2.matcher.Matcher[Any])

and i have tried the capture style like so:

      val mockSchedulerDriver = mock[SchedulerDriver]
      val offerIdCollectionCaptor = capture[Collection[OfferID]]
      val taskInfoCollectionCaptor = capture[Collection[TaskInfo]]
      there was one(mockSchedulerDriver).launchTasks(offerIdCollectionCaptor, taskInfoCollectionCaptor)

and get:

overloaded method value launchTasks with alternatives: (x$1: org.apache.mesos.Protos.OfferID,x$2: java.util.Collection[org.apache.mesos.Protos.TaskInfo])org.apache.mesos.Protos.Status <and> (x$1: java.util.Collection[org.apache.mesos.Protos.OfferID],x$2: java.util.Collection[org.apache.mesos.Protos.TaskInfo])org.apache.mesos.Protos.Status cannot be applied to (org.specs2.mock.mockito.ArgumentCapture[java.util.Collection[mesosphere.mesos.protos.OfferID]], org.specs2.mock.mockito.ArgumentCapture[java.util.Collection[org.apache.mesos.Protos.TaskInfo]])

any guidance or suggestions on how to approach this appreciated…!

best,
tony.

etorreborre

unread,
Sep 27, 2015, 4:21:16 AM9/27/15
to specs2-users
Please see my answer on StackOverflow.
Reply all
Reply to author
Forward
0 new messages