@Test public void testGetUserByUsername_OK() { User user = UserFactoryForTests.getDefaultTestUser(); String salt = "salt"; try { userDAO.createUser(dbConnection, user, user.getPassword(), salt); User retrievedUser = userDAO.getUserByUsername(dbConnection, user.getUsername()); assertEquals(0, user.compareTo(retrievedUser)); } catch (SQLException e) { ExceptionUtilsForTests.logAndFailOnUnexpectedException(e); } }
@Test public void testCountUsersTable_NOK() { User user = UserFactoryForTests.getDefaultTestUser(); try { assertEquals(0, userDAO.countUsersTable(dbConnection)); int numberOfUsersIntoDb = userDAO.getAllUsers(dbConnection).size(); assertEquals(0, numberOfUsersIntoDb); assertEquals(numberOfUsersIntoDb, userDAO.countUsersTable(dbConnection)); User retrievedUser = userDAO.getUserByUsername(dbConnection, user.getUsername()); assertEquals(0, user.compareTo(retrievedUser)); } catch (SQLException e) { ExceptionUtilsForTests.logAndFailOnUnexpectedException(e); } }