mercredi 23 novembre 2016

Slick Scala Mockito dao mocking

I have a base trait for dao:

trait BaseDao[T, A] {
  ...
  def deleteByFilter[C: CanBeQueryCondition](f: T => C): Future[Int]
}

and I would love to be able to mock such a method. Maybe someting like this:

val someMock = mock[BaseDao[EntityTable, Entity]]
someMock.deleteByFilter(anyFunction1[Posts, Rep[Boolean]].apply) returns Future(1)
// or
someMock.deleteByFilter(anyFunction1[Posts, Rep[Boolean]]) returns Future(1)

but no metter what I try I always get:

[info]   org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers!
[info] 2 matchers expected, 1 recorded:
[info] -> at org.specs2.mock.mockito.ArgThat$class.anArgThat(ArgThat.scala:11)

How can I successfully stub this method?

Aucun commentaire:

Enregistrer un commentaire