A method to mock a new instance in the class is using the powermockito. Powermockito has a function whenNew. This one can be used to solve this kind of problem.