There is a lot of refractoring that needs to be done on the current spring application which I am working on for unittesting.
But we are not suppose to go with refractoring...There is a strict no no from clients.
I would like to create a mock for an " instance created in a class using a new operator". because they didn't go with the
dependency injection.(no setters/constructors).
Below is the code
My Mock
Test case: I am creating Mock on the "metastoreDAOManager" as below
As there is no setter/Constructor injection done for "metastoreDAOManager" in searchcontroller.class I am not able to perform the mock on ""MetastoreDAOManager"".
Can you please let me know how to achive mock on the "new operator" created in a class..
Note:
We are not allowed for refractoring.
Mythoughts:
Create a proxy for the below code when getUserPreferenceFromMetastore(request) is called.using spring AOP.Is this the right way: