Package org.apache.tapestry5

Examples of org.apache.tapestry5.ValidationTracker


    @Test
    public void label_when_field_not_in_error()
    {
        Environment env = mockEnvironment();
        Field field = mockField();
        ValidationTracker tracker = mockValidationTracker();

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, false);

        replay();
View Full Code Here


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");

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

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

        replay();

        ValidationTracker tracker = new ValidationTrackerImpl();

        tracker.recordError("one");
        tracker.recordInput(fieldb, "input b");
        tracker.recordError(fieldb, "fieldb: two");
        tracker.recordError("three");
        tracker.recordInput(fielda, "input a");
        tracker.recordError(fielda, "fielda: four");

        tracker.clear();

        assertFalse(tracker.getHasErrors());
        assertTrue(tracker.getErrors().isEmpty());
        assertNull(tracker.getInput(fielda));
        assertNull(tracker.getInput(fieldb));

        verify();
    }
View Full Code Here

public class FormTest extends TapestryTestCase
{
    @Test
    public void record_error()
    {
        ValidationTracker tracker = mockValidationTracker();
        String message = "A recorded message.";

        tracker.recordError(message);

        replay();

        Form form = new Form();
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.ValidationTracker

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.