fix(测试计划): 修复【测试用例】导出再导入,会把步骤排序号带进步骤里的问题,修复责任人不显示的问题
修复【测试用例】导出再导入,会把步骤排序号带进步骤里的问题,修复责任人不显示的问题
This commit is contained in:
parent
79c55ef6c9
commit
648c248a04
|
@ -194,7 +194,9 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
|
|||
// excel exist
|
||||
stringBuilder.append(Translator.get("test_case_already_exists_excel") + ":" + data.getName() + "; ");
|
||||
} else {
|
||||
excelDataList.add(data);
|
||||
if(!dbExist){
|
||||
excelDataList.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -344,12 +346,14 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
|
|||
StringBuffer stepBuffer = new StringBuffer();
|
||||
int lastStepIndex = 1;
|
||||
for (String row : stepDesc) {
|
||||
int rowIndex = this.parseIndexInRow(row);
|
||||
RowInfo rowInfo = this.parseIndexInRow(row);
|
||||
int rowIndex = rowInfo.index;
|
||||
String rowMessage = rowInfo.rowInfo;
|
||||
if(rowIndex > -1){
|
||||
listUtils.set(stepDescList,lastStepIndex-1,stepBuffer.toString(),"");
|
||||
stepBuffer = new StringBuffer();
|
||||
lastStepIndex = rowIndex;
|
||||
stepBuffer.append(row);
|
||||
stepBuffer.append(rowMessage);
|
||||
}else {
|
||||
stepBuffer.append(row);
|
||||
}
|
||||
|
@ -366,12 +370,14 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
|
|||
StringBuffer stepBuffer = new StringBuffer();
|
||||
int lastStepIndex = 1;
|
||||
for (String row : stepRes) {
|
||||
int rowIndex = this.parseIndexInRow(row);
|
||||
RowInfo rowInfo = this.parseIndexInRow(row);
|
||||
int rowIndex = rowInfo.index;
|
||||
String rowMessage = rowInfo.rowInfo;
|
||||
if(rowIndex > -1){
|
||||
listUtils.set(stepResList,lastStepIndex-1,stepBuffer.toString(),"");
|
||||
stepBuffer = new StringBuffer();
|
||||
lastStepIndex = rowIndex;
|
||||
stepBuffer.append(row);
|
||||
stepBuffer.append(rowMessage);
|
||||
}else {
|
||||
stepBuffer.append(row);
|
||||
}
|
||||
|
@ -403,12 +409,14 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
|
|||
return jsonArray.toJSONString();
|
||||
}
|
||||
|
||||
private int parseIndexInRow(String row) {
|
||||
private RowInfo parseIndexInRow(String row) {
|
||||
RowInfo rowInfo = new RowInfo();
|
||||
String parseString = row;
|
||||
int index = -1;
|
||||
String rowMessage = row;
|
||||
String [] indexSplitCharArr = new String[]{")",")","]","】",".",",",",","。"};
|
||||
if(StringUtils.startsWithAny(row,"(","(","[","【")){
|
||||
parseString = parseString.substring(1);
|
||||
parseString = parseString.substring(1);
|
||||
}
|
||||
for (String splitChar : indexSplitCharArr) {
|
||||
if(StringUtils.contains(parseString,splitChar)){
|
||||
|
@ -418,15 +426,24 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
|
|||
if(StringUtils.isNumeric(indexString)){
|
||||
try {
|
||||
index = Integer.parseInt(indexString);
|
||||
rowMessage = StringUtils.substring(parseString,indexString.length()+splitChar.length());
|
||||
}catch (Exception e){}
|
||||
|
||||
if(index > -1){
|
||||
break;
|
||||
}else {
|
||||
rowMessage = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
rowInfo.index = index;
|
||||
if(rowMessage == null){
|
||||
rowMessage = "";
|
||||
}
|
||||
rowInfo.rowInfo = rowMessage;
|
||||
return rowInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -463,4 +480,10 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
|
|||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class RowInfo{
|
||||
public int index;
|
||||
public String rowInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,9 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
// excel exist
|
||||
stringBuilder.append(Translator.get("test_case_already_exists_excel") + ":" + data.getName() + "; ");
|
||||
} else {
|
||||
excelDataList.add(data);
|
||||
if(!dbExist){
|
||||
excelDataList.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -350,40 +352,23 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
|
||||
List<String> stepDescList = new ArrayList<>();
|
||||
List<String> stepResList = new ArrayList<>();
|
||||
// String[] stepDesc = new String[1];
|
||||
// String[] stepRes = new String[1];
|
||||
ListUtils<String> listUtils = new ListUtils<String>();
|
||||
if (data.getStepDesc() != null) {
|
||||
String[] stepDesc = data.getStepDesc().split("\r\n|\n");
|
||||
StringBuffer stepBuffer = new StringBuffer();
|
||||
int lastStepIndex = 1;
|
||||
for (String row : stepDesc) {
|
||||
int rowIndex = this.parseIndexInRow(row);
|
||||
RowInfo rowInfo = this.parseIndexInRow(row);
|
||||
int rowIndex = rowInfo.index;
|
||||
String rowMessage = rowInfo.rowInfo;
|
||||
if(rowIndex > -1){
|
||||
|
||||
listUtils.set(stepDescList,lastStepIndex-1,stepBuffer.toString(),"");
|
||||
// stepResList.set(stepIndex-1,stepBuffer.toString());
|
||||
stepBuffer = new StringBuffer();
|
||||
lastStepIndex = rowIndex;
|
||||
stepBuffer.append(row);
|
||||
stepBuffer.append(rowMessage);
|
||||
}else {
|
||||
stepBuffer.append(row);
|
||||
}
|
||||
// if(StringUtils.startsWithAny(row,
|
||||
// stepIndex+")","("+stepIndex+")","(\"+stepIndex+\")",
|
||||
// stepIndex+".",stepIndex+",",stepIndex+",")){
|
||||
// if(StringUtils.isNotEmpty(stepBuffer.toString())){
|
||||
// stepDescList.add(stepBuffer.toString());
|
||||
// }
|
||||
// stepBuffer = new StringBuffer();
|
||||
// stepIndex++;
|
||||
// stepBuffer.append(row);
|
||||
// }else {
|
||||
// if(StringUtils.isNotEmpty(stepBuffer.toString())){
|
||||
// stepBuffer.append("\r\n");
|
||||
// }
|
||||
// stepBuffer.append(row);
|
||||
// }
|
||||
}
|
||||
if(StringUtils.isNotEmpty(stepBuffer.toString())){
|
||||
listUtils.set(stepDescList,lastStepIndex-1,stepBuffer.toString(),"");
|
||||
|
@ -397,32 +382,17 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
StringBuffer stepBuffer = new StringBuffer();
|
||||
int lastStepIndex = 1;
|
||||
for (String row : stepRes) {
|
||||
int rowIndex = this.parseIndexInRow(row);
|
||||
RowInfo rowInfo = this.parseIndexInRow(row);
|
||||
int rowIndex = rowInfo.index;
|
||||
String rowMessage = rowInfo.rowInfo;
|
||||
if(rowIndex > -1){
|
||||
|
||||
listUtils.set(stepResList,lastStepIndex-1,stepBuffer.toString(),"");
|
||||
// stepResList.set(stepIndex-1,stepBuffer.toString());
|
||||
stepBuffer = new StringBuffer();
|
||||
lastStepIndex = rowIndex;
|
||||
stepBuffer.append(row);
|
||||
stepBuffer.append(rowMessage);
|
||||
}else {
|
||||
stepBuffer.append(row);
|
||||
}
|
||||
// if(StringUtils.startsWithAny(row,
|
||||
// stepIndex+")","("+stepIndex+")","(\"+stepIndex+\")",
|
||||
// stepIndex+".",stepIndex+",",stepIndex+",")){
|
||||
// if(StringUtils.isNotEmpty(stepBuffer.toString())){
|
||||
// stepResList.add(stepBuffer.toString());
|
||||
// }
|
||||
// stepBuffer = new StringBuffer();
|
||||
// stepIndex++;
|
||||
// stepBuffer.append(row);
|
||||
// }else {
|
||||
// if(StringUtils.isNotEmpty(stepBuffer.toString())){
|
||||
// stepBuffer.append("\r\n");
|
||||
// }
|
||||
// stepBuffer.append(row);
|
||||
// }
|
||||
}
|
||||
if(StringUtils.isNotEmpty(stepBuffer.toString())){
|
||||
listUtils.set(stepResList,lastStepIndex-1,stepBuffer.toString(),"");
|
||||
|
@ -431,7 +401,6 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
stepResList.add("");
|
||||
}
|
||||
|
||||
// String pattern = "(^\\d+)(\\.)?";
|
||||
int index = stepDescList.size() > stepResList.size() ? stepDescList.size() : stepResList.size();
|
||||
|
||||
for (int i = 0; i < index; i++) {
|
||||
|
@ -439,27 +408,11 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
// 保持插入顺序,判断用例是否有相同的steps
|
||||
JSONObject step = new JSONObject(true);
|
||||
step.put("num", i + 1);
|
||||
|
||||
// Pattern descPattern = Pattern.compile(pattern);
|
||||
// Pattern resPattern = Pattern.compile(pattern);
|
||||
|
||||
if (i < stepDescList.size()) {
|
||||
// Matcher descMatcher = descPattern.matcher(stepDescList.get(i));
|
||||
// if (descMatcher.find()) {
|
||||
// step.put("desc", descMatcher.replaceAll(""));
|
||||
// } else {
|
||||
// step.put("desc", stepDescList.get(i));
|
||||
// }
|
||||
step.put("desc", stepDescList.get(i));
|
||||
}
|
||||
|
||||
if (i < stepResList.size()) {
|
||||
// Matcher resMatcher = resPattern.matcher(stepResList.get(i));
|
||||
// if (resMatcher.find()) {
|
||||
// step.put("result", resMatcher.replaceAll(""));
|
||||
// } else {
|
||||
// step.put("result", stepResList.get(i));
|
||||
// }
|
||||
step.put("result", stepResList.get(i));
|
||||
}
|
||||
|
||||
|
@ -468,9 +421,11 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
return jsonArray.toJSONString();
|
||||
}
|
||||
|
||||
private int parseIndexInRow(String row) {
|
||||
private RowInfo parseIndexInRow(String row) {
|
||||
RowInfo rowInfo = new RowInfo();
|
||||
String parseString = row;
|
||||
int index = -1;
|
||||
String rowMessage = row;
|
||||
String [] indexSplitCharArr = new String[]{")",")","]","】",".",",",",","。"};
|
||||
if(StringUtils.startsWithAny(row,"(","(","[","【")){
|
||||
parseString = parseString.substring(1);
|
||||
|
@ -483,15 +438,24 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
if(StringUtils.isNumeric(indexString)){
|
||||
try {
|
||||
index = Integer.parseInt(indexString);
|
||||
rowMessage = StringUtils.substring(parseString,indexString.length()+splitChar.length());
|
||||
}catch (Exception e){}
|
||||
|
||||
if(index > -1){
|
||||
break;
|
||||
}else {
|
||||
rowMessage = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
rowInfo.index = index;
|
||||
if(rowMessage == null){
|
||||
rowMessage = "";
|
||||
}
|
||||
rowInfo.rowInfo = rowMessage;
|
||||
return rowInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -528,4 +492,10 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class RowInfo{
|
||||
public int index;
|
||||
public String rowInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue