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,11 +201,13 @@ 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 {
ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString(ID)); if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), "Copy")) {
if (definitionWithBLOBs != null) { ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString(ID));
element.put(ID, definitionWithBLOBs.getId()); if (definitionWithBLOBs != null) {
this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable()); element.put(ID, definitionWithBLOBs.getId());
isExist = true; this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable());
isExist = true;
}
} }
} }
if (!isExist) { if (!isExist) {