@Test(expectedExceptions = EmptyResultDataAccessException.class) public void verifyLogin_throwsException_withBadInput() { user = null; int check = uRep.verifyLogin(user); }
public int verifyLogin(User user) { User login; int valid = 1; try { login = this.jdbcTemplate.queryForObject("SELECT * FROM user WHERE userName = ?", new Object[] {user.getUsername()}, new UserMapperWithPassword()); if (user.getPassword().compareTo(login.getPassword()) != 0) { valid = 0; }else { valid = login.getID(); } }catch (EmptyResultDataAccessException e) { valid = -1; } return valid; }
UserRepository { public int verifyLogin(User user) { User login; int valid = 1; try { login = this.jdbcTemplate.queryForObject("SELECT * FROM user WHERE userName = ?", new Object[] {user.getUsername()}, new UserMapperWithPassword()); if (user.getPassword().compareTo(login.getPassword()) != 0) { valid = 0; }else { valid = login.getID(); } }catch (EmptyResultDataAccessException e) { valid = -1; } return valid; } }
UserRepository { public int verifyLogin(User user) { User login; int valid = 1; try { login = this.jdbcTemplate.queryForObject("SELECT * FROM user WHERE userName = ?", new Object[] {user.getUsername()}, new UserMapperWithPassword()); if (user.getPassword().compareTo(login.getPassword()) != 0) { valid = 0; }else { valid = login.getID(); } }catch (EmptyResultDataAccessException e) { valid = -1; } return valid; }  }
UserRepository { public int verifyLogin(User user) { User login; int valid = 1; try { login = this.jdbcTemplate.queryForObject("SELECT * FROM user WHERE userName = ?", new Object[] {user.getUsername()}, new UserMapperWithPassword()); if (user.getPassword().compareTo(login.getPassword()) != 0) { valid = 0; }else { valid = login.getID(); } }catch (EmptyResultDataAccessException e) { valid = -1; } return valid; }  List<User> viewAllUsernames(); User getById(int id); String getPasswordTest(); int verifyLogin(User user); int createUser(User user); boolean updateUser(User user, int id); }
UserRepository { public int verifyLogin(User user) { User login; int valid = 1; try { login = this.jdbcTemplate.queryForObject("SELECT * FROM user WHERE userName = ?", new Object[] {user.getUsername()}, new UserMapperWithPassword()); if (user.getPassword().compareTo(login.getPassword()) != 0) { valid = 0; }else { valid = login.getID(); } }catch (EmptyResultDataAccessException e) { valid = -1; } return valid; }  List<User> viewAllUsernames(); User getById(int id); String getPasswordTest(); int verifyLogin(User user); int createUser(User user); boolean updateUser(User user, int id);  }