use of org.apache.tapestry5.beanmodel.PropertyModel 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();
}
use of org.apache.tapestry5.beanmodel.PropertyModel in project tapestry-5 by apache.
the class AbstractBeanModelSourceImplTest method add_before_using_default_conduit.
@Test
public void add_before_using_default_conduit() {
Messages messages = mockMessages();
stub_contains(messages, false);
replay();
BeanModel model = source.create(SimpleBean.class, true, messages);
model.exclude("firstname");
assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age"));
// Note the use of case insensitivity here.
PropertyModel property = model.add(RelativePosition.BEFORE, "lastname", "firstName");
assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));
assertEquals(property.getPropertyName(), "firstName");
assertSame(property.getPropertyType(), String.class);
verify();
}
use of org.apache.tapestry5.beanmodel.PropertyModel 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();
}
use of org.apache.tapestry5.beanmodel.PropertyModel 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;
}
use of org.apache.tapestry5.beanmodel.PropertyModel in project tapestry-5 by apache.
the class BeanModelImpl method add.
public PropertyModel add(RelativePosition position, String existingPropertyName, String propertyName, PropertyConduit conduit) {
assert position != null;
validateNewPropertyName(propertyName);
// Locate the existing one.
PropertyModel existing = get(existingPropertyName);
// Use the case normalized property name.
int pos = propertyNames.indexOf(existing.getPropertyName());
PropertyModel newModel = new PropertyModelImpl(this, propertyName, conduit, messages);
properties.put(propertyName, newModel);
int offset = position == RelativePosition.AFTER ? 1 : 0;
propertyNames.add(pos + offset, propertyName);
return newModel;
}
Aggregations