From 7cf999ea44c0f736e8a003bc19ca86d2aa5a18f6 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Tue, 29 Aug 2023 18:17:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=AF=BC=E5=85=A5=E7=94=A8=E4=BE=8B=E7=9A=84?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1029261 --user=宋昌昌 【测试跟踪】导入用例-同一单元格换行显示-导入后ms步骤和多了空行 https://www.tapd.cn/55049933/s/1409721 --- .../listener/TestCaseNoModelDataListener.java | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java index e30a6720b3..a7c5943abd 100644 --- a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java +++ b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java @@ -481,7 +481,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener> getSingleRowSteps(String cellDesc, String cellResult, Integer startStepIndex) { List> steps = new ArrayList<>(); - List stepDescList = new ArrayList<>(); - List 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 stepDescList = parseStepCell(cellDesc); + List 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 parseStepCell(String cellContent) { + List 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;