use of org.apache.beam.model.pipeline.v1.RunnerApi.WindowIntoPayload in project beam by apache.
the class WindowIntoTranslationTest method testToFromProto.
@Test
public void testToFromProto() throws InvalidProtocolBufferException {
pipeline.apply(GenerateSequence.from(0)).apply(Window.<Long>into((WindowFn) windowFn));
final AtomicReference<AppliedPTransform<?, ?, Assign<?>>> assign = new AtomicReference<>(null);
pipeline.traverseTopologically(new PipelineVisitor.Defaults() {
@Override
public void visitPrimitiveTransform(Node node) {
if (node.getTransform() instanceof Window.Assign) {
checkState(assign.get() == null);
assign.set((AppliedPTransform<?, ?, Assign<?>>) node.toAppliedPTransform(getPipeline()));
}
}
});
checkState(assign.get() != null);
SdkComponents components = SdkComponents.create();
components.registerEnvironment(Environments.createDockerEnvironment("java"));
WindowIntoPayload payload = WindowIntoTranslation.toProto(assign.get().getTransform(), components);
assertEquals(windowFn, WindowingStrategyTranslation.windowFnFromProto(payload.getWindowFn()));
}
Aggregations