feat(测试计划): 测试计划通知相关&更新表索引

This commit is contained in:
WangXu10 2024-05-21 11:09:24 +08:00 committed by 刘瑞斌
parent 47c6b0f7c3
commit 1c104344cc
8 changed files with 26 additions and 34 deletions

View File

@ -167,6 +167,8 @@ ALTER TABLE test_plan_config MODIFY pass_threshold DECIMAL(10, 2) NOT NULL;
-- 修改测试计划模块名称长度
ALTER TABLE test_plan_module MODIFY COLUMN `name` varchar(255);
ALTER TABLE test_plan DROP INDEX uq_name_project;
-- set innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -82,7 +82,7 @@ public class TestPlanController {
@Operation(summary = "测试计划-更新测试计划")
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
@CheckOwner(resourceId = "#request.getId()", resourceType = "test_plan")
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.sendUpdateNotice(#request)", targetClass = TestPlanSendNoticeService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.sendUpdateNotice(#request)", targetClass = TestPlanSendNoticeService.class)
public String add(@Validated @RequestBody TestPlanUpdateRequest request) {
testPlanManagementService.checkModuleIsOpen(request.getId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
return testPlanService.update(request, SessionUtils.getUserId(), "/test-plan/update", HttpMethodConstants.POST.name());
@ -92,7 +92,7 @@ public class TestPlanController {
@Operation(summary = "测试计划-删除测试计划")
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_DELETE)
@CheckOwner(resourceId = "#id", resourceType = "test_plan")
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.sendDeleteNotice(#id)", targetClass = TestPlanSendNoticeService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.sendDeleteNotice(#id)", targetClass = TestPlanSendNoticeService.class)
public void delete(@NotBlank @PathVariable String id) {
testPlanManagementService.checkModuleIsOpen(id, TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
testPlanService.delete(id, SessionUtils.getUserId(), "/test-plan/delete", HttpMethodConstants.GET.name());

View File

@ -10,7 +10,6 @@ import io.metersphere.plan.mapper.ExtTestPlanMapper;
import io.metersphere.plan.mapper.TestPlanMapper;
import io.metersphere.sdk.constants.HttpMethodConstants;
import io.metersphere.sdk.constants.ModuleConstants;
import io.metersphere.sdk.constants.TestPlanConstants;
import io.metersphere.sdk.constants.TestPlanResourceConstants;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.Translator;
@ -41,19 +40,6 @@ public class TestPlanBaseUtilsService {
@Resource
private TestPlanResourceLogService testPlanResourceLogService;
/**
* 校验模块下重名
*
* @param testPlan
*/
public void validateTestPlan(TestPlan testPlan) {
if (StringUtils.equals(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN) && !StringUtils.equals(testPlan.getGroupId(), TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID)) {
TestPlan group = testPlanMapper.selectByPrimaryKey(testPlan.getGroupId());
testPlan.setModuleId(group.getModuleId());
}
}
/**
* 校验模块
*

View File

@ -45,7 +45,8 @@ public class TestPlanBatchMoveService extends TestPlanBaseUtilsService {
List<TestPlan> testPlans = plans.get(TestPlanConstants.TEST_PLAN_TYPE_PLAN);
testPlans.forEach(testPlan -> {
testPlan.setModuleId(request.getModuleId());
validateTestPlan(testPlan);
// 5.21查询需求文档测试用例测试计划名称允许重复
// validateTestPlan(testPlan);
});
List<String> ids = testPlans.stream().map(TestPlan::getId).collect(Collectors.toList());
extTestPlanMapper.batchMove(ids, request.getModuleId(), userId, System.currentTimeMillis());

View File

@ -511,17 +511,17 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
//发通知
if (StringUtils.isNotBlank(notifier)) {
List<String> relatedUsers = Arrays.asList(notifier.split(";"));
testPlanSendNoticeService.sendNoticeCase(relatedUsers, userId, caseId, NoticeConstants.TaskType.TEST_PLAN_TASK, NoticeConstants.Event.REVIEW_AT, testPlanId);
testPlanSendNoticeService.sendNoticeCase(relatedUsers, userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.REVIEW_AT, testPlanId);
}
if (StringUtils.equalsIgnoreCase(lastExecResult, FunctionalCaseExecuteResult.SUCCESS.name())) {
//成功 发送通知
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.TEST_PLAN_TASK, NoticeConstants.Event.EXECUTE_PASSED, testPlanId);
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_PASSED, testPlanId);
}
if (StringUtils.equalsIgnoreCase(lastExecResult, FunctionalCaseExecuteResult.ERROR.name())) {
//失败 发送通知
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.TEST_PLAN_TASK, NoticeConstants.Event.EXECUTE_FAIL, testPlanId);
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_FAIL, testPlanId);
}
}

View File

@ -107,7 +107,8 @@ public class TestPlanService extends TestPlanBaseUtilsService {
TestPlan createTestPlan = new TestPlan();
BeanUtils.copyBean(createTestPlan, createOrCopyRequest);
validateTestPlan(createTestPlan);
// 5.21查询需求文档测试用例测试计划名称允许重复
// validateTestPlan(createTestPlan);
createTestPlan.setId(IDGenerator.nextStr());
long operateTime = System.currentTimeMillis();
@ -298,7 +299,8 @@ public class TestPlanService extends TestPlanBaseUtilsService {
if (StringUtils.isNotBlank(request.getName())) {
updateTestPlan.setName(request.getName());
updateTestPlan.setProjectId(testPlan.getProjectId());
validateTestPlan(updateTestPlan);
// 5.21查询需求文档测试用例测试计划名称允许重复
// validateTestPlan(updateTestPlan);
}
if (CollectionUtils.isNotEmpty(request.getTags())) {
updateTestPlan.setTags(new ArrayList<>(request.getTags()));

View File

@ -549,12 +549,6 @@ public class TestPlanTests extends BaseTest {
a1b1NodeCount++;
}
if (i == 201) {
//第201时先测试能否添加重复用例
request.setName("testPlan_200");
request.setModuleId(moduleId);
this.requestPost(URL_POST_TEST_PLAN_ADD, request).andExpect(status().is5xxServerError());
}
//添加测试计划
request.setName("testPlan_" + i);
request.setModuleId(moduleId);
@ -865,6 +859,13 @@ public class TestPlanTests extends BaseTest {
Assertions.assertEquals(returnId, testPlan.getId());
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
//名称重复
updateRequest.setName("testPlan_400");
this.requestPost(URL_POST_TEST_PLAN_UPDATE, updateRequest).andExpect(status().isOk());
//修改回来
updateRequest.setName("testPlan_21");
this.requestPost(URL_POST_TEST_PLAN_UPDATE, updateRequest).andExpect(status().isOk());
//修改模块
BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2");
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
@ -967,10 +968,6 @@ public class TestPlanTests extends BaseTest {
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
//反例名称重复
updateRequest.setName("testPlan_400");
this.requestPost(URL_POST_TEST_PLAN_UPDATE, updateRequest).andExpect(status().is5xxServerError());
//因为有条数据被移动了测试计划组里所以检查一下moduleCount.
TestPlanTableRequest testPlanTableRequest = new TestPlanTableRequest();
testPlanTableRequest.setProjectId(project.getId());

View File

@ -60,8 +60,12 @@ public class TestPlanTestService {
public TestPlan selectTestPlanByName(String name) {
TestPlanExample testPlanExample = new TestPlanExample();
testPlanExample.createCriteria().andNameEqualTo(name);
TestPlan testPlan = testPlanMapper.selectByExample(testPlanExample).get(0);
return testPlan;
List<TestPlan> testPlanList = testPlanMapper.selectByExample(testPlanExample);
if (CollectionUtils.isEmpty(testPlanList)) {
return null;
} else {
return testPlanList.getFirst();
}
}
public void checkTestPlanByAddTest() {
/*