From 90402710d962aa357062ecb94649e0f277c1dfb3 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 29 三月 2026 21:03:48 +0800
Subject: [PATCH] #
---
src/test/java/com/zy/core/thread/impl/ZyStationV5ThreadTest.java | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/src/test/java/com/zy/core/thread/impl/ZyStationV5ThreadTest.java b/src/test/java/com/zy/core/thread/impl/ZyStationV5ThreadTest.java
index bb1da07..ad2ac25 100644
--- a/src/test/java/com/zy/core/thread/impl/ZyStationV5ThreadTest.java
+++ b/src/test/java/com/zy/core/thread/impl/ZyStationV5ThreadTest.java
@@ -2,9 +2,15 @@
import com.zy.asrs.entity.DeviceConfig;
import com.zy.common.utils.RedisUtil;
+import com.zy.core.cache.MessageQueue;
+import com.zy.core.enums.SlaveType;
+import com.zy.core.model.Task;
+import com.zy.core.model.command.StationCommand;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.model.protocol.StationTaskBufferItem;
import com.zy.core.network.ZyStationConnectDriver;
+import com.zy.core.thread.impl.v5.StationV5SegmentExecutor;
+import com.zy.core.thread.impl.v5.StationV5StatusReader;
import org.junit.jupiter.api.Test;
import org.springframework.test.util.ReflectionTestUtils;
@@ -17,10 +23,35 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
class ZyStationV5ThreadTest {
+
+ @Test
+ void pollAndDispatchQueuedCommand_submitsQueuedMoveCommandToSegmentExecutor() {
+ DeviceConfig deviceConfig = new DeviceConfig();
+ deviceConfig.setDeviceNo(1);
+ RedisUtil redisUtil = mock(RedisUtil.class);
+ StationCommand command = new StationCommand();
+ StationV5SegmentExecutor segmentExecutor = mock(StationV5SegmentExecutor.class);
+
+ ZyStationV5Thread thread = new ZyStationV5Thread(deviceConfig, redisUtil);
+ ReflectionTestUtils.setField(thread, "segmentExecutor", segmentExecutor);
+
+ MessageQueue.init(SlaveType.Devp, 1);
+ try {
+ MessageQueue.offer(SlaveType.Devp, 1, new Task(2, command));
+
+ ReflectionTestUtils.invokeMethod(thread, "pollAndDispatchQueuedCommand");
+
+ verify(segmentExecutor, timeout(1000)).execute(command);
+ } finally {
+ MessageQueue.clear(SlaveType.Devp, 1);
+ thread.close();
+ }
+ }
@Test
void clearPath_delegatesPureSlotClearingToDriver() {
@@ -46,7 +77,8 @@
station10.setStationId(10);
station10.setTaskBufferItems(List.of(hitItem));
- ReflectionTestUtils.setField(thread, "statusList", Arrays.asList(station20, station10));
+ StationV5StatusReader statusReader = (StationV5StatusReader) ReflectionTestUtils.getField(thread, "statusReader");
+ ReflectionTestUtils.setField(statusReader, "statusList", Arrays.asList(station20, station10));
boolean result = thread.clearPath(100);
--
Gitblit v1.9.1