This seems like it should be simple but I'm running around in circles.
I have:
@Mock
SimpleAbstractCacheWithInputs<Key, Value, Inputs> underlyingCache;
I then try to set up a call on the cache in setup()
:
when(underlyingCache.getOrCreate(usdgbpKey)).thenReturn(usdgbpCfi);
But this throws a null pointer exception from within getOrCreate()
because it's trying to execute the actual code in the real object, not mocked at all, and that isn't set up.
But I don't want to ever run getOrCreate
real code, I just want it to return the mocked value!
So how do I do this without having to set up everything inside underlyingCache
that I'm never going to use in order to mock this one method call?