fix(测试跟踪): 用例步骤为文本描述,导出xmind为步骤描述的内容

--bug=1032040 --user=陈建星 【测试跟踪】github#27112,功能列表分别写了 文本描述、步骤描述写用例, 导出excel为文本描述 导出脑图为步骤描述,导入更新的内容不一样 https://www.tapd.cn/55049933/s/1427740
This commit is contained in:
AgAngle 2023-10-18 15:44:58 +08:00 committed by jianxing
parent 397254ded2
commit e296ce89d2
1 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.xmind.utils; package io.metersphere.xmind.utils;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.TestCaseDTO; import io.metersphere.dto.TestCaseDTO;
@ -42,7 +43,6 @@ public class XmindExportUtil {
try { try {
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("TestCaseExport", StandardCharsets.UTF_8.name()) + ".xmind"); response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("TestCaseExport", StandardCharsets.UTF_8.name()) + ".xmind");
workBook.save(response.getOutputStream()); workBook.save(response.getOutputStream());
// EasyExcel.write(response.getOutputStream(), this.clazz).registerWriteHandler(horizontalCellStyleStrategy).sheet(sheetName).doWrite(data);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new ExcelException("Utf-8 encoding is not supported"); throw new ExcelException("Utf-8 encoding is not supported");
@ -252,7 +252,27 @@ public class XmindExportUtil {
} }
} }
if (dto.getSteps() != null) { if (StringUtils.equals(dto.getStepModel(), TestCaseConstants.StepModel.TEXT.name())) {
// 如果是文本描述导出文本描述的内容
ITopic stepTopic = workbook.createTopic();
String desc = dto.getStepDescription();
stepTopic.setTitleText(desc == null ? "" : desc);
if (style != null) {
stepTopic.setStyleId(style.getId());
}
String result = dto.getExpectedResult();
ITopic resultTopic = workbook.createTopic();
resultTopic.setTitleText(result == null ? "" : result);
if (style != null) {
resultTopic.setStyleId(style.getId());
}
stepTopic.add(resultTopic, ITopic.ATTACHED);
if (StringUtils.isNotEmpty(desc) || StringUtils.isNotEmpty(result)) {
itemTopic.add(stepTopic, ITopic.ATTACHED);
}
} else if (dto.getSteps() != null) {
try { try {
List<Map> arr = JSON.parseArray(dto.getSteps()); List<Map> arr = JSON.parseArray(dto.getSteps());
for (int i = 0; i < arr.size(); i++) { for (int i = 0; i < arr.size(); i++) {