From b80da9b9ae10060faf1799c61ab81fa6a28d533a Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 9 Mar 2021 17:41:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=89=A7=E8=A1=8C=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiAutomationService.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index c1badc7da4..2084a7eb85 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -157,17 +157,6 @@ public class ApiAutomationService { return request; } - - public List selectIdsNotExistsInPlan(String projectId, String planId) { - return extApiScenarioMapper.selectIdsNotExistsInPlan(projectId, planId); - } - - public void deleteByIds(List nodeIds) { - ApiScenarioExample example = new ApiScenarioExample(); - example.createCriteria().andApiScenarioModuleIdIn(nodeIds); - apiScenarioMapper.deleteByExample(example); - } - public void removeToGcByIds(List nodeIds) { ApiScenarioExample example = new ApiScenarioExample(); example.createCriteria().andApiScenarioModuleIdIn(nodeIds); @@ -387,7 +376,7 @@ public class ApiAutomationService { return report; } - private void pase(String scenarioDefinition, MsScenario scenario) { + private void parse(String scenarioDefinition, MsScenario scenario) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { @@ -424,7 +413,7 @@ public class ApiAutomationService { if (planEnvMap.size() > 0) { scenario.setEnvironmentMap(planEnvMap); } - pase(item.getScenarioDefinition(), scenario); + parse(item.getScenarioDefinition(), scenario); group.setEnableCookieShare(scenario.isEnableCookieShare()); LinkedList scenarios = new LinkedList<>(); @@ -453,7 +442,7 @@ public class ApiAutomationService { if (scenario == null) { return null; } - pase(apiScenario.getScenarioDefinition(), scenario); + parse(apiScenario.getScenarioDefinition(), scenario); // 针对导入的jmx 处理 if (CollectionUtils.isNotEmpty(scenario.getHashTree()) && (scenario.getHashTree().get(0) instanceof MsJmeterElement)) { scenario.toHashTree(jmeterHashTree, scenario.getHashTree(), config); @@ -527,12 +516,13 @@ public class ApiAutomationService { report = createScenarioReport(reportId, item.getId(), item.getName(), request.getTriggerMode(), request.getExecuteType(), item.getProjectId(), request.getReportUserID()); } - //存储报告 - batchMapper.insert(report); // 生成报告和HashTree HashTree hashTree = generateHashTree(item, reportId, planEnvMap); + //存储报告 + batchMapper.insert(report); + // 调用执行方法 jMeterService.runDefinition(report.getId(), hashTree, request.getReportId(), request.getRunMode()); // 重置报告ID