Search in sources :

Example 16 with FieldValidatorSource

use of org.apache.tapestry5.services.FieldValidatorSource in project tapestry-5 by apache.

the class ValidateBindingFactoryTest method success.

@Test
public void success() {
    FieldValidatorSource source = mockFieldValidatorSource();
    ComponentResources container = mockComponentResources();
    ComponentResources component = mockComponentResources();
    FieldComponent instance = mockFieldComponent();
    Location l = mockLocation();
    FieldValidator validator = mockFieldValidator();
    String expression = "required,minLength=5";
    train_getComponent(component, instance);
    expect(source.createValidators(instance, expression)).andReturn(validator);
    replay();
    BindingFactory factory = new ValidateBindingFactory(source, interner);
    Binding binding = factory.newBinding("descrip", container, component, expression, l);
    assertSame(binding.get(), validator);
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) FieldValidatorSource(org.apache.tapestry5.services.FieldValidatorSource) FieldComponent(org.apache.tapestry5.root.FieldComponent) FieldValidator(org.apache.tapestry5.FieldValidator) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) BindingFactory(org.apache.tapestry5.services.BindingFactory) Test(org.testng.annotations.Test)

Aggregations

FieldValidatorSource (org.apache.tapestry5.services.FieldValidatorSource)16 Test (org.testng.annotations.Test)16 FieldValidator (org.apache.tapestry5.FieldValidator)15 Messages (org.apache.tapestry5.commons.Messages)14 ComponentResources (org.apache.tapestry5.ComponentResources)13 Validator (org.apache.tapestry5.Validator)11 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)11 ValidatorMacro (org.apache.tapestry5.validator.ValidatorMacro)11 FormSupport (org.apache.tapestry5.services.FormSupport)10 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)9 Locale (java.util.Locale)3 Field (org.apache.tapestry5.Field)3 AnnotationProvider (org.apache.tapestry5.commons.AnnotationProvider)3 FieldValidatorDefaultSource (org.apache.tapestry5.services.FieldValidatorDefaultSource)3 ValidationConstraintGenerator (org.apache.tapestry5.services.ValidationConstraintGenerator)3 Location (org.apache.tapestry5.commons.Location)2 FieldComponent (org.apache.tapestry5.root.FieldComponent)2 BindingFactory (org.apache.tapestry5.services.BindingFactory)2 Binding (org.apache.tapestry5.Binding)1 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)1