Search in sources :

Example 1 with BeanWithBoxedFields

use of org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithBoxedFields in project beam by apache.

the class JavaBeanUtilsTest method testGeneratedSimpleBoxedGetters.

@Test
public void testGeneratedSimpleBoxedGetters() {
    BeanWithBoxedFields bean = new BeanWithBoxedFields();
    bean.setaByte((byte) 41);
    bean.setaShort((short) 42);
    bean.setAnInt(43);
    bean.setaLong(44L);
    bean.setaBoolean(true);
    List<FieldValueGetter> getters = JavaBeanUtils.getGetters(BeanWithBoxedFields.class, BEAN_WITH_BOXED_FIELDS_SCHEMA, new JavaBeanSchema.GetterTypeSupplier(), new DefaultTypeConversionsFactory());
    assertEquals((byte) 41, getters.get(0).get(bean));
    assertEquals((short) 42, getters.get(1).get(bean));
    assertEquals((int) 43, getters.get(2).get(bean));
    assertEquals((long) 44, getters.get(3).get(bean));
    assertTrue((Boolean) getters.get(4).get(bean));
}
Also used : FieldValueGetter(org.apache.beam.sdk.schemas.FieldValueGetter) JavaBeanSchema(org.apache.beam.sdk.schemas.JavaBeanSchema) BeanWithBoxedFields(org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithBoxedFields) DefaultTypeConversionsFactory(org.apache.beam.sdk.schemas.utils.ByteBuddyUtils.DefaultTypeConversionsFactory) GetterTypeSupplier(org.apache.beam.sdk.schemas.JavaBeanSchema.GetterTypeSupplier) Test(org.junit.Test)

Example 2 with BeanWithBoxedFields

use of org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithBoxedFields in project beam by apache.

the class JavaBeanUtilsTest method testGeneratedSimpleBoxedSetters.

@Test
public void testGeneratedSimpleBoxedSetters() {
    BeanWithBoxedFields bean = new BeanWithBoxedFields();
    List<FieldValueSetter> setters = JavaBeanUtils.getSetters(BeanWithBoxedFields.class, BEAN_WITH_BOXED_FIELDS_SCHEMA, new SetterTypeSupplier(), new DefaultTypeConversionsFactory());
    setters.get(0).set(bean, (byte) 41);
    setters.get(1).set(bean, (short) 42);
    setters.get(2).set(bean, (int) 43);
    setters.get(3).set(bean, (long) 44);
    setters.get(4).set(bean, true);
    assertEquals((byte) 41, bean.getaByte().byteValue());
    assertEquals((short) 42, bean.getaShort().shortValue());
    assertEquals((int) 43, bean.getAnInt().intValue());
    assertEquals((long) 44, bean.getaLong().longValue());
    assertTrue(bean.getaBoolean().booleanValue());
}
Also used : BeanWithBoxedFields(org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithBoxedFields) DefaultTypeConversionsFactory(org.apache.beam.sdk.schemas.utils.ByteBuddyUtils.DefaultTypeConversionsFactory) FieldValueSetter(org.apache.beam.sdk.schemas.FieldValueSetter) SetterTypeSupplier(org.apache.beam.sdk.schemas.JavaBeanSchema.SetterTypeSupplier) Test(org.junit.Test)

Aggregations

DefaultTypeConversionsFactory (org.apache.beam.sdk.schemas.utils.ByteBuddyUtils.DefaultTypeConversionsFactory)2 BeanWithBoxedFields (org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithBoxedFields)2 Test (org.junit.Test)2 FieldValueGetter (org.apache.beam.sdk.schemas.FieldValueGetter)1 FieldValueSetter (org.apache.beam.sdk.schemas.FieldValueSetter)1 JavaBeanSchema (org.apache.beam.sdk.schemas.JavaBeanSchema)1 GetterTypeSupplier (org.apache.beam.sdk.schemas.JavaBeanSchema.GetterTypeSupplier)1 SetterTypeSupplier (org.apache.beam.sdk.schemas.JavaBeanSchema.SetterTypeSupplier)1