Search in sources :

Example 1 with Html5Support

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

the class EmailTest method input_mismatch.

@Test
public void input_mismatch() throws Exception {
    Field field = mockField();
    MessageFormatter formatter = mockMessageFormatter();
    Html5Support html5Support = mockHtml5Support();
    replay();
    Email validator = new Email(null, html5Support);
    try {
        validator.validate(field, null, formatter, "invalid_email");
        unreachable();
    } catch (ValidationException ex) {
    }
    try {
        validator.validate(field, null, formatter, "@mail.com");
        unreachable();
    } catch (ValidationException ex) {
    }
    // TAP5-2282
    try {
        validator.validate(field, null, formatter, "aaa@bbb/cc");
        unreachable();
    } catch (ValidationException ex) {
    }
    verify();
}
Also used : Field(org.apache.tapestry5.Field) Html5Support(org.apache.tapestry5.services.Html5Support) ValidationException(org.apache.tapestry5.ValidationException) MessageFormatter(org.apache.tapestry5.commons.MessageFormatter) Test(org.testng.annotations.Test)

Example 2 with Html5Support

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

the class RequiredTest method blank_value.

@Test
public void blank_value() {
    MessageFormatter formatter = mockMessageFormatter();
    Field field = mockFieldWithLabel("My Field");
    train_format(formatter, "{message}", "My Field");
    Html5Support html5Support = mockHtml5Support();
    replay();
    try {
        new Required(null, html5Support).validate(field, null, formatter, "");
        unreachable();
    } catch (ValidationException ex) {
        assertEquals(ex.getMessage(), "{message}");
    }
    verify();
}
Also used : Field(org.apache.tapestry5.Field) Html5Support(org.apache.tapestry5.services.Html5Support) ValidationException(org.apache.tapestry5.ValidationException) MessageFormatter(org.apache.tapestry5.commons.MessageFormatter) Test(org.testng.annotations.Test)

Example 3 with Html5Support

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

the class RequiredTest method empty_collection_value.

@Test
public void empty_collection_value() {
    MessageFormatter formatter = mockMessageFormatter();
    Field field = mockFieldWithLabel("My Field");
    train_format(formatter, "{message}", "My Field");
    Html5Support html5Support = mockHtml5Support();
    replay();
    try {
        new Required(null, html5Support).validate(field, null, formatter, Arrays.asList());
        unreachable();
    } catch (ValidationException ex) {
        assertEquals(ex.getMessage(), "{message}");
    }
    verify();
}
Also used : Field(org.apache.tapestry5.Field) Html5Support(org.apache.tapestry5.services.Html5Support) ValidationException(org.apache.tapestry5.ValidationException) MessageFormatter(org.apache.tapestry5.commons.MessageFormatter) Test(org.testng.annotations.Test)

Example 4 with Html5Support

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

the class RequiredTest method non_blank_value.

@Test
public void non_blank_value() throws Exception {
    MessageFormatter formatter = mockMessageFormatter();
    Field field = mockField();
    Html5Support html5Support = mockHtml5Support();
    replay();
    new Required(null, html5Support).validate(field, null, formatter, "not null");
    verify();
}
Also used : Field(org.apache.tapestry5.Field) Html5Support(org.apache.tapestry5.services.Html5Support) MessageFormatter(org.apache.tapestry5.commons.MessageFormatter) Test(org.testng.annotations.Test)

Example 5 with Html5Support

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

the class RequiredTest method not_empty_collection_value.

@Test
public void not_empty_collection_value() throws Exception {
    MessageFormatter formatter = mockMessageFormatter();
    Field field = mockField();
    Html5Support html5Support = mockHtml5Support();
    replay();
    new Required(null, html5Support).validate(field, null, formatter, Arrays.asList("A", "B"));
    verify();
}
Also used : Field(org.apache.tapestry5.Field) Html5Support(org.apache.tapestry5.services.Html5Support) MessageFormatter(org.apache.tapestry5.commons.MessageFormatter) Test(org.testng.annotations.Test)

Aggregations

Field (org.apache.tapestry5.Field)7 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)7 Html5Support (org.apache.tapestry5.services.Html5Support)7 Test (org.testng.annotations.Test)7 ValidationException (org.apache.tapestry5.ValidationException)4 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 NumericTranslator (org.apache.tapestry5.internal.translator.NumericTranslator)1 StringTranslator (org.apache.tapestry5.internal.translator.StringTranslator)1