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/02/03 21:00:50 UTC

[GitHub] [kafka] mimaison commented on a change in pull request #11672: KAFKA-13577: Replace easymock with mockito in kafka:core - part 1

mimaison commented on a change in pull request #11672:
URL: https://github.com/apache/kafka/pull/11672#discussion_r798964433



##########
File path: core/src/test/scala/kafka/common/InterBrokerSendThreadTest.scala
##########
@@ -134,36 +129,33 @@ class InterBrokerSendThreadTest {
 
     val clientRequest = new ClientRequest("dest", request, 0, "1", 0, true, requestTimeoutMs, handler.handler)
 
-    EasyMock.expect(networkClient.newClientRequest(
-      EasyMock.eq("1"),
-      EasyMock.same(handler.request),
-      EasyMock.anyLong(),
-      EasyMock.eq(true),
-      EasyMock.eq(requestTimeoutMs),
-      EasyMock.same(handler.handler)))
-      .andReturn(clientRequest)
+    when(networkClient.newClientRequest(
+      ArgumentMatchers.eq("1"),
+      same(handler.request),
+      anyLong(),
+      ArgumentMatchers.eq(true),
+      ArgumentMatchers.eq(requestTimeoutMs),
+      same(handler.handler)))
+      .thenReturn(clientRequest)
 
-    EasyMock.expect(networkClient.ready(node, time.milliseconds()))
-      .andReturn(false)
+    when(networkClient.ready(node, time.milliseconds()))
+      .thenReturn(false)
 
-    EasyMock.expect(networkClient.connectionDelay(EasyMock.anyObject(), EasyMock.anyLong()))
-      .andReturn(0)
+    when(networkClient.connectionDelay(any[Node], anyLong()))
+      .thenReturn(0)
 
-    EasyMock.expect(networkClient.poll(EasyMock.anyLong(), EasyMock.anyLong()))
-      .andReturn(new util.ArrayList())
+    when(networkClient.poll(anyLong(), anyLong()))
+      .thenReturn(new util.ArrayList[ClientResponse]())
 
-    EasyMock.expect(networkClient.connectionFailed(node))
-      .andReturn(true)
+   when(networkClient.connectionFailed(node))
+      .thenReturn(true)
 
-    EasyMock.expect(networkClient.authenticationException(node))
-      .andReturn(new AuthenticationException(""))
-
-    EasyMock.replay(networkClient)
+    when(networkClient.authenticationException(node))
+      .thenReturn(new AuthenticationException(""))
 
     sendThread.enqueue(handler)
     sendThread.doWork()
 
-    EasyMock.verify(networkClient)

Review comment:
       Yeah it's tricky to get the exact same coverage with Mockito. I've tried to verify all the important calls, especially on the component being tested, and whenever possible verify all the mocks. 
   
   




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