Step4Action extends ConsentWizardAction { @Override public void validate() { super.validate(); if (!researchPermission) { addFieldError("researchPermission", getText(FIELD_REQUIRED_KEY)); } if (!redistributePermission) { addFieldError("redistributePermission", getText(FIELD_REQUIRED_KEY)); } if (!publishPermission) { addFieldError("publishPermission", getText(FIELD_REQUIRED_KEY)); } if (!commercializePermission) { addFieldError("commercializePermission", getText(FIELD_REQUIRED_KEY)); } }  @Override void validate(); boolean isResearchPermission(); void setResearchPermission(boolean researchPermission); boolean isRedistributePermission(); void setRedistributePermission(boolean redistributePermission); boolean isPublishPermission(); void setPublishPermission(boolean publishPermission); boolean isCommercializePermission(); void setCommercializePermission(boolean commercializePermission);  }
@Test public void validate() { Step4Action action = getTestAction(); assertFalse(action.isResearchPermission()); assertFalse(action.isRedistributePermission()); assertFalse(action.isPublishPermission()); assertFalse(action.isCommercializePermission()); action.validate(); assertTrue(action.hasFieldErrors()); assertEquals(4, action.getFieldErrors().size()); assertNotNull(action.getFieldErrors().get("researchPermission")); assertNotNull(action.getFieldErrors().get("redistributePermission")); assertNotNull(action.getFieldErrors().get("publishPermission")); assertNotNull(action.getFieldErrors().get("commercializePermission")); action.clearErrorsAndMessages(); action.setResearchPermission(true); action.setRedistributePermission(true); action.setPublishPermission(true); action.setCommercializePermission(true); action.validate(); assertFalse(action.hasFieldErrors()); }