refactor(测试计划): 测试计划消息通知

This commit is contained in:
WangXu10 2024-05-21 15:29:40 +08:00 committed by Craftsman
parent 75fdb4edf3
commit 73f1b1df6c
5 changed files with 36 additions and 30 deletions

View File

@ -83,7 +83,7 @@ public class TestPlanController {
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
@CheckOwner(resourceId = "#request.getId()", resourceType = "test_plan")
@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 TestPlan 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());
}

View File

@ -4,8 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author wx
@ -14,20 +12,20 @@ import java.util.List;
@NoArgsConstructor
public class TestPlanDTO {
@Schema(description ="message.domain.test_plan_num")
private String num;
@Schema(description = "message.domain.test_plan_num")
private Long num;
@Schema(description ="message.domain.test_plan_name")
@Schema(description = "message.domain.test_plan_name")
private String name;
@Schema(description ="message.domain.test_plan_status")
@Schema(description = "message.domain.test_plan_status")
private String status;
@Schema(description ="message.domain.test_plan_type")
@Schema(description = "message.domain.test_plan_type")
private String type;
@Schema(description ="message.domain.test_plan_tags")
private List<String> tags;
@Schema(description = "message.domain.test_plan_tags")
private java.util.List<String> tags;
@Schema(description = "message.domain.test_plan_createTime")
private Long createTime;
@ -54,6 +52,6 @@ public class TestPlanDTO {
private Long actualEndTime;
@Schema(description = "message.domain.test_plan_description")
private Long description;
private String description;
}

View File

@ -140,6 +140,13 @@ public class TestPlanSendNoticeService {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getId());
dto.setStatus(testPlan.getStatus());
dto.setType(testPlan.getType());
dto.setActualEndTime(testPlan.getActualEndTime());
dto.setActualStartTime(testPlan.getActualStartTime());
dto.setCreateTime(testPlan.getCreateTime());
dto.setCreateUser(testPlan.getCreateUser());
dto.setUpdateTime(testPlan.getUpdateTime());
dto.setUpdateUser(testPlan.getUpdateUser());
dto.setNum(testPlan.getNum());
return dto;
}
@ -147,8 +154,11 @@ public class TestPlanSendNoticeService {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(id);
TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(id);
TestPlanDTO dto = new TestPlanDTO();
BeanUtils.copyBean(dto, testPlan);
BeanUtils.copyBean(dto, testPlanConfig);
return dto;
if (testPlan != null) {
BeanUtils.copyBean(dto, testPlan);
BeanUtils.copyBean(dto, testPlanConfig);
return dto;
}
return null;
}
}

View File

@ -286,7 +286,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
* @param requestMethod
* @return
*/
public String update(TestPlanUpdateRequest request, String userId, String requestUrl, String requestMethod) {
public TestPlan update(TestPlanUpdateRequest request, String userId, String requestUrl, String requestMethod) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getId());
if (!ObjectUtils.allNull(request.getName(), request.getModuleId(), request.getTags(), request.getPlannedEndTime(), request.getPlannedStartTime(), request.getDescription(), request.getTestPlanGroupId())) {
TestPlan updateTestPlan = new TestPlan();
@ -323,7 +323,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
testPlanConfigMapper.updateByPrimaryKeySelective(testPlanConfig);
}
testPlanLogService.saveUpdateLog(testPlan, testPlanMapper.selectByPrimaryKey(request.getId()), testPlan.getProjectId(), userId, requestUrl, requestMethod);
return request.getId();
return testPlan;
}

View File

@ -842,12 +842,9 @@ public class TestPlanTests extends BaseTest {
String returnStr = mvcResult.getResponse().getContentAsString();
ResultHolder holder = JSON.parseObject(returnStr, ResultHolder.class);
String returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
//操作日志检查
LOG_CHECK_LIST.add(
new CheckLogModel(returnId, OperationLogType.UPDATE, URL_POST_TEST_PLAN_UPDATE)
);
//修改回来
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
@ -856,7 +853,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
//名称重复
@ -874,7 +871,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
//修改回来
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
@ -883,7 +880,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
//修改标签
@ -893,7 +890,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
testPlan = testPlanTestService.selectTestPlanByName("testPlan_21");
@ -905,7 +902,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
testPlan = testPlanTestService.selectTestPlanByName("testPlan_21");
@ -916,7 +913,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
testPlan = testPlanTestService.selectTestPlanByName("testPlan_21");
@ -929,7 +926,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
@ -940,7 +937,7 @@ public class TestPlanTests extends BaseTest {
returnStr = mvcResult.getResponse().getContentAsString();
holder = JSON.parseObject(returnStr, ResultHolder.class);
returnId = holder.getData().toString();
Assertions.assertEquals(returnId, testPlan.getId());
Assertions.assertNotNull(returnId);
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
testPlan = testPlanTestService.selectTestPlanByName("testPlan_21");
testPlanConfig = testPlanTestService.selectTestPlanConfigById(testPlan.getId());
@ -1546,6 +1543,7 @@ public class TestPlanTests extends BaseTest {
testPlanBugService.getNextOrder(DEFAULT_PROJECT_ID);
testPlanFunctionalCaseService.getNextOrder(DEFAULT_PROJECT_ID);
}
private void checkModuleIsEmpty(String id) {
TestPlanModuleExample example = new TestPlanModuleExample();
example.createCriteria().andParentIdEqualTo(id);
@ -1867,7 +1865,7 @@ public class TestPlanTests extends BaseTest {
request.setProjectId("123");
request.setType("ALL");
request.setModuleId("3");
request.setSelectIds(Arrays.asList("wx_test_plan_id_3","wx_test_plan_id_4"));
request.setSelectIds(Arrays.asList("wx_test_plan_id_3", "wx_test_plan_id_4"));
this.requestPostWithOkAndReturn(URL_TEST_PLAN_BATCH_MOVE, request);