Browse Source

refactor minimum password length tests and add getter/setter

feature-password-validator
binsky 3 years ago
parent
commit
5de9fadc40
  1. 8
      src/main/java/PasswordValidator.java
  2. 3
      src/test/java/PasswordValidatorTest.java

8
src/main/java/PasswordValidator.java

@ -4,4 +4,12 @@ public class PasswordValidator {
public boolean validate(String password) {
return password.length() >= minLength;
}
public int getMinLength() {
return minLength;
}
public void setMinLength(int minLength) {
this.minLength = minLength;
}
}

3
src/test/java/PasswordValidatorTest.java

@ -10,6 +10,9 @@ class PasswordValidatorTest {
assertFalse(passwordValidator.validate(""));
// test minimum password length
passwordValidator.setMinLength(6);
assertFalse(passwordValidator.validate("abcde"));
assertTrue(passwordValidator.validate("abcdef"));
assertTrue(passwordValidator.validate("abcdefg"));
}
}
Loading…
Cancel
Save