PatrickRen commented on a change in pull request #16838:
URL: https://github.com/apache/flink/pull/16838#discussion_r692192964



##########
File path: 
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/reader/KafkaPartitionSplitReaderTest.java
##########
@@ -115,6 +130,76 @@ public void testWakeUp() throws Exception {
         assertNull(error.get());
     }
 
+    @Test
+    public void testNumBytesInCounter() throws Exception {
+        // Create a task metric group for intercepting numBytesOut
+        final InterceptingTaskMetricGroup taskMetricGroup = new 
InterceptingTaskMetricGroup();
+        final OperatorMetricGroup operatorMetricGroup =
+                taskMetricGroup.getOrAddOperator(new OperatorID(0, 0), 
"fakeOperator");
+        KafkaPartitionSplitReader<Integer> reader =
+                createReader(
+                        new Properties(),
+                        
InternalSourceReaderMetricGroup.wrap(operatorMetricGroup));

Review comment:
       What about using Mockito? 
   
   ```java
   // Mock an operator metric group for intercepting numBytesIn
   final OperatorMetricGroup operatorMetricGroup =
           Mockito.mock(OperatorMetricGroup.class, Mockito.RETURNS_DEEP_STUBS);
   Counter numBytesInCounter = new SimpleCounter();
   Mockito.when(operatorMetricGroup.getIOMetricGroup().getNumBytesInCounter())
           .thenReturn(numBytesInCounter);
   SourceReaderMetricGroup sourceReaderMetricGroup =
           InternalSourceReaderMetricGroup.wrap(operatorMetricGroup);
   ```
   
   This can avoid implementing another ```NumBytesInOperatorIOMetricGroup``` 
with a bunch of ```return null``` stuff. 




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to