Step7Action extends ConsentWizardAction { @Override public void validate() { if (!affirmUncertainty) { addFieldError("affirmUncertainty", getText(FIELD_REQUIRED_KEY)); } if (!affirmConsent) { addFieldError("affirmConsent", getText(FIELD_REQUIRED_KEY)); } if (!affirmWithdrawlPolicy) { addFieldError("affirmWithdrawlPolicy", getText(FIELD_REQUIRED_KEY)); } }  @Override void validate(); boolean isAffirmUncertainty(); void setAffirmUncertainty(boolean affirmUncertainty); boolean isAffirmConsent(); void setAffirmConsent(boolean affirmConsent); boolean isAffirmWithdrawlPolicy(); void setAffirmWithdrawlPolicy(boolean affirmWithdrawlPolicy);  }
@Test public void validate() { Step7Action action = getTestAction(); assertFalse(action.isAffirmUncertainty()); assertFalse(action.isAffirmConsent()); assertFalse(action.isAffirmWithdrawlPolicy()); action.validate(); assertTrue(action.hasFieldErrors()); assertEquals(3, action.getFieldErrors().size()); assertNotNull(action.getFieldErrors().get("affirmUncertainty")); assertNotNull(action.getFieldErrors().get("affirmConsent")); assertNotNull(action.getFieldErrors().get("affirmWithdrawlPolicy")); action.clearErrorsAndMessages(); action.setAffirmUncertainty(true); action.setAffirmConsent(true); action.setAffirmWithdrawlPolicy(true); action.validate(); assertFalse(action.hasFieldErrors()); }