コード例 #1
0
  private StartupForm getExampleStartupForm() {
    StartupForm startupForm = new StartupForm();
    startupForm.setAdminLogin("admin");
    startupForm.setAdminPassword("password");
    startupForm.setAdminConfirmPassword("password");
    startupForm.setAdminEmail("*****@*****.**");

    return startupForm;
  }
コード例 #2
0
  @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"));
  }