BCryptPasswordSecurity implements PasswordSecurity { @Override public Boolean check(String password, String hashPassword) { return BCrypt.checkpw(password, hashPassword); }  @Override Boolean check(String password, String hashPassword); @Override String hashPassword(String password);  }
@Test public void checkingAValidPasswordShouldReturnTrue() { PasswordSecurity passwordSecurity = new BCryptPasswordSecurity(); String hashPassword = BCrypt.hashpw(VALID_PASSWORD, BCrypt.gensalt()); Boolean check = passwordSecurity.check(VALID_PASSWORD, hashPassword); assertTrue(check); }
@Test public void checkingAnInvalidPasswordShouldReturnFalse() { PasswordSecurity passwordSecurity = new BCryptPasswordSecurity(); String hashPassword = BCrypt.hashpw(VALID_PASSWORD, BCrypt.gensalt()); Boolean check = passwordSecurity.check(INVALID_PASSWORD, hashPassword); assertFalse(check); }