ValidationRule extends AbstractRuleHolder { @Override public String toString() { String rule = "<rule "; if (path != null && path.length() > 0) { rule += "path=\"" + path + "\" "; } if (type != null && type.length() > 0) { rule += "type=\"" + type + "\" "; } if (value != null && value.length() > 0) { rule += "value=\"" + value + "\" "; } if (message != null && message.length() > 0) { rule += "message=\"" + message + "\" "; } if (messageText != null && messageText.length() > 0) { rule += "messageText=\"" + messageText + "\" "; } if (errorPath != null && errorPath.length() > 0) { rule += "errorPath=\"" + errorPath + "\" "; } if (collectionStrategy != null) { rule += "collectionStrategy=\"" + collectionStrategy.getXmlValue() + "\" "; } if (onFail != null) { rule += "onFail=\"" + onFail.getXmlValue() + "\" "; } rule += "/>"; return rule; } ValidationRule();  ValidationRule(String path, String type, String value); boolean hasChildren(); @Override String toString(); String getPath(); void setPath(String path); String getType(); void setType(String type); RuleExecutor<?, ?> getRuleExecutor(); void setRuleExecutor(RuleExecutor<?, ?> ruleExecutor); void setHandler(RuleExecutor<?, ?> handlerImpl); void setHandler(String handlerName); String getValue(); void setValue(String value); void setArgument(String value); synchronized String getMessage(); synchronized void setMessage(String message); synchronized void setMessageCode(String message); String getMessageText(); void setMessageText(String messageText); String getErrorPath(); void setErrorPath(String errorPath); CollectionStrategy getCollectionStrategy(); void setCollectionStrategy(CollectionStrategy collectionStrategy); RuleErrorMode getOnFail(); void setOnFail(RuleErrorMode onFail);  }
@Test public void testToString() { ValidationRule rule = new ValidationRule("", "", ""); assertEquals("<rule />", rule.toString()); rule.setPath("path"); assertEquals("<rule path=\"path\" />", rule.toString()); rule.setType("type"); assertEquals("<rule path=\"path\" type=\"type\" />", rule.toString()); rule.setValue("value"); assertEquals("<rule path=\"path\" type=\"type\" value=\"value\" />", rule.toString()); rule.setMessage("message"); assertEquals("<rule path=\"path\" type=\"type\" value=\"value\" " + "message=\"message\" />", rule.toString()); rule.setErrorPath("errorPath"); assertEquals("<rule path=\"path\" type=\"type\" value=\"value\" " + "message=\"message\" errorPath=\"errorPath\" />", rule.toString()); }