Search in sources :

Example 1 with ChangeSecurityQuestionForm

use of org.orcid.frontend.web.forms.ChangeSecurityQuestionForm in project ORCID-Source by ORCID.

the class ChangeSecurityDetailsValidatorTest method blankEntryNotPermittedWhenIndexNot0.

@Test
public void blankEntryNotPermittedWhenIndexNot0() {
    ChangeSecurityQuestionForm form = new ChangeSecurityQuestionForm();
    form.setSecurityQuestionAnswer("");
    form.setSecurityQuestionId(3);
    Set<ConstraintViolation<ChangeSecurityQuestionForm>> violations = validator.validate(form);
    Set<String> fieldLevelErrors = retrieveErrorValuesOnly(violations);
    assertTrue(fieldLevelErrors.contains("Please provide an answer to your challenge question."));
    form.setSecurityQuestionAnswer("An answer");
    form.setSecurityQuestionId(3);
    violations = validator.validate(form);
    fieldLevelErrors = retrieveErrorValuesOnly(violations);
    assertFalse(fieldLevelErrors.contains("Please provide an answer to your challenge question."));
}
Also used : ChangeSecurityQuestionForm(org.orcid.frontend.web.forms.ChangeSecurityQuestionForm) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 2 with ChangeSecurityQuestionForm

use of org.orcid.frontend.web.forms.ChangeSecurityQuestionForm in project ORCID-Source by ORCID.

the class ChangeSecurityDetailsValidatorTest method allValuesPopulatedHappyPath.

@Test
public void allValuesPopulatedHappyPath() {
    ChangeSecurityQuestionForm form = new ChangeSecurityQuestionForm();
    form.setSecurityQuestionAnswer("My answer");
    form.setSecurityQuestionId(2);
    Set<ConstraintViolation<ChangeSecurityQuestionForm>> errors = validator.validate(form);
    assertEquals("Should be no errors", 0, errors.size());
}
Also used : ChangeSecurityQuestionForm(org.orcid.frontend.web.forms.ChangeSecurityQuestionForm) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 3 with ChangeSecurityQuestionForm

use of org.orcid.frontend.web.forms.ChangeSecurityQuestionForm in project ORCID-Source by ORCID.

the class ChangeSecurityDetailsValidatorTest method blankEntryPermittedWhenIndex0.

@Test
public void blankEntryPermittedWhenIndex0() {
    ChangeSecurityQuestionForm form = new ChangeSecurityQuestionForm();
    form.setSecurityQuestionAnswer("My answer");
    form.setSecurityQuestionId(0);
    Set<ConstraintViolation<ChangeSecurityQuestionForm>> violations = validator.validate(form);
    Set<String> fieldLevelErrors = retrieveErrorValuesOnly(violations);
    assertTrue(fieldLevelErrors.contains("Please provide an answer to your challenge question."));
    form.setSecurityQuestionAnswer("");
    form.setSecurityQuestionId(0);
    violations = validator.validate(form);
    fieldLevelErrors = retrieveErrorValuesOnly(violations);
    assertFalse(fieldLevelErrors.contains("Please provide an answer to your challenge question."));
}
Also used : ChangeSecurityQuestionForm(org.orcid.frontend.web.forms.ChangeSecurityQuestionForm) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Aggregations

ConstraintViolation (javax.validation.ConstraintViolation)3 Test (org.junit.Test)3 ChangeSecurityQuestionForm (org.orcid.frontend.web.forms.ChangeSecurityQuestionForm)3