Search in sources :

Example 1 with Label

use of org.apache.tapestry5.internal.plastic.asm.Label in project tapestry-5 by apache.

the class ComponentDefaultProviderImplTest method default_label_key_missing.

@Test
public void default_label_key_missing() {
    ComponentResources resources = mockComponentResources();
    ComponentResources container = mockComponentResources();
    Messages messages = mockMessages();
    String componentId = "myField";
    String key = componentId + "-label";
    train_getId(resources, componentId);
    train_getContainerResources(resources, container);
    train_getMessages(container, messages);
    train_contains(messages, key, false);
    replay();
    ComponentDefaultProvider provider = new ComponentDefaultProviderImpl(null, null, null, null, null);
    assertEquals(provider.defaultLabel(resources), "My Field");
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) ComponentResources(org.apache.tapestry5.ComponentResources) ComponentDefaultProvider(org.apache.tapestry5.services.ComponentDefaultProvider) Test(org.testng.annotations.Test)

Example 2 with Label

use of org.apache.tapestry5.internal.plastic.asm.Label in project tapestry-5 by apache.

the class AbstractBeanModelSourceImplTest method edit_property_label.

@Test
public void edit_property_label() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages).get("age").label("Decrepitude").model();
    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 3 with Label

use of org.apache.tapestry5.internal.plastic.asm.Label in project tapestry-5 by apache.

the class AbstractBeanModelSourceImplTest method composite_bean.

@Test
public void composite_bean() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    train_contains(messages, "simpleage-label", true);
    train_get(messages, "simpleage-label", "Years of Age");
    replay();
    BeanModel model = source.create(CompositeBean.class, true, messages);
    // No editor for CompositeBean, so this will be empty.
    assertEquals(model.getPropertyNames(), Collections.emptyList());
    // There's not editor for string arrays yet, so it won't show up normally.
    PropertyModel firstName = model.add("simple.firstName");
    assertEquals(firstName.getLabel(), "First Name");
    PropertyModel age = model.add("simple.age");
    assertEquals(age.getLabel(), "Years of Age");
    CompositeBean bean = new CompositeBean();
    firstName.getConduit().set(bean, "Fred");
    age.getConduit().set(bean, "97");
    assertEquals(bean.getSimple().getFirstName(), "Fred");
    assertEquals(bean.getSimple().getAge(), 97);
    bean.getSimple().setAge(24);
    assertEquals(age.getConduit().get(bean), new Integer(24));
    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 4 with Label

use of org.apache.tapestry5.internal.plastic.asm.Label 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 5 with Label

use of org.apache.tapestry5.internal.plastic.asm.Label in project tapestry-5 by apache.

the class PropertyConduitSourceImplTest method not_operator_in_subexpression.

@Test
public void not_operator_in_subexpression() {
    PropertyConduit conduit = source.create(Switch.class, "label(! value)");
    Switch sw = new Switch();
    assertEquals(conduit.get(sw), "aye");
    sw.setValue(true);
    assertEquals(conduit.get(sw), "nay");
}
Also used : PropertyConduit(org.apache.tapestry5.beanmodel.PropertyConduit) InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) PropBindingFactoryTest(org.apache.tapestry5.internal.bindings.PropBindingFactoryTest) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)26 Messages (org.apache.tapestry5.commons.Messages)15 Label (org.apache.tapestry5.internal.plastic.asm.Label)12 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)10 Field (org.apache.tapestry5.Field)9 OptionModel (org.apache.tapestry5.OptionModel)7 BeanModel (org.apache.tapestry5.beanmodel.BeanModel)6 FieldTranslator (org.apache.tapestry5.FieldTranslator)5 MarkupWriter (org.apache.tapestry5.MarkupWriter)5 Translator (org.apache.tapestry5.Translator)5 ValidationException (org.apache.tapestry5.ValidationException)5 FieldTranslatorSource (org.apache.tapestry5.services.FieldTranslatorSource)5 FormSupport (org.apache.tapestry5.services.FormSupport)5 TranslatorSource (org.apache.tapestry5.services.TranslatorSource)5 Locale (java.util.Locale)4 Map (java.util.Map)4 AnnotationProvider (org.apache.tapestry5.commons.AnnotationProvider)4 ComponentResources (org.apache.tapestry5.ComponentResources)3 OptionGroupModel (org.apache.tapestry5.OptionGroupModel)3 Element (org.apache.tapestry5.dom.Element)3