diff --git a/backend/framework/sdk/src/main/resources/i18n/case.properties b/backend/framework/sdk/src/main/resources/i18n/case.properties index f8a0b09889..6c8970cc35 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case.properties @@ -101,6 +101,7 @@ minder_extra_node.steps_expected_result=预期结果 minder_extra_node.text_description=文本描述 minder_extra_node.text_expected_result=预期结果 minder_extra_node.description=备注信息 +minder_extra_node.text_node_empty=文本节点名称不能为空 #module:CaseReview case_review.id.not_blank=ID不能为空 case_review.name.length_range=名称长度必须在1-200之间 diff --git a/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties index de4c9e34a6..1960ed9e0b 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case_en_US.properties @@ -137,6 +137,7 @@ minder_extra_node.steps_expected_result=ExpectedResult minder_extra_node.text_description=TextDescription minder_extra_node.text_expected_result=ExpectedResult minder_extra_node.description=Description +minder_extra_node.text_node_empty=Text node name cannot be empty #module:CaseReview case_review.id.not_blank=ID cannot be empty case_review.name.length_range=The name length must be between 1 and 200 diff --git a/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties index a1d6bb9bec..b8094bdf7c 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case_zh_CN.properties @@ -136,6 +136,7 @@ minder_extra_node.steps_expected_result=预期结果 minder_extra_node.text_description=文本描述 minder_extra_node.text_expected_result=预期结果 minder_extra_node.description=备注信息 +minder_extra_node.text_node_empty=文本节点名称不能为空 #module:CaseReview case_review.id.not_blank=ID不能为空 case_review.name.length_range=名称长度必须在1-200之间 diff --git a/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties index 192aadb2c3..603e9fdb26 100644 --- a/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/case_zh_TW.properties @@ -137,6 +137,7 @@ minder_extra_node.steps_expected_result=預期結果 minder_extra_node.text_description=文字描述 minder_extra_node.text_expected_result=預期結果 minder_extra_node.description=備註資訊 +minder_extra_node.text_node_empty=文字節點名稱不能為空 #module:CaseReview case_review.id.not_blank=ID不能為空 case_review.name.length_range=名稱長度必須在1-200之間 diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java index 4c2ba8a508..2180138a93 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java @@ -738,6 +738,9 @@ public class FunctionalCaseMinderService { if (mindAdditionalNodeRequest.getName().length()>255) { mindAdditionalNodeRequest.setName(mindAdditionalNodeRequest.getName().substring(0,249)); } + if (StringUtils.isBlank(mindAdditionalNodeRequest.getName())) { + throw new MSException(Translator.get("minder_extra_node.text_node_empty")); + } mindAdditionalNode.setName(mindAdditionalNodeRequest.getName()); mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId()); mindAdditionalNode.setUpdateTime(System.currentTimeMillis()); @@ -753,6 +756,9 @@ public class FunctionalCaseMinderService { if (mindAdditionalNodeRequest.getName().length()>255) { mindAdditionalNodeRequest.setName(mindAdditionalNodeRequest.getName().substring(0,249)); } + if (StringUtils.isBlank(mindAdditionalNodeRequest.getName())) { + throw new MSException(Translator.get("minder_extra_node.text_node_empty")); + } mindAdditionalNode.setName(mindAdditionalNodeRequest.getName()); mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId()); mindAdditionalNode.setProjectId(request.getProjectId()); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java index cb4dd8add0..751604473f 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseMinderControllerTest.java @@ -24,6 +24,8 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @AutoConfigureMockMvc @@ -329,6 +331,27 @@ public class FunctionalCaseMinderControllerTest extends BaseTest { this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_EDIT_URL, request); functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases)); + + mindAdditionalNodeRequest = new MindAdditionalNodeRequest(); + mindAdditionalNodeRequest.setId("sss2"); + mindAdditionalNodeRequest.setType("ADD"); + mindAdditionalNodeRequest.setName(""); + mindAdditionalNodeRequest.setParentId("TEST_MINDER_MODULE_ID_GYQ"); + additionalNodeList.add(mindAdditionalNodeRequest); + request.setAdditionalNodeList(additionalNodeList); + + this.requestPost(FUNCTIONAL_CASE_EDIT_URL, request).andExpect(status().is5xxServerError()); + request.getAdditionalNodeList().remove(additionalNodeList.size()-1); + mindAdditionalNodeRequest = new MindAdditionalNodeRequest(); + mindAdditionalNodeRequest.setId("additional2"); + mindAdditionalNodeRequest.setType("UPDATE"); + mindAdditionalNodeRequest.setName(""); + mindAdditionalNodeRequest.setParentId("TEST_MINDER_MODULE_ID_GYQ"); + additionalNodeList.add(mindAdditionalNodeRequest); + request.setAdditionalNodeList(additionalNodeList); + + this.requestPost(FUNCTIONAL_CASE_EDIT_URL, request).andExpect(status().is5xxServerError()); + } @Test