use of org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit in project tapestry-5 by apache.
the class PropertyConduitSourceImplTest method method_names_are_matched_caselessly.
@Test
public void method_names_are_matched_caselessly() {
InternalPropertyConduit conduit = (InternalPropertyConduit) source.create(CompositeBean.class, "GETSIMPLE().firstName");
assertEquals(conduit.getPropertyName(), "firstName");
CompositeBean bean = new CompositeBean();
SimpleBean inner = new SimpleBean();
bean.setSimple(inner);
conduit.set(bean, "Howard");
assertEquals(inner.getFirstName(), "Howard");
}
use of org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit in project tapestry-5 by apache.
the class PropertyConduitSourceImplTest method question_dot_operator_for_object_type.
@Test
public void question_dot_operator_for_object_type() {
InternalPropertyConduit normal = (InternalPropertyConduit) source.create(CompositeBean.class, "simple.firstName");
InternalPropertyConduit smart = (InternalPropertyConduit) source.create(CompositeBean.class, "simple?.firstName");
CompositeBean bean = new CompositeBean();
bean.setSimple(null);
assertEquals(normal.getPropertyName(), "firstName");
assertEquals(smart.getPropertyName(), "firstName");
try {
normal.get(bean);
unreachable();
} catch (NullPointerException ex) {
// Expected.
}
assertNull(smart.get(bean));
try {
normal.set(bean, "Howard");
unreachable();
} catch (NullPointerException ex) {
// Expected.
}
// This will be a no-op due to the null property in the expression
smart.set(bean, "Howard");
}
use of org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit in project tapestry-5 by apache.
the class TapestryInternalUtilsTest method to_internal_property_conduit_wrapper.
@Test
public void to_internal_property_conduit_wrapper() {
PropertyConduit conduit = mockPropertyConduit();
Integer result = 123;
Width width = newMock(Width.class);
expect(conduit.get("")).andReturn(result);
expect(conduit.getAnnotation(Width.class)).andReturn(width);
expect(conduit.getPropertyType()).andReturn(Integer.class);
conduit.set("", 345);
replay();
InternalPropertyConduit conduit2 = TapestryInternalUtils.toInternalPropertyConduit(conduit);
assertNull(conduit2.getPropertyName());
assertSame(conduit2.get(""), result);
assertSame(conduit2.getAnnotation(Width.class), width);
assertSame(conduit2.getPropertyType(), Integer.class);
conduit2.set("", 345);
verify();
}
use of org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit in project tapestry-5 by apache.
the class TapestryInternalUtilsTest method to_internal_property_conduit_no_wrapper_needed.
@Test
public void to_internal_property_conduit_no_wrapper_needed() {
InternalPropertyConduit conduit2 = newMock(InternalPropertyConduit.class);
assertSame(TapestryInternalUtils.toInternalPropertyConduit(conduit2), conduit2);
}
Aggregations