Search in sources :

Example 1 with POJOWithBoxedFields

use of org.apache.beam.sdk.schemas.utils.TestPOJOs.POJOWithBoxedFields in project beam by apache.

the class POJOUtilsTest method testGeneratedSimpleBoxedGetters.

@Test
public void testGeneratedSimpleBoxedGetters() {
    POJOWithBoxedFields pojo = new POJOWithBoxedFields((byte) 41, (short) 42, 43, 44L, true);
    List<FieldValueGetter> getters = POJOUtils.getGetters(POJOWithBoxedFields.class, POJO_WITH_BOXED_FIELDS_SCHEMA, JavaFieldTypeSupplier.INSTANCE, new DefaultTypeConversionsFactory());
    assertEquals((byte) 41, getters.get(0).get(pojo));
    assertEquals((short) 42, getters.get(1).get(pojo));
    assertEquals((int) 43, getters.get(2).get(pojo));
    assertEquals((long) 44, getters.get(3).get(pojo));
    assertTrue((Boolean) getters.get(4).get(pojo));
}
Also used : FieldValueGetter(org.apache.beam.sdk.schemas.FieldValueGetter) DefaultTypeConversionsFactory(org.apache.beam.sdk.schemas.utils.ByteBuddyUtils.DefaultTypeConversionsFactory) POJOWithBoxedFields(org.apache.beam.sdk.schemas.utils.TestPOJOs.POJOWithBoxedFields) Test(org.junit.Test)

Example 2 with POJOWithBoxedFields

use of org.apache.beam.sdk.schemas.utils.TestPOJOs.POJOWithBoxedFields in project beam by apache.

the class POJOUtilsTest method testGeneratedSimpleBoxedSetters.

@Test
public void testGeneratedSimpleBoxedSetters() {
    POJOWithBoxedFields pojo = new POJOWithBoxedFields();
    List<FieldValueSetter> setters = POJOUtils.getSetters(POJOWithBoxedFields.class, POJO_WITH_BOXED_FIELDS_SCHEMA, JavaFieldTypeSupplier.INSTANCE, new DefaultTypeConversionsFactory());
    setters.get(0).set(pojo, (byte) 41);
    setters.get(1).set(pojo, (short) 42);
    setters.get(2).set(pojo, (int) 43);
    setters.get(3).set(pojo, (long) 44);
    setters.get(4).set(pojo, true);
    assertEquals((byte) 41, pojo.aByte.byteValue());
    assertEquals((short) 42, pojo.aShort.shortValue());
    assertEquals((int) 43, pojo.anInt.intValue());
    assertEquals((long) 44, pojo.aLong.longValue());
    assertTrue(pojo.aBoolean.booleanValue());
}
Also used : DefaultTypeConversionsFactory(org.apache.beam.sdk.schemas.utils.ByteBuddyUtils.DefaultTypeConversionsFactory) FieldValueSetter(org.apache.beam.sdk.schemas.FieldValueSetter) POJOWithBoxedFields(org.apache.beam.sdk.schemas.utils.TestPOJOs.POJOWithBoxedFields) Test(org.junit.Test)

Aggregations

DefaultTypeConversionsFactory (org.apache.beam.sdk.schemas.utils.ByteBuddyUtils.DefaultTypeConversionsFactory)2 POJOWithBoxedFields (org.apache.beam.sdk.schemas.utils.TestPOJOs.POJOWithBoxedFields)2 Test (org.junit.Test)2 FieldValueGetter (org.apache.beam.sdk.schemas.FieldValueGetter)1 FieldValueSetter (org.apache.beam.sdk.schemas.FieldValueSetter)1