feat(测试计划): 测试计划通知相关&更新表索引
This commit is contained in:
parent
47c6b0f7c3
commit
1c104344cc
|
@ -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_module MODIFY COLUMN `name` varchar(255);
|
||||||
|
|
||||||
|
ALTER TABLE test_plan DROP INDEX uq_name_project;
|
||||||
|
|
||||||
-- set innodb lock wait timeout to default
|
-- set innodb lock wait timeout to default
|
||||||
SET SESSION innodb_lock_wait_timeout = DEFAULT;
|
SET SESSION innodb_lock_wait_timeout = DEFAULT;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class TestPlanController {
|
||||||
@Operation(summary = "测试计划-更新测试计划")
|
@Operation(summary = "测试计划-更新测试计划")
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||||
@CheckOwner(resourceId = "#request.getId()", resourceType = "test_plan")
|
@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) {
|
public String add(@Validated @RequestBody TestPlanUpdateRequest request) {
|
||||||
testPlanManagementService.checkModuleIsOpen(request.getId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
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());
|
return testPlanService.update(request, SessionUtils.getUserId(), "/test-plan/update", HttpMethodConstants.POST.name());
|
||||||
|
@ -92,7 +92,7 @@ public class TestPlanController {
|
||||||
@Operation(summary = "测试计划-删除测试计划")
|
@Operation(summary = "测试计划-删除测试计划")
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_DELETE)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_DELETE)
|
||||||
@CheckOwner(resourceId = "#id", resourceType = "test_plan")
|
@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) {
|
public void delete(@NotBlank @PathVariable String id) {
|
||||||
testPlanManagementService.checkModuleIsOpen(id, TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
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());
|
testPlanService.delete(id, SessionUtils.getUserId(), "/test-plan/delete", HttpMethodConstants.GET.name());
|
||||||
|
|
|
@ -10,7 +10,6 @@ import io.metersphere.plan.mapper.ExtTestPlanMapper;
|
||||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||||
import io.metersphere.sdk.constants.ModuleConstants;
|
import io.metersphere.sdk.constants.ModuleConstants;
|
||||||
import io.metersphere.sdk.constants.TestPlanConstants;
|
|
||||||
import io.metersphere.sdk.constants.TestPlanResourceConstants;
|
import io.metersphere.sdk.constants.TestPlanResourceConstants;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
|
@ -41,19 +40,6 @@ public class TestPlanBaseUtilsService {
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanResourceLogService testPlanResourceLogService;
|
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验模块
|
* 校验模块
|
||||||
*
|
*
|
||||||
|
|
|
@ -45,7 +45,8 @@ public class TestPlanBatchMoveService extends TestPlanBaseUtilsService {
|
||||||
List<TestPlan> testPlans = plans.get(TestPlanConstants.TEST_PLAN_TYPE_PLAN);
|
List<TestPlan> testPlans = plans.get(TestPlanConstants.TEST_PLAN_TYPE_PLAN);
|
||||||
testPlans.forEach(testPlan -> {
|
testPlans.forEach(testPlan -> {
|
||||||
testPlan.setModuleId(request.getModuleId());
|
testPlan.setModuleId(request.getModuleId());
|
||||||
validateTestPlan(testPlan);
|
// 5.21,查询需求文档、测试用例:测试计划名称允许重复
|
||||||
|
// validateTestPlan(testPlan);
|
||||||
});
|
});
|
||||||
List<String> ids = testPlans.stream().map(TestPlan::getId).collect(Collectors.toList());
|
List<String> ids = testPlans.stream().map(TestPlan::getId).collect(Collectors.toList());
|
||||||
extTestPlanMapper.batchMove(ids, request.getModuleId(), userId, System.currentTimeMillis());
|
extTestPlanMapper.batchMove(ids, request.getModuleId(), userId, System.currentTimeMillis());
|
||||||
|
|
|
@ -511,17 +511,17 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
||||||
//发通知
|
//发通知
|
||||||
if (StringUtils.isNotBlank(notifier)) {
|
if (StringUtils.isNotBlank(notifier)) {
|
||||||
List<String> relatedUsers = Arrays.asList(notifier.split(";"));
|
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())) {
|
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())) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,8 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
|
|
||||||
TestPlan createTestPlan = new TestPlan();
|
TestPlan createTestPlan = new TestPlan();
|
||||||
BeanUtils.copyBean(createTestPlan, createOrCopyRequest);
|
BeanUtils.copyBean(createTestPlan, createOrCopyRequest);
|
||||||
validateTestPlan(createTestPlan);
|
// 5.21,查询需求文档、测试用例:测试计划名称允许重复
|
||||||
|
// validateTestPlan(createTestPlan);
|
||||||
|
|
||||||
createTestPlan.setId(IDGenerator.nextStr());
|
createTestPlan.setId(IDGenerator.nextStr());
|
||||||
long operateTime = System.currentTimeMillis();
|
long operateTime = System.currentTimeMillis();
|
||||||
|
@ -298,7 +299,8 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
if (StringUtils.isNotBlank(request.getName())) {
|
if (StringUtils.isNotBlank(request.getName())) {
|
||||||
updateTestPlan.setName(request.getName());
|
updateTestPlan.setName(request.getName());
|
||||||
updateTestPlan.setProjectId(testPlan.getProjectId());
|
updateTestPlan.setProjectId(testPlan.getProjectId());
|
||||||
validateTestPlan(updateTestPlan);
|
// 5.21,查询需求文档、测试用例:测试计划名称允许重复
|
||||||
|
// validateTestPlan(updateTestPlan);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(request.getTags())) {
|
if (CollectionUtils.isNotEmpty(request.getTags())) {
|
||||||
updateTestPlan.setTags(new ArrayList<>(request.getTags()));
|
updateTestPlan.setTags(new ArrayList<>(request.getTags()));
|
||||||
|
|
|
@ -549,12 +549,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
a1b1NodeCount++;
|
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.setName("testPlan_" + i);
|
||||||
request.setModuleId(moduleId);
|
request.setModuleId(moduleId);
|
||||||
|
@ -865,6 +859,13 @@ public class TestPlanTests extends BaseTest {
|
||||||
Assertions.assertEquals(returnId, testPlan.getId());
|
Assertions.assertEquals(returnId, testPlan.getId());
|
||||||
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
|
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");
|
BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2");
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
|
@ -967,10 +968,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
|
|
||||||
//反例:名称重复
|
|
||||||
updateRequest.setName("testPlan_400");
|
|
||||||
this.requestPost(URL_POST_TEST_PLAN_UPDATE, updateRequest).andExpect(status().is5xxServerError());
|
|
||||||
|
|
||||||
//因为有条数据被移动了测试计划组里,所以检查一下moduleCount.
|
//因为有条数据被移动了测试计划组里,所以检查一下moduleCount.
|
||||||
TestPlanTableRequest testPlanTableRequest = new TestPlanTableRequest();
|
TestPlanTableRequest testPlanTableRequest = new TestPlanTableRequest();
|
||||||
testPlanTableRequest.setProjectId(project.getId());
|
testPlanTableRequest.setProjectId(project.getId());
|
||||||
|
|
|
@ -60,8 +60,12 @@ public class TestPlanTestService {
|
||||||
public TestPlan selectTestPlanByName(String name) {
|
public TestPlan selectTestPlanByName(String name) {
|
||||||
TestPlanExample testPlanExample = new TestPlanExample();
|
TestPlanExample testPlanExample = new TestPlanExample();
|
||||||
testPlanExample.createCriteria().andNameEqualTo(name);
|
testPlanExample.createCriteria().andNameEqualTo(name);
|
||||||
TestPlan testPlan = testPlanMapper.selectByExample(testPlanExample).get(0);
|
List<TestPlan> testPlanList = testPlanMapper.selectByExample(testPlanExample);
|
||||||
return testPlan;
|
if (CollectionUtils.isEmpty(testPlanList)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return testPlanList.getFirst();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void checkTestPlanByAddTest() {
|
public void checkTestPlanByAddTest() {
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue