Have you mocked ChefServiceProvider.getApi()
? Mockito is telling you that you've not passed it a mocked object.
Native Mockito won't let you mock static methods. I would perhaps check out PowerMock for additional features allowing you to do this sort of stuff, and investigate inversion-of-control for the future to allow you to inject such dependencies.
PowerMock is a framework that extend other mock libraries such as
EasyMock with more powerful capabilities. PowerMock uses a custom
classloader and bytecode manipulation to enable mocking of static
methods, constructors, final classes and methods, private methods,
removal of static initializers and more
When I've used PowerMock I've used it to create a unit test around poorly written code, and then refactored the code to a better pattern, using PowerMock to perform regression tests. Once refactored I can then use standard Mockito practises and remove the need for PowerMock.