fix(接口测试): 修复消息通知人错误问题
--bug=1021753 --user=赵勇 【项目设置】站内消息通知用户名显示错误 https://www.tapd.cn/55049933/s/1324990
This commit is contained in:
parent
1df1817063
commit
32d335c6fd
|
@ -11,4 +11,7 @@ public class CommonConstants {
|
||||||
public static final String USER_ID = "userId";
|
public static final String USER_ID = "userId";
|
||||||
public static final String METHODS_KEY = "methods";
|
public static final String METHODS_KEY = "methods";
|
||||||
public static final String CASE = "CASE";
|
public static final String CASE = "CASE";
|
||||||
|
public static final String USER = "user";
|
||||||
|
public static final String USER_NAME = "userName";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,18 +95,7 @@ public class ApiDefinitionExecResultService {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result.setResourceId(dto.getTestId());
|
result.setResourceId(dto.getTestId());
|
||||||
apiExecutionInfoService.insertExecutionInfo(result);
|
apiExecutionInfoService.insertExecutionInfo(result);
|
||||||
User user = null;
|
User user = getUser(dto, result);
|
||||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters())) {
|
|
||||||
if (dto.getExtendedParameters().containsKey(CommonConstants.USER_ID) && dto.getExtendedParameters().containsKey("userName")) {
|
|
||||||
user = new User() {{
|
|
||||||
this.setId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
|
||||||
this.setName(dto.getExtendedParameters().get("userName").toString());
|
|
||||||
}};
|
|
||||||
result.setUserId(user.getId());
|
|
||||||
} else if (dto.getExtendedParameters().containsKey(CommonConstants.USER_ID)) {
|
|
||||||
result.setUserId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//如果是测试计划用例,更新接口用例的上次执行结果
|
//如果是测试计划用例,更新接口用例的上次执行结果
|
||||||
TestPlanApiCase testPlanApiCase = testPlanApiCaseMapper.selectByPrimaryKey(dto.getTestId());
|
TestPlanApiCase testPlanApiCase = testPlanApiCaseMapper.selectByPrimaryKey(dto.getTestId());
|
||||||
if (testPlanApiCase != null) {
|
if (testPlanApiCase != null) {
|
||||||
|
@ -147,10 +136,12 @@ public class ApiDefinitionExecResultService {
|
||||||
// 批量更新关联关系状态
|
// 批量更新关联关系状态
|
||||||
batchEditStatus(dto.getRunMode(), result.getStatus(), result.getId(), dto.getTestId(), planApiCaseMapper, batchApiTestCaseMapper);
|
batchEditStatus(dto.getRunMode(), result.getStatus(), result.getId(), dto.getTestId(), planApiCaseMapper, batchApiTestCaseMapper);
|
||||||
}
|
}
|
||||||
if (result != null && !StringUtils.startsWithAny(dto.getRunMode(), "SCHEDULE")) {
|
if (result != null && !StringUtils.startsWithAny(dto.getRunMode(), NoticeConstants.Mode.SCHEDULE)) {
|
||||||
User user = null;
|
User user = getUser(dto, result);
|
||||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("user") && dto.getExtendedParameters().get("user") instanceof User) {
|
if (MapUtils.isNotEmpty(dto.getExtendedParameters())
|
||||||
user = (User) dto.getExtendedParameters().get("user");
|
&& dto.getExtendedParameters().containsKey(CommonConstants.USER)
|
||||||
|
&& dto.getExtendedParameters().get(CommonConstants.USER) instanceof User) {
|
||||||
|
user = (User) dto.getExtendedParameters().get(CommonConstants.USER);
|
||||||
}
|
}
|
||||||
// 发送通知
|
// 发送通知
|
||||||
result.setResourceId(dto.getTestId());
|
result.setResourceId(dto.getTestId());
|
||||||
|
@ -166,6 +157,23 @@ public class ApiDefinitionExecResultService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private User getUser(ResultDTO dto, ApiDefinitionExecResult result) {
|
||||||
|
User user = null;
|
||||||
|
if (MapUtils.isNotEmpty(dto.getExtendedParameters())) {
|
||||||
|
if (dto.getExtendedParameters().containsKey(CommonConstants.USER_ID)
|
||||||
|
&& dto.getExtendedParameters().containsKey(CommonConstants.USER_NAME)) {
|
||||||
|
user = new User() {{
|
||||||
|
this.setId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
||||||
|
this.setName(dto.getExtendedParameters().get(CommonConstants.USER_NAME).toString());
|
||||||
|
}};
|
||||||
|
result.setUserId(user.getId());
|
||||||
|
} else if (dto.getExtendedParameters().containsKey(CommonConstants.USER_ID)) {
|
||||||
|
result.setUserId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
private void sendNotice(ApiDefinitionExecResult result, User user) {
|
private void sendNotice(ApiDefinitionExecResult result, User user) {
|
||||||
try {
|
try {
|
||||||
String resourceId = result.getResourceId();
|
String resourceId = result.getResourceId();
|
||||||
|
|
Loading…
Reference in New Issue