ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
@@ -84,6 +84,26 @@ } @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 void createShouldRejectBatteryOutsideSelectedGroup() { TTest test = validTest(); ruoyi-system/src/main/java/com/ruoyi/system/domain/TTest.java
@@ -48,7 +48,6 @@ @NotEmpty(message = "测试至少绑定一个电池号") private List<TTestBattery> batteries; @Valid @NotEmpty(message = "计划工步不能为空") private List<TTestPlanStep> planSteps; @Valid @NotEmpty(message = "阈值配置不能为空") ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestServiceImpl.java
@@ -220,6 +220,8 @@ private void validateConfiguration(TTest test) { // 新建测试只建立业务身份和通道关系,计划工步可在开始监测前补充。 if (test.getPlanSteps() == null) test.setPlanSteps(new ArrayList<>()); validateBatteries(test.getBatteries()); validatePlanSteps(test.getPlanSteps()); validateThresholds(test.getThresholds()); @@ -271,7 +273,7 @@ private void validatePlanSteps(List<TTestPlanStep> planSteps) { if (planSteps == null || planSteps.isEmpty()) throw new ServiceException("计划工步不能为空"); if (planSteps.isEmpty()) return; Set<String> identities = new HashSet<>(); Set<Integer> orders = new HashSet<>(); for (TTestPlanStep step : planSteps)