Search in sources :

Example 1 with PubSubReadPayload

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);
}
Also used : RunnerApi(org.apache.beam.model.pipeline.v1.RunnerApi) PubSubReadPayload(org.apache.beam.model.pipeline.v1.RunnerApi.PubSubReadPayload) SdkComponents(org.apache.beam.runners.core.construction.SdkComponents) Test(org.junit.Test)

Aggregations

RunnerApi (org.apache.beam.model.pipeline.v1.RunnerApi)1 PubSubReadPayload (org.apache.beam.model.pipeline.v1.RunnerApi.PubSubReadPayload)1 SdkComponents (org.apache.beam.runners.core.construction.SdkComponents)1 Test (org.junit.Test)1