feat(项目管理): 项目管理增加测试计划增删改和功能用例执行通过失败的事件

This commit is contained in:
guoyuqi 2024-05-10 17:30:18 +08:00 committed by 刘瑞斌
parent 2b6ef2d8f9
commit c245a17d72
10 changed files with 196 additions and 15 deletions

View File

@ -217,7 +217,7 @@ message.functional_case_task_delete=${OPERATOR}删除了功能用例:${name}
message.functional_case_task_comment=${OPERATOR}评论了你的功能用例:${name} message.functional_case_task_comment=${OPERATOR}评论了你的功能用例:${name}
message.functional_case_task_review=${OPERATOR}评审了${reviewName}${name} message.functional_case_task_review=${OPERATOR}评审了${reviewName}${name}
message.functional_case_task_review_at=${OPERATOR}在${reviewName}${name}@了你 message.functional_case_task_review_at=${OPERATOR}在${reviewName}${name}@了你
message.functional_case_task_plan=${OPERATOR}评审了${testPlanName}${name} message.functional_case_task_plan=${OPERATOR}执行了${testPlanName}${name}
message.functional_case_task_plan_at=${OPERATOR}在${testPlanName}${name}@了你 message.functional_case_task_plan_at=${OPERATOR}在${testPlanName}${name}@了你
message.functional_case_task_at_comment=${OPERATOR}评论了功能用例:${name} 并@了你 message.functional_case_task_at_comment=${OPERATOR}评论了功能用例:${name} 并@了你

View File

@ -255,7 +255,7 @@ message.functional_case_task_delete=${OPERATOR} deleted the functional case: ${n
message.functional_case_task_comment=${OPERATOR} commented on your functional case: ${name} message.functional_case_task_comment=${OPERATOR} commented on your functional case: ${name}
message.functional_case_task_review=${OPERATOR} reviewed ${reviewName} ${name} message.functional_case_task_review=${OPERATOR} reviewed ${reviewName} ${name}
message.functional_case_task_review_at=${OPERATOR} @ you in ${reviewName} ${name} message.functional_case_task_review_at=${OPERATOR} @ you in ${reviewName} ${name}
message.functional_case_task_plan=${OPERATOR} reviewed ${testPlanName} ${name} message.functional_case_task_plan=${OPERATOR} executed ${testPlanName} ${name}
message.functional_case_task_plan_at=${OPERATOR} @ you in ${testPlanName} ${name} message.functional_case_task_plan_at=${OPERATOR} @ you in ${testPlanName} ${name}

View File

@ -255,7 +255,7 @@ message.functional_case_task_delete=${OPERATOR}删除了功能用例:${name}
message.functional_case_task_comment=${OPERATOR}评论了你的功能用例:${name} message.functional_case_task_comment=${OPERATOR}评论了你的功能用例:${name}
message.functional_case_task_review=${OPERATOR}评审了${reviewName}${name} message.functional_case_task_review=${OPERATOR}评审了${reviewName}${name}
message.functional_case_task_review_at=${OPERATOR}在${reviewName}${name}@了你 message.functional_case_task_review_at=${OPERATOR}在${reviewName}${name}@了你
message.functional_case_task_plan=${OPERATOR}评审了${testPlanName}${name} message.functional_case_task_plan=${OPERATOR}执行了${testPlanName}${name}
message.functional_case_task_plan_at=${OPERATOR}在${testPlanName}${name}@了你 message.functional_case_task_plan_at=${OPERATOR}在${testPlanName}${name}@了你

View File

@ -255,7 +255,7 @@ message.functional_case_task_delete=${OPERATOR}刪除了功能用例:${name}
message.functional_case_task_comment=${OPERATOR}評論了你的功能用例:${name} message.functional_case_task_comment=${OPERATOR}評論了你的功能用例:${name}
message.functional_case_task_review=${OPERATOR}評審了${reviewName}${name} message.functional_case_task_review=${OPERATOR}評審了${reviewName}${name}
message.functional_case_task_review_at=${OPERATOR}在${reviewName}${name}@了你 message.functional_case_task_review_at=${OPERATOR}在${reviewName}${name}@了你
message.functional_case_task_plan=${OPERATOR}評審了${testPlanName}${name} message.functional_case_task_plan=${OPERATOR}執行了${testPlanName}${name}
message.functional_case_task_plan_at=${OPERATOR}在${testPlanName}${name}@了你 message.functional_case_task_plan_at=${OPERATOR}在${testPlanName}${name}@了你

View File

@ -12,6 +12,12 @@ import io.metersphere.functional.request.FunctionalCaseAddRequest;
import io.metersphere.functional.request.FunctionalCaseCommentRequest; import io.metersphere.functional.request.FunctionalCaseCommentRequest;
import io.metersphere.functional.request.FunctionalCaseEditRequest; import io.metersphere.functional.request.FunctionalCaseEditRequest;
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest; import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
import io.metersphere.plan.domain.TestPlan;
import io.metersphere.plan.domain.TestPlanExample;
import io.metersphere.plan.domain.TestPlanFunctionalCase;
import io.metersphere.plan.domain.TestPlanFunctionalCaseExample;
import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper;
import io.metersphere.plan.mapper.TestPlanMapper;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.JSON;
import io.metersphere.system.domain.CustomField; import io.metersphere.system.domain.CustomField;
@ -52,6 +58,10 @@ public class FunctionalCaseNoticeService {
@Resource @Resource
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper; private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
@Resource @Resource
private TestPlanFunctionalCaseMapper testPlanFunctionalCaseMapper;
@Resource
private TestPlanMapper testPlanMapper;
@Resource
private CaseReviewMapper caseReviewMapper; private CaseReviewMapper caseReviewMapper;
@Resource @Resource
@ -66,7 +76,7 @@ public class FunctionalCaseNoticeService {
setNotifier(functionalCaseCommentRequest, functionalCaseDTO); setNotifier(functionalCaseCommentRequest, functionalCaseDTO);
List<OptionDTO> customFields = getCustomFields(functionalCaseCommentRequest.getCaseId()); List<OptionDTO> customFields = getCustomFields(functionalCaseCommentRequest.getCaseId());
functionalCaseDTO.setFields(customFields); functionalCaseDTO.setFields(customFields);
//TODO:设置测试计划名称 setPlanName(functionalCaseCommentRequest.getCaseId(), functionalCaseDTO);
setReviewName(functionalCaseCommentRequest.getCaseId(), functionalCaseDTO); setReviewName(functionalCaseCommentRequest.getCaseId(), functionalCaseDTO);
return functionalCaseDTO; return functionalCaseDTO;
} }
@ -168,7 +178,7 @@ public class FunctionalCaseNoticeService {
} }
} }
functionalCaseDTO.setFields(fields); functionalCaseDTO.setFields(fields);
//TODO:设置测试计划名称 setPlanName(request.getId(), functionalCaseDTO);
return functionalCaseDTO; return functionalCaseDTO;
} }
@ -187,6 +197,21 @@ public class FunctionalCaseNoticeService {
} }
} }
private void setPlanName(String caseId, FunctionalCaseDTO functionalCaseDTO) {
TestPlanFunctionalCaseExample testPlanFunctionalCaseExample = new TestPlanFunctionalCaseExample();
testPlanFunctionalCaseExample.createCriteria().andFunctionalCaseIdEqualTo(caseId);
List<TestPlanFunctionalCase> testPlanFunctionalCases = testPlanFunctionalCaseMapper.selectByExample(testPlanFunctionalCaseExample);
List<String> planIds = testPlanFunctionalCases.stream().map(TestPlanFunctionalCase::getTestPlanId).distinct().toList();
if (CollectionUtils.isNotEmpty(planIds)) {
TestPlanExample testPlanExample = new TestPlanExample();
testPlanExample.createCriteria().andIdIn(planIds);
List<TestPlan> testPlans = testPlanMapper.selectByExample(testPlanExample);
List<String> planName = testPlans.stream().map(TestPlan::getName).toList();
String string = planName.toString();
functionalCaseDTO.setTestPlanName(string);
}
}
public FunctionalCaseDTO getDeleteFunctionalCaseDTO(String id) { public FunctionalCaseDTO getDeleteFunctionalCaseDTO(String id) {
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(id); FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(id);
@ -197,7 +222,7 @@ public class FunctionalCaseNoticeService {
functionalCaseDTO.setFields(customFields); functionalCaseDTO.setFields(customFields);
}); });
//TODO:设置测试计划名称 setPlanName(id, functionalCaseDTO);
setReviewName(id, functionalCaseDTO); setReviewName(id, functionalCaseDTO);
return functionalCaseDTO; return functionalCaseDTO;
} }
@ -218,6 +243,10 @@ public class FunctionalCaseNoticeService {
caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(ids); caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(ids);
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
List<String> reviewIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getReviewId).distinct().toList(); List<String> reviewIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getReviewId).distinct().toList();
TestPlanFunctionalCaseExample testPlanFunctionalCaseExample = new TestPlanFunctionalCaseExample();
testPlanFunctionalCaseExample.createCriteria().andFunctionalCaseIdIn(ids);
List<TestPlanFunctionalCase> testPlanFunctionalCases = testPlanFunctionalCaseMapper.selectByExample(testPlanFunctionalCaseExample);
List<String> planIds = testPlanFunctionalCases.stream().map(TestPlanFunctionalCase::getTestPlanId).distinct().toList();
Map<String, String> reviewMap = new HashMap<>(); Map<String, String> reviewMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(reviewIds)) { if (CollectionUtils.isNotEmpty(reviewIds)) {
CaseReviewExample caseReviewExample = new CaseReviewExample(); CaseReviewExample caseReviewExample = new CaseReviewExample();
@ -225,8 +254,17 @@ public class FunctionalCaseNoticeService {
List<CaseReview> caseReviews = caseReviewMapper.selectByExample(caseReviewExample); List<CaseReview> caseReviews = caseReviewMapper.selectByExample(caseReviewExample);
reviewMap = caseReviews.stream().collect(Collectors.toMap(CaseReview::getId, CaseReview::getName)); reviewMap = caseReviews.stream().collect(Collectors.toMap(CaseReview::getId, CaseReview::getName));
} }
Map<String, String> planMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(planIds)) {
TestPlanExample testPlanExample = new TestPlanExample();
testPlanExample.createCriteria().andIdIn(planIds);
List<TestPlan> testPlans = testPlanMapper.selectByExample(testPlanExample);
planMap = testPlans.stream().collect(Collectors.toMap(TestPlan::getId, TestPlan::getName));
}
Map<String, List<CaseReviewFunctionalCase>> caseReviewMap = caseReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId)); Map<String, List<CaseReviewFunctionalCase>> caseReviewMap = caseReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId));
Map<String, List<TestPlanFunctionalCase>> casePlanMap = testPlanFunctionalCases.stream().collect(Collectors.groupingBy(TestPlanFunctionalCase::getFunctionalCaseId));
Map<String, String> finalReviewMap = reviewMap; Map<String, String> finalReviewMap = reviewMap;
Map<String, String> finalPlanMap = planMap;
ids.forEach(id -> { ids.forEach(id -> {
FunctionalCase functionalCase = functionalCaseMap.get(id); FunctionalCase functionalCase = functionalCaseMap.get(id);
if (functionalCase != null) { if (functionalCase != null) {
@ -249,12 +287,23 @@ public class FunctionalCaseNoticeService {
reviewName.add(s); reviewName.add(s);
} }
} }
List<TestPlanFunctionalCase> planFunctionalCases = casePlanMap.get(id);
List<String>planName = new ArrayList<>();
if (CollectionUtils.isNotEmpty(planFunctionalCases)) {
for (TestPlanFunctionalCase planFunctionalCase : planFunctionalCases) {
String s = finalPlanMap.get(planFunctionalCase.getTestPlanId());
planName.add(s);
}
}
List<String> list = reviewName.stream().distinct().toList(); List<String> list = reviewName.stream().distinct().toList();
functionalCaseDTO.setReviewName(list.toString()); functionalCaseDTO.setReviewName(list.toString());
List<String> planNameList = planName.stream().distinct().toList();
functionalCaseDTO.setTestPlanName(planNameList.toString());
dtoList.add(functionalCaseDTO); dtoList.add(functionalCaseDTO);
} }
}); });
//TODO:设置测试计划名称
} }
return dtoList; return dtoList;
} }
@ -267,6 +316,7 @@ public class FunctionalCaseNoticeService {
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(request.getId()); FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(request.getId());
BeanUtils.copyBean(functionalCaseDTO, functionalCase); BeanUtils.copyBean(functionalCaseDTO, functionalCase);
setReviewName(request.getId(), functionalCaseDTO); setReviewName(request.getId(), functionalCaseDTO);
setPlanName(request.getId(), functionalCaseDTO);
functionalCaseDTO.setTriggerMode(NoticeConstants.TriggerMode.MANUAL_EXECUTION); functionalCaseDTO.setTriggerMode(NoticeConstants.TriggerMode.MANUAL_EXECUTION);
List<OptionDTO> fields = new ArrayList<>(); List<OptionDTO> fields = new ArrayList<>();
FunctionalCaseCustomFieldExample fieldExample = new FunctionalCaseCustomFieldExample(); FunctionalCaseCustomFieldExample fieldExample = new FunctionalCaseCustomFieldExample();
@ -294,7 +344,6 @@ public class FunctionalCaseNoticeService {
} }
} }
functionalCaseDTO.setFields(fields); functionalCaseDTO.setFields(fields);
//TODO:设置测试计划名称
return functionalCaseDTO; return functionalCaseDTO;
} }

View File

@ -1,4 +1,87 @@
[ [
{
"projectId":"",
"type":"TEST_PLAN_MANAGEMENT",
"name":"",
"messageTaskTypeDTOList":[
{
"taskType":"TEST_PLAN_TASK",
"taskTypeName":"",
"messageTaskDetailDTOList":[
{
"event":"CREATE",
"eventName":"",
"receivers":[
{
"id": "",
"name": ""
}
],
"projectRobotConfigList":[
{
"robotId":"",
"enable":"",
"template":"",
"defaultTemplate":"",
"useDefaultTemplate":true,
"subject":"",
"defaultSubject":"",
"useDefaultSubject":true
}
]
},
{
"event":"UPDATE",
"eventName":"",
"receivers":[
{
"id": "CREATE_USER",
"name": ""
},
{
"id": "FOLLOW_PEOPLE",
"name": ""
}
],
"projectRobotConfigList":[
{
"robotId":"",
"enable":"",
"template":"",
"defaultTemplate":"",
"useDefaultTemplate":true,
"subject":"",
"defaultSubject":"",
"useDefaultSubject":true
}
]
},
{
"event":"DELETE",
"eventName":"",
"receivers":[
{
"id": "CREATE_USER",
"name": ""
}
],
"projectRobotConfigList":[
{
"robotId":"",
"enable":"",
"template":"",
"defaultTemplate":"",
"useDefaultTemplate":true,
"subject":"",
"defaultSubject":"",
"useDefaultSubject":true
}
]
}
]
}
]
},
{ {
"projectId":"", "projectId":"",
"type":"BUG_MANAGEMENT", "type":"BUG_MANAGEMENT",
@ -255,6 +338,50 @@
} }
] ]
}, },
{
"event":"EXECUTE_PASSED",
"eventName":"",
"receivers":[
{
"id": "CREATE_USER",
"name": ""
}
],
"projectRobotConfigList":[
{
"robotId":"",
"enable":"",
"template":"",
"defaultTemplate":"",
"useDefaultTemplate":true,
"subject":"",
"defaultSubject":"",
"useDefaultSubject":true
}
]
},
{
"event":"EXECUTE_FAIL",
"eventName":"",
"receivers":[
{
"id": "CREATE_USER",
"name": ""
}
],
"projectRobotConfigList":[
{
"robotId":"",
"enable":"",
"template":"",
"defaultTemplate":"",
"useDefaultTemplate":true,
"subject":"",
"defaultSubject":"",
"useDefaultSubject":true
}
]
},
{ {
"event":"COMMENT", "event":"COMMENT",
"eventName":"", "eventName":"",

View File

@ -11,9 +11,9 @@ public class FunctionalCaseMessageDTO {
@Schema(description ="message.domain.name") @Schema(description ="message.domain.name")
private String name; private String name;
/* @Schema(description = "message.domain.testPlanName") @Schema(description = "message.domain.testPlanName")
private String testPlanName; private String testPlanName;
*/
@Schema(description = "message.domain.reviewName") @Schema(description = "message.domain.reviewName")
private String reviewName; private String reviewName;
@ -23,8 +23,8 @@ public class FunctionalCaseMessageDTO {
@Schema(description = "message.domain.caseModel") @Schema(description = "message.domain.caseModel")
private String caseEditType; private String caseEditType;
/* @Schema(description = "message.domain.lastExecuteResult") @Schema(description = "message.domain.lastExecuteResult")
private String lastExecuteResult;*/ private String lastExecuteResult;
@Schema(description = "message.domain.createUser") @Schema(description = "message.domain.createUser")
private String createUser; private String createUser;

View File

@ -255,9 +255,9 @@ public interface NoticeConstants {
@Schema(description = "message.functional_case_task_review_at") @Schema(description = "message.functional_case_task_review_at")
String FUNCTIONAL_CASE_TASK_REVIEW_AT = "FUNCTIONAL_CASE_TASK_REVIEW_AT";//${OPERATOR}在${reviewName}${name} @了你 String FUNCTIONAL_CASE_TASK_REVIEW_AT = "FUNCTIONAL_CASE_TASK_REVIEW_AT";//${OPERATOR}在${reviewName}${name} @了你
@Schema(description = "message.functional_case_task_plan") @Schema(description = "message.functional_case_task_plan")
String FUNCTIONAL_CASE_TASK_EXECUTE_PASSED = "FUNCTIONAL_CASE_TASK_EXECUTE_PASSED";//${OPERATOR}评审了${testPlanName}${name} String FUNCTIONAL_CASE_TASK_EXECUTE_PASSED = "FUNCTIONAL_CASE_TASK_EXECUTE_PASSED";//${OPERATOR}执行了${testPlanName}${name}
@Schema(description = "message.functional_case_task_plan") @Schema(description = "message.functional_case_task_plan")
String FUNCTIONAL_CASE_TASK_EXECUTE_FAIL = "FUNCTIONAL_CASE_TASK_EXECUTE_FAIL";//${OPERATOR}评审了${testPlanName}${name} String FUNCTIONAL_CASE_TASK_EXECUTE_FAIL = "FUNCTIONAL_CASE_TASK_EXECUTE_FAIL";//${OPERATOR}执行了${testPlanName}${name}
@Schema(description = "message.functional_case_task_plan_at") @Schema(description = "message.functional_case_task_plan_at")
String FUNCTIONAL_CASE_TASK_EXECUTE_AT = "FUNCTIONAL_CASE_TASK_EXECUTE_AT";//${OPERATOR}在${testPlanName}${name}@了你 String FUNCTIONAL_CASE_TASK_EXECUTE_AT = "FUNCTIONAL_CASE_TASK_EXECUTE_AT";//${OPERATOR}在${testPlanName}${name}@了你
@Schema(description = "message.functional_case_task_at_comment") @Schema(description = "message.functional_case_task_at_comment")

View File

@ -95,6 +95,9 @@ public class NotificationService {
if (k.contains("SCHEDULE")) { if (k.contains("SCHEDULE")) {
countMap.merge("SCHEDULE", v.size(), Integer::sum); countMap.merge("SCHEDULE", v.size(), Integer::sum);
} }
if (k.contains("TEST_PLAN")) {
countMap.merge("TEST_PLAN", v.size(), Integer::sum);
}
}); });
countMap.forEach((k, v) -> { countMap.forEach((k, v) -> {
OptionDTO optionDTO = new OptionDTO(); OptionDTO optionDTO = new OptionDTO();

View File

@ -299,6 +299,8 @@
key = 'API'; key = 'API';
} else if (key === 'SCHEDULE_TASK_MANAGEMENT') { } else if (key === 'SCHEDULE_TASK_MANAGEMENT') {
key = 'SCHEDULE'; key = 'SCHEDULE';
} else if (key === 'TEST_PLAN_MANAGEMENT') {
key = 'TEST_PLAN';
} else { } else {
key = ''; key = '';
} }