@Test public void testSideOutputAfterSelectIsForbidden() { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SingleOutputStreamOperator<String> processInput = env.fromElements("foo") .process(new DummyProcessFunction()); processInput.split(Collections::singleton); try { processInput.getSideOutput(outputTag); Assert.fail("Should have failed early with an exception."); } catch (UnsupportedOperationException expected){ // expected } }
@Test public void testSelectAfterSideOutputIsForbidden() { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); SingleOutputStreamOperator<String> processInput = env.fromElements("foo") .process(new DummyProcessFunction()); processInput.getSideOutput(outputTag); try { processInput.split(Collections::singleton); Assert.fail("Should have failed early with an exception."); } catch (UnsupportedOperationException expected){ // expected } }
/** * Verify that a {@link DataStream#process(ProcessFunction)} call is correctly translated to an operator. */ @Test public void testProcessTranslation() { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Long> src = env.generateSequence(0, 0); ProcessFunction<Long, Integer> processFunction = new ProcessFunction<Long, Integer>() { private static final long serialVersionUID = 1L; @Override public void processElement( Long value, Context ctx, Collector<Integer> out) throws Exception { // Do nothing } @Override public void onTimer( long timestamp, OnTimerContext ctx, Collector<Integer> out) throws Exception { // Do nothing } }; DataStream<Integer> processed = src .process(processFunction); processed.addSink(new DiscardingSink<Integer>()); assertEquals(processFunction, getFunctionForDataStream(processed)); assertTrue(getOperatorForDataStream(processed) instanceof ProcessOperator); }
TypeInformation.of(TransactionEvent.class)); final SingleOutputStreamOperator<DepositEvent> deposits = depositsAndTransactions.process( new ProcessFunction<Either<DepositEvent, TransactionEvent>, DepositEvent>() {