Search in sources :

Example 1 with DefaultCoderProvider

use of org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider in project beam by apache.

the class DefaultCoderTest method testUnknown.

@Test
public void testUnknown() throws Exception {
    thrown.expect(CannotProvideCoderException.class);
    new DefaultCoderProvider().coderFor(TypeDescriptor.of(Unknown.class), Collections.<Coder<?>>emptyList());
}
Also used : DefaultCoderProvider(org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider) Test(org.junit.Test)

Example 2 with DefaultCoderProvider

use of org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider in project beam by apache.

the class DefaultCoderTest method testDefaultCoderInCollection.

@Test
public void testDefaultCoderInCollection() throws Exception {
    CoderRegistry registry = CoderRegistry.createDefault();
    registry.registerCoderProvider(new DefaultCoderProvider());
    Coder<List<AvroRecord>> avroRecordCoder = registry.getCoder(new TypeDescriptor<List<AvroRecord>>() {
    });
    assertThat(avroRecordCoder, instanceOf(ListCoder.class));
    assertThat(((ListCoder) avroRecordCoder).getElemCoder(), instanceOf(AvroCoder.class));
    assertThat(registry.getCoder(new TypeDescriptor<List<SerializableRecord>>() {
    }), Matchers.<Coder<List<SerializableRecord>>>equalTo(ListCoder.of(SerializableCoder.of(SerializableRecord.class))));
}
Also used : DefaultCoderProvider(org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider) TypeDescriptor(org.apache.beam.sdk.values.TypeDescriptor) List(java.util.List) Test(org.junit.Test)

Example 3 with DefaultCoderProvider

use of org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider in project beam by apache.

the class DefaultCoderTest method testCodersWithoutComponents.

@Test
public void testCodersWithoutComponents() throws Exception {
    CoderRegistry registry = CoderRegistry.createDefault();
    registry.registerCoderProvider(new DefaultCoderProvider());
    assertThat(registry.getCoder(AvroRecord.class), instanceOf(AvroCoder.class));
    assertThat(registry.getCoder(SerializableRecord.class), instanceOf(SerializableCoder.class));
    assertThat(registry.getCoder(CustomRecord.class), instanceOf(CustomSerializableCoder.class));
    assertThat(registry.getCoder(OldCustomRecord.class), instanceOf(OldCustomSerializableCoder.class));
}
Also used : DefaultCoderProvider(org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider) Test(org.junit.Test)

Aggregations

DefaultCoderProvider (org.apache.beam.sdk.coders.DefaultCoder.DefaultCoderProviderRegistrar.DefaultCoderProvider)3 Test (org.junit.Test)3 List (java.util.List)1 TypeDescriptor (org.apache.beam.sdk.values.TypeDescriptor)1