EricGao888 commented on code in PR #15380:
URL: 
https://github.com/apache/dolphinscheduler/pull/15380#discussion_r1437972285


##########
dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerConnectionStateListenerTest.java:
##########
@@ -0,0 +1,48 @@
+package org.apache.dolphinscheduler.server.worker.registry;
+import static org.mockito.BDDMockito.given;
+
+import org.apache.dolphinscheduler.common.IStoppable;
+import org.apache.dolphinscheduler.common.model.Server;
+import org.apache.dolphinscheduler.common.utils.NetUtils;
+import org.apache.dolphinscheduler.registry.api.ConnectionState;
+import org.apache.dolphinscheduler.registry.api.RegistryClient;
+import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType;
+import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
+import 
org.apache.dolphinscheduler.server.worker.runner.WorkerTaskExecutorThreadPool;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Optional;
+
+import org.junit.Assert;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * worker registry test
+ */
+@ExtendWith(MockitoExtension.class)
+public class WorkerConnectionStateListenerTest {
+    private static final Logger log = 
LoggerFactory.getLogger(WorkerConnectionStateListenerTest.class);
+    @InjectMocks
+    private WorkerConnectionStateListener workerConnectionStateListener;
+    @Mock
+    private WorkerConfig workerConfig;
+    @Mock
+    private WorkerConnectStrategy workerConnectStrategy;
+
+    @Test
+    public void testWorkerConnectionStateListener() {

Review Comment:
   I think you should add some call checks in this test case. 
https://github.com/apache/dolphinscheduler/blob/1c1d4bd59297942499a8242066de1c8ae0143a58/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerConnectionStateListener.java#L40-L56
   
   Do something like:
   
   ```java
   Mockito.verify(workerConnectStrategy, times(1)).reconnect(); 
   ```
   
   Otherwise, this case is kind of meaningless.



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