Search in sources :

Example 1 with InternalPropertyConduit

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");
}
Also used : InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) PropBindingFactoryTest(org.apache.tapestry5.internal.bindings.PropBindingFactoryTest) Test(org.testng.annotations.Test)

Example 2 with InternalPropertyConduit

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");
}
Also used : InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) PropBindingFactoryTest(org.apache.tapestry5.internal.bindings.PropBindingFactoryTest) Test(org.testng.annotations.Test)

Example 3 with InternalPropertyConduit

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();
}
Also used : InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) PropertyConduit(org.apache.tapestry5.beanmodel.PropertyConduit) InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) Width(org.apache.tapestry5.beaneditor.Width) Test(org.testng.annotations.Test)

Example 4 with InternalPropertyConduit

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);
}
Also used : InternalPropertyConduit(org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit) Test(org.testng.annotations.Test)

Aggregations

InternalPropertyConduit (org.apache.tapestry5.beanmodel.internal.InternalPropertyConduit)4 Test (org.testng.annotations.Test)4 PropBindingFactoryTest (org.apache.tapestry5.internal.bindings.PropBindingFactoryTest)2 Width (org.apache.tapestry5.beaneditor.Width)1 PropertyConduit (org.apache.tapestry5.beanmodel.PropertyConduit)1