refactor (接口测试): 优化场景步骤初始化方法

This commit is contained in:
fit2-zhao 2022-03-14 14:13:04 +08:00 committed by fit2-zhao
parent 36a1bfe8b9
commit 64b6b6a9ca
2 changed files with 10 additions and 7 deletions

View File

@ -1174,7 +1174,7 @@ public class ApiDefinitionService {
.build(); .build();
noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel); noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel);
} }
}catch (Exception e){ } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
MSException.throwException(Translator.get("user_import_format_wrong")); MSException.throwException(Translator.get("user_import_format_wrong"));
} }
@ -1809,13 +1809,14 @@ public class ApiDefinitionService {
public ApiDefinitionResult getById(String id) { public ApiDefinitionResult getById(String id) {
ApiDefinitionRequest request = new ApiDefinitionRequest(); ApiDefinitionRequest request = new ApiDefinitionRequest();
request.setId(id); request.setId(id);
List<ApiDefinitionResult> list = list(request); List<ApiDefinitionResult> list = extApiDefinitionMapper.list(request);
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
return list.get(0); return list.get(0);
} }
return null; return null;
} }
public long countEffectiveByProjectId(String projectId) { public long countEffectiveByProjectId(String projectId) {
if (StringUtils.isEmpty(projectId)) { if (StringUtils.isEmpty(projectId)) {
return 0; return 0;

View File

@ -201,6 +201,7 @@ public class MsHashTreeService {
this.setElement(element, apiTestCase.getNum(), enable, apiTestCase.getVersionName(), apiTestCase.getVersionEnable()); this.setElement(element, apiTestCase.getNum(), enable, apiTestCase.getVersionName(), apiTestCase.getVersionEnable());
} }
} else { } else {
if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), "Copy")) {
ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString(ID)); ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString(ID));
if (definitionWithBLOBs != null) { if (definitionWithBLOBs != null) {
element.put(ID, definitionWithBLOBs.getId()); element.put(ID, definitionWithBLOBs.getId());
@ -208,6 +209,7 @@ public class MsHashTreeService {
isExist = true; isExist = true;
} }
} }
}
if (!isExist) { if (!isExist) {
if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), REF)) { if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), REF)) {
element.put(ENABLE, false); element.put(ENABLE, false);