mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 12:09:13 +08:00
fix(测试计划): 修复测试计划重复关联用例时功能用例数
--bug=1040713 --user=宋天阳 【测试计划】模块树-当前项目与其他项目重名-创建模块树失败了 https://www.tapd.cn/55049933/s/1518669
This commit is contained in:
parent
985135a621
commit
b4e59664d0
@ -13,9 +13,11 @@ import io.metersphere.functional.mapper.*;
|
||||
import io.metersphere.functional.request.*;
|
||||
import io.metersphere.functional.result.CaseManagementResultCode;
|
||||
import io.metersphere.plan.domain.TestPlanCaseExecuteHistoryExample;
|
||||
import io.metersphere.plan.domain.TestPlanConfig;
|
||||
import io.metersphere.plan.domain.TestPlanFunctionalCase;
|
||||
import io.metersphere.plan.domain.TestPlanFunctionalCaseExample;
|
||||
import io.metersphere.plan.mapper.TestPlanCaseExecuteHistoryMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper;
|
||||
import io.metersphere.project.domain.*;
|
||||
import io.metersphere.project.dto.ModuleCountDTO;
|
||||
@ -55,6 +57,7 @@ import io.metersphere.system.uid.NumGenerator;
|
||||
import io.metersphere.system.utils.ServiceUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
@ -125,6 +128,9 @@ public class FunctionalCaseService {
|
||||
@Resource
|
||||
private UserLoginService userLoginService;
|
||||
|
||||
@Resource
|
||||
private TestPlanConfigMapper testPlanConfigMapper;
|
||||
|
||||
private static final String CASE_MODULE_COUNT_ALL = "all";
|
||||
|
||||
private static final String ADD_FUNCTIONAL_CASE_FILE_LOG_URL = "/functional/case/add";
|
||||
@ -982,6 +988,9 @@ public class FunctionalCaseService {
|
||||
}
|
||||
|
||||
public Map<String, Long> moduleCount(FunctionalCasePageRequest request, boolean delete) {
|
||||
if (StringUtils.isNotEmpty(request.getTestPlanId())) {
|
||||
this.checkTestPlanRepeatCase(request);
|
||||
}
|
||||
//查出每个模块节点下的资源数量。 不需要按照模块进行筛选
|
||||
request.setModuleIds(null);
|
||||
List<ModuleCountDTO> moduleCountDTOList = extFunctionalCaseMapper.countModuleIdByRequest(request, delete);
|
||||
@ -994,6 +1003,14 @@ public class FunctionalCaseService {
|
||||
|
||||
}
|
||||
|
||||
private void checkTestPlanRepeatCase(FunctionalCasePageRequest request) {
|
||||
TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||
if (testPlanConfig != null && BooleanUtils.isTrue(testPlanConfig.getRepeatCase())) {
|
||||
//测试计划允许重复用例,意思就是统计不受测试计划影响。去掉这个条件,
|
||||
request.setTestPlanId(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void editPos(PosRequest request) {
|
||||
ServiceUtils.updatePosField(request,
|
||||
FunctionalCase.class,
|
||||
|
@ -13,6 +13,8 @@ import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
|
||||
import io.metersphere.functional.request.*;
|
||||
import io.metersphere.functional.result.CaseManagementResultCode;
|
||||
import io.metersphere.functional.utils.FileBaseUtils;
|
||||
import io.metersphere.plan.domain.TestPlanConfig;
|
||||
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
||||
import io.metersphere.project.domain.Notification;
|
||||
import io.metersphere.project.domain.NotificationExample;
|
||||
import io.metersphere.project.mapper.NotificationMapper;
|
||||
@ -439,6 +441,9 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||
Assertions.assertNotNull(editResultHolder);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private TestPlanConfigMapper testPlanConfigMapper;
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
public void testGetPageList() throws Exception {
|
||||
@ -494,6 +499,56 @@ public class FunctionalCaseControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
Assertions.assertTrue(moduleCount.containsKey("all"));
|
||||
|
||||
{
|
||||
//测试count接口的入参中包含不存在的测试计划、存在的开启/关闭了重复用例的测试计划
|
||||
TestPlanConfig testPlanConfig = new TestPlanConfig();
|
||||
testPlanConfig.setTestPlanId(IDGenerator.nextStr());
|
||||
testPlanConfig.setRepeatCase(false);
|
||||
testPlanConfig.setAutomaticStatusUpdate(false);
|
||||
testPlanConfig.setTestPlanning(false);
|
||||
testPlanConfig.setPassThreshold(100.00);
|
||||
|
||||
request.setTestPlanId(testPlanConfig.getTestPlanId());
|
||||
|
||||
mvcResult = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_MODULE_COUNT, request);
|
||||
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
moduleCount = JSON.parseObject(JSON.toJSONString(
|
||||
JSON.parseObject(moduleCountMvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
|
||||
Map.class);
|
||||
Assertions.assertTrue(moduleCount.containsKey("all"));
|
||||
|
||||
//不开启用例重复的测试计划入库,再次调用
|
||||
testPlanConfigMapper.insert(testPlanConfig);
|
||||
|
||||
mvcResult = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_MODULE_COUNT, request);
|
||||
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
moduleCount = JSON.parseObject(JSON.toJSONString(
|
||||
JSON.parseObject(moduleCountMvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
|
||||
Map.class);
|
||||
Assertions.assertTrue(moduleCount.containsKey("all"));
|
||||
|
||||
//开启用例重复的测试计划,再次调用
|
||||
testPlanConfig.setRepeatCase(true);
|
||||
testPlanConfigMapper.updateByPrimaryKey(testPlanConfig);
|
||||
|
||||
mvcResult = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_MODULE_COUNT, request);
|
||||
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
moduleCount = JSON.parseObject(JSON.toJSONString(
|
||||
JSON.parseObject(moduleCountMvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
|
||||
Map.class);
|
||||
Assertions.assertTrue(moduleCount.containsKey("all"));
|
||||
|
||||
//使用完后删除该数据
|
||||
testPlanConfigMapper.deleteByPrimaryKey(testPlanConfig.getTestPlanId());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,9 +38,9 @@ public class TestPlanAssociateController {
|
||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
|
||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||
public Pager<List<FunctionalCasePageDTO>> getFunctionalCasePage(@Validated @RequestBody FunctionalCasePageRequest request) {
|
||||
Boolean isRepeat = false;
|
||||
boolean isRepeat = false;
|
||||
if (StringUtils.isNotBlank(request.getTestPlanId())) {
|
||||
isRepeat = testPlanConfigService.getConfigById(request.getTestPlanId());
|
||||
isRepeat = testPlanConfigService.isRepeatCase(request.getTestPlanId());
|
||||
}
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
|
||||
|
@ -27,7 +27,7 @@ public class TestPlanConfigService {
|
||||
testPlanConfigMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public boolean getConfigById(String testPlanId) {
|
||||
public boolean isRepeatCase(String testPlanId) {
|
||||
TestPlanConfig testPlanConfig = testPlanConfigMapper.selectByPrimaryKey(testPlanId);
|
||||
return testPlanConfig.getRepeatCase();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user