I am trying to write a Unit Tests to a legacy code using Mockito.
But I am not able to understand how do I mock it. Can some please help.
The real problem I am facing is actually I am not able to decide how to make a decision on what exactly is to be mocked? Below is the code. I have looked at numerous videos on YouTube and read many Mockito Tutorials but all of them seem to be guiding mostly about how to use the Mockito Framework.
The basic idea of what to Mock is still unclear. Please guide if you have a better source. I do understand that the code showed below does not really showcase the best coding practice.
public class DataFacade { public boolean checkUserPresent(String userId){ return getSomeDao.checkUserPresent(userId); } private SomeDao getSomeDao() { DataSource dataSource = MyDataSourceFactory.getMySQLDataSource(); SomeDao someDao = new SomeDao(dataSource); } }