fix(接口测试): 定时任务导入问题

--user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001016673
This commit is contained in:
guoyuqi 2022-09-08 18:24:42 +08:00 committed by xiaomeinvG
parent af1428fa21
commit 7a7260f014
1 changed files with 6 additions and 6 deletions

View File

@ -173,6 +173,7 @@ public class ApiDefinitionService {
private final ThreadLocal<Long> currentApiOrder = new ThreadLocal<>(); private final ThreadLocal<Long> currentApiOrder = new ThreadLocal<>();
private final ThreadLocal<Long> currentApiCaseOrder = new ThreadLocal<>(); private final ThreadLocal<Long> currentApiCaseOrder = new ThreadLocal<>();
private static final String COPY = "Copy"; private static final String COPY = "Copy";
private static final String SCHEDULE = "schedule";
public List<ApiDefinitionResult> list(ApiDefinitionRequest request) { public List<ApiDefinitionResult> list(ApiDefinitionRequest request) {
request = this.initRequest(request, true, true); request = this.initRequest(request, true, true);
@ -1674,7 +1675,7 @@ public class ApiDefinitionService {
MSException.throwException(e.getMessage()); MSException.throwException(e.getMessage());
} }
} }
if (StringUtils.equals(request.getType(), "schedule")) { if (StringUtils.equals(request.getType(), SCHEDULE)) {
request.setProtocol("HTTP"); request.setProtocol("HTTP");
} }
try { try {
@ -1702,7 +1703,7 @@ public class ApiDefinitionService {
request.setId(JSON.toJSONString(ids)); request.setId(JSON.toJSONString(ids));
} }
// 发送通知 // 发送通知
if (StringUtils.equals(request.getType(), "schedule")) { if (StringUtils.equals(request.getType(), SCHEDULE)) {
String scheduleId = scheduleService.getScheduleInfo(request.getResourceId()); String scheduleId = scheduleService.getScheduleInfo(request.getResourceId());
String context = request.getSwaggerUrl() + "导入成功"; String context = request.getSwaggerUrl() + "导入成功";
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
@ -1717,7 +1718,7 @@ public class ApiDefinitionService {
.build(); .build();
noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel); noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel);
} }
if (CollectionUtils.isNotEmpty(apiImportSendNoticeDTOS)) { if (!StringUtils.equals(request.getType(), SCHEDULE) && CollectionUtils.isNotEmpty(apiImportSendNoticeDTOS)) {
for (ApiImportSendNoticeDTO apiImportSendNoticeDTO : apiImportSendNoticeDTOS) { for (ApiImportSendNoticeDTO apiImportSendNoticeDTO : apiImportSendNoticeDTOS) {
if (apiImportSendNoticeDTO.getApiDefinitionResult() != null && !apiImportSendNoticeDTO.getApiDefinitionResult().isUpdated()) { if (apiImportSendNoticeDTO.getApiDefinitionResult() != null && !apiImportSendNoticeDTO.getApiDefinitionResult().isUpdated()) {
sendImportApiCreateNotice(apiImportSendNoticeDTO.getApiDefinitionResult()); sendImportApiCreateNotice(apiImportSendNoticeDTO.getApiDefinitionResult());
@ -1729,8 +1730,7 @@ public class ApiDefinitionService {
for (ApiTestCaseDTO apiTestCaseDTO : apiImportSendNoticeDTO.getCaseDTOList()) { for (ApiTestCaseDTO apiTestCaseDTO : apiImportSendNoticeDTO.getCaseDTOList()) {
if (apiTestCaseDTO.isUpdated()) { if (apiTestCaseDTO.isUpdated()) {
sendImportCaseUpdateNotice(apiTestCaseDTO); sendImportCaseUpdateNotice(apiTestCaseDTO);
} } else {
if (!apiTestCaseDTO.isUpdated()) {
sendImportCaseCreateNotice(apiTestCaseDTO); sendImportCaseCreateNotice(apiTestCaseDTO);
} }
} }
@ -1746,7 +1746,7 @@ public class ApiDefinitionService {
} }
private void sendFailMessage(ApiTestImportRequest request, Project project) { private void sendFailMessage(ApiTestImportRequest request, Project project) {
if (StringUtils.equals(request.getType(), "schedule")) { if (StringUtils.equals(request.getType(), SCHEDULE)) {
String scheduleId = scheduleService.getScheduleInfo(request.getResourceId()); String scheduleId = scheduleService.getScheduleInfo(request.getResourceId());
String context = request.getSwaggerUrl() + "导入失败"; String context = request.getSwaggerUrl() + "导入失败";
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();