fix(接口测试): 优化导入接口时的报错提示

--bug=1010779 --user=宋天阳
【接口测试】接口列表导入接口自动化的数据,报错
https://www.tapd.cn/55049933/s/1113276
This commit is contained in:
song-tianyang 2022-03-03 17:13:55 +08:00 committed by CountryBuilder
parent 7132d3ff3e
commit 6735f22213
1 changed files with 28 additions and 23 deletions

View File

@ -1148,29 +1148,34 @@ public class ApiDefinitionService {
noticeSendService.send(NoticeConstants.TaskType.SWAGGER_TASK, noticeModel);
}
}
importApi(request, apiImport);
if (CollectionUtils.isNotEmpty(apiImport.getData())) {
List<String> names = apiImport.getData().stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
request.setName(String.join(",", names));
List<String> ids = apiImport.getData().stream().map(ApiDefinitionWithBLOBs::getId).collect(Collectors.toList());
request.setId(JSON.toJSONString(ids));
}
// 发送通知
if (StringUtils.equals(request.getType(), "schedule")) {
String scheduleId = scheduleService.getScheduleInfo(request.getResourceId());
String context = request.getSwaggerUrl() + "导入成功";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("url", request.getSwaggerUrl());
NoticeModel noticeModel = NoticeModel.builder()
.operator(SessionUtils.getUserId())
.context(context)
.testId(scheduleId)
.subject(Translator.get("swagger_url_scheduled_import_notification"))
.successMailTemplate("SwaggerImport")
.paramMap(paramMap)
.event(NoticeConstants.Event.EXECUTE_SUCCESSFUL)
.build();
noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel);
try {
importApi(request, apiImport);
if (CollectionUtils.isNotEmpty(apiImport.getData())) {
List<String> names = apiImport.getData().stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
request.setName(String.join(",", names));
List<String> ids = apiImport.getData().stream().map(ApiDefinitionWithBLOBs::getId).collect(Collectors.toList());
request.setId(JSON.toJSONString(ids));
}
// 发送通知
if (StringUtils.equals(request.getType(), "schedule")) {
String scheduleId = scheduleService.getScheduleInfo(request.getResourceId());
String context = request.getSwaggerUrl() + "导入成功";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("url", request.getSwaggerUrl());
NoticeModel noticeModel = NoticeModel.builder()
.operator(SessionUtils.getUserId())
.context(context)
.testId(scheduleId)
.subject(Translator.get("swagger_url_scheduled_import_notification"))
.successMailTemplate("SwaggerImport")
.paramMap(paramMap)
.event(NoticeConstants.Event.EXECUTE_SUCCESSFUL)
.build();
noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel);
}
}catch (Exception e){
LogUtil.error(e);
MSException.throwException(Translator.get("user_import_format_wrong"));
}
return apiImport;
}