Search in sources :

Example 26 with Messages

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

the class AbstractBeanModelSourceImplTest method default_properties_exclude_write_only.

@Test
public void default_properties_exclude_write_only() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(WriteOnlyBean.class, false, messages);
    assertEquals(model.getPropertyNames(), Arrays.asList("readOnly", "readWrite"));
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Test(org.testng.annotations.Test)

Example 27 with Messages

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

the class AbstractBeanModelSourceImplTest method sortable_annotation.

// https://issues.apache.org/jira/browse/TAP5-2305
@Test
public void sortable_annotation() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel<SortableBean> model = source.createDisplayModel(SortableBean.class, messages);
    model.add("nonSortableByDefault");
    model.add("sortable");
    // checking whether non-@Sortable annotated properties still behave in the old ways
    assertTrue(model.get("sortableByDefault").isSortable());
    assertFalse(model.get("nonSortableByDefault").isSortable());
    // checking @Sortable itself
    assertFalse(model.get("nonSortable").isSortable());
    assertTrue(model.get("sortable").isSortable());
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) Test(org.testng.annotations.Test)

Example 28 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)

Example 29 with Messages

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

the class AbstractBeanModelSourceImplTest method order_via_annotation.

@Test
public void order_via_annotation() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(StoogeBean.class, true, messages);
    assertEquals(model.getPropertyNames(), Arrays.asList("larry", "moe", "shemp", "curly"));
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Test(org.testng.annotations.Test)

Example 30 with Messages

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

the class BeanModelImpl method add.

public PropertyModel add(String propertyName, PropertyConduit conduit) {
    validateNewPropertyName(propertyName);
    PropertyModel propertyModel = new PropertyModelImpl(this, propertyName, conduit, messages);
    properties.put(propertyName, propertyModel);
    // Remember the order in which the properties were added.
    propertyNames.add(propertyName);
    return propertyModel;
}
Also used : PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel)

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