From 9fed155adefdb73dd349ff99a897f2d2da5ea03e Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期五, 28 八月 2026 17:51:32 +0800
Subject: [PATCH] 修复:恢复 Redis 模拟器嵌套状态

---
 ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
index 71aa715..75541e4 100644
--- a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
+++ b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
@@ -4,6 +4,7 @@
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.never;
@@ -80,6 +81,26 @@
         assertEquals(10L, testService.createTest(test));
 
         verify(testMapper, never()).countCollectorEnabled(anyLong());
+    }
+
+    @Test
+    void createShouldAllowPlanStepsToBeConfiguredLater()
+    {
+        TTest test = validTest();
+        test.setPlanSteps(Collections.emptyList());
+        mockEnabledOptions();
+        when(testMapper.insertTest(any(TTest.class))).thenAnswer(invocation -> {
+            invocation.<TTest>getArgument(0).setTestId(10L);
+            return 1;
+        });
+        doAnswer(invocation -> {
+            invocation.<TTestBattery>getArgument(0).setRelationId(20L);
+            return 1;
+        }).when(testMapper).insertTestBattery(any(TTestBattery.class));
+
+        assertEquals(10L, testService.createTest(test));
+
+        verify(testMapper, never()).insertTestPlanStep(any(TTestPlanStep.class));
     }
 
     @Test
@@ -198,6 +219,20 @@
         verify(testMapper).insertTestAudit(anyLong(), any(), anyLong(), any(), any(), any());
     }
 
+    @Test
+    void deleteBeforeMonitoringShouldAppendAudit()
+    {
+        TTest current = validTest();
+        current.setTestId(10L);
+        current.setMonitoringStatus("NOT_MONITORED");
+        when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current);
+        when(testMapper.deleteTestById(10L, "operator")).thenReturn(1);
+
+        assertEquals(1, testService.deleteTestByIds(new Long[] { 10L }, 7L, "operator"));
+
+        verify(testMapper).insertTestAudit(eq(10L), eq("TEST_DELETED"), eq(7L), eq("operator"), any(), isNull());
+    }
+
     private void mockEnabledOptions()
     {
         mockEnabledPeopleAndType();

--
Gitblit v1.7.1