fix(测试跟踪): 去除导入用例的步骤换行

--bug=1029261 --user=宋昌昌 【测试跟踪】导入用例-同一单元格换行显示-导入后ms步骤和多了空行 https://www.tapd.cn/55049933/s/1409721
This commit is contained in:
song-cc-rock 2023-08-29 18:17:07 +08:00 committed by fit2-zhao
parent 34d10d4c7c
commit 7cf999ea44
1 changed files with 26 additions and 25 deletions

View File

@ -481,7 +481,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
break;
}
}
//增加字数校验每一层不能超过100
//增加字数校验每一层不能超过100
for (int i = 0; i < nodes.length; i++) {
String nodeStr = nodes[i];
if (StringUtils.isNotEmpty(nodeStr)) {
@ -723,30 +723,8 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
private List<Map<String, Object>> getSingleRowSteps(String cellDesc, String cellResult, Integer startStepIndex) {
List<Map<String, Object>> steps = new ArrayList<>();
List<String> stepDescList = new ArrayList<>();
List<String> stepResList = new ArrayList<>();
if (StringUtils.isNotEmpty(cellDesc)) {
// 根据[1], [2]...分割步骤描述, 开头空字符去掉, 末尾保留
String[] stepDesc = cellDesc.split("\\[\\d+]", -1);
if (StringUtils.isEmpty(stepDesc[0])) {
stepDesc = Arrays.copyOfRange(stepDesc, 1, stepDesc.length);
}
stepDescList.addAll(Arrays.asList(stepDesc));
} else {
stepDescList.add(StringUtils.EMPTY);
}
if (StringUtils.isNotEmpty(cellResult)) {
// 根据[1], [2]...分割步骤描述, 开头空字符去掉, 末尾保留
String[] stepRes = cellResult.split("\\[\\d+]", -1);
if (StringUtils.isEmpty(stepRes[0])) {
stepRes = Arrays.copyOfRange(stepRes, 1, stepRes.length);
}
stepResList.addAll(Arrays.asList(stepRes));
} else {
stepResList.add(StringUtils.EMPTY);
}
List<String> stepDescList = parseStepCell(cellDesc);
List<String> stepResList = parseStepCell(cellResult);
int index = Math.max(stepDescList.size(), stepResList.size());
for (int i = 0; i < index; i++) {
@ -889,6 +867,29 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
return result;
}
/**
* 解析步骤类型的单元格内容
*
* @param cellContent 单元格内容
* @return 解析后的字符文本
*/
private List<String> parseStepCell(String cellContent) {
List<String> cellStepContentList = new ArrayList<>();
if (StringUtils.isNotEmpty(cellContent)) {
// 根据[1], [2]...分割步骤描述, 开头空字符去掉, 末尾保留
String[] cellContentArr = cellContent.split("\\[\\d+]", -1);
if (StringUtils.isEmpty(cellContentArr[0])) {
cellContentArr = Arrays.copyOfRange(cellContentArr, 1, cellContentArr.length);
}
for (String stepContent : cellContentArr) {
cellStepContentList.add(stepContent.replaceAll("^\n*|\n*$", StringUtils.EMPTY));
}
} else {
cellStepContentList.add(StringUtils.EMPTY);
}
return cellStepContentList;
}
class RowInfo {
public int index;
public String rowInfo;