RuleValidator { public boolean validateFieldInline(String value, FormGroup field, HelpBlock help) { if (!isValid(value)) { field.setValidationState(ValidationState.ERROR); help.setText(getValidationError()); return false; } else { field.setValidationState(ValidationState.NONE); help.setText(""); return true; } }  abstract boolean isValid(String value); abstract String getValidationError(); boolean validateFieldInline(String value,
                                       FormGroup field,
                                       HelpBlock help);  }
@Test public void validRuleValidatorTest() { validRuleValidator.validateFieldInline(VALID_VALUE, field, help); verify(field).setValidationState(ValidationState.NONE); verify(help).setText(""); }
@Test public void invalidRuleValidatorTest() { invalidRuleValidator.validateFieldInline(INVALID_VALUE, field, help); verify(field).setValidationState(ValidationState.ERROR); verify(help).setText(ERROR_MESSAGE); }