lianetm commented on code in PR #16140:
URL: https://github.com/apache/kafka/pull/16140#discussion_r1625060556


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThreadTest.java:
##########
@@ -270,30 +326,27 @@ void testPollResultTimer() {
     void testMaximumTimeToWait() {
         // Initial value before runOnce has been called
         assertEquals(ConsumerNetworkThread.MAX_POLL_TIMEOUT_MS, 
consumerNetworkThread.maximumTimeToWait());
+
+        
when(requestManagers.entries()).thenReturn(Collections.singletonList(Optional.of(heartbeatRequestManager)));
+        
when(heartbeatRequestManager.maximumTimeToWait(time.milliseconds())).thenReturn((long)
 DEFAULT_HEARTBEAT_INTERVAL_MS);
+
         consumerNetworkThread.runOnce();
         // After runOnce has been called, it takes the default heartbeat 
interval from the heartbeat request manager
         assertEquals(DEFAULT_HEARTBEAT_INTERVAL_MS, 
consumerNetworkThread.maximumTimeToWait());
     }
 
     @Test
-    void testRequestManagersArePolledOnce() {
-        consumerNetworkThread.runOnce();
-        testBuilder.requestManagers.entries().forEach(rmo -> rmo.ifPresent(rm 
-> verify(rm, times(1)).poll(anyLong())));
-        testBuilder.requestManagers.entries().forEach(rmo -> rmo.ifPresent(rm 
-> verify(rm, times(1)).maximumTimeToWait(anyLong())));
-        verify(networkClient, times(1)).poll(anyLong(), anyLong());
-    }
+    void testEnsureEventsAreCompleted() {
+        Cluster cluster = mock(Cluster.class);
+        when(metadata.fetch()).thenReturn(cluster);
 
-    @Test
-    void testEnsureMetadataUpdateOnPoll() {
-        MetadataResponse metadataResponse = 
RequestTestUtils.metadataUpdateWith(2, Collections.emptyMap());
-        client.prepareMetadataUpdate(metadataResponse);
-        metadata.requestUpdate(false);
-        consumerNetworkThread.runOnce();
-        verify(metadata, 
times(1)).updateWithCurrentRequestVersion(eq(metadataResponse), eq(false), 
anyLong());
-    }
+        List<Node> list = new ArrayList<>();
+        list.add(new Node(0, "host", 0));
+        when(cluster.nodes()).thenReturn(list);

Review Comment:
   what about simplifying to a single 
`when(cluster.nodes()).thenReturn(Collections.singletonList(new Node(0, "host", 
0)));` ?



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to