@Test public void shouldRejectEmptyUserFieldsWhenLoginModeIsRepository() { StartupForm startupForm = new StartupForm(); when(userService.hasActiveMotechAdmin()).thenReturn(false); startupForm.setLoginMode("repository"); startupForm.setLanguage("en"); startupFormValidator = new StartupFormValidatorFactory().getStartupFormValidator(startupForm, userService); List<String> errors = startupFormValidator.validate(startupForm, ConfigSource.FILE); assertTrue(errors.contains(String.format("server.error.required.%s", ADMIN_LOGIN))); assertTrue(errors.contains(String.format("server.error.required.%s", ADMIN_PASSWORD))); assertTrue(errors.contains("server.error.invalid.email")); }
public List<String> validate(StartupForm target, ConfigSource configSource) { List<String> errors = new ArrayList<>(); for (AbstractValidator validator : validators) { validator.validate(target, errors, configSource); } return errors; }
StartupFormValidator { public List<String> validate(StartupForm target, ConfigSource configSource) { List<String> errors = new ArrayList<>(); for (AbstractValidator validator : validators) { validator.validate(target, errors, configSource); } return errors; } }
StartupFormValidator { public List<String> validate(StartupForm target, ConfigSource configSource) { List<String> errors = new ArrayList<>(); for (AbstractValidator validator : validators) { validator.validate(target, errors, configSource); } return errors; } StartupFormValidator(); }
StartupFormValidator { public List<String> validate(StartupForm target, ConfigSource configSource) { List<String> errors = new ArrayList<>(); for (AbstractValidator validator : validators) { validator.validate(target, errors, configSource); } return errors; } StartupFormValidator(); List<String> validate(StartupForm target, ConfigSource configSource); void add(AbstractValidator validator); List<AbstractValidator> getValidators(); }
StartupFormValidator { public List<String> validate(StartupForm target, ConfigSource configSource) { List<String> errors = new ArrayList<>(); for (AbstractValidator validator : validators) { validator.validate(target, errors, configSource); } return errors; } StartupFormValidator(); List<String> validate(StartupForm target, ConfigSource configSource); void add(AbstractValidator validator); List<AbstractValidator> getValidators();  }