yun-wang commented on a change in pull request #12619:
URL: https://github.com/apache/flink/pull/12619#discussion_r439611794



##########
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:
       Sure I can update the test.
   
   Out of curiosity, any particular reason to avoid `mock` whenever possible? 
In this case adding a simple implementation class would serve the exact same 
purpose as the mock, only lengthier.




----------------------------------------------------------------
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:
[email protected]


Reply via email to