Mockito.any() for
Note that documentToPojo takes a Class as its second argument. any(Foo.class) returns an argument of type Foo, not of type Class<Foo>, whereas eq(WorkItemDTO.class) should return a Class<WorkItemDTO> as expected. I’d do it this way: when(mongoUtil.documentToPojo( Mockito.any(Document.class), Mockito.eq(WorkItemDTO.class))).thenReturn(…);