private StartupForm getExampleStartupForm() { StartupForm startupForm = new StartupForm(); startupForm.setAdminLogin("admin"); startupForm.setAdminPassword("password"); startupForm.setAdminConfirmPassword("password"); startupForm.setAdminEmail("*****@*****.**"); return startupForm; }
@Test public void shouldRejectInvalidEmail() { PersistedUserValidator persistedUserValidator = new PersistedUserValidator(userService); StartupForm startupForm = getExampleStartupForm(); startupForm.setAdminEmail("admin@motech"); when(userService.hasUser("admin")).thenReturn(false); List<String> errors = new ArrayList<>(); persistedUserValidator.validate(startupForm, errors, ConfigSource.FILE); assertTrue(errors.contains("server.error.invalid.email")); }