Ajit Goel wrote:
I am getting a null pointer exception on the line where the system expects the dependency to be injected.
And which line is that? It's not immediately obvious to bleary-eyed me. And welcome to the Ranch, Ajit!
My experience with mocking is that you should strive to mock as little as possible. Try and use ordinary tests as much as possible and isolate the logic that needs a mocked service to the absolute minimum of code. If at all possible, inject a simulated object in place of a mocked object. You can do a lot of this by internally refactoring private (or package-scope private) methods in the class to be tested without unduly affecting external users (and after all, you're supposed to have thoroughly tested the internal methods!)
Depending on the mocking framework you use, making a mocked object do anything useful can be difficult. Mockito, I learned to my pain, basically wants to treat every method call to the mocked object as a dummy do-nothing call with the mock object keeping no internal state. When asked to return data, it will return null unless you add a lot of gnarly support code, and even then basically it wants to be both stateless and independent of calling parameter values.
So I don't have a specific answer for you, unfortunately, but maybe these guidelines will help.