I am not getting how to switch the database connection from the actual database to my testing database.I have been calling the function defined in the DAO class from my testing class- So, in test class i have-
userDAO = new UserDAO();
userDAO.conn= databaseTester.getConnection().getConnection();
and in userDAO class i have-
public UserDemoProfileDTO getUserByOTP(String deviceUUID) {
conn = DBConnector.getPooledConnection(); // here creating connection with actual database
PreparedStatement pstmt = null;
ResultSet rs = null;
UserDemoProfileDTO userDto = new UserDemoProfileDTO();
try { ...
Problem is how to ensure that when the function is called from the test class it doesn't connect to the actual database (as it is getting connected inside the function) instead gets connected to testing database? I don't know, there must be some function or something to switch between. As I am new to development world, please reply in a basic way. Thank you.