You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/08/02 13:58:13 UTC

[GitHub] [kafka] divijvaidya commented on a diff in pull request #12472: KAFKA-14134: Replace EasyMock with Mockito for WorkerConnectorTest

divijvaidya commented on code in PR #12472:
URL: https://github.com/apache/kafka/pull/12472#discussion_r935609616


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConnectorTest.java:
##########
@@ -60,15 +64,15 @@ public class WorkerConnectorTest extends EasyMockSupport {
     public ConnectorConfig connectorConfig;
     public MockConnectMetrics metrics;
 
-    @Mock Plugins plugins;
-    @Mock SourceConnector sourceConnector;
-    @Mock SinkConnector sinkConnector;
-    @Mock Connector connector;
-    @Mock CloseableConnectorContext ctx;
-    @Mock ConnectorStatus.Listener listener;
-    @Mock CloseableOffsetStorageReader offsetStorageReader;
-    @Mock ConnectorOffsetBackingStore offsetStore;
-    @Mock ClassLoader classLoader;
+    private final Plugins plugins = mock(Plugins.class);
+    private final SourceConnector sourceConnector = mock(SourceConnector.class);
+    private final SinkConnector sinkConnector = mock(SinkConnector.class);
+    private final CloseableConnectorContext ctx = mock(CloseableConnectorContext.class);
+    private final ConnectorStatus.Listener listener = mock(ConnectorStatus.Listener.class);
+    private final CloseableOffsetStorageReader offsetStorageReader = mock(CloseableOffsetStorageReader.class);
+    private final ConnectorOffsetBackingStore offsetStore = mock(ConnectorOffsetBackingStore.class);
+    private final ClassLoader classLoader = mock(ClassLoader.class);
+    private Connector connector;

Review Comment:
   Is there a reason that this field is a member? Perhaps we could use a local variable in each of the test for this.



##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConnectorTest.java:
##########
@@ -86,31 +90,8 @@ public void testInitializeFailure() {
         RuntimeException exception = new RuntimeException();
         connector = sourceConnector;
 
-        connector.version();
-        expectLastCall().andReturn(VERSION);
-
-        offsetStore.start();

Review Comment:
   I am adding this comment here to help other reviewers in reviewing the changes in these lines.
   
   It is ok to remove these void calls because Mockito automatically creates stubs for void method calls. As long as we are verifying that they are being invoked, we should be good.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org