StartupFormValidatorFactory { public StartupFormValidator getStartupFormValidator(StartupForm startupSettings, MotechUserService userService) { StartupFormValidator startupFormValidator = new StartupFormValidator(); startupFormValidator.add(new RequiredFieldValidator(StartupForm.LANGUAGE, startupSettings.getLanguage())); startupFormValidator.add(new RequiredFieldValidator(StartupForm.LOGIN_MODE, startupSettings.getLoginMode())); startupFormValidator.add(new UserRegistrationValidator(new PersistedUserValidator(userService), new OpenIdUserValidator(new UrlValidator()))); return startupFormValidator; }  StartupFormValidator getStartupFormValidator(StartupForm startupSettings, MotechUserService userService);  }
@Test public void shouldCreateStartupFormValidator() { when(motechUserService.hasActiveMotechAdmin()).thenReturn(false); StartupFormValidator startupFormValidator = startupFormValidatorFactory.getStartupFormValidator(new StartupForm(), motechUserService); assertNotNull(startupFormValidator); List<AbstractValidator> validators = startupFormValidator.getValidators(); assertFalse(validators.isEmpty()); assertTrue(validators.contains(new RequiredFieldValidator(StartupForm.LANGUAGE, ""))); assertTrue(validators.contains(new RequiredFieldValidator(StartupForm.LOGIN_MODE, ""))); assertContainsValidatorOfType(UserRegistrationValidator.class, validators); }