use of org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload in project beam by apache.
the class ReadTranslationTest method testToFromProtoUnbounded.
@Test
public void testToFromProtoUnbounded() throws Exception {
assumeThat(source, instanceOf(UnboundedSource.class));
UnboundedSource<?, ?> unboundedSource = (UnboundedSource<?, ?>) this.source;
SplittableParDo.PrimitiveUnboundedRead<?> unboundedRead = new SplittableParDo.PrimitiveUnboundedRead<>(Read.from(unboundedSource));
// No environment set for unbounded sources
ReadPayload payload = ReadTranslation.toProto(unboundedRead);
assertThat(payload.getIsBounded(), equalTo(RunnerApi.IsBounded.Enum.UNBOUNDED));
UnboundedSource<?, ?> deserializedSource = ReadTranslation.unboundedSourceFromProto(payload);
assertThat(deserializedSource, equalTo(source));
}
use of org.apache.beam.model.pipeline.v1.RunnerApi.ReadPayload in project beam by apache.
the class ReadTranslationTest method testToFromProtoBounded.
@Test
public void testToFromProtoBounded() throws Exception {
// TODO: Split into two tests.
assumeThat(source, instanceOf(BoundedSource.class));
BoundedSource<?> boundedSource = (BoundedSource<?>) this.source;
SplittableParDo.PrimitiveBoundedRead<?> boundedRead = new SplittableParDo.PrimitiveBoundedRead<>(Read.from(boundedSource));
ReadPayload payload = ReadTranslation.toProto(boundedRead);
assertThat(payload.getIsBounded(), equalTo(RunnerApi.IsBounded.Enum.BOUNDED));
BoundedSource<?> deserializedSource = ReadTranslation.boundedSourceFromProto(payload);
assertThat(deserializedSource, equalTo(source));
}
Aggregations