Mockito.any() for <T>

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(...);

You can match a generic Class<T> argument using simply any( Class.class ), eg.:

Mockito.when( mongoUtil.documentToPojo( Mockito.any( Document.class ),
                                        Mockito.any( Class.class ) ) );

Cheers,