@Test public void passwordIsTooShort() { List<String> errorMessages = unit.validate("ann-acm", "Ac3$"); assertTrue(errorMessages.size() == 1); assertEquals("Password must be of minimum length of 7.", errorMessages.get(0)); }
public List<String> validate(String userId, String password) { return passwordRules.stream() .map(rule -> rule.runValidationAndGetMessage(userId, password)) .filter(Objects::nonNull) .collect(Collectors.toList()); }
PasswordValidationService { public List<String> validate(String userId, String password) { return passwordRules.stream() .map(rule -> rule.runValidationAndGetMessage(userId, password)) .filter(Objects::nonNull) .collect(Collectors.toList()); } }
PasswordValidationService { public List<String> validate(String userId, String password) { return passwordRules.stream() .map(rule -> rule.runValidationAndGetMessage(userId, password)) .filter(Objects::nonNull) .collect(Collectors.toList()); }  }
PasswordValidationService { public List<String> validate(String userId, String password) { return passwordRules.stream() .map(rule -> rule.runValidationAndGetMessage(userId, password)) .filter(Objects::nonNull) .collect(Collectors.toList()); }  List<String> validate(String userId, String password); void setPasswordRules(List<PasswordValidationRule> passwordRules); }
PasswordValidationService { public List<String> validate(String userId, String password) { return passwordRules.stream() .map(rule -> rule.runValidationAndGetMessage(userId, password)) .filter(Objects::nonNull) .collect(Collectors.toList()); }  List<String> validate(String userId, String password); void setPasswordRules(List<PasswordValidationRule> passwordRules);  }