@Test public void unknown_validator_type() { Validator validator = mockValidator(); TypeCoercer coercer = mockTypeCoercer(); FieldComponent field = newFieldComponent(); ComponentResources resources = mockComponentResources(); Messages containerMessages = mockMessages(); Map<String, Validator> map = newMap(); ValidatorMacro macro = mockValidatorMacro(); train_getComponentResources(field, resources); train_getId(resources, "fred"); train_getContainerMessages(resources, containerMessages); train_alwaysNull(macro); map.put("alpha", validator); map.put("beta", validator); replay(); FieldValidatorSource source = new FieldValidatorSourceImpl(null, coercer, null, map, macro); try { source.createValidator(field, "foo", null); unreachable(); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage(), "Unknown validator type 'foo'. Configured validators are alpha, beta."); } verify(); }
public FieldValidator createValidator(Field field, String validatorType, String constraintValue) { Component component = (Component) field; assert InternalUtils.isNonBlank(validatorType); ComponentResources componentResources = component.getComponentResources(); String overrideId = componentResources.getId(); Messages overrideMessages = componentResources.getContainerMessages(); return createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, null); }
FieldValidatorSourceImpl implements FieldValidatorSource { public FieldValidator createValidator(Field field, String validatorType, String constraintValue) { Component component = (Component) field; assert InternalUtils.isNonBlank(validatorType); ComponentResources componentResources = component.getComponentResources(); String overrideId = componentResources.getId(); Messages overrideMessages = componentResources.getContainerMessages(); return createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, null); } }
FieldValidatorSourceImpl implements FieldValidatorSource { public FieldValidator createValidator(Field field, String validatorType, String constraintValue) { Component component = (Component) field; assert InternalUtils.isNonBlank(validatorType); ComponentResources componentResources = component.getComponentResources(); String overrideId = componentResources.getId(); Messages overrideMessages = componentResources.getContainerMessages(); return createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, null); } FieldValidatorSourceImpl(Messages globalMessages, TypeCoercer typeCoercer,
                                    FormSupport formSupport, Map<String, Validator> validators, ValidatorMacro validatorMacro); }
FieldValidatorSourceImpl implements FieldValidatorSource { public FieldValidator createValidator(Field field, String validatorType, String constraintValue) { Component component = (Component) field; assert InternalUtils.isNonBlank(validatorType); ComponentResources componentResources = component.getComponentResources(); String overrideId = componentResources.getId(); Messages overrideMessages = componentResources.getContainerMessages(); return createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, null); } FieldValidatorSourceImpl(Messages globalMessages, TypeCoercer typeCoercer,
                                    FormSupport formSupport, Map<String, Validator> validators, ValidatorMacro validatorMacro); FieldValidator createValidator(Field field, String validatorType, String constraintValue); FieldValidator createValidator(Field field, String validatorType, String constraintValue, String overrideId,
                                          Messages overrideMessages, Locale locale); FieldValidator createValidators(Field field, String specification); }
FieldValidatorSourceImpl implements FieldValidatorSource { public FieldValidator createValidator(Field field, String validatorType, String constraintValue) { Component component = (Component) field; assert InternalUtils.isNonBlank(validatorType); ComponentResources componentResources = component.getComponentResources(); String overrideId = componentResources.getId(); Messages overrideMessages = componentResources.getContainerMessages(); return createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, null); } FieldValidatorSourceImpl(Messages globalMessages, TypeCoercer typeCoercer,
                                    FormSupport formSupport, Map<String, Validator> validators, ValidatorMacro validatorMacro); FieldValidator createValidator(Field field, String validatorType, String constraintValue); FieldValidator createValidator(Field field, String validatorType, String constraintValue, String overrideId,
                                          Messages overrideMessages, Locale locale); FieldValidator createValidators(Field field, String specification);  }