refactor(接口测试): 接口测试发送脚本通知增加报错日志

This commit is contained in:
wxg0103 2023-05-22 17:11:52 +08:00 committed by fit2-zhao
parent 260c2dca4c
commit 412c2270fc
2 changed files with 66 additions and 38 deletions

View File

@ -1348,6 +1348,7 @@ public class ApiTestCaseService {
String requestTarget,
String sendUser) {
try {
ProjectApplication scriptEnable = baseProjectApplicationService
.getProjectApplication(projectId, ProjectApplicationType.API_REVIEW_TEST_SCRIPT.name());
@ -1377,6 +1378,9 @@ public class ApiTestCaseService {
}
}
}
} catch (Exception e) {
LogUtil.error("发送通知失败", e);
}
}
}

View File

@ -85,6 +85,8 @@ public class BaseEnvironmentService extends NodeTreeService<ApiModuleDTO> {
private BaseProjectApplicationService baseProjectApplicationService;
@Resource
private NotificationService notificationService;
@Resource
private UserGroupMapper userGroupMapper;
public static final String MOCK_EVN_NAME = "Mock环境";
@ -505,6 +507,23 @@ public class BaseEnvironmentService extends NodeTreeService<ApiModuleDTO> {
ApiTestEnvironmentWithBLOBs envOrg = apiTestEnvironmentMapper.selectByPrimaryKey(apiTestEnvironment.getId());
apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment);
if (StringUtils.isBlank(apiTestEnvironment.getCreateUser())) {
UserGroupExample example = new UserGroupExample();
example.createCriteria().andSourceIdEqualTo(apiTestEnvironment.getProjectId()).andGroupIdEqualTo("project_admin");
List<UserGroup> userGroups = userGroupMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(userGroups)) {
userGroups.forEach(userGroup -> {
checkAndSendReviewMessage(apiTestEnvironment.getId(),
apiTestEnvironment.getName(),
apiTestEnvironment.getProjectId(),
NoticeConstants.TaskType.ENV_TASK,
envOrg.getConfig(),
apiTestEnvironment.getConfig(),
userGroup.getUserId()
);
});
}
} else {
checkAndSendReviewMessage(apiTestEnvironment.getId(),
apiTestEnvironment.getName(),
apiTestEnvironment.getProjectId(),
@ -513,6 +532,7 @@ public class BaseEnvironmentService extends NodeTreeService<ApiModuleDTO> {
apiTestEnvironment.getConfig(),
apiTestEnvironment.getCreateUser()
);
}
}
@ -1019,6 +1039,7 @@ public class BaseEnvironmentService extends NodeTreeService<ApiModuleDTO> {
String requestOrg,
String requestTarget,
String sendUser) {
try {
ProjectApplication scriptEnable = baseProjectApplicationService
.getProjectApplication(projectId, ProjectApplicationType.API_REVIEW_TEST_SCRIPT.name());
@ -1050,6 +1071,9 @@ public class BaseEnvironmentService extends NodeTreeService<ApiModuleDTO> {
}
}
}
} catch (Exception e) {
LogUtil.error("发送通知失败", e);
}
}
public static List<String> scriptList(String request) {