fix(接口测试): 版本创建问题

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-07-08 18:47:06 +08:00 committed by f2c-ci-robot[bot]
parent 6b63f338fa
commit 736657536f
5 changed files with 5 additions and 5 deletions

View File

@ -1334,6 +1334,7 @@ public class ApiAutomationService {
if (StringUtils.equals("fullCoverage", apiTestImportRequest.getModeId())) { if (StringUtils.equals("fullCoverage", apiTestImportRequest.getModeId())) {
_importCreate(sameList, batchMapper, extApiScenarioMapper, scenarioWithBLOBs, apiTestImportRequest, apiTestCaseMapper, apiDefinitionMapper); _importCreate(sameList, batchMapper, extApiScenarioMapper, scenarioWithBLOBs, apiTestImportRequest, apiTestCaseMapper, apiDefinitionMapper);
} else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) { } else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) {
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
if (CollectionUtils.isEmpty(sameList)) { if (CollectionUtils.isEmpty(sameList)) {
if (scenarioWithBLOBs.getVersionId() != null && scenarioWithBLOBs.getVersionId().equals("new")) { if (scenarioWithBLOBs.getVersionId() != null && scenarioWithBLOBs.getVersionId().equals("new")) {
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion())); scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
@ -1342,7 +1343,6 @@ public class ApiAutomationService {
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId()); scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
scenarioWithBLOBs.setLatest(true); scenarioWithBLOBs.setLatest(true);
} }
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) { if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getVersionId()); scenarioWithBLOBs.setVersionId(apiTestImportRequest.getVersionId());
} else { } else {

View File

@ -804,6 +804,7 @@ public class ApiDefinitionService {
} else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) { } else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) {
if (CollectionUtils.isEmpty(collect)) { if (CollectionUtils.isEmpty(collect)) {
String originId = apiDefinition.getId(); String originId = apiDefinition.getId();
apiDefinition.setId(UUID.randomUUID().toString());
//postman 可能含有前置脚本接口定义去掉脚本 //postman 可能含有前置脚本接口定义去掉脚本
if (apiDefinition.getVersionId() != null && apiDefinition.getVersionId().equals("new")) { if (apiDefinition.getVersionId() != null && apiDefinition.getVersionId().equals("new")) {
apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion())); apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
@ -812,7 +813,6 @@ public class ApiDefinitionService {
apiDefinition.setRefId(apiDefinition.getId()); apiDefinition.setRefId(apiDefinition.getId());
apiDefinition.setLatest(true); // 新增的接口 latest = true apiDefinition.setLatest(true); // 新增的接口 latest = true
} }
apiDefinition.setId(UUID.randomUUID().toString());
if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) { if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) {
apiDefinition.setVersionId(apiTestImportRequest.getVersionId()); apiDefinition.setVersionId(apiTestImportRequest.getVersionId());
} else { } else {
@ -820,7 +820,6 @@ public class ApiDefinitionService {
} }
batchMapper.insert(apiDefinition); batchMapper.insert(apiDefinition);
String requestStr = setImportHashTree(apiDefinition); String requestStr = setImportHashTree(apiDefinition);
// case 设置版本 // case 设置版本
cases.forEach(c -> { cases.forEach(c -> {
c.setVersionId(apiDefinition.getVersionId()); c.setVersionId(apiDefinition.getVersionId());

View File

@ -749,7 +749,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
List<String> nameList = optionData.stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList()); List<String> nameList = optionData.stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
//获取系统内重复数据 //获取系统内重复数据
repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByProtocol(nameList, protocol); repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByProtocol(nameList, protocol, projectId);
Map<String, ApiDefinitionWithBLOBs> repeatDataMap = null; Map<String, ApiDefinitionWithBLOBs> repeatDataMap = null;

View File

@ -97,7 +97,7 @@ public interface ExtApiDefinitionMapper {
List<ApiDefinitionWithBLOBs> selectRepeatByBLOBsSameUrl(@Param("blobs") List<ApiDefinitionWithBLOBs> blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId); List<ApiDefinitionWithBLOBs> selectRepeatByBLOBsSameUrl(@Param("blobs") List<ApiDefinitionWithBLOBs> blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId);
List<ApiDefinitionWithBLOBs> selectRepeatByProtocol(@Param("names") List<String> names, @Param("protocol") String protocol); List<ApiDefinitionWithBLOBs> selectRepeatByProtocol(@Param("names") List<String> names, @Param("protocol") String protocol, @Param("projectId") String projectId);
int countById(String id); int countById(String id);
} }

View File

@ -1102,6 +1102,7 @@
#{name} #{name}
</foreach> </foreach>
and protocol = #{protocol} and protocol = #{protocol}
and project_id = #{projectId}
and status != 'Trash' and status != 'Trash'
</select> </select>
<sql id="Same_Where_Clause"> <sql id="Same_Where_Clause">