fix(测试计划): 同步关联接口/场景测试点

This commit is contained in:
WangXu10 2024-07-18 15:32:28 +08:00 committed by Craftsman
parent 300545a4a5
commit d52cace152
3 changed files with 16 additions and 16 deletions

View File

@ -590,7 +590,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
if (selectAllModule) { if (selectAllModule) {
// 选择了全部模块 // 选择了全部模块
List<ApiTestCase> apiTestCaseList = extApiTestCaseMapper.selectAllApiCase(isRepeat, apiCase.getModules().getProjectId(), testPlan.getId()); List<ApiTestCase> apiTestCaseList = extApiTestCaseMapper.selectAllApiCase(isRepeat, apiCase.getModules().getProjectId(), testPlan.getId());
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList); buildTestPlanApiCaseDTO(apiCase.getCollectionId(), apiTestCaseList, testPlan, user, testPlanApiCaseList);
} else { } else {
AssociateCaseDTO dto = super.getCaseIds(moduleMaps); AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
List<ApiTestCase> apiTestCaseList = new ArrayList<>(); List<ApiTestCase> apiTestCaseList = new ArrayList<>();
@ -614,7 +614,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
if (CollectionUtils.isNotEmpty(apiTestCaseList)) { if (CollectionUtils.isNotEmpty(apiTestCaseList)) {
List<ApiTestCase> list = apiTestCaseList.stream().sorted(Comparator.comparing(ApiTestCase::getPos).reversed()).toList(); List<ApiTestCase> list = apiTestCaseList.stream().sorted(Comparator.comparing(ApiTestCase::getPos).reversed()).toList();
buildTestPlanApiCaseDTO(apiCase, list, testPlan, user, testPlanApiCaseList); buildTestPlanApiCaseDTO(apiCase.getCollectionId(), list, testPlan, user, testPlanApiCaseList);
} }
} }
@ -632,7 +632,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
if (selectAllModule) { if (selectAllModule) {
// 选择了全部模块 // 选择了全部模块
List<ApiTestCase> apiTestCaseList = extApiTestCaseMapper.selectAllApiCase(isRepeat, apiCase.getModules().getProjectId(), testPlan.getId()); List<ApiTestCase> apiTestCaseList = extApiTestCaseMapper.selectAllApiCase(isRepeat, apiCase.getModules().getProjectId(), testPlan.getId());
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList); buildTestPlanApiCaseDTO(apiCase.getCollectionId(), apiTestCaseList, testPlan, user, testPlanApiCaseList);
} else { } else {
AssociateCaseDTO dto = super.getCaseIds(moduleMaps); AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
List<ApiTestCase> apiTestCaseList = new ArrayList<>(); List<ApiTestCase> apiTestCaseList = new ArrayList<>();
@ -656,7 +656,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
if (CollectionUtils.isNotEmpty(apiTestCaseList)) { if (CollectionUtils.isNotEmpty(apiTestCaseList)) {
List<ApiTestCase> list = apiTestCaseList.stream().sorted(Comparator.comparing(ApiTestCase::getPos).reversed()).toList(); List<ApiTestCase> list = apiTestCaseList.stream().sorted(Comparator.comparing(ApiTestCase::getPos).reversed()).toList();
buildTestPlanApiCaseDTO(apiCase, list, testPlan, user, testPlanApiCaseList); buildTestPlanApiCaseDTO(apiCase.getCollectionId(), list, testPlan, user, testPlanApiCaseList);
} }
} }
@ -668,18 +668,18 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
/** /**
* 构建测试计划接口用例对象 * 构建测试计划接口用例对象
* *
* @param apiCase * @param collectionId
* @param apiTestCaseList * @param apiTestCaseList
* @param testPlan * @param testPlan
* @param user * @param user
* @param testPlanApiCaseList * @param testPlanApiCaseList
*/ */
public void buildTestPlanApiCaseDTO(BaseCollectionAssociateRequest apiCase, List<ApiTestCase> apiTestCaseList, TestPlan testPlan, SessionUser user, List<TestPlanApiCase> testPlanApiCaseList) { public void buildTestPlanApiCaseDTO(String collectionId, List<ApiTestCase> apiTestCaseList, TestPlan testPlan, SessionUser user, List<TestPlanApiCase> testPlanApiCaseList) {
AtomicLong nextOrder = new AtomicLong(getNextOrder(apiCase.getCollectionId())); AtomicLong nextOrder = new AtomicLong(getNextOrder(collectionId));
apiTestCaseList.forEach(apiTestCase -> { apiTestCaseList.forEach(apiTestCase -> {
TestPlanApiCase testPlanApiCase = new TestPlanApiCase(); TestPlanApiCase testPlanApiCase = new TestPlanApiCase();
testPlanApiCase.setId(IDGenerator.nextStr()); testPlanApiCase.setId(IDGenerator.nextStr());
testPlanApiCase.setTestPlanCollectionId(apiCase.getCollectionId()); testPlanApiCase.setTestPlanCollectionId(collectionId);
testPlanApiCase.setTestPlanId(testPlan.getId()); testPlanApiCase.setTestPlanId(testPlan.getId());
testPlanApiCase.setApiCaseId(apiTestCase.getId()); testPlanApiCase.setApiCaseId(apiTestCase.getId());
testPlanApiCase.setEnvironmentId(apiTestCase.getEnvironmentId()); testPlanApiCase.setEnvironmentId(apiTestCase.getEnvironmentId());

View File

@ -201,7 +201,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
if (selectAllModule) { if (selectAllModule) {
// 选择了全部模块 // 选择了全部模块
List<ApiScenario> scenarioList = extApiScenarioMapper.selectAllCase(isRepeat, apiScenario.getModules().getProjectId(), testPlan.getId()); List<ApiScenario> scenarioList = extApiScenarioMapper.selectAllCase(isRepeat, apiScenario.getModules().getProjectId(), testPlan.getId());
buildTestPlanApiScenarioDTO(apiScenario, scenarioList, testPlan, user, testPlanApiScenarioList); buildTestPlanApiScenarioDTO(apiScenario.getCollectionId(), scenarioList, testPlan, user, testPlanApiScenarioList);
} else { } else {
AssociateCaseDTO dto = super.getCaseIds(moduleMaps); AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
List<ApiScenario> scenarioList = new ArrayList<>(); List<ApiScenario> scenarioList = new ArrayList<>();
@ -225,7 +225,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
if (CollectionUtils.isNotEmpty(scenarioList)) { if (CollectionUtils.isNotEmpty(scenarioList)) {
List<ApiScenario> list = scenarioList.stream().sorted(Comparator.comparing(ApiScenario::getPos).reversed()).toList(); List<ApiScenario> list = scenarioList.stream().sorted(Comparator.comparing(ApiScenario::getPos).reversed()).toList();
buildTestPlanApiScenarioDTO(apiScenario, list, testPlan, user, testPlanApiScenarioList); buildTestPlanApiScenarioDTO(apiScenario.getCollectionId(), list, testPlan, user, testPlanApiScenarioList);
} }
} }
@ -236,20 +236,20 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
/** /**
* 构建测试计划场景用例对象 * 构建测试计划场景用例对象
* *
* @param apiScenario * @param collectionId
* @param scenarioList * @param scenarioList
* @param testPlan * @param testPlan
* @param user * @param user
* @param testPlanApiScenarioList * @param testPlanApiScenarioList
*/ */
public void buildTestPlanApiScenarioDTO(BaseCollectionAssociateRequest apiScenario, List<ApiScenario> scenarioList, TestPlan testPlan, SessionUser user, List<TestPlanApiScenario> testPlanApiScenarioList) { public void buildTestPlanApiScenarioDTO(String collectionId, List<ApiScenario> scenarioList, TestPlan testPlan, SessionUser user, List<TestPlanApiScenario> testPlanApiScenarioList) {
AtomicLong nextOrder = new AtomicLong(getNextOrder(apiScenario.getCollectionId())); AtomicLong nextOrder = new AtomicLong(getNextOrder(collectionId));
scenarioList.forEach(scenario -> { scenarioList.forEach(scenario -> {
TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario(); TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario();
testPlanApiScenario.setId(IDGenerator.nextStr()); testPlanApiScenario.setId(IDGenerator.nextStr());
testPlanApiScenario.setTestPlanId(testPlan.getId()); testPlanApiScenario.setTestPlanId(testPlan.getId());
testPlanApiScenario.setApiScenarioId(scenario.getId()); testPlanApiScenario.setApiScenarioId(scenario.getId());
testPlanApiScenario.setTestPlanCollectionId(apiScenario.getCollectionId()); testPlanApiScenario.setTestPlanCollectionId(collectionId);
testPlanApiScenario.setGrouped(scenario.getGrouped()); testPlanApiScenario.setGrouped(scenario.getGrouped());
testPlanApiScenario.setEnvironmentId(scenario.getEnvironmentId()); testPlanApiScenario.setEnvironmentId(scenario.getEnvironmentId());
testPlanApiScenario.setCreateTime(System.currentTimeMillis()); testPlanApiScenario.setCreateTime(System.currentTimeMillis());

View File

@ -866,7 +866,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
List<String> caseIds = functionalCaseList.stream().map(FunctionalCase::getId).toList(); List<String> caseIds = functionalCaseList.stream().map(FunctionalCase::getId).toList();
List<ApiScenario> scenarioList = extFunctionalCaseTestMapper.selectApiScenarioByCaseIds(caseIds); List<ApiScenario> scenarioList = extFunctionalCaseTestMapper.selectApiScenarioByCaseIds(caseIds);
List<TestPlanApiScenario> testPlanApiScenarioList = new ArrayList<>(); List<TestPlanApiScenario> testPlanApiScenarioList = new ArrayList<>();
testPlanApiScenarioService.buildTestPlanApiScenarioDTO(functional, scenarioList, testPlan, user, testPlanApiScenarioList); testPlanApiScenarioService.buildTestPlanApiScenarioDTO(functional.getModules().getApiScenarioCollectionId(), scenarioList, testPlan, user, testPlanApiScenarioList);
if (CollectionUtils.isNotEmpty(testPlanApiScenarioList)) { if (CollectionUtils.isNotEmpty(testPlanApiScenarioList)) {
testPlanApiScenarioMapper.batchInsert(testPlanApiScenarioList); testPlanApiScenarioMapper.batchInsert(testPlanApiScenarioList);
} }
@ -886,7 +886,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
List<String> caseIds = functionalCaseList.stream().map(FunctionalCase::getId).toList(); List<String> caseIds = functionalCaseList.stream().map(FunctionalCase::getId).toList();
List<ApiTestCase> apiTestCaseList = extFunctionalCaseTestMapper.selectApiCaseByCaseIds(caseIds); List<ApiTestCase> apiTestCaseList = extFunctionalCaseTestMapper.selectApiCaseByCaseIds(caseIds);
List<TestPlanApiCase> testPlanApiCaseList = new ArrayList<>(); List<TestPlanApiCase> testPlanApiCaseList = new ArrayList<>();
testPlanApiCaseService.buildTestPlanApiCaseDTO(functional, apiTestCaseList, testPlan, user, testPlanApiCaseList); testPlanApiCaseService.buildTestPlanApiCaseDTO(functional.getModules().getApiCaseCollectionId(), apiTestCaseList, testPlan, user, testPlanApiCaseList);
if (CollectionUtils.isNotEmpty(testPlanApiCaseList)) { if (CollectionUtils.isNotEmpty(testPlanApiCaseList)) {
testPlanApiCaseMapper.batchInsert(testPlanApiCaseList); testPlanApiCaseMapper.batchInsert(testPlanApiCaseList);
} }