From edcdcf9966bfc4c91a79ea165c8a4ac7ddd163e3 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 20 Oct 2022 13:00:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=9B=B4=E6=AD=A3=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=8D=95=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/automation/GenScenarioRequest.java | 2 +- .../dto/automation/RunScenarioRequest.java | 2 +- .../datacount/response/ApiDataCountDTO.java | 4 +- .../dto/datacount/response/CoverageDTO.java | 4 +- .../api/dto/share/ApiDocumentInfoDTO.java | 4 +- .../io/metersphere/api/jmeter/TestResult.java | 6 +- .../api/parse/HarScenarioAbstractParser.java | 115 +---------- .../api/parse/JmeterDocumentParser.java | 6 +- .../metersphere/api/parse/api/ESBParser.java | 4 +- .../metersphere/api/parse/api/HarParser.java | 10 +- .../api/parse/api/JMeterScriptUtil.java | 26 +-- .../{HarQueryParm.java => HarQueryParam.java} | 8 +- .../api/parse/api/har/model/HarRequest.java | 2 +- .../parse/scenario/ApiScenarioImportUtil.java | 4 +- .../api/parse/scenario/EsbDataParser.java | 14 +- .../api/parse/scenario/HarScenarioParser.java | 2 +- .../ext/ExtApiDefinitionExecResultMapper.java | 2 +- .../ext/ExtApiDefinitionExecResultMapper.xml | 2 +- .../commons/utils/mock/MockApiUtils.java | 22 +-- .../definition/ApiTestCaseController.java | 4 +- .../controller/home/ApiHomeController.java | 16 +- .../metersphere/service/ShareInfoService.java | 14 +- .../ApiDefinitionExecResultService.java | 15 +- .../definition/ApiDefinitionService.java | 6 +- .../service/definition/ApiModuleService.java | 178 +++++++++--------- .../definition/ApiTestCaseService.java | 8 +- .../definition/EsbApiParamService.java | 10 +- .../scenario/ApiScenarioModuleService.java | 6 +- .../service/scenario/ApiScenarioService.java | 4 +- .../resources/i18n/messages_en_US.properties | 2 +- .../resources/jmeter/bin/jmeter.properties | 6 +- api-test/frontend/src/api/api-test-case.js | 2 +- .../automation/report/ApiReportExport.vue | 40 ++-- ...tem.vue => ApiReportRequestHeaderItem.vue} | 2 +- .../report/components/SqlResultTable.vue | 14 +- .../business/automation/scenario/EnvGroup.vue | 6 +- .../scenario/EnvGroupWithOption.vue | 6 +- .../automation/scenario/MsInputTag.vue | 6 +- .../scenario/component/StepExtendBtns.vue | 4 +- .../scenario/variable/VariableList.vue | 12 +- .../commons/json-schema/convert/convert.js | 2 +- .../json-schema/schema/editor/main.vue | 2 +- .../definition/components/ApiVariable.vue | 4 +- .../components/ApiVariableAdvance.vue | 6 +- .../definition/components/MsCodeEdit.vue | 2 +- .../definition/components/body/ApiBody.vue | 2 +- .../components/complete/table/TcpXmlTable.vue | 4 +- .../components/document/ApiDocumentAnchor.vue | 13 +- .../document/components/ApiInfoCollapse.vue | 18 +- .../document/components/ApiInformation.vue | 21 +-- .../document/components/ApiRequestInfo.vue | 22 +-- .../document/components/ApiResponseInfo.vue | 22 +-- .../components/JsonSchema/JsonSchemaPanel.vue | 2 +- .../definition/components/esb/EsbTable.vue | 4 +- .../esb/MxEsbDefinitionResponse.vue | 2 +- .../components/import/ApiImport.vue | 2 +- .../components/import/ApiSchedule.vue | 2 +- .../components/import/SwaggerTaskList.vue | 6 +- .../components/list/ApiCaseSimpleList.vue | 8 +- .../definition/components/list/ApiList.vue | 4 +- .../mock/Components/MockApiVariable.vue | 1 - .../Components/MockCombinationCondition.vue | 5 +- .../components/reference/ApiExtendBtns.vue | 2 +- .../request/http/ApiHttpRequestForm.vue | 4 +- .../src/business/history/ApiHistory.vue | 6 +- .../api/json-view/schema/editor/main.vue | 2 +- .../src/business/home/ApiTestHome.vue | 8 +- .../components/ApiFailureTestCaseList.vue | 10 +- .../home/components/ApiNewTestCaseList.vue | 56 +----- .../home/components/ApiRunningTaskList.vue | 14 +- .../home/components/FailureTestCaseList.vue | 10 +- .../home/components/RunningTaskList.vue | 14 +- .../home/components/card/ApiCountCard.vue | 8 +- .../components/card/ScenarioCountCard.vue | 12 +- api-test/frontend/src/i18n/lang/en-US.js | 38 ++++ api-test/frontend/src/i18n/lang/zh-CN.js | 40 +++- api-test/frontend/src/i18n/lang/zh-TW.js | 38 ++++ .../frontend/src/components/MsCodeEdit.vue | 2 +- .../template/CustomFieldFormList.vue | 2 +- .../menu/file/list/FileCaseRelevanceList.vue | 2 +- .../menu/template/CustomFieldFormList.vue | 2 +- .../menu/template/IssueTemplateEdit.vue | 2 +- .../menu/template/TestCaseTemplateEdit.vue | 4 +- .../menu/template/TestCaseTemplateList.vue | 2 +- .../components/list/ProjectReportList.vue | 2 +- .../home/components/FailureTestCaseList.vue | 10 +- .../home/components/RunningTaskList.vue | 14 +- .../business/plan/components/TestPlanList.vue | 2 +- 88 files changed, 509 insertions(+), 551 deletions(-) rename api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/{HarQueryParm.java => HarQueryParam.java} (87%) rename api-test/frontend/src/business/automation/report/{ApiReportReqestHeaderItem.vue => ApiReportRequestHeaderItem.vue} (89%) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/automation/GenScenarioRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/automation/GenScenarioRequest.java index 8d36b3dc13..0f478de36c 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/automation/GenScenarioRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/automation/GenScenarioRequest.java @@ -38,7 +38,7 @@ public class GenScenarioRequest extends ApiScenarioWithBLOBs { private RunModeConfigDTO config; private boolean isTestPlanScheduleJob = false; - //生成测试报告:当isTestPlanScheduleJob为ture时使用 + //生成测试报告:当isTestPlanScheduleJob为true时使用 private String testPlanReportId; private String requestOriginator; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/automation/RunScenarioRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/automation/RunScenarioRequest.java index 0d7e41dd59..c2bf2dbdc0 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/automation/RunScenarioRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/automation/RunScenarioRequest.java @@ -43,7 +43,7 @@ public class RunScenarioRequest { private boolean isTestPlanScheduleJob = false; - //生成测试报告:当isTestPlanScheduleJob为ture时使用 + //生成测试报告:当isTestPlanScheduleJob为true时使用 private String testPlanReportId; private String requestOriginator; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java index 7e82f8cb67..43da264cce 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java @@ -124,11 +124,11 @@ public class ApiDataCountDTO { private String interfaceCoverage = " 0%"; /** - * 对Protocal视角对查询结果进行统计 + * 对Protocol视角对查询结果进行统计 * * @param countResultList 查询参数 */ - public void countProtocal(List countResultList) { + public void countProtocol(List countResultList) { for (ApiDataCountResult countResult : countResultList) { switch (countResult.getGroupField().toUpperCase()) { diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/CoverageDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/CoverageDTO.java index 02517b6b99..f590f694ca 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/CoverageDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/response/CoverageDTO.java @@ -7,6 +7,6 @@ import lombok.Setter; @Setter public class CoverageDTO { public String rateOfCoverage = "0%"; - public long coverate = 0; - public long notCoverate = 0; + public long coverage = 0; + public long notCoverage = 0; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java index de40cbf9ab..95bfb88a4e 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/share/ApiDocumentInfoDTO.java @@ -29,7 +29,7 @@ public class ApiDocumentInfoDTO { private String restParams; private String requestBodyParamType; private String requestBodyFormData; - private String requestBodyStrutureData; + private String requestBodyStructureData; private Object requestPreviewData; private JSONSchemaBodyDTO jsonSchemaBody; @@ -38,7 +38,7 @@ public class ApiDocumentInfoDTO { private Object jsonSchemaResponseBody; private String responseBodyParamType; private String responseBodyFormData; - private String responseBodyStrutureData; + private String responseBodyStructureData; private String responseCode; private boolean sharePopoverVisible = false; diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java index 878074434f..9fc7f35997 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java @@ -105,13 +105,13 @@ public class TestResult { //如果有全局前后置脚本,会出现前后置的测试步骤,影响统计。此处略过不处理。 // 同时,jmeter会将前后置脚本步骤作为一个请求来计算。当检测到有前后置脚本步骤执行时,请求数也要做处理 - List formatedResult = new ArrayList<>(); + List formattedResult = new ArrayList<>(); int successStep = 0; int errorStep = 0; for (RequestResult item :result.getRequestResults()) { if(!StringUtils.startsWithAny(item.getName(),"PRE_PROCESSOR_ENV_","POST_PROCESSOR_ENV_")){ - formatedResult.add(item); + formattedResult.add(item); }else { if(StringUtils.equalsAnyIgnoreCase(item.getName(),"PRE_PROCESSOR_ENV_false","POST_PROCESSOR_ENV_false")){ if(item.isSuccess()){ @@ -128,7 +128,7 @@ public class TestResult { this.error = this.error-errorStep; this.total = this.total - successStep - errorStep; - result.setRequestResults(formatedResult); + result.setRequestResults(formattedResult); result.getRequestResults().forEach(item -> { String itemAndScenarioName = StringUtils.EMPTY; diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java index 5d191b4631..f7af7e7177 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/HarScenarioAbstractParser.java @@ -1,31 +1,20 @@ package io.metersphere.api.parse; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor; import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy; import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.parse.api.har.model.*; -import io.metersphere.api.parse.postman.PostmanEvent; -import io.metersphere.api.parse.postman.PostmanKeyValue; -import io.metersphere.api.parse.postman.PostmanRequest; -import io.metersphere.api.parse.postman.PostmanScript; -import io.metersphere.commons.constants.ElementConstants; -import io.metersphere.commons.constants.MsRequestBodyType; -import io.metersphere.commons.constants.PostmanRequestBodyMode; -import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.JSONUtil; import io.metersphere.commons.utils.XMLUtil; -import io.metersphere.plugin.core.MsTestElement; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; -import java.util.*; -import java.util.stream.Collectors; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public abstract class HarScenarioAbstractParser extends ApiImportAbstractParser { @@ -50,9 +39,9 @@ public abstract class HarScenarioAbstractParser extends ApiImportAbstractPars } private void parseParameters(HarRequest harRequest, MsHTTPSamplerProxy request) { - List queryStringList = harRequest.queryString; - queryStringList.forEach(harQueryParm -> { - parseQueryParameters(harQueryParm, request.getArguments()); + List queryStringList = harRequest.queryString; + queryStringList.forEach(harQueryParam -> { + parseQueryParameters(harQueryParam, request.getArguments()); }); List harHeaderList = harRequest.headers; harHeaderList.forEach(harHeader -> { @@ -138,8 +127,8 @@ public abstract class HarScenarioAbstractParser extends ApiImportAbstractPars } - private void parseQueryParameters(HarQueryParm harQueryParm, List arguments) { - arguments.add(new KeyValue(harQueryParm.name, harQueryParm.value, harQueryParm.comment, false)); + private void parseQueryParameters(HarQueryParam harQueryParam, List arguments) { + arguments.add(new KeyValue(harQueryParam.name, harQueryParam.value, harQueryParam.comment, false)); } private void parseCookieParameters(HarCookie harCookie, List headers) { @@ -150,99 +139,11 @@ public abstract class HarScenarioAbstractParser extends ApiImportAbstractPars addHeader(headers, harHeader.name, harHeader.value, harHeader.comment, StringUtils.EMPTY, false); } - private void addPreScript(MsHTTPSamplerProxy request, List event) { - if (request != null && CollectionUtils.isNotEmpty(event)) { - StringBuilder scriptStr = new StringBuilder(); - event = event.stream() - .filter(item -> item.getScript() != null) - .collect(Collectors.toList()); - event.forEach(item -> { - PostmanScript script = item.getScript(); - if (script != null && item.getListen().contains("prerequest")) { - List exec = script.getExec(); - if (CollectionUtils.isNotEmpty(exec)) { - exec.forEach(col -> { - if (StringUtils.isNotEmpty(col)) { - scriptStr.append(col + StringUtils.LF); - } - }); - } - } - }); - if (StringUtils.isNotBlank(scriptStr)) { - MsJSR223PreProcessor jsr223PreProcessor = new MsJSR223PreProcessor(); - jsr223PreProcessor.setName(ElementConstants.JSR223_PRE); - jsr223PreProcessor.setScriptLanguage("javascript"); - jsr223PreProcessor.setScript(scriptStr.toString()); - LinkedList hashTree = new LinkedList<>(); - hashTree.add(jsr223PreProcessor); - request.setHashTree(hashTree); - } - } - } - - private List parseKeyValue(List postmanKeyValues) { - if (postmanKeyValues == null) { - return null; - } - List keyValues = new ArrayList<>(); - postmanKeyValues.forEach(item -> keyValues.add(new KeyValue(item.getKey(), item.getValue(), item.getDescription(), item.getContentType()))); - return keyValues; - } - - private void parseBody(Body body, PostmanRequest requestDesc) { - ObjectNode postmanBody = requestDesc.getBody(); - if (postmanBody == null) { - return; - } - String bodyMode = postmanBody.get("mode").textValue(); - if (StringUtils.isBlank(bodyMode)) { - return; - } - if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.RAW.value())) { - parseRawBody(body, postmanBody, bodyMode); - } else if (StringUtils.equalsAny(bodyMode, PostmanRequestBodyMode.FORM_DATA.value(), PostmanRequestBodyMode.URLENCODED.value())) { - List postmanKeyValues = JSON.parseArray(postmanBody.get(bodyMode).textValue(), PostmanKeyValue.class); - body.setKvs(parseKeyValue(postmanKeyValues)); - if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.FORM_DATA.value())) { - body.setType(Body.FORM_DATA); - } else if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.URLENCODED.value())) { - body.setType(Body.WWW_FROM); - } - } else if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.FILE.value())) { - body.setType(Body.BINARY); - body.setKvs(new ArrayList<>()); - } - } - private String parseXmlBody(String xmlString) { JSONObject object = JSONUtil.parseObject(getDefaultStringValue(xmlString)); return XMLUtil.jsonToXmlStr(object); } - private void parseRawBody(Body body, ObjectNode postmanBody, String bodyMode) { - body.setRaw(postmanBody.get(bodyMode).textValue()); - body.setType(MsRequestBodyType.RAW.value()); - JsonNode options = postmanBody.get("options"); - if (options != null) { - JsonNode raw = options.get(PostmanRequestBodyMode.RAW.value()); - if (raw != null) { - String bodyType = StringUtils.EMPTY; - switch (raw.get("language").textValue()) { - case "json": - bodyType = Body.JSON_STR; - break; - case "xml": - bodyType = Body.XML; - break; - default: - bodyType = Body.RAW; - } - body.setType(bodyType); - } - } - } - private String getDefaultStringValue(String val) { return StringUtils.isBlank(val) ? StringUtils.EMPTY : val; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java index 93872f1ba8..3a68cdc814 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java @@ -190,9 +190,9 @@ public class JmeterDocumentParser { // 解析访问地址 if (url.contains("?")) { - String[] strUrlPatten = url.split("\\?"); - strUrl = strUrlPatten[0]; - strUrlParams = strUrlPatten[1]; + String[] strUrlPattern = url.split("\\?"); + strUrl = strUrlPattern[0]; + strUrlParams = strUrlPattern[1]; } else { strUrl = url; diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/ESBParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/ESBParser.java index b9a2ff7d70..b40cb41816 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/ESBParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/ESBParser.java @@ -87,7 +87,7 @@ public class ESBParser extends EsbAbstractParser { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFFont font = workbook.createFont(); font.setFontHeightInPoints((short) 9); - Map cellStyleMap = createCellStle(workbook); + Map cellStyleMap = createCellStyle(workbook); XSSFSheet headSheet = workbook.createSheet("公共报文头"); generateSheet(headSheet, font, cellStyleMap); XSSFSheet bodySheet = workbook.createSheet("接口报文信息"); @@ -95,7 +95,7 @@ public class ESBParser extends EsbAbstractParser { return workbook; } - private static Map createCellStle(XSSFWorkbook workbook) { + private static Map createCellStyle(XSSFWorkbook workbook) { Map cellStype = new HashMap<>(); short[] colorIndexArr = {IndexedColors.LIGHT_GREEN.getIndex(), IndexedColors.ORCHID.getIndex(), IndexedColors.YELLOW.getIndex()}; for (short colorIndex : colorIndexArr) { diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/HarParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/HarParser.java index cce1193570..8d3cdeea7b 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/HarParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/HarParser.java @@ -118,9 +118,9 @@ public class HarParser extends HarAbstractParser { } private void parseParameters(HarRequest harRequest, MsHTTPSamplerProxy request) { - List queryStringList = harRequest.queryString; - queryStringList.forEach(harQueryParm -> { - parseQueryParameters(harQueryParm, request.getArguments()); + List queryStringList = harRequest.queryString; + queryStringList.forEach(harQueryParam -> { + parseQueryParameters(harQueryParam, request.getArguments()); }); List harHeaderList = harRequest.headers; harHeaderList.forEach(harHeader -> { @@ -278,7 +278,7 @@ public class HarParser extends HarAbstractParser { return XMLUtil.jsonToXmlStr(object); } - private void parseQueryParameters(HarQueryParm harQueryParm, List arguments) { - arguments.add(new KeyValue(harQueryParm.name, harQueryParm.value, harQueryParm.comment, false)); + private void parseQueryParameters(HarQueryParam harQueryParam, List arguments) { + arguments.add(new KeyValue(harQueryParam.name, harQueryParam.value, harQueryParam.comment, false)); } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/JMeterScriptUtil.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/JMeterScriptUtil.java index 86f97e5f63..27002e7e55 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/JMeterScriptUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/JMeterScriptUtil.java @@ -20,13 +20,13 @@ public class JMeterScriptUtil { /** * 判断脚本是否被过滤 * - * @param filterProtocals 要过滤掉的请求类型 - * @param protocal 当前请求类型 + * @param filterProtocols 要过滤掉的请求类型 + * @param protocol 当前请求类型 * @return */ - public static boolean isScriptFilter(List filterProtocals, String protocal) { - if (!CollectionUtils.isEmpty(filterProtocals)) { - return filterProtocals.contains(protocal); + public static boolean isScriptFilter(List filterProtocols, String protocol) { + if (!CollectionUtils.isEmpty(filterProtocols)) { + return filterProtocols.contains(protocol); } else { return false; } @@ -62,26 +62,26 @@ public class JMeterScriptUtil { * @param envConfig 环境配置信息 * @param samplerHashTree sampler的hashtree * @param isAfterPrivateScript 是否将脚本放置在sampler的私有脚本之后 - * @param protocal 请求类型 + * @param protocol 请求类型 * @param environmentId 环境ID * @param config 参数配置 */ - public static void setScriptByEnvironmentConfig(EnvironmentConfig envConfig, HashTree samplerHashTree, String protocal, String environmentId, ParameterConfig config, boolean isAfterPrivateScript) { + public static void setScriptByEnvironmentConfig(EnvironmentConfig envConfig, HashTree samplerHashTree, String protocol, String environmentId, ParameterConfig config, boolean isAfterPrivateScript) { GlobalScriptConfig globalScriptConfig = envConfig != null ? envConfig.getGlobalScriptConfig() : null; MsJSR223PreProcessor preProcessor = JMeterScriptUtil.getPreScript(envConfig); MsJSR223PostProcessor postProcessor = JMeterScriptUtil.getPostScript(envConfig); - setScript(globalScriptConfig, protocal, isAfterPrivateScript, environmentId, config, samplerHashTree, preProcessor, postProcessor); + setScript(globalScriptConfig, protocol, isAfterPrivateScript, environmentId, config, samplerHashTree, preProcessor, postProcessor); } - public static void setScript(GlobalScriptConfig globalScriptConfig, String protocal, boolean isAfterPrivateScript, String environmentId, ParameterConfig config, + public static void setScript(GlobalScriptConfig globalScriptConfig, String protocol, boolean isAfterPrivateScript, String environmentId, ParameterConfig config, HashTree samplerHashTree, MsJSR223PreProcessor preProcessor, MsJSR223PostProcessor postProcessor) { boolean isPreScriptExecAfterPrivateScript = globalScriptConfig == null ? false : globalScriptConfig.isPreScriptExecAfterPrivateScript(); boolean isPostScriptExecAfterPrivateScript = globalScriptConfig == null ? false : globalScriptConfig.isPostScriptExecAfterPrivateScript(); - List preFilterProtocal = globalScriptConfig == null ? null : globalScriptConfig.getFilterRequestPreScript(); - List postFilterProtocal = globalScriptConfig == null ? null : globalScriptConfig.getFilterRequestPostScript(); - boolean globalPreScriptIsFilter = JMeterScriptUtil.isScriptFilter(preFilterProtocal, protocal); - boolean globalPostScriptIsFilter = JMeterScriptUtil.isScriptFilter(postFilterProtocal, protocal); + List preFilterProtocol = globalScriptConfig == null ? null : globalScriptConfig.getFilterRequestPreScript(); + List postFilterProtocol = globalScriptConfig == null ? null : globalScriptConfig.getFilterRequestPostScript(); + boolean globalPreScriptIsFilter = JMeterScriptUtil.isScriptFilter(preFilterProtocol, protocol); + boolean globalPostScriptIsFilter = JMeterScriptUtil.isScriptFilter(postFilterProtocol, protocol); if (isAfterPrivateScript) { if (isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter && preProcessor != null && StringUtils.isNotEmpty(preProcessor.getScript())) { addItemHashTree(preProcessor, samplerHashTree, config, environmentId); diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParm.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParam.java similarity index 87% rename from api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParm.java rename to api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParam.java index 1ffb8d6a14..372c847f04 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParm.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParam.java @@ -21,7 +21,7 @@ package io.metersphere.api.parse.api.har.model; -public class HarQueryParm { +public class HarQueryParam { public String name; @@ -45,7 +45,7 @@ public class HarQueryParm { @Override public boolean equals(Object obj) { - if(!(obj instanceof HarQueryParm)) { + if(!(obj instanceof HarQueryParam)) { return false; } @@ -53,8 +53,8 @@ public class HarQueryParm { return false; } - HarQueryParm harQueryParm = (HarQueryParm) obj; - return this.name.equals(harQueryParm.name); + HarQueryParam harQueryParam = (HarQueryParam) obj; + return this.name.equals(harQueryParam.name); } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarRequest.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarRequest.java index f869be4b0e..87fb2e53c7 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarRequest.java @@ -37,7 +37,7 @@ public class HarRequest { public List headers; - public List queryString; + public List queryString; public HarPostData postData; diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/ApiScenarioImportUtil.java b/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/ApiScenarioImportUtil.java index fc361163d9..34e19c209a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/ApiScenarioImportUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/ApiScenarioImportUtil.java @@ -198,8 +198,8 @@ public class ApiScenarioImportUtil { public static ApiDefinitionResult structureApiDefinitionByJson(ApiDefinitionService apiDefinitionService, JSONObject object, String versionId, String projectId, ApiDefinitionMapper apiDefinitionMapper, Map definitionMap) { ApiDefinitionResult test = new ApiDefinitionResult(); apiDefinitionService.checkQuota(projectId); - String protocal = object.optString("protocal"); - if (StringUtils.equals(protocal, "DUBBO")) { + String protocol = object.optString("protocol"); + if (StringUtils.equals(protocol, "DUBBO")) { test.setMethod("dubbo://"); } else { test.setMethod(object.optString("method")); diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/EsbDataParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/EsbDataParser.java index 716d52e81f..fb9afb380e 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/EsbDataParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/EsbDataParser.java @@ -70,22 +70,22 @@ public class EsbDataParser { EsbDataStruct returnData = null; if (paramArr.length > index) { String param = paramArr[index]; - for (EsbDataStruct dataStuct : esbDataList) { - if (StringUtils.equals(dataStuct.getName(), param)) { + for (EsbDataStruct dataStruct : esbDataList) { + if (StringUtils.equals(dataStruct.getName(), param)) { int newIndex = index + 1; - if (paramArr.length > newIndex && dataStuct.getChildren() != null) { - EsbDataStruct childElement = selectEsbDataStructByNameStruct(dataStuct.getChildren(), paramArr, newIndex); + if (paramArr.length > newIndex && dataStruct.getChildren() != null) { + EsbDataStruct childElement = selectEsbDataStructByNameStruct(dataStruct.getChildren(), paramArr, newIndex); if (childElement != null) { - returnData = dataStuct.copy(false); + returnData = dataStruct.copy(false); returnData.getChildren().add(childElement); } } else { - returnData = dataStuct.copy(true); + returnData = dataStruct.copy(true); } } else if (index == 0) { //如果是第一个节点不符合,则遍历子节点是否有符合的。 int newIndex = index; - EsbDataStruct itemData = selectEsbDataStructByNameStruct(dataStuct.getChildren(), paramArr, newIndex); + EsbDataStruct itemData = selectEsbDataStructByNameStruct(dataStruct.getChildren(), paramArr, newIndex); if (itemData != null) { returnData = itemData; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/HarScenarioParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/HarScenarioParser.java index ee1818dea6..7e00aa46c0 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/HarScenarioParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/scenario/HarScenarioParser.java @@ -84,7 +84,7 @@ public class HarScenarioParser extends HarScenarioAbstractParser if (samplerProxy.getBody() != null) { List keyValueList = new ArrayList<>(); if (!ObjectUtils.isEmpty(request.queryString)) { - for (HarQueryParm model : request.queryString) { + for (HarQueryParam model : request.queryString) { KeyValue keyValue = new KeyValue(model.name, model.value); keyValueList.add(keyValue); } diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java index e4e4bce9d8..c6eb8b8a10 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java @@ -28,7 +28,7 @@ public interface ExtApiDefinitionExecResultMapper { long countByTestCaseIDInProject(String projectId); - List findFaliureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("selectFunctionCase") boolean selectFunctionCase, @Param("startTimestamp") long startTimestamp); + List findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("selectFunctionCase") boolean selectFunctionCase, @Param("startTimestamp") long startTimestamp); String selectExecResult(String resourceId); diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml index 462c6e99ad..c830ecadee 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml @@ -65,7 +65,7 @@ WHERE integrated_report_id = #{0} -