OutputFormatSinkFunction extends RichSinkFunction<IN> implements InputTypeConfigurable { @Override public void setRuntimeContext(RuntimeContext context) { super.setRuntimeContext(context); if (format instanceof RichOutputFormat) { ((RichOutputFormat) format).setRuntimeContext(context); } } OutputFormatSinkFunction(OutputFormat<IN> format); @Override void open(Configuration parameters); @Override void setRuntimeContext(RuntimeContext context); @Override void setInputType(TypeInformation<?> type, ExecutionConfig executionConfig); @Override void invoke(IN record); @Override void close();  }
@Test public void setRuntimeContext() throws Exception { RuntimeContext mockRuntimeContext = Mockito.mock(RuntimeContext.class); RichOutputFormat<?> mockRichOutputFormat = Mockito.mock(RichOutputFormat.class); new OutputFormatSinkFunction<>(mockRichOutputFormat).setRuntimeContext(mockRuntimeContext); Mockito.verify(mockRichOutputFormat, Mockito.times(1)).setRuntimeContext(Mockito.eq(mockRuntimeContext)); OutputFormat<?> mockOutputFormat = Mockito.mock(OutputFormat.class); new OutputFormatSinkFunction<>(mockOutputFormat).setRuntimeContext(mockRuntimeContext); }