diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java b/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java index 3f27a059ad..f8da87f225 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/xmind/parser/XMindCaseParser.java @@ -344,11 +344,15 @@ public class XMindCaseParser { testCase.setTextDescription(replace(item.getTitle(), DESCRIPTION)); } else if (isAvailable(item.getTitle(), TAGS)) { String tag = replace(item.getTitle(), TAGS); - String[] tagArr = tag.split("\\|"); - if (CollectionUtils.isNotEmpty(Arrays.asList(tagArr))) { - String tags = StringUtils.joinWith(",", Arrays.asList(tagArr)); - testCase.setTags(tags); + if (StringUtils.isBlank(tag)) { + testCase.setTags(""); + } else { + String[] tagArr = tag.split("\\|"); + if (CollectionUtils.isNotEmpty(Arrays.asList(tagArr))) { + testCase.setTags(String.join(",", tagArr)); + } } + } else if (isAvailable(item.getTitle(), STEP_DESCRIPTION)) { if (item.getChildren() != null) { testCase.setSteps(this.getSteps(item.getChildren().getAttached(), title)); diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java index d4da611c4a..072f6c02cb 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/FunctionalCaseControllerTests.java @@ -784,13 +784,14 @@ public class FunctionalCaseControllerTests extends BaseTest { @Test @Order(19) public void testImportXmind() throws Exception { - String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/1xml.xmind")).getPath(); - MockMultipartFile file = new MockMultipartFile("file", "11.xmind", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileBaseUtils.getFileBytes(filePath)); FunctionalCaseImportRequest request = new FunctionalCaseImportRequest(); request.setCover(true); request.setProjectId("100001100001"); request.setCount("1"); LinkedMultiValueMap paramMap = new LinkedMultiValueMap<>(); + + String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/1xml.xmind")).getPath(); + MockMultipartFile file = new MockMultipartFile("file", "11.xmind", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileBaseUtils.getFileBytes(filePath)); paramMap.add("request", JSON.toJSONString(request)); paramMap.add("file", file); MvcResult functionalCaseMvcResult = this.requestMultipartWithOkAndReturn(IMPORT_XMIND_URL, paramMap); @@ -815,9 +816,8 @@ public class FunctionalCaseControllerTests extends BaseTest { functionalCaseResultHolder = JSON.parseObject(functionalCaseImportResponseData, ResultHolder.class); functionalCaseImportResponse = JSON.parseObject(JSON.toJSONString(functionalCaseResultHolder.getData()), FunctionalCaseImportResponse.class); Assertions.assertNotNull(functionalCaseImportResponse); - System.out.println(JSON.toJSONString(functionalCaseImportResponse)); functionalCaseExample = new FunctionalCaseExample(); - functionalCaseExample.createCriteria().andNameEqualTo("用例名称"); + functionalCaseExample.createCriteria().andNameLike("%" + "用例名称"+"%"); functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); Assertions.assertNotNull(functionalCases); @@ -852,7 +852,7 @@ public class FunctionalCaseControllerTests extends BaseTest { paramMap = new LinkedMultiValueMap<>(); paramMap.add("request", JSON.toJSONString(request)); paramMap.add("file", file2); - this.requestMultipart(IMPORT_XMIND_URL, paramMap).andExpect(status().is5xxServerError());; + this.requestMultipart(IMPORT_XMIND_URL, paramMap).andExpect(status().is5xxServerError()); } @Test diff --git a/backend/services/case-management/src/test/resources/file/2module.xmind b/backend/services/case-management/src/test/resources/file/2module.xmind index 1b88eb0fff..08458dc8f3 100644 Binary files a/backend/services/case-management/src/test/resources/file/2module.xmind and b/backend/services/case-management/src/test/resources/file/2module.xmind differ