fix: 导入用例步骤描述以大数字开头导入失败

--bug=1010265 --user=陈建星 标准模板用例导入失败,提示 Packet for query is too large (128,530,704 > 67,108,864) https://www.tapd.cn/55049933/s/1105293
This commit is contained in:
chenjianxing 2022-02-17 17:51:09 +08:00 committed by jianxing
parent 4385e73401
commit 36b7029d10
1 changed files with 19 additions and 29 deletions

View File

@ -517,27 +517,17 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
List<String> stepDescList = new ArrayList<>(); List<String> stepDescList = new ArrayList<>();
List<String> stepResList = new ArrayList<>(); List<String> stepResList = new ArrayList<>();
ListUtils<String> listUtils = new ListUtils<String>(); ListUtils<String> listUtils = new ListUtils<>();
Set<Integer> rowNums = new HashSet<>();
if (data.getStepDesc() != null) { if (data.getStepDesc() != null) {
String desc = data.getStepDesc().replaceAll("\\n([0-9]+\\.)", "\r\n$1"); String[] stepDesc = data.getStepDesc().split("\r\n");
String[] stepDesc = desc.split("\r\n");
StringBuffer stepBuffer = new StringBuffer(); int rowIndex = 1;
int lastStepIndex = 1;
for (String row : stepDesc) { for (String row : stepDesc) {
RowInfo rowInfo = this.parseIndexInRow(row); TestCaseNoModelDataListener.RowInfo rowInfo = this.parseIndexInRow(row);
int rowIndex = rowInfo.index; stepDescList.add(rowInfo.rowInfo);
String rowMessage = rowInfo.rowInfo; rowNums.add(rowIndex++);
if (rowIndex > -1) {
listUtils.set(stepDescList, lastStepIndex - 1, stepBuffer.toString(), "");
stepBuffer = new StringBuffer();
lastStepIndex = rowIndex;
stepBuffer.append(rowMessage);
} else {
stepBuffer.append(row);
}
}
if (StringUtils.isNotEmpty(stepBuffer.toString())) {
listUtils.set(stepDescList, lastStepIndex - 1, stepBuffer.toString(), "");
} }
} else { } else {
stepDescList.add(""); stepDescList.add("");
@ -546,24 +536,20 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
if (data.getStepResult() != null) { if (data.getStepResult() != null) {
String stepResult = data.getStepResult().replaceAll("\\n([0-9]+\\.)", "\r\n$1"); String stepResult = data.getStepResult().replaceAll("\\n([0-9]+\\.)", "\r\n$1");
String[] stepRes = stepResult.split("\r\n"); String[] stepRes = stepResult.split("\r\n");
StringBuffer stepBuffer = new StringBuffer();
int lastStepIndex = 1; int lastStepIndex = 1;
for (String row : stepRes) { for (String row : stepRes) {
RowInfo rowInfo = this.parseIndexInRow(row); TestCaseNoModelDataListener.RowInfo rowInfo = this.parseIndexInRow(row);
int rowIndex = rowInfo.index; int rowIndex = rowInfo.index;
String rowMessage = rowInfo.rowInfo; String rowMessage = rowInfo.rowInfo;
if (rowIndex > -1) {
listUtils.set(stepResList, lastStepIndex - 1, stepBuffer.toString(), ""); if (rowIndex > -1 && rowNums.contains(rowIndex)) {
stepBuffer = new StringBuffer(); listUtils.set(stepResList, lastStepIndex - 1, rowMessage, "");
lastStepIndex = rowIndex; lastStepIndex = rowIndex;
stepBuffer.append(rowMessage);
} else { } else {
stepBuffer.append(row); listUtils.set(stepResList, lastStepIndex - 1, rowMessage, "");
lastStepIndex++;
} }
} }
if (StringUtils.isNotEmpty(stepBuffer.toString())) {
listUtils.set(stepResList, lastStepIndex - 1, stepBuffer.toString(), "");
}
} else { } else {
stepResList.add(""); stepResList.add("");
} }
@ -577,10 +563,14 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
step.put("num", i + 1); step.put("num", i + 1);
if (i < stepDescList.size()) { if (i < stepDescList.size()) {
step.put("desc", stepDescList.get(i)); step.put("desc", stepDescList.get(i));
} else {
step.put("desc", "");
} }
if (i < stepResList.size()) { if (i < stepResList.size()) {
step.put("result", stepResList.get(i)); step.put("result", stepResList.get(i));
} else {
step.put("result", "");
} }
jsonArray.add(step); jsonArray.add(step);