Search in sources :

Example 6 with ValidationTrackerImpl

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

the class ValidationTrackerImplTest method record_error_for_form.

@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"));
}
Also used : ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Example 7 with ValidationTrackerImpl

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

the class ValidationTrackerImplTest method data_survives_serialization.

@Test
public void data_survives_serialization() throws Exception {
    Field fielda = newFieldWithControlName("fieldA");
    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"));
    verify();
}
Also used : Field(org.apache.tapestry5.Field) ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Example 8 with ValidationTrackerImpl

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

the class ValidationTrackerImplTest method record_input.

@Test
public void record_input() {
    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();
}
Also used : Field(org.apache.tapestry5.Field) ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Example 9 with ValidationTrackerImpl

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

the class ValidationTrackerImplTest method order_added_is_maintained.

@Test
public void order_added_is_maintained() {
    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"));
    verify();
}
Also used : Field(org.apache.tapestry5.Field) ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Aggregations

ValidationTrackerImpl (org.apache.tapestry5.ValidationTrackerImpl)9 ValidationTracker (org.apache.tapestry5.ValidationTracker)8 Test (org.testng.annotations.Test)8 Field (org.apache.tapestry5.Field)6 ComponentActionSink (org.apache.tapestry5.corelib.internal.ComponentActionSink)1 HiddenFieldPositioner (org.apache.tapestry5.corelib.internal.HiddenFieldPositioner)1