问题描述
private static SingleOutputStreamOperator<Tuple> methodName(KeyedStream<Event,String> stream) {
return stream.window(TumblingEventTimeWindows.of(Time.minutes(10)))
.process(new ProcessFunction());
}
和
ProcessFunction extends ProcessWindowFunction<IN,OUT,KEY,W>
我在Flink页面中找到的所有线束测试都是从KeyedProcessFunction扩展而来的,这不是我的情况。 谢谢。 亲切的问候!
解决方法
通常,这些测试工具期望测试操作员,而不是用户功能。因此,对于ProcessWindowFunction
,您需要首先创建一个合适的窗口运算符以传递到测试工具。
您可以使用ProcessWindowFunction
实例化OneInputStreamOperatorTestHarness
并用WindowOperator
包裹ProcessWindowFunction
来测试implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.0'
。恐怕这并不是特别简单,但我可以举个例子向您推荐https://github.com/apache/flink/blob/release-1.11/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/windowing/WindowOperatorTest.java#L437。
Ververica的Apache Flink培训课程涵盖测试(https://training.ververica.com/decks/testing),其中包含有关如何使用这些测试工具的更多信息。