For me the reason I was getting NPE is that I was using Mockito.any()
when mocking primitives. I found that by switching to using the correct variant from mockito gets rid of the errors.
For example, to mock a function that takes a primitive long
as parameter, instead of using any()
, you should be more specific and replace that with any(Long.class)
or Mockito.anyLong()
.
Hope that helps someone.