Search in sources :

Example 6 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 7 with Messages

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

the class AbstractBeanModelSourceImplTest method exclude_property.

@Test
public void exclude_property() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    assertSame(model.exclude("age"), model);
    assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName"));
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Test(org.testng.annotations.Test)

Example 8 with Messages

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

the class AbstractBeanModelSourceImplTest method reorder.

@Test
public void reorder() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    assertSame(model.getBeanType(), SimpleBean.class);
    // Based on order of the getter methods (no longer alphabetical)
    assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
    // Testing a couple of things here:
    // 1) case insensitive
    // 2) unreferenced property names added to the end.
    model.reorder("lastname", "AGE");
    assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age", "firstName"));
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) Test(org.testng.annotations.Test)

Example 9 with Messages

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

the class AbstractBeanModelSourceImplTest method array_type_bean.

@Test
public void array_type_bean() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(StringArrayBean.class, true, messages);
    // There's not editor for string arrays yet, so it won't show up normally.
    PropertyModel propertyModel = model.add("array");
    assertSame(propertyModel.getPropertyType(), String[].class);
    String[] value = { "foo", "bar" };
    StringArrayBean bean = new StringArrayBean();
    PropertyConduit conduit = propertyModel.getConduit();
    conduit.set(bean, value);
    assertSame(bean.getArray(), value);
    assertSame(conduit.get(bean), value);
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel) PropertyConduit(org.apache.tapestry5.beanmodel.PropertyConduit) Test(org.testng.annotations.Test)

Example 10 with Messages

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

the class AbstractBeanModelSourceImplTest method add_after.

@Test
public void add_after() {
    Messages messages = mockMessages();
    PropertyConduit conduit = mockPropertyConduit();
    Class propertyType = String.class;
    stub_contains(messages, false);
    expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
    expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
    PropertyModel property = model.add(RelativePosition.AFTER, "firstname", "middleInitial", conduit);
    assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "middleInitial", "lastName", "age"));
    assertEquals(property.getPropertyName(), "middleInitial");
    assertSame(property.getConduit(), conduit);
    assertSame(property.getPropertyType(), propertyType);
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel) BeforeClass(org.testng.annotations.BeforeClass) PropertyConduit(org.apache.tapestry5.beanmodel.PropertyConduit) 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