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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations