@Test public void validate() { RegisterPatientAction action = getTestAction(); PLCUser user = TestPLCEntityFactory.createPLCUser(); user.setPassword("password"); action.setUser(user); assertNull(action.getRepeatPassword()); assertNull(action.getRepeatEmail()); assertNull(action.getChallengeQuestion()); assertNull(action.getChallengeAnswer()); action.validate(); assertTrue(action.hasFieldErrors()); assertEquals(6, action.getFieldErrors().size()); assertNotNull(action.getFieldErrors().get("repeatPassword")); assertNotNull(action.getFieldErrors().get("repeatEmail")); assertNotNull(action.getFieldErrors().get("user.password")); assertNotNull(action.getFieldErrors().get("challengeQuestion")); assertNotNull(action.getFieldErrors().get("challengeAnswer")); action.clearErrorsAndMessages(); action.setChallengeQuestion("Question"); action.setChallengeAnswer("Answer"); action.setRepeatPassword("notTheSame"); action.setRepeatEmail("notTheSame"); action.validate(); assertTrue(action.hasFieldErrors()); assertEquals(4, action.getFieldErrors().size()); assertNotNull(action.getFieldErrors().get("repeatPassword")); assertNotNull(action.getFieldErrors().get("user.password")); assertNotNull(action.getFieldErrors().get("repeatEmail")); assertNotNull(action.getFieldErrors().get("user.email")); action.clearErrorsAndMessages(); action.setRepeatEmail(action.getUser().getEmail()); action.setRepeatPassword(action.getUser().getPassword()); action.validate(); assertTrue(action.hasFieldErrors()); assertEquals(1, action.getFieldErrors().size()); action.clearErrorsAndMessages(); action.getUser().setPassword("P@ssword1!"); action.setRepeatPassword("P@ssword1!"); action.validate(); assertFalse(action.hasFieldErrors()); }
@Override public void validate() { super.validate(); if (!Pattern.matches(PASSWORD_PATTERN, user.getPassword())) { addFieldError("user.password", getText(FIELD_PASSWORD_INVALID_KEY)); } if (!StringUtils.equals(user.getPassword(), getRepeatPassword())) { addFieldError("user.password", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); addFieldError("repeatPassword", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); } if (!StringUtils.equals(user.getEmail(), getRepeatEmail())) { addFieldError("user.email", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); addFieldError("repeatEmail", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); } if (StringUtils.isEmpty(challengeQuestion)) { addFieldError("challengeQuestion", getText(FIELD_REQUIRED_KEY)); } if (StringUtils.isEmpty(challengeAnswer)) { addFieldError("challengeAnswer", getText(FIELD_REQUIRED_KEY)); } }
RegisterPatientAction extends ConsentWizardAction { @Override public void validate() { super.validate(); if (!Pattern.matches(PASSWORD_PATTERN, user.getPassword())) { addFieldError("user.password", getText(FIELD_PASSWORD_INVALID_KEY)); } if (!StringUtils.equals(user.getPassword(), getRepeatPassword())) { addFieldError("user.password", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); addFieldError("repeatPassword", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); } if (!StringUtils.equals(user.getEmail(), getRepeatEmail())) { addFieldError("user.email", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); addFieldError("repeatEmail", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); } if (StringUtils.isEmpty(challengeQuestion)) { addFieldError("challengeQuestion", getText(FIELD_REQUIRED_KEY)); } if (StringUtils.isEmpty(challengeAnswer)) { addFieldError("challengeAnswer", getText(FIELD_REQUIRED_KEY)); } } }
RegisterPatientAction extends ConsentWizardAction { @Override public void validate() { super.validate(); if (!Pattern.matches(PASSWORD_PATTERN, user.getPassword())) { addFieldError("user.password", getText(FIELD_PASSWORD_INVALID_KEY)); } if (!StringUtils.equals(user.getPassword(), getRepeatPassword())) { addFieldError("user.password", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); addFieldError("repeatPassword", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); } if (!StringUtils.equals(user.getEmail(), getRepeatEmail())) { addFieldError("user.email", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); addFieldError("repeatEmail", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); } if (StringUtils.isEmpty(challengeQuestion)) { addFieldError("challengeQuestion", getText(FIELD_REQUIRED_KEY)); } if (StringUtils.isEmpty(challengeAnswer)) { addFieldError("challengeAnswer", getText(FIELD_REQUIRED_KEY)); } } @Inject  RegisterPatientAction(PatientInformationService patientService); }
RegisterPatientAction extends ConsentWizardAction { @Override public void validate() { super.validate(); if (!Pattern.matches(PASSWORD_PATTERN, user.getPassword())) { addFieldError("user.password", getText(FIELD_PASSWORD_INVALID_KEY)); } if (!StringUtils.equals(user.getPassword(), getRepeatPassword())) { addFieldError("user.password", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); addFieldError("repeatPassword", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); } if (!StringUtils.equals(user.getEmail(), getRepeatEmail())) { addFieldError("user.email", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); addFieldError("repeatEmail", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); } if (StringUtils.isEmpty(challengeQuestion)) { addFieldError("challengeQuestion", getText(FIELD_REQUIRED_KEY)); } if (StringUtils.isEmpty(challengeAnswer)) { addFieldError("challengeAnswer", getText(FIELD_REQUIRED_KEY)); } } @Inject  RegisterPatientAction(PatientInformationService patientService); String register(); @Override void validate(); PLCUser getUser(); void setUser(PLCUser user); String getRepeatPassword(); void setRepeatPassword(String repeatPassword); String getRepeatEmail(); void setRepeatEmail(String repeatEmail); String getChallengeQuestion(); void setChallengeQuestion(String challengeQuestion); String getChallengeAnswer(); void setChallengeAnswer(String challengeAnswer); }
RegisterPatientAction extends ConsentWizardAction { @Override public void validate() { super.validate(); if (!Pattern.matches(PASSWORD_PATTERN, user.getPassword())) { addFieldError("user.password", getText(FIELD_PASSWORD_INVALID_KEY)); } if (!StringUtils.equals(user.getPassword(), getRepeatPassword())) { addFieldError("user.password", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); addFieldError("repeatPassword", getText(FIELD_REPEAT_PASSWORD_MISSMATCH_KEY)); } if (!StringUtils.equals(user.getEmail(), getRepeatEmail())) { addFieldError("user.email", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); addFieldError("repeatEmail", getText(FIELD_REPEAT_EMAIL_MISSMATCH_KEY)); } if (StringUtils.isEmpty(challengeQuestion)) { addFieldError("challengeQuestion", getText(FIELD_REQUIRED_KEY)); } if (StringUtils.isEmpty(challengeAnswer)) { addFieldError("challengeAnswer", getText(FIELD_REQUIRED_KEY)); } } @Inject  RegisterPatientAction(PatientInformationService patientService); String register(); @Override void validate(); PLCUser getUser(); void setUser(PLCUser user); String getRepeatPassword(); void setRepeatPassword(String repeatPassword); String getRepeatEmail(); void setRepeatEmail(String repeatEmail); String getChallengeQuestion(); void setChallengeQuestion(String challengeQuestion); String getChallengeAnswer(); void setChallengeAnswer(String challengeAnswer);  }