use of org.apache.beam.sdk.schemas.FieldValueSetter 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());
}
use of org.apache.beam.sdk.schemas.FieldValueSetter 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());
}
use of org.apache.beam.sdk.schemas.FieldValueSetter in project beam by apache.
the class JavaBeanUtilsTest method testGeneratedByteBufferSetters.
@Test
public void testGeneratedByteBufferSetters() {
BeanWithByteArray bean = new BeanWithByteArray();
List<FieldValueSetter> setters = JavaBeanUtils.getSetters(BeanWithByteArray.class, BEAN_WITH_BYTE_ARRAY_SCHEMA, new SetterTypeSupplier(), new DefaultTypeConversionsFactory());
setters.get(0).set(bean, "field1".getBytes(StandardCharsets.UTF_8));
setters.get(1).set(bean, "field2".getBytes(StandardCharsets.UTF_8));
assertArrayEquals("not equal", "field1".getBytes(StandardCharsets.UTF_8), bean.getBytes1());
assertEquals(ByteBuffer.wrap("field2".getBytes(StandardCharsets.UTF_8)), bean.getBytes2());
}
Aggregations