fix(接口测试): 修复接口场景导入时会保留之前执行次数的问题

--bug=1016877 --user=宋天阳 【接口测试】导入的场景,首页统计的通过率、执行次数不对
https://www.tapd.cn/55049933/s/1245892
This commit is contained in:
song-tianyang 2022-09-19 19:12:51 +08:00 committed by 建国
parent 80dddac4e8
commit fd1d8e79ef
1 changed files with 2 additions and 29 deletions

View File

@ -65,26 +65,10 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
ScenarioImport scenarioImport = JSON.parseObject(testStr, ScenarioImport.class, Feature.DisableSpecialKeyDetect); ScenarioImport scenarioImport = JSON.parseObject(testStr, ScenarioImport.class, Feature.DisableSpecialKeyDetect);
List<ApiScenarioWithBLOBs> data = scenarioImport.getData(); List<ApiScenarioWithBLOBs> data = scenarioImport.getData();
/*Set<String> moduleIdSet = scenarioImport.getData().stream()
.map(ApiScenarioWithBLOBs::getApiScenarioModuleId).collect(Collectors.toSet());*/
/*
Map<String, NodeTree> nodeMap = null;
*/
/*
List<NodeTree> nodeTree = scenarioImport.getNodeTree();
*/
/*if (CollectionUtils.isNotEmpty(nodeTree)) {
cutDownTree(nodeTree, moduleIdSet);
ApiScenarioImportUtil.createNodeTree(nodeTree, projectId, importRequest.getModuleId());
nodeMap = getNodeMap(nodeTree);
}*/
if (CollectionUtils.isNotEmpty(data)) { if (CollectionUtils.isNotEmpty(data)) {
/*
Map<String, NodeTree> finalNodeMap = nodeMap;
*/
data.forEach(item -> { data.forEach(item -> {
//导入的用例执行次数应当归零否则会影响到首页的统计
item.setExecuteTimes(0);
String scenarioDefinitionStr = item.getScenarioDefinition(); String scenarioDefinitionStr = item.getScenarioDefinition();
if (StringUtils.isNotBlank(scenarioDefinitionStr)) { if (StringUtils.isNotBlank(scenarioDefinitionStr)) {
JSONObject scenarioDefinition = JSONObject.parseObject(scenarioDefinitionStr, Feature.DisableSpecialKeyDetect); JSONObject scenarioDefinition = JSONObject.parseObject(scenarioDefinitionStr, Feature.DisableSpecialKeyDetect);
@ -101,17 +85,6 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
} }
} }
/*if (finalNodeMap != null && finalNodeMap.get(item.getApiScenarioModuleId()) != null) {
NodeTree node = finalNodeMap.get(item.getApiScenarioModuleId());
item.setApiScenarioModuleId(node.getNewId());
item.setModulePath(node.getPath());
} else {
if (StringUtils.isBlank(item.getModulePath())) {
item.setApiScenarioModuleId(null);
}
// 旧版本未导出模块
parseModule(item.getModulePath(), importRequest, item);
}*/
item.setProjectId(this.projectId); item.setProjectId(this.projectId);
}); });
} }