KarmaGYZ commented on a change in pull request #12619: URL: https://github.com/apache/flink/pull/12619#discussion_r439900022
########## 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: I think this reflects how well our design adheres to the principles of dependency injection. If our design is good enough, we could directly use the constructor in the test. ---------------------------------------------------------------- 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