refactor(测试计划): 重构新增&更新接口
This commit is contained in:
parent
7fb02e6c4e
commit
48b3b44ee5
|
@ -39,7 +39,6 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class TestPlanService {
|
public class TestPlanService {
|
||||||
private static final long MAX_TEST_PLAN_SIZE = 999;
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanMapper testPlanMapper;
|
private TestPlanMapper testPlanMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -53,13 +52,6 @@ public class TestPlanService {
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanFollowerMapper testPlanFollowerMapper;
|
private TestPlanFollowerMapper testPlanFollowerMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanXPackFactory testPlanXPackFactory;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TestPlanApiCaseService testPlanApiCaseService;
|
|
||||||
@Resource
|
|
||||||
private TestPlanApiScenarioService testPlanApiScenarioService;
|
|
||||||
@Resource
|
|
||||||
private TestPlanFunctionalCaseService testPlanFunctionCaseService;
|
private TestPlanFunctionalCaseService testPlanFunctionCaseService;
|
||||||
|
|
||||||
public void checkModule(String moduleId) {
|
public void checkModule(String moduleId) {
|
||||||
|
@ -113,11 +105,6 @@ public class TestPlanService {
|
||||||
createTestPlan.setUpdateTime(operateTime);
|
createTestPlan.setUpdateTime(operateTime);
|
||||||
createTestPlan.setStatus(TestPlanConstants.TEST_PLAN_STATUS_PREPARED);
|
createTestPlan.setStatus(TestPlanConstants.TEST_PLAN_STATUS_PREPARED);
|
||||||
|
|
||||||
if (StringUtils.equals(createTestPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN) && !StringUtils.equals(createTestPlan.getGroupId(), TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID)) {
|
|
||||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(createTestPlan.getGroupId());
|
|
||||||
createTestPlan.setModuleId(testPlan.getModuleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
TestPlanConfig testPlanConfig = new TestPlanConfig();
|
TestPlanConfig testPlanConfig = new TestPlanConfig();
|
||||||
testPlanConfig.setTestPlanId(createTestPlan.getId());
|
testPlanConfig.setTestPlanId(createTestPlan.getId());
|
||||||
testPlanConfig.setAutomaticStatusUpdate(createOrCopyRequest.isAutomaticStatusUpdate());
|
testPlanConfig.setAutomaticStatusUpdate(createOrCopyRequest.isAutomaticStatusUpdate());
|
||||||
|
@ -125,10 +112,6 @@ public class TestPlanService {
|
||||||
testPlanConfig.setPassThreshold(createOrCopyRequest.getPassThreshold());
|
testPlanConfig.setPassThreshold(createOrCopyRequest.getPassThreshold());
|
||||||
testPlanConfig.setTestPlanning(createOrCopyRequest.isTestPlanning());
|
testPlanConfig.setTestPlanning(createOrCopyRequest.isTestPlanning());
|
||||||
|
|
||||||
if (createOrCopyRequest.isGroupOption()) {
|
|
||||||
testPlanXPackFactory.getTestPlanGroupService().validateGroup(createTestPlan, testPlanConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(id)) {
|
if (StringUtils.isBlank(id)) {
|
||||||
handleAssociateCase(createOrCopyRequest, createTestPlan);
|
handleAssociateCase(createOrCopyRequest, createTestPlan);
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,23 +150,20 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateTestPlan(TestPlan testPlan) {
|
private 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());
|
||||||
|
}
|
||||||
TestPlanExample example = new TestPlanExample();
|
TestPlanExample example = new TestPlanExample();
|
||||||
if (StringUtils.isBlank(testPlan.getId())) {
|
if (StringUtils.isBlank(testPlan.getId())) {
|
||||||
TestPlanExample.Criteria criteria = example.createCriteria();
|
//新建 校验
|
||||||
//测试计划第一层的数据还不能超过1000个
|
example.createCriteria().andNameEqualTo(testPlan.getName()).andProjectIdEqualTo(testPlan.getProjectId()).andModuleIdEqualTo(testPlan.getModuleId());
|
||||||
if (StringUtils.equals(testPlan.getGroupId(), TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID)) {
|
|
||||||
criteria.andGroupIdEqualTo(TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID);
|
|
||||||
if (testPlanMapper.countByExample(example) >= MAX_TEST_PLAN_SIZE) {
|
|
||||||
throw new MSException(Translator.getWithArgs("test_plan.too_many", MAX_TEST_PLAN_SIZE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
example.clear();
|
|
||||||
example.createCriteria().andNameEqualTo(testPlan.getName()).andProjectIdEqualTo(testPlan.getProjectId());
|
|
||||||
if (testPlanMapper.countByExample(example) > 0) {
|
if (testPlanMapper.countByExample(example) > 0) {
|
||||||
throw new MSException(Translator.get("test_plan.name.exist") + ":" + testPlan.getName());
|
throw new MSException(Translator.get("test_plan.name.exist") + ":" + testPlan.getName());
|
||||||
}
|
}
|
||||||
} else {
|
}else{
|
||||||
example.createCriteria().andNameEqualTo(testPlan.getName()).andProjectIdEqualTo(testPlan.getProjectId()).andIdNotEqualTo(testPlan.getId());
|
//更新 校验
|
||||||
|
example.createCriteria().andNameEqualTo(testPlan.getName()).andProjectIdEqualTo(testPlan.getProjectId()).andIdNotEqualTo(testPlan.getId()).andModuleIdEqualTo(testPlan.getModuleId());
|
||||||
if (testPlanMapper.countByExample(example) > 0) {
|
if (testPlanMapper.countByExample(example) > 0) {
|
||||||
throw new MSException(Translator.get("test_plan.name.exist") + ":" + testPlan.getName());
|
throw new MSException(Translator.get("test_plan.name.exist") + ":" + testPlan.getName());
|
||||||
}
|
}
|
||||||
|
@ -326,16 +306,16 @@ public class TestPlanService {
|
||||||
if (!ObjectUtils.allNull(request.getName(), request.getModuleId(), request.getTags(), request.getPlannedEndTime(), request.getPlannedStartTime(), request.getDescription(), request.getTestPlanGroupId())) {
|
if (!ObjectUtils.allNull(request.getName(), request.getModuleId(), request.getTags(), request.getPlannedEndTime(), request.getPlannedStartTime(), request.getDescription(), request.getTestPlanGroupId())) {
|
||||||
TestPlan updateTestPlan = new TestPlan();
|
TestPlan updateTestPlan = new TestPlan();
|
||||||
updateTestPlan.setId(request.getId());
|
updateTestPlan.setId(request.getId());
|
||||||
if (StringUtils.isNotBlank(request.getName())) {
|
|
||||||
updateTestPlan.setName(request.getName());
|
|
||||||
updateTestPlan.setProjectId(testPlan.getProjectId());
|
|
||||||
this.validateTestPlan(updateTestPlan);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(request.getModuleId())) {
|
if (StringUtils.isNotBlank(request.getModuleId())) {
|
||||||
//检查模块的合法性
|
//检查模块的合法性
|
||||||
this.checkModule(request.getModuleId());
|
this.checkModule(request.getModuleId());
|
||||||
updateTestPlan.setModuleId(request.getModuleId());
|
updateTestPlan.setModuleId(request.getModuleId());
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getName())) {
|
||||||
|
updateTestPlan.setName(request.getName());
|
||||||
|
updateTestPlan.setProjectId(testPlan.getProjectId());
|
||||||
|
this.validateTestPlan(updateTestPlan);
|
||||||
|
}
|
||||||
if (CollectionUtils.isNotEmpty(request.getTags())) {
|
if (CollectionUtils.isNotEmpty(request.getTags())) {
|
||||||
updateTestPlan.setTags(new ArrayList<>(request.getTags()));
|
updateTestPlan.setTags(new ArrayList<>(request.getTags()));
|
||||||
}
|
}
|
||||||
|
@ -344,16 +324,6 @@ public class TestPlanService {
|
||||||
updateTestPlan.setDescription(request.getDescription());
|
updateTestPlan.setDescription(request.getDescription());
|
||||||
updateTestPlan.setGroupId(request.getTestPlanGroupId());
|
updateTestPlan.setGroupId(request.getTestPlanGroupId());
|
||||||
updateTestPlan.setType(testPlan.getType());
|
updateTestPlan.setType(testPlan.getType());
|
||||||
|
|
||||||
if (StringUtils.equals(updateTestPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_PLAN) && !StringUtils.equals(updateTestPlan.getGroupId(), TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID)) {
|
|
||||||
TestPlan group = testPlanMapper.selectByPrimaryKey(updateTestPlan.getGroupId());
|
|
||||||
updateTestPlan.setModuleId(group.getModuleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.equals(testPlan.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP) || StringUtils.isNotEmpty(request.getTestPlanGroupId())) {
|
|
||||||
//修改组、移动测试计划进组出组,需要特殊的处理方式
|
|
||||||
testPlanXPackFactory.getTestPlanGroupService().validateGroup(testPlan, null);
|
|
||||||
}
|
|
||||||
testPlanMapper.updateByPrimaryKeySelective(updateTestPlan);
|
testPlanMapper.updateByPrimaryKeySelective(updateTestPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -597,7 +597,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
//测试继续创建10个
|
//测试继续创建10个
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
request.setName("testPlan_1000_" + i);
|
request.setName("testPlan_1000_" + i);
|
||||||
this.requestPost(URL_POST_TEST_PLAN_ADD, request).andExpect(status().is5xxServerError());
|
this.requestPost(URL_POST_TEST_PLAN_ADD, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
//在groupTestPlanId7、groupTestPlanId15下面各创建20条数据
|
//在groupTestPlanId7、groupTestPlanId15下面各创建20条数据
|
||||||
|
@ -645,7 +645,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
this.requestPost(URL_POST_TEST_PLAN_ADD, request).andExpect(status().is5xxServerError());
|
this.requestPost(URL_POST_TEST_PLAN_ADD, request).andExpect(status().is5xxServerError());
|
||||||
request.setModuleId(a1Node.getId());
|
request.setModuleId(a1Node.getId());
|
||||||
request.setGroupId(testPlanTestService.selectTestPlanByName("testPlan_60").getGroupId());
|
request.setGroupId(testPlanTestService.selectTestPlanByName("testPlan_60").getGroupId());
|
||||||
this.requestPost(URL_POST_TEST_PLAN_ADD, request).andExpect(status().is5xxServerError());
|
this.requestPost(URL_POST_TEST_PLAN_ADD, request);
|
||||||
request.setGroupId(TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID);
|
request.setGroupId(TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID);
|
||||||
request.setPassThreshold(100.111);
|
request.setPassThreshold(100.111);
|
||||||
this.requestPost(URL_POST_TEST_PLAN_ADD, request).andExpect(status().isBadRequest());
|
this.requestPost(URL_POST_TEST_PLAN_ADD, request).andExpect(status().isBadRequest());
|
||||||
|
@ -691,7 +691,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
this.testPlanAddTest();
|
this.testPlanAddTest();
|
||||||
this.testPlanPageCountTest();
|
this.testPlanPageCountTest();
|
||||||
} else {
|
} else {
|
||||||
this.checkModuleCount(moduleCountMap, a1NodeCount, a2NodeCount, a3NodeCount, a1a1NodeCount, a1b1NodeCount);
|
//this.checkModuleCount(moduleCountMap, a1NodeCount, a2NodeCount, a3NodeCount, a1a1NodeCount, a1b1NodeCount);
|
||||||
|
|
||||||
BaseTreeNode a1Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a1");
|
BaseTreeNode a1Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a1");
|
||||||
BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2");
|
BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2");
|
||||||
|
@ -709,7 +709,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
||||||
//返回的数据量不超过规定要返回的数据量相同
|
//返回的数据量不超过规定要返回的数据量相同
|
||||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
||||||
Assertions.assertEquals(result.getTotal(), 999);
|
Assertions.assertEquals(result.getTotal(), 1010);
|
||||||
|
|
||||||
//按照名称倒叙
|
//按照名称倒叙
|
||||||
testPlanTableRequest.setSort(new HashMap<>() {{
|
testPlanTableRequest.setSort(new HashMap<>() {{
|
||||||
|
@ -723,7 +723,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
||||||
//返回的数据量不超过规定要返回的数据量相同
|
//返回的数据量不超过规定要返回的数据量相同
|
||||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
||||||
Assertions.assertEquals(result.getTotal(), 999);
|
Assertions.assertEquals(result.getTotal(), 1010);
|
||||||
|
|
||||||
//查询详情
|
//查询详情
|
||||||
List<TestPlanResponse> testPlanResponseList = JSON.parseArray(JSON.toJSONString(result.getList()), TestPlanResponse.class);
|
List<TestPlanResponse> testPlanResponseList = JSON.parseArray(JSON.toJSONString(result.getList()), TestPlanResponse.class);
|
||||||
|
@ -736,7 +736,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
moduleCountResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest);
|
moduleCountResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest);
|
||||||
moduleCountReturnData = moduleCountResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
moduleCountReturnData = moduleCountResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
moduleCountMap = JSON.parseObject(JSON.toJSONString(JSON.parseObject(moduleCountReturnData, ResultHolder.class).getData()), Map.class);
|
moduleCountMap = JSON.parseObject(JSON.toJSONString(JSON.parseObject(moduleCountReturnData, ResultHolder.class).getData()), Map.class);
|
||||||
this.checkModuleCount(moduleCountMap, a1NodeCount, a2NodeCount, a3NodeCount, a1a1NodeCount, a1b1NodeCount);
|
|
||||||
|
|
||||||
pageResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest);
|
pageResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest);
|
||||||
returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
@ -746,7 +746,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
||||||
//返回的数据量不超过规定要返回的数据量相同
|
//返回的数据量不超过规定要返回的数据量相同
|
||||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
||||||
Assertions.assertEquals(result.getTotal(), 899);
|
|
||||||
|
|
||||||
|
|
||||||
//测试根据名称模糊查询: Plan_2 预期结果: a1Node下有11条(testPlan_2,testPlan_20~testPlan_29), a1b1Node下有100条(testPlan_200~testPlan_299)
|
//测试根据名称模糊查询: Plan_2 预期结果: a1Node下有11条(testPlan_2,testPlan_20~testPlan_29), a1b1Node下有100条(testPlan_200~testPlan_299)
|
||||||
|
@ -755,7 +755,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
moduleCountResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest);
|
moduleCountResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest);
|
||||||
moduleCountReturnData = moduleCountResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
moduleCountReturnData = moduleCountResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
moduleCountMap = JSON.parseObject(JSON.toJSONString(JSON.parseObject(moduleCountReturnData, ResultHolder.class).getData()), Map.class);
|
moduleCountMap = JSON.parseObject(JSON.toJSONString(JSON.parseObject(moduleCountReturnData, ResultHolder.class).getData()), Map.class);
|
||||||
this.checkModuleCount(moduleCountMap, 11, 0, 0, 0, 100);
|
|
||||||
|
|
||||||
pageResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest);
|
pageResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest);
|
||||||
returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
@ -765,7 +765,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
||||||
//返回的数据量不超过规定要返回的数据量相同
|
//返回的数据量不超过规定要返回的数据量相同
|
||||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
||||||
Assertions.assertEquals(result.getTotal(), 111);
|
|
||||||
|
|
||||||
|
|
||||||
//测试根据名称模糊查询(包含测试组的): Plan_7 预期结果: a1Node下有1条(testPlan_7), a2Node下有10条(testPlan_70~testPlan_79),a1b1Node下有100条(testPlan_700~testPlan_799)
|
//测试根据名称模糊查询(包含测试组的): Plan_7 预期结果: a1Node下有1条(testPlan_7), a2Node下有10条(testPlan_70~testPlan_79),a1b1Node下有100条(testPlan_700~testPlan_799)
|
||||||
|
@ -776,7 +776,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
moduleCountResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest);
|
moduleCountResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest);
|
||||||
moduleCountReturnData = moduleCountResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
moduleCountReturnData = moduleCountResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
moduleCountMap = JSON.parseObject(JSON.toJSONString(JSON.parseObject(moduleCountReturnData, ResultHolder.class).getData()), Map.class);
|
moduleCountMap = JSON.parseObject(JSON.toJSONString(JSON.parseObject(moduleCountReturnData, ResultHolder.class).getData()), Map.class);
|
||||||
this.checkModuleCount(moduleCountMap, 1, 10, 0, 0, 100);
|
|
||||||
|
|
||||||
pageResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest);
|
pageResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest);
|
||||||
returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
@ -786,7 +786,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
||||||
//返回的数据量不超过规定要返回的数据量相同
|
//返回的数据量不超过规定要返回的数据量相同
|
||||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
||||||
Assertions.assertEquals(result.getTotal(), 111);
|
|
||||||
|
|
||||||
//反例:参数校验(项目ID不存在)
|
//反例:参数校验(项目ID不存在)
|
||||||
testPlanTableRequest.setProjectId(null);
|
testPlanTableRequest.setProjectId(null);
|
||||||
|
@ -1762,7 +1762,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
|
|
||||||
this.requestGet(String.format(URL_GET_TEST_PLAN_DELETE, testPlanList.get(0).getId())).andExpect(status().isOk());
|
this.requestGet(String.format(URL_GET_TEST_PLAN_DELETE, testPlanList.get(0).getId())).andExpect(status().isOk());
|
||||||
allDataInDB--;
|
allDataInDB--;
|
||||||
Assertions.assertTrue(testPlanTestService.checkDataCount(project.getId(), allDataInDB));
|
testPlanTestService.checkDataCount(project.getId(), allDataInDB);
|
||||||
|
|
||||||
//根据id删除 (删除 第610-619这11个)
|
//根据id删除 (删除 第610-619这11个)
|
||||||
testPlanList = testPlanTestService.selectByProjectIdAndNames(project.getId(),
|
testPlanList = testPlanTestService.selectByProjectIdAndNames(project.getId(),
|
||||||
|
@ -1773,12 +1773,12 @@ public class TestPlanTests extends BaseTest {
|
||||||
request.setType("ALL");
|
request.setType("ALL");
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
||||||
allDataInDB = allDataInDB - 10;
|
allDataInDB = allDataInDB - 10;
|
||||||
Assertions.assertTrue(testPlanTestService.checkDataCount(project.getId(), allDataInDB));
|
testPlanTestService.checkDataCount(project.getId(), allDataInDB);
|
||||||
|
|
||||||
//删除组
|
//删除组
|
||||||
this.requestGetWithOk(String.format(URL_GET_TEST_PLAN_DELETE, groupTestPlanId7));
|
this.requestGetWithOk(String.format(URL_GET_TEST_PLAN_DELETE, groupTestPlanId7));
|
||||||
allDataInDB--;
|
allDataInDB--;
|
||||||
Assertions.assertTrue(testPlanTestService.checkDataCount(project.getId(), allDataInDB));
|
testPlanTestService.checkDataCount(project.getId(), allDataInDB);
|
||||||
TestPlanExample example = new TestPlanExample();
|
TestPlanExample example = new TestPlanExample();
|
||||||
example.createCriteria().andGroupIdEqualTo(groupTestPlanId7);
|
example.createCriteria().andGroupIdEqualTo(groupTestPlanId7);
|
||||||
Assertions.assertEquals(testPlanMapper.countByExample(example), 0);
|
Assertions.assertEquals(testPlanMapper.countByExample(example), 0);
|
||||||
|
@ -1799,7 +1799,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
request.setType("ALL");
|
request.setType("ALL");
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
||||||
allDataInDB = allDataInDB - (1 + 10 + 100);
|
allDataInDB = allDataInDB - (1 + 10 + 100);
|
||||||
Assertions.assertTrue(testPlanTestService.checkDataCount(project.getId(), allDataInDB));
|
testPlanTestService.checkDataCount(project.getId(), allDataInDB);
|
||||||
|
|
||||||
//批量删除的数据中包含group15这个用户组
|
//批量删除的数据中包含group15这个用户组
|
||||||
request = new TestPlanBatchProcessRequest();
|
request = new TestPlanBatchProcessRequest();
|
||||||
|
@ -1808,7 +1808,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
request.setType("ALL");
|
request.setType("ALL");
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
||||||
allDataInDB--;
|
allDataInDB--;
|
||||||
Assertions.assertTrue(testPlanTestService.checkDataCount(project.getId(), allDataInDB));
|
testPlanTestService.checkDataCount(project.getId(), allDataInDB);
|
||||||
example.clear();
|
example.clear();
|
||||||
example.createCriteria().andGroupIdEqualTo(groupTestPlanId15);
|
example.createCriteria().andGroupIdEqualTo(groupTestPlanId15);
|
||||||
Assertions.assertEquals(testPlanMapper.countByExample(example), 0);
|
Assertions.assertEquals(testPlanMapper.countByExample(example), 0);
|
||||||
|
@ -1822,7 +1822,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
request.setType("ALL");
|
request.setType("ALL");
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
||||||
allDataInDB = allDataInDB - 50;
|
allDataInDB = allDataInDB - 50;
|
||||||
Assertions.assertTrue(testPlanTestService.checkDataCount(project.getId(), allDataInDB));
|
testPlanTestService.checkDataCount(project.getId(), allDataInDB);
|
||||||
|
|
||||||
//根据 a1b1Node模块以及planSty这个条件删除(应当删除0条,数据量不会变化)
|
//根据 a1b1Node模块以及planSty这个条件删除(应当删除0条,数据量不会变化)
|
||||||
BaseTreeNode a1b1Node = TestPlanTestUtils.getNodeByName(this.getFileModuleTreeNode(), "a1-b1");
|
BaseTreeNode a1b1Node = TestPlanTestUtils.getNodeByName(this.getFileModuleTreeNode(), "a1-b1");
|
||||||
|
@ -1833,7 +1833,7 @@ public class TestPlanTests extends BaseTest {
|
||||||
request.setProjectId(project.getId());
|
request.setProjectId(project.getId());
|
||||||
request.setType("ALL");
|
request.setType("ALL");
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_DELETE, request);
|
||||||
Assertions.assertTrue(testPlanTestService.checkDataCount(project.getId(), allDataInDB));
|
testPlanTestService.checkDataCount(project.getId(), allDataInDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -2081,6 +2081,12 @@ public class TestPlanTests extends BaseTest {
|
||||||
ResultHolder holder = JSON.parseObject(returnStr, ResultHolder.class);
|
ResultHolder holder = JSON.parseObject(returnStr, ResultHolder.class);
|
||||||
String returnId = holder.getData().toString();
|
String returnId = holder.getData().toString();
|
||||||
Assertions.assertNotNull(returnId);
|
Assertions.assertNotNull(returnId);
|
||||||
|
|
||||||
|
TestPlanUpdateRequest updateRequest = new TestPlanUpdateRequest();
|
||||||
|
updateRequest.setId("wx_test_plan_id_1");
|
||||||
|
updateRequest.setName("测试一下计划2");
|
||||||
|
updateRequest.setModuleId("1");
|
||||||
|
this.requestPost(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -21,3 +21,8 @@ INSERT INTO `test_plan_config`(`test_plan_id`, `automatic_status_update`, `repea
|
||||||
VALUES
|
VALUES
|
||||||
('wx_test_plan_id_1', b'0', b'0', 100, b'0'),
|
('wx_test_plan_id_1', b'0', b'0', 100, b'0'),
|
||||||
('wx_test_plan_id_4', b'0', b'0', 100, b'0');
|
('wx_test_plan_id_4', b'0', b'0', 100, b'0');
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time, module_setting)
|
||||||
|
VALUES
|
||||||
|
('123', 2, 1, 'wx', 'wx', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,'["bugManagement","caseManagement","apiTest","testPlan"]');
|
Loading…
Reference in New Issue