Package org.apache.tapestry5

Examples of org.apache.tapestry5.ValidationTrackerImpl$FieldTracker


public class ValidationTrackerImplTest extends TapestryTestCase
{
    @Test
    public void empty_tracker_has_no_errors()
    {
        ValidationTracker tracker = new ValidationTrackerImpl();

        assertTrue(tracker.getErrors().isEmpty());
        assertFalse(tracker.getHasErrors());
    }
View Full Code Here


        Field fielda = newFieldWithControlName("fieldA");
        Field fieldb = newFieldWithControlName("fieldB");

        replay();

        ValidationTracker tracker = new ValidationTrackerImpl();

        tracker.recordError("one");
        tracker.recordError(fieldb, "fieldb: two");
        tracker.recordError("three");
        tracker.recordError(fielda, "fielda: four");

        assertEquals(tracker.getErrors(), Arrays.asList(
                "one",
                "three",
                "fieldb: two",
                "fielda: four"));
View Full Code Here

    {
        Field field = newFieldWithControlName("field");

        replay();

        ValidationTracker tracker = new ValidationTrackerImpl();

        assertNull(tracker.getInput(field));

        tracker.recordInput(field, "one");

        assertEquals(tracker.getInput(field), "one");

        tracker.recordInput(field, "two");

        assertEquals(tracker.getInput(field), "two");

        verify();
    }
View Full Code Here

    {
        Field field = newFieldWithControlName("field");

        replay();

        ValidationTracker tracker = new ValidationTrackerImpl();

        assertFalse(tracker.getHasErrors());
        assertFalse(tracker.inError(field));
        assertNull(tracker.getError(field));

        tracker.recordError(field, "one");

        assertTrue(tracker.getHasErrors());
        assertTrue(tracker.inError(field));
        assertEquals(tracker.getError(field), "one");

        tracker.recordError(field, "two");
        assertEquals(tracker.getError(field), "two");

        verify();
    }
View Full Code Here

    }

    @Test
    public void unsassoicated_errors_listed_first() {

        ValidationTracker tracker = new ValidationTrackerImpl();

        Field field = newFieldWithControlName("field");

        replay();

        tracker.recordError(field, "one");

        tracker.recordError("two");

        assertEquals(tracker.getErrors(), Arrays.asList("two", "one"));

        assertEquals(tracker.getUnassociatedErrors(), Arrays.asList("two"));

        verify();
    }
View Full Code Here

    }

    @Test
    public void record_error_for_form()
    {
        ValidationTracker tracker = new ValidationTrackerImpl();

        assertFalse(tracker.getHasErrors());

        assertTrue(tracker.getErrors().isEmpty());

        tracker.recordError("one");

        assertEquals(tracker.getErrors(), Arrays.asList("one"));

        tracker.recordError("two");

        assertEquals(tracker.getErrors(), Arrays.asList("one", "two"));
    }
View Full Code Here

        Field fieldb = newFieldWithControlName("fieldB");
        Field fieldc = newFieldWithControlName("fieldC");

        replay();

        ValidationTracker tracker = new ValidationTrackerImpl();

        tracker.recordError("one");
        tracker.recordError(fieldb, "fieldb: two");
        tracker.recordError("three");
        tracker.recordError(fielda, "fielda: four");

        ValidationTracker copy = cloneBySerialiation(tracker);

        copy.recordError(fieldc, "fieldc: five");
View Full Code Here

        actionSink = new ComponentActionSink(logger, clientDataEncoder);

        formSupport = createInternalFormSupport(formClientId, formComponentId, actionSink);

        environment.push(FormSupport.class, formSupport);
        environment.push(ValidationTracker.class, new ValidationTrackerImpl());

        heartbeat.begin();
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void validator_with_no_constraint() throws Exception
    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        FormSupport fs = mockFormSupport();

        Map<String, Validator> map = singletonMap("required", validator);

        train_getConstraintType(validator, null);

        train_getFormValidationId(fs, "form");

        train_getComponentResources(field, resources);

        train_getId(resources, "fred");
        train_getContainerMessages(resources, containerMessages);
        train_contains(containerMessages, "form-fred-required-message", false);
        train_contains(containerMessages, "fred-required-message", false);

        train_getLocale(resources, Locale.FRENCH);

        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);

        train_getMessageKey(validator, "key");
        train_getMessageFormatter(messages, "key", formatter);

        train_isRequired(validator, false);
        train_getValueType(validator, Object.class);
        validator.validate(field, null, formatter, inputValue);

        replay();

        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, null);
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void component_messages_overrides_validator_messages() throws Exception
    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        FormSupport fs = mockFormSupport();

        Map<String, Validator> map = singletonMap("required", validator);

        train_getConstraintType(validator, null);

        train_getFormValidationId(fs, "form");

        train_getComponentResources(field, resources);
        train_getId(resources, "fred");
        train_getLocale(resources, Locale.ENGLISH);
        train_getContainerMessages(resources, containerMessages);

        train_contains(containerMessages, "form-fred-required-message", false);
        train_contains(containerMessages, "fred-required-message", true);

        train_getMessageFormatter(containerMessages, "fred-required-message", formatter);

        train_isRequired(validator, false);
        train_getValueType(validator, Object.class);
        validator.validate(field, null, formatter, inputValue);

        replay();

        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, null);
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.ValidationTrackerImpl$FieldTracker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.