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);  }
@Test public void verifyLogin_detects_non_user() { user = new User(0,"noUserName","noEmail","password"); int check = uRep.verifyLogin(user); Assert.assertTrue(check == -1); }
@Test(expectedExceptions = EmptyResultDataAccessException.class) public void verifyLogin_throwsException_withBadInput() { user = null; int check = uRep.verifyLogin(user); }