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 2021/07/24 09:14:33 UTC

[GitHub] [kafka] wycccccc commented on a change in pull request #10881: KAFKA-12947 Replace EasyMock and PowerMock with Mockito for Streams…

wycccccc commented on a change in pull request #10881:
URL: https://github.com/apache/kafka/pull/10881#discussion_r675973748



##########
File path: streams/src/test/java/org/apache/kafka/streams/kstream/internals/graph/TableSourceNodeTest.java
##########
@@ -23,43 +23,32 @@
 import org.apache.kafka.streams.kstream.internals.MaterializedInternal;
 import org.apache.kafka.streams.kstream.internals.graph.TableSourceNode.TableSourceNodeBuilder;
 import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder;
-import org.easymock.EasyMock;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
 
 import java.util.Properties;
 
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({InternalTopologyBuilder.class})
+import static org.mockito.Mockito.mock;
+
 public class TableSourceNodeTest {
 
     private static final String STORE_NAME = "store-name";
     private static final String TOPIC = "input-topic";
 
-    private final InternalTopologyBuilder topologyBuilder = PowerMock.createNiceMock(InternalTopologyBuilder.class);
+    private final InternalTopologyBuilder topologyBuilder = mock(InternalTopologyBuilder.class);
 
     @Test
     public void shouldConnectStateStoreToInputTopicIfInputTopicIsUsedAsChangelog() {
         final boolean shouldReuseSourceTopicForChangelog = true;
         topologyBuilder.connectSourceStoreAndTopic(STORE_NAME, TOPIC);
-        EasyMock.replay(topologyBuilder);
 
         buildTableSourceNode(shouldReuseSourceTopicForChangelog);
-
-        EasyMock.verify(topologyBuilder);

Review comment:
       In my opinion, the `verfiy(object) `in easymock is to verify whether the stubbed method is actually called.
   And this step will be automatically detected in mockito. The call form of verfiy method in mockito is `verfit(object).callmethod`, which is used for some specific detections, such as the number of times the method is called (atMostOnec, atLeastOnec) .
   So unless it is a specific test, the general easymock verify is not required by mockito.




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