Search in sources :

Example 16 with Messages

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

the class AbstractBeanModelSourceImplTest method unknown_property_name.

@Test
public void unknown_property_name() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    try {
        model.get("frobozz");
        unreachable();
    } catch (UnknownValueException ex) {
        assertEquals(ex.getMessage(), "Bean editor model for org.apache.tapestry5.internal.services.SimpleBean does not contain a property named \'frobozz\'.");
        assertListsEquals(ex.getAvailableValues().getValues(), "age", "firstName", "lastName");
    }
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) UnknownValueException(org.apache.tapestry5.commons.util.UnknownValueException) Test(org.testng.annotations.Test)

Example 17 with Messages

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

the class AbstractBeanModelSourceImplTest method include_properties.

@Test
public void include_properties() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    assertSame(model.getBeanType(), SimpleBean.class);
    model.include("lastname", "firstname");
    // Based on order of the getter methods (no longer alphabetical)
    assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "firstName"));
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Test(org.testng.annotations.Test)

Example 18 with Messages

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

the class AbstractBeanModelSourceImplTest method label_from_component_messages.

@Test
public void label_from_component_messages() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    train_contains(messages, "age-label", true);
    train_get(messages, "age-label", "Decrepitude");
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    assertEquals(model.get("age").getLabel(), "Decrepitude");
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Test(org.testng.annotations.Test)

Example 19 with Messages

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

the class AbstractBeanModelSourceImplTest method add_duplicate_property_name_is_failure.

@Test
public void add_duplicate_property_name_is_failure() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    try {
        model.add("age");
        unreachable();
    } catch (RuntimeException ex) {
        assertEquals(ex.getMessage(), "Bean editor model for org.apache.tapestry5.internal.services.SimpleBean already contains a property model for property \'age\'.");
    }
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Test(org.testng.annotations.Test)

Example 20 with Messages

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

the class AbstractBeanModelSourceImplTest method get_added_property_by_name.

@Test
public void get_added_property_by_name() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    PropertyModel pm = model.addEmpty("shrub.foo()");
    assertSame(model.get("Shrub.Foo()"), pm);
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel) Test(org.testng.annotations.Test)

Aggregations

Messages (org.apache.tapestry5.commons.Messages)111 Test (org.testng.annotations.Test)102 BeanModel (org.apache.tapestry5.beanmodel.BeanModel)54 ComponentResources (org.apache.tapestry5.ComponentResources)23 PropertyModel (org.apache.tapestry5.beanmodel.PropertyModel)21 FieldValidator (org.apache.tapestry5.FieldValidator)18 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)15 FormSupport (org.apache.tapestry5.services.FormSupport)15 FieldValidatorSource (org.apache.tapestry5.services.FieldValidatorSource)14 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)13 Validator (org.apache.tapestry5.Validator)12 Locale (java.util.Locale)11 ValidatorMacro (org.apache.tapestry5.validator.ValidatorMacro)11 Field (org.apache.tapestry5.Field)10 PropertyConduit (org.apache.tapestry5.beanmodel.PropertyConduit)9 AnnotationProvider (org.apache.tapestry5.commons.AnnotationProvider)9 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)7 FieldTranslatorSource (org.apache.tapestry5.services.FieldTranslatorSource)7 TranslatorSource (org.apache.tapestry5.services.TranslatorSource)6 Map (java.util.Map)5