I'm writing a unit test for a class that has the Play2 class DefaultSyncCacheApi
as a dependency.
I'm calling the method getOrElseUpdate[A: ClassTag](key: String, expiration: Duration)(orElse: => A): A
from inside the class that I'm testing.
Of course, I don't want to test the caching class but I just want to mock it so I can test other functionality.
I tried using Mockito:
mockCache = mock[DefaultSyncCacheApi]
when(mockCache.getOrElseUpdate(any(),any())(any())(any()).thenReturn(Future[String])
I started with any() in the first place, then I also tried:
when(mockCache.getOrElseUpdate[List[Item]](any(),any())
(any[List[Item]])
(any[ClassTag[List[Item]]])
).thenReturn(List(new Item))
I always get the same error:
InvalidUseOfMatchersException:
Invalid use of argument matchers!
4 matchers expected, 3 recorded:
So, in the end I'm not able to apply all 4 matchers from the method definition.