I am attempting to verify that a method with the following signature was called:
public void process(Map<String, Set<String>> data) { ... } The nested parameterized Set is causing me difficulties. I can get it to verify correctly with the any() matcher like so:
verify(dataProcessor).process(Matchers.<Map<String, Set<String>>> any()); As described in Mockito: Verifying with generic parameters although annoyingly it doesn't work if I do a direct static import of Matchers.any and call it as just:
verify(dataProcessor).process(<Map<String, Set<String>>> any()) But anyMapOf(clazz, clazz) seems the more appropriate matcher in this case. Since you can't do Set.class I'm not sure how you would do this. The following doesn't work because of the lack of generic:
verify(dataProcessor).process(anyMapOf(String.class, Set.class)); Is it possible to verify this situation with anyMapOf or should I stick with Matchers.<>any()?
any()? Code not calling your method with aMap<String, Set<String>>will not even compile...anybased on the parameter types available inprocess, becauseprocesscould have overloads and/or type parameters of its own. It does do so in return values and fields, because the type is already defined explicitly as the return value type or field type. It's all in the extremely-opaque JLS 15.12.2.