use of org.apache.beam.model.pipeline.v1.RunnerApi.PubSubReadPayload in project beam by apache.
the class PubSubReadPayloadTranslationTest method testTranslateSourceToFunctionSpec.
@Test
public void testTranslateSourceToFunctionSpec() throws Exception {
PCollection<byte[]> output = pipeline.apply(readFromPubSub);
AppliedPTransform<?, ?, Read.Unbounded<byte[]>> appliedPTransform = AppliedPTransform.of("ReadFromPubsub", PValues.expandInput(pipeline.begin()), PValues.expandOutput(output), readFromPubSub, ResourceHints.create(), pipeline);
SdkComponents components = SdkComponents.create();
components.registerEnvironment(Environments.createDockerEnvironment("java"));
RunnerApi.FunctionSpec spec = sourceTranslator.translate((AppliedPTransform) appliedPTransform, components);
assertEquals(PTransformTranslation.PUBSUB_READ, spec.getUrn());
PubSubReadPayload result = PubSubReadPayload.parseFrom(spec.getPayload());
assertEquals(pubsubReadPayload, result);
}
Aggregations