fix(接口测试): 场景导入失败

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-08-19 15:30:42 +08:00 committed by 刘瑞斌
parent 357d14dff6
commit 1f0d9a0d21
1 changed files with 9 additions and 8 deletions

View File

@ -581,7 +581,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
Map<String, ApiScenarioWithBLOBs> nameModuleMap = null;
Map<String, ApiScenarioWithBLOBs> repeatDataMap = null;
if (chooseModule != null) {
if (!repeatApiScenarioWithBLOBs.isEmpty()) {
if (!CollectionUtils.isEmpty(repeatApiScenarioWithBLOBs)) {
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
nameModuleMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + chooseModulePath, scenario -> scenario));
@ -608,7 +608,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
removeRepeat(optionData, nameModuleMap, repeatDataMap, moduleMap, versionId);
}
if (!repeatApiScenarioWithBLOBs.isEmpty()) {
if (!CollectionUtils.isEmpty(repeatApiScenarioWithBLOBs)) {
Map<String, ApiScenarioWithBLOBs> repeatMap = repeatApiScenarioWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), scenario -> scenario));
Map<String, ApiScenarioWithBLOBs> optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), scenario -> scenario));
if (fullCoverage) {
@ -786,7 +786,6 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
ApiScenarioModule scenarioModule = map.get(modulePath);
if (chooseModule != null) {
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
//导入时选了模块且接口有模块的
if (StringUtils.isNotBlank(modulePath)) {
//场景的全部路径的集合
@ -833,8 +832,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
if (chooseModule.getParentId() == null) {
chooseModule.setParentId("root");
}
String chooseModuleParentId = chooseModule.getParentId();
return chooseModuleParentId;
return chooseModule.getParentId();
}
private String getChooseModulePath(Map<String, String> idPathMap, ApiScenarioModuleDTO chooseModule, String chooseModuleParentId) {
@ -867,9 +865,12 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
for (int i = 0; i < tagTree.length; i++) {
int finalI = i;
//查找上一级里面是否有当前全路径的第一级没有则需要创建
List<ApiScenarioModule> collect = parentModuleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList());
List<ApiScenarioModule> collect = null;
if (!CollectionUtils.isEmpty(parentModuleList)) {
collect = parentModuleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList());
}
if (collect.isEmpty()) {
if (CollectionUtils.isEmpty(collect)) {
if (i == 0) {
//证明需要在根目录创建
parentModule = new ApiScenarioModule();
@ -877,7 +878,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
parentModule.setId("root");
parentModule.setLevel(0);
} else {
if (!parentModuleList.isEmpty() && parentModule == null) {
if (!CollectionUtils.isEmpty(parentModuleList) && parentModule == null) {
String parentId = parentModuleList.get(0).getParentId();
ApiScenarioModuleDTO apiScenarioModuleDTO = idModuleMap.get(parentId);
parentModule = JSON.parseObject(JSON.toJSONString(apiScenarioModuleDTO), ApiScenarioModule.class);