Search in sources :

Example 1 with BeanWithByteArray

use of org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithByteArray 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());
}
Also used : BeanWithByteArray(org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithByteArray) 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

FieldValueSetter (org.apache.beam.sdk.schemas.FieldValueSetter)1 SetterTypeSupplier (org.apache.beam.sdk.schemas.JavaBeanSchema.SetterTypeSupplier)1 DefaultTypeConversionsFactory (org.apache.beam.sdk.schemas.utils.ByteBuddyUtils.DefaultTypeConversionsFactory)1 BeanWithByteArray (org.apache.beam.sdk.schemas.utils.TestJavaBeans.BeanWithByteArray)1 Test (org.junit.Test)1