Follow-up: In short, is it possible to add a source to Stream Execution Environment, execute the stream once, and then reuse the stream multiple times for different test cases? Simpler example/idea below:
stream.addSource(obj); stream.addSink(sink); stream.execute() when: obj.updateData("123") test: sink.data == "123" when: obj.updateData("345") test: sink.data == "345" - When I update the obj, I want the stream to update too without having to call execute() again. Is this a possibility (and what would be the steps to achieve this)? Thanks, Chris ---------- Forwarded message --------- From: chrisgopherrong <sirhc8...@gmail.com> Date: Mon, Dec 14, 2020 at 2:01 PM Subject: Unit Test modify SourceFunction() Instance? Is this possible? To: <dev@flink.apache.org> Hi Flink dev team, I have a requirement where I need to add a source (Source Function instance) to a StreamExecutionEnvironment instance, and unit test by reusing the source instance and just changing its values. The stream flow: class1{ List<Integer> list = new List(1,2,3) static MarketObj marketObj = new MarketObj(list); setup: an instance of class2 will take the marketObj test1: assert calculations are correct test2: list = new List(4,5,6); marketObj.updateList(list); assert calculations are correct } class2 (MarketObj marketObj) { StreamExecutionEnvironment env = new Stream... env.addSource(marketObj); ... env.execute() } MarketObject would be a class that extends SourceFunction and should have a List instance accessible and modifiable by the unit test class (i.e. class 1, each new assert that changes the MarketObject instance). - Would this be possible? I have tried both SourceFunction and RichFlatMapFunction but didn't have success with either. If this can be done, can you show me an example? Thanks, Chris