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

This commit is contained in:
fit2-zhao 2022-03-14 14:13:04 +08:00 committed by fit2-zhao
parent 5c2be79342
commit 8cd262f3f4
2 changed files with 10 additions and 7 deletions

View File

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

View File

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