fix(接口测试): 接口导入其他协议判断导入无新增接口不增加模块
--user=郭雨琦 --bug=1014632 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014632
This commit is contained in:
parent
6ce353e65e
commit
53c0caeb53
|
@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -698,6 +699,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
|
|
||||||
moduleMap = getOtherApiModuleMap(fullCoverage, fullCoverageApi, chooseModuleId, moduleMap, toUpdateList, idPathMap, chooseModule, optionData, repeatApiDefinitionWithBLOBs);
|
moduleMap = getOtherApiModuleMap(fullCoverage, fullCoverageApi, chooseModuleId, moduleMap, toUpdateList, idPathMap, chooseModule, optionData, repeatApiDefinitionWithBLOBs);
|
||||||
|
|
||||||
|
//系统内检查重复
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
||||||
Map<String, ApiDefinitionWithBLOBs> repeatMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
Map<String, ApiDefinitionWithBLOBs> repeatMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
||||||
Map<String, ApiDefinitionWithBLOBs> optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
Map<String, ApiDefinitionWithBLOBs> optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
||||||
|
@ -767,10 +769,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
private Map<String, ApiModule> cover(Map<String, ApiModule> moduleMap, List<ApiDefinitionWithBLOBs> toUpdateList, Map<String, ApiDefinitionWithBLOBs> nameModuleMap, Map<String, ApiDefinitionWithBLOBs> repeatDataMap) {
|
private Map<String, ApiModule> cover(Map<String, ApiModule> moduleMap, List<ApiDefinitionWithBLOBs> toUpdateList, Map<String, ApiDefinitionWithBLOBs> nameModuleMap, Map<String, ApiDefinitionWithBLOBs> repeatDataMap) {
|
||||||
//覆盖但不覆盖模块
|
//覆盖但不覆盖模块
|
||||||
if (nameModuleMap != null) {
|
if (nameModuleMap != null) {
|
||||||
//导入文件没有新增场景无需创建接口模块
|
//导入文件没有新增接口无需创建接口模块
|
||||||
if (repeatDataMap.size() >= nameModuleMap.size()) {
|
moduleMap = judgeModule(moduleMap, nameModuleMap, repeatDataMap);
|
||||||
moduleMap = new HashMap<>();
|
|
||||||
}
|
|
||||||
Map<String, ApiDefinitionWithBLOBs> finalNameModuleMap = nameModuleMap;
|
Map<String, ApiDefinitionWithBLOBs> finalNameModuleMap = nameModuleMap;
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = finalNameModuleMap.get(k);
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = finalNameModuleMap.get(k);
|
||||||
|
@ -791,6 +791,23 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
return moduleMap;
|
return moduleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, ApiModule> judgeModule(Map<String, ApiModule> moduleMap, Map<String, ApiDefinitionWithBLOBs> nameModuleMap, Map<String, ApiDefinitionWithBLOBs> repeatDataMap) {
|
||||||
|
AtomicBoolean remove = new AtomicBoolean(true);
|
||||||
|
|
||||||
|
if (repeatDataMap.size() >= nameModuleMap.size()) {
|
||||||
|
repeatDataMap.forEach((k, v) -> {
|
||||||
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
||||||
|
if (apiDefinitionWithBLOBs == null) {
|
||||||
|
remove.set(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (remove.get()) {
|
||||||
|
moduleMap = new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return moduleMap;
|
||||||
|
}
|
||||||
|
|
||||||
private void coverModule(List<ApiDefinitionWithBLOBs> toUpdateList, Map<String, ApiDefinitionWithBLOBs> nameModuleMap, Map<String, ApiDefinitionWithBLOBs> repeatDataMap) {
|
private void coverModule(List<ApiDefinitionWithBLOBs> toUpdateList, Map<String, ApiDefinitionWithBLOBs> nameModuleMap, Map<String, ApiDefinitionWithBLOBs> repeatDataMap) {
|
||||||
if (nameModuleMap != null) {
|
if (nameModuleMap != null) {
|
||||||
Map<String, ApiDefinitionWithBLOBs> finalNameModuleMap = nameModuleMap;
|
Map<String, ApiDefinitionWithBLOBs> finalNameModuleMap = nameModuleMap;
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -72,14 +73,6 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
Map<String, List<String>> filters = new LinkedHashMap<>();
|
Map<String, List<String>> filters = new LinkedHashMap<>();
|
||||||
filters.put("status", list);
|
filters.put("status", list);
|
||||||
request.setFilters(filters);
|
request.setFilters(filters);
|
||||||
//优化:所有SQL统一查出来
|
|
||||||
// nodes.forEach(node -> {
|
|
||||||
// List<String> scenarioNodes = new ArrayList<>();
|
|
||||||
// scenarioNodes = this.nodeList(nodes, node.getId(), scenarioNodes);
|
|
||||||
// scenarioNodes.add(node.getId());
|
|
||||||
// request.setModuleIds(scenarioNodes);
|
|
||||||
// node.setCaseNum(extApiScenarioMapper.listModule(request));
|
|
||||||
// });
|
|
||||||
List<String> allModuleIdList = new ArrayList<>();
|
List<String> allModuleIdList = new ArrayList<>();
|
||||||
for (ApiScenarioModuleDTO node : nodes) {
|
for (ApiScenarioModuleDTO node : nodes) {
|
||||||
List<String> moduleIds = new ArrayList<>();
|
List<String> moduleIds = new ArrayList<>();
|
||||||
|
@ -629,9 +622,19 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, ApiScenarioModule> judgeModuleMap(Map<String, ApiScenarioModule> moduleMap, Map<String, ApiScenarioWithBLOBs> nameModuleMap, Map<String, ApiScenarioWithBLOBs> repeatDataMap) {
|
private Map<String, ApiScenarioModule> judgeModuleMap(Map<String, ApiScenarioModule> moduleMap, Map<String, ApiScenarioWithBLOBs> nameModuleMap, Map<String, ApiScenarioWithBLOBs> repeatDataMap) {
|
||||||
|
AtomicBoolean remove = new AtomicBoolean(true);
|
||||||
|
|
||||||
if (repeatDataMap.size() >= nameModuleMap.size()) {
|
if (repeatDataMap.size() >= nameModuleMap.size()) {
|
||||||
|
repeatDataMap.forEach((k, v) -> {
|
||||||
|
ApiScenarioWithBLOBs scenario = nameModuleMap.get(k);
|
||||||
|
if (scenario == null) {
|
||||||
|
remove.set(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (remove.get()) {
|
||||||
moduleMap = new HashMap<>();
|
moduleMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return moduleMap;
|
return moduleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue