@Test public void passwordIsValid() { List<String> errorMessages = unit.validate("ann-acm", "AcMd3v["); assertTrue(errorMessages.isEmpty()); }
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);  }