@Test public void shouldNotValidateUserDetailsWhenLoginModeIsNull() { PersistedUserValidator persistedUserValidator = mock(PersistedUserValidator.class); OpenIdUserValidator openIdUserValidator = mock(OpenIdUserValidator.class); StartupForm target = new StartupForm(); target.setLoginMode(null); UserRegistrationValidator userRegistrationValidator = new UserRegistrationValidator(persistedUserValidator, openIdUserValidator); userRegistrationValidator.validate(target, new ArrayList<String>(), ConfigSource.FILE); verify(persistedUserValidator, never()).validate(target, new ArrayList<String>(), ConfigSource.FILE); verify(openIdUserValidator, never()).validate(target, new ArrayList<String>(), ConfigSource.FILE); }
@Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { LoginMode loginMode = LoginMode.valueOf(target.getLoginMode()); if (loginMode == null) { return; } if (loginMode.isOpenId()) { openIdUserValidator.validate(target, errors, configSource); } else { persistedUserValidator.validate(target, errors, configSource); } }
UserRegistrationValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { LoginMode loginMode = LoginMode.valueOf(target.getLoginMode()); if (loginMode == null) { return; } if (loginMode.isOpenId()) { openIdUserValidator.validate(target, errors, configSource); } else { persistedUserValidator.validate(target, errors, configSource); } } }
UserRegistrationValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { LoginMode loginMode = LoginMode.valueOf(target.getLoginMode()); if (loginMode == null) { return; } if (loginMode.isOpenId()) { openIdUserValidator.validate(target, errors, configSource); } else { persistedUserValidator.validate(target, errors, configSource); } } UserRegistrationValidator(PersistedUserValidator persistedUserValidator, OpenIdUserValidator openIdUserValidator); }
UserRegistrationValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { LoginMode loginMode = LoginMode.valueOf(target.getLoginMode()); if (loginMode == null) { return; } if (loginMode.isOpenId()) { openIdUserValidator.validate(target, errors, configSource); } else { persistedUserValidator.validate(target, errors, configSource); } } UserRegistrationValidator(PersistedUserValidator persistedUserValidator, OpenIdUserValidator openIdUserValidator); @Override void validate(StartupForm target, List<String> errors, ConfigSource configSource); }
UserRegistrationValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { LoginMode loginMode = LoginMode.valueOf(target.getLoginMode()); if (loginMode == null) { return; } if (loginMode.isOpenId()) { openIdUserValidator.validate(target, errors, configSource); } else { persistedUserValidator.validate(target, errors, configSource); } } UserRegistrationValidator(PersistedUserValidator persistedUserValidator, OpenIdUserValidator openIdUserValidator); @Override void validate(StartupForm target, List<String> errors, ConfigSource configSource);  }