diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java index 9c64c4d7db..f2331214de 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java @@ -4,6 +4,7 @@ import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs; import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.SubListUtil; import io.metersphere.dto.*; import io.metersphere.plan.dto.*; import io.metersphere.plan.request.api.ApiTestCaseRequest; @@ -184,12 +185,9 @@ public class PlanTestPlanApiCaseService extends ApiTestService { } //分批处理参数时为了不影响初始参数,这里使用新的对象进行处理 List returnList = new ArrayList<>(); - List paramList = new ArrayList<>(apiAllCases); - while (CollectionUtils.isNotEmpty(paramList)) { - List requestList = BatchProcessingUtil.subList(paramList, 20); - returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", requestList, TestPlanApiDTO.class)); - paramList.removeAll(requestList); - } + SubListUtil.dealForSubList(apiAllCases, 200, (list) -> { + returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", list, TestPlanApiDTO.class)); + }); return returnList; } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java index 9917055def..1747f57bc0 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java @@ -4,6 +4,7 @@ import io.metersphere.base.domain.TestPlanReport; import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.SubListUtil; import io.metersphere.dto.*; import io.metersphere.plan.constant.ApiReportStatus; import io.metersphere.plan.dto.*; @@ -197,13 +198,10 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService { return null; } //分批处理参数时为了不影响初始参数,这里使用新的对象进行处理 - List paramList = new ArrayList<>(scenarioCases); List returnList = new ArrayList<>(); - while (CollectionUtils.isNotEmpty(paramList)) { - List requestList = BatchProcessingUtil.subList(paramList, 5); - returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", scenarioCases, TestPlanScenarioDTO.class)); - paramList.removeAll(requestList); - } + SubListUtil.dealForSubList(scenarioCases, 20, (list) -> { + returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", list, TestPlanScenarioDTO.class)); + }); return returnList; } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java index 1d66d74fd9..0435ee5ead 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java @@ -4,6 +4,7 @@ import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.constants.TestPlanLoadCaseStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.SubListUtil; import io.metersphere.dto.PlanReportCaseDTO; import io.metersphere.dto.TestPlanLoadCaseDTO; import io.metersphere.dto.TestPlanLoadResultReportDTO; @@ -140,13 +141,10 @@ public class PlanTestPlanLoadCaseService extends LoadTestService { return null; } //分批处理参数时为了不影响初始参数,这里使用新的对象进行处理 - List paramList = new ArrayList<>(loadCases); List returnList = new ArrayList<>(); - while (CollectionUtils.isNotEmpty(paramList)) { - List requestList = BatchProcessingUtil.subList(paramList, 5); - returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", loadCases, TestPlanLoadCaseDTO.class)); - paramList.removeAll(requestList); - } + SubListUtil.dealForSubList(loadCases, 20, (paramList) -> { + returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", paramList, TestPlanLoadCaseDTO.class)); + }); return returnList; } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java index 063a6b9e4e..5473d50a31 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java @@ -6,6 +6,7 @@ import io.metersphere.base.domain.UiScenarioReportWithBLOBs; import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.SubListUtil; import io.metersphere.dto.*; import io.metersphere.plan.constant.ApiReportStatus; import io.metersphere.plan.dto.*; @@ -161,13 +162,10 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService { } //分批处理参数时为了不影响初始参数,这里使用新的对象进行处理 - List paramList = new ArrayList<>(uiCases); List returnList = new ArrayList<>(); - while (CollectionUtils.isNotEmpty(paramList)) { - List requestList = BatchProcessingUtil.subList(paramList, 5); - returnList.addAll(microService.postForDataArray(serviceName, BASE_URL + "/build/response", uiCases, TestPlanUiScenarioDTO.class)); - paramList.removeAll(requestList); - } + SubListUtil.dealForSubList(uiCases, 20, list -> { + returnList.addAll(microService.postForDataArray(serviceName, BASE_URL + "/build/response", list, TestPlanUiScenarioDTO.class)); + }); return returnList; }