RequiredValidator implements Validator { @Override public void validate(FacesContext context, UIComponent component, Object value) { if (UIInput.isEmpty(value)) { FacesMessage msg; String requiredMessageStr = null; if (component instanceof UIInput) { requiredMessageStr = ((UIInput) component).getRequiredMessage(); } if (requiredMessageStr != null) { msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessageStr, requiredMessageStr); } else { msg = MessageFactory.getMessage(context, UIInput.REQUIRED_MESSAGE_ID, MessageFactory.getLabel(context, component)); } throw new ValidatorException(msg); } }  @Override void validate(FacesContext context,
                         UIComponent component,
                         Object value); static final String VALIDATOR_ID; }
@Test public void testValidate() { RequiredValidator validator = new RequiredValidator(); validator.validate(null, null, "notempty"); }