I am trying to stub this method: QueryUtils.toOrder(sort, root, builder) and I am doing
when(QueryUtils.toOrder(any(Sort.class), any(Root.class), any(CriteriaBuilder.class)).thenReturn(mock(List.class));
but it goes into the queryUtils method body and it will say Sort is null and it will throw a NPE. But why would it need to go into the method body when it is a stub? I haven't had this issue before and I don't think it should care what the internal logic of the method is.