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."));
}
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());
}
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."));
}
Aggregations