KarmaGYZ commented on a change in pull request #12619: URL: https://github.com/apache/flink/pull/12619#discussion_r439168264
########## File path: flink-connectors/flink-connector-elasticsearch-base/src/test/java/org/apache/flink/streaming/connectors/elasticsearch/ElasticsearchSinkBaseTest.java ########## @@ -412,6 +414,21 @@ public void testDoesNotWaitForPendingRequestsIfFlushingDisabled() throws Excepti testHarness.close(); } + @Test + public void testOpenAndCloseInSinkFunction() throws Exception { + @SuppressWarnings("unchecked") + ElasticsearchSinkFunction<String> sinkFunction = (ElasticsearchSinkFunction<String>) mock(ElasticsearchSinkFunction.class); + final DummyElasticsearchSink<String> sink = new DummyElasticsearchSink<>( + new HashMap<>(), sinkFunction, new DummyRetryFailureHandler()); + + sink.open(mock(Configuration.class)); + sink.close(); + + verify(sinkFunction, times(1)).open(); + verify(sinkFunction, times(1)).close(); + verifyNoMoreInteractions(sinkFunction); Review comment: The community tends to avoid `mock` if possible. In this case, I think we could add `TestingElasticsearchSinkFunction` or just an anonymous class. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org