From ab63f3867e12109e5a272978c844e0f20a6d13dc Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 22 Nov 2022 14:05:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E7=BB=9F=E4=B8=80=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/ApiCaseRelevanceRequest.java | 2 +- .../metersphere/api/dto/BodyFileRequest.java | 1 + .../api/dto/ErrorReportLibraryParseDTO.java | 8 +- .../dto/automation/GenScenarioRequest.java | 4 +- .../request/QueryTestPlanRequest.java | 1 + .../definition/SaveApiDefinitionRequest.java | 2 +- .../definition/SwaggerApiExportResult.java | 2 +- .../request/assertions/MsAssertions.java | 10 +- .../request/extract/MsExtractCommon.java | 2 +- .../request/sampler/MsDebugSampler.java | 7 +- .../dto/mock/ApiDefinitionResponseDTO.java | 2 +- .../api/dto/mock/MockExpectConfigDTO.java | 2 +- .../TestPlanScenarioStepCountSimpleDTO.java | 2 +- .../api/dto/scenario/ApiScenarioParamDTO.java | 21 ++++ .../api/dto/scenario/KeyValue.java | 2 +- .../environment/EnvironmentConfig.java | 2 +- .../GlobalScriptFilterRequest.java | 2 +- .../environment/item/EnvJSR223Processor.java | 1 + .../api/dto/share/ShareInfoType.java | 2 +- .../api/dto/shell/filter/ScriptFilter.java | 2 +- .../scenario/ApiScenarioExecuteService.java | 8 +- .../api/jmeter/JMeterThreadUtils.java | 2 +- .../io/metersphere/api/jmeter/TestResult.java | 18 ++-- .../parse/PostmanAbstractParserParser.java | 2 +- .../api/parse/api/ApiDefinitionImport.java | 2 +- .../api/ApiDefinitionImportParserFactory.java | 4 +- .../metersphere/api/parse/api/ESBParser.java | 1 - .../api/parse/api/EsbAbstractParser.java | 2 +- .../api/parse/api/HarAbstractParser.java | 2 +- .../api/parse/api/Swagger3Parser.java | 8 +- .../api/parse/api/SwaggerAbstractParser.java | 2 +- .../api/parse/api/esb/EsbSheetDataStruct.java | 20 ++-- .../api/parse/api/har/model/Har.java | 24 +++-- .../api/parse/api/har/model/HarCache.java | 24 +++-- .../parse/api/har/model/HarCacheDetails.java | 32 +++---- .../api/parse/api/har/model/HarContent.java | 36 ++++--- .../api/parse/api/har/model/HarCookie.java | 94 +++++++++--------- .../api/parse/api/har/model/HarCreator.java | 35 ++++--- .../api/parse/api/har/model/HarEntry.java | 82 ++++++++-------- .../api/parse/api/har/model/HarHeader.java | 80 ++++++++-------- .../api/parse/api/har/model/HarLog.java | 53 +++++------ .../api/parse/api/har/model/HarPage.java | 95 +++++++++---------- .../parse/api/har/model/HarPageTiming.java | 35 ++++--- .../api/parse/api/har/model/HarPostData.java | 28 +++--- .../api/parse/api/har/model/HarPostParam.java | 86 ++++++++--------- .../parse/api/har/model/HarQueryParam.java | 80 ++++++++-------- .../api/parse/api/har/model/HarRequest.java | 62 ++++++------ .../api/parse/api/har/model/HarResponse.java | 56 ++++++----- .../api/parse/api/har/model/HarTiming.java | 57 ++++++----- .../parse/scenario/ApiScenarioImportUtil.java | 32 +++---- .../java/io/metersphere/api/tcp/TCPPool.java | 49 +++++----- .../metersphere/api/tcp/server/TCPServer.java | 10 +- .../constants/RequestTypeConstants.java | 2 +- .../commons/utils/mock/MockTestDataUtil.java | 25 ++--- .../ApiDefinitionExecResultController.java | 2 +- .../plan/TestPlanScenarioCaseController.java | 1 + .../scenario/ApiScenarioController.java | 1 + .../listener/TestPlanDeletedListener.java | 3 +- .../service/definition/EsbImportService.java | 2 +- .../definition/TcpApiParamService.java | 6 +- .../ext/ExtFileAssociationService.java | 1 + .../service/scenario/ApiScenarioService.java | 16 ++-- .../scenario/dto/ApiScenarioParamDto.java | 21 ---- 63 files changed, 623 insertions(+), 655 deletions(-) create mode 100644 api-test/backend/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioParamDTO.java delete mode 100644 api-test/backend/src/main/java/io/metersphere/service/scenario/dto/ApiScenarioParamDto.java diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/ApiCaseRelevanceRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiCaseRelevanceRequest.java index a4f376f516..37e025721a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/ApiCaseRelevanceRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/ApiCaseRelevanceRequest.java @@ -33,7 +33,7 @@ public class ApiCaseRelevanceRequest { */ private Map> mapping; /** - *测试评审ID + * 测试评审ID */ private String reviewId; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/BodyFileRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/BodyFileRequest.java index 6b7a6dcfee..2d35ee1e23 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/BodyFileRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/BodyFileRequest.java @@ -1,4 +1,5 @@ package io.metersphere.api.dto; + import io.metersphere.request.BodyFile; import lombok.Data; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/ErrorReportLibraryParseDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/ErrorReportLibraryParseDTO.java index b3ea038fd0..ababe7a031 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/ErrorReportLibraryParseDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/ErrorReportLibraryParseDTO.java @@ -20,11 +20,11 @@ public class ErrorReportLibraryParseDTO { this.errorCodeList = new ArrayList<>(); } - public String getErrorCodeStr(){ - if(CollectionUtils.isNotEmpty(this.errorCodeList)){ - String errorCodeStr = StringUtils.join(this.errorCodeList,";"); + public String getErrorCodeStr() { + if (CollectionUtils.isNotEmpty(this.errorCodeList)) { + String errorCodeStr = StringUtils.join(this.errorCodeList, ";"); return errorCodeStr; - }else { + } else { return StringUtils.EMPTY; } 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 0f478de36c..eb9fa91131 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 @@ -22,7 +22,9 @@ public class GenScenarioRequest extends ApiScenarioWithBLOBs { private String runMode; - /**测试情景和测试计划的关联ID*/ + /** + * 测试情景和测试计划的关联ID + */ private String planScenarioId; private List planCaseIds; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/request/QueryTestPlanRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/request/QueryTestPlanRequest.java index 94631d8d3d..53264fd21d 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/request/QueryTestPlanRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/datacount/request/QueryTestPlanRequest.java @@ -1,4 +1,5 @@ package io.metersphere.api.dto.datacount.request; + import io.metersphere.request.OrderRequest; import io.metersphere.request.TestPlanRequest; import lombok.Getter; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java index 0ae8f68862..5854d7f603 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java @@ -83,7 +83,7 @@ public class SaveApiDefinitionRequest { //发送信息给场景创建人 private Boolean scenarioCreator; - + //是否新建 private Boolean newCreate; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SwaggerApiExportResult.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SwaggerApiExportResult.java index ce294dfb1d..0d0318e5b4 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SwaggerApiExportResult.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/SwaggerApiExportResult.java @@ -11,7 +11,7 @@ import java.util.List; @Getter @Setter -public class SwaggerApiExportResult extends ApiExportResult{ +public class SwaggerApiExportResult extends ApiExportResult { private String openapi; private SwaggerInfo info; private JsonNode externalDocs; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index 4c2230e36e..6bdc09a20b 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -106,22 +106,22 @@ public class MsAssertions extends MsTestElement { private ResponseAssertion responseAssertion(MsAssertionRegex assertionRegex) { ResponseAssertion assertion = null; boolean isErrorReportAssertion = false; - if(StringUtils.startsWith(this.getName(),"ErrorReportAssertion:")){ + if (StringUtils.startsWith(this.getName(), "ErrorReportAssertion:")) { assertion = new ErrorReportAssertion(); isErrorReportAssertion = true; - }else { + } else { assertion = new ResponseAssertion(); } assertion.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(assertionRegex.getDescription())) { - if(!isErrorReportAssertion){ + if (!isErrorReportAssertion) { //正常断言要在desc增加匹配信息,用于接受结果后和误报断言进行匹配 - assertionRegex.setDescription(assertionRegex.getDescription() + ErrorReportLibraryUtil.ASSERTION_CONTENT_REGEX_DELIMITER + assertionRegex.getSubject()+":"+assertionRegex.getExpression()); + assertionRegex.setDescription(assertionRegex.getDescription() + ErrorReportLibraryUtil.ASSERTION_CONTENT_REGEX_DELIMITER + assertionRegex.getSubject() + ":" + assertionRegex.getExpression()); } assertion.setName(this.getName() + delimiter + assertionRegex.getDescription()); } else { - assertion.setName(this.getName() + delimiter + "AssertionRegex" + ErrorReportLibraryUtil.ASSERTION_CONTENT_REGEX_DELIMITER + assertionRegex.getSubject()+":"+assertionRegex.getExpression()); + assertion.setName(this.getName() + delimiter + "AssertionRegex" + ErrorReportLibraryUtil.ASSERTION_CONTENT_REGEX_DELIMITER + assertionRegex.getSubject() + ":" + assertionRegex.getExpression()); } assertion.setProperty(TestElement.TEST_CLASS, ResponseAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui")); diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java index 767a295102..0210b172f5 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java @@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils; @EqualsAndHashCode(callSuper = true) @Data -public class MsExtractCommon extends MsExtractType{ +public class MsExtractCommon extends MsExtractType { private String variable; private String value; private String expression; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java index 2c3007bde2..563b223a5f 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java @@ -48,7 +48,6 @@ public class MsDebugSampler extends MsTestElement { } - private DebugSampler debugSampler() { DebugSampler debugSampler = new DebugSampler(); debugSampler.setEnabled(this.isEnable()); @@ -64,9 +63,9 @@ public class MsDebugSampler extends MsTestElement { debugSampler.setDisplayJMeterProperties(this.displayJMeterProperties); //上面三行直接Set属性会导致DebugSampler构建时取不到值,可能是JMeter的Bug,需要SetProperty - debugSampler.setProperty("displayJMeterProperties",this.displayJMeterProperties); - debugSampler.setProperty("displayJMeterVariables",this.displayJMeterVariables); - debugSampler.setProperty("displaySystemProperties",this.displaySystemProperties); + debugSampler.setProperty("displayJMeterProperties", this.displayJMeterProperties); + debugSampler.setProperty("displayJMeterVariables", this.displayJMeterVariables); + debugSampler.setProperty("displaySystemProperties", this.displaySystemProperties); return debugSampler; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/mock/ApiDefinitionResponseDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/mock/ApiDefinitionResponseDTO.java index c48d723b38..512f7a716d 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/mock/ApiDefinitionResponseDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/mock/ApiDefinitionResponseDTO.java @@ -11,5 +11,5 @@ import java.util.Map; public class ApiDefinitionResponseDTO { private String returnData; private int returnCode = 404; - private Map headers = new HashMap<>(); + private Map headers = new HashMap<>(); } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/mock/MockExpectConfigDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/mock/MockExpectConfigDTO.java index 51fd52d04b..defd5548cf 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/mock/MockExpectConfigDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/mock/MockExpectConfigDTO.java @@ -6,7 +6,7 @@ import lombok.Setter; @Getter @Setter -public class MockExpectConfigDTO{ +public class MockExpectConfigDTO { private String projectId; private MockExpectConfigWithBLOBs mockExpectConfig; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/plan/TestPlanScenarioStepCountSimpleDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/plan/TestPlanScenarioStepCountSimpleDTO.java index d2865c7156..10d0bdda2b 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/plan/TestPlanScenarioStepCountSimpleDTO.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/plan/TestPlanScenarioStepCountSimpleDTO.java @@ -10,6 +10,6 @@ import java.util.List; @Setter public class TestPlanScenarioStepCountSimpleDTO { private TestPlanScenarioStepCountDTO stepCount; - private int underwayStepsCounts ; + private int underwayStepsCounts; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioParamDTO.java b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioParamDTO.java new file mode 100644 index 0000000000..51bcd95b93 --- /dev/null +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioParamDTO.java @@ -0,0 +1,21 @@ +package io.metersphere.api.dto.scenario; + +import io.metersphere.base.domain.ApiDefinition; +import io.metersphere.base.mapper.ApiDefinitionMapper; +import io.metersphere.base.mapper.ApiScenarioMapper; +import io.metersphere.base.mapper.ApiTestCaseMapper; +import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; +import lombok.Data; + +import java.util.Map; +import java.util.Set; + +@Data +public class ApiScenarioParamDTO { + private ApiScenarioMapper batchMapper; + private ExtApiScenarioMapper extApiScenarioMapper; + private ApiTestCaseMapper apiTestCaseMapper; + private ApiDefinitionMapper apiDefinitionMapper; + private Map definitionMap; + private Map> apiIdCaseNameMap; +} diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java index 28fe3fc5d5..b81862c043 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java @@ -59,7 +59,7 @@ public class KeyValue { } public boolean valueIsNotEmpty() { - return StringUtils.isNotEmpty(this.getValue()); + return StringUtils.isNotEmpty(this.getValue()); } public boolean isValid() { diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/EnvironmentConfig.java b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/EnvironmentConfig.java index 8c2f8b7c79..18ddb62d75 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/EnvironmentConfig.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/EnvironmentConfig.java @@ -32,7 +32,7 @@ public class EnvironmentConfig { //全局前后置脚本都配置 private GlobalScriptConfig globalScriptConfig; private EnvAuthManager authManager; - @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS,include = JsonTypeInfo.As.WRAPPER_ARRAY,defaultImpl = EnvAssertions.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_ARRAY, defaultImpl = EnvAssertions.class) private List assertions; private boolean useErrorCode; private boolean higherThanSuccess; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/GlobalScriptFilterRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/GlobalScriptFilterRequest.java index a61d577ae7..3eccbb0edf 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/GlobalScriptFilterRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/GlobalScriptFilterRequest.java @@ -1,5 +1,5 @@ package io.metersphere.api.dto.scenario.environment; public enum GlobalScriptFilterRequest { - HTTP,TCP,JDBC,DUBBO + HTTP, TCP, JDBC, DUBBO } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/item/EnvJSR223Processor.java b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/item/EnvJSR223Processor.java index 5f6b17935d..8442525153 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/item/EnvJSR223Processor.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/scenario/environment/item/EnvJSR223Processor.java @@ -1,4 +1,5 @@ package io.metersphere.api.dto.scenario.environment.item; + import io.metersphere.commons.constants.ElementConstants; import lombok.Data; diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/share/ShareInfoType.java b/api-test/backend/src/main/java/io/metersphere/api/dto/share/ShareInfoType.java index 8447a5a439..12b183d314 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/share/ShareInfoType.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/share/ShareInfoType.java @@ -1,5 +1,5 @@ package io.metersphere.api.dto.share; public enum ShareInfoType { - Single,Batch + Single, Batch } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java b/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java index 6d3df4e049..fe54e51af1 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/shell/filter/ScriptFilter.java @@ -28,7 +28,7 @@ public class ScriptFilter { } public static void verify(String language, String label, String script) { - if(language == null){ + if (language == null) { language = ""; } if (StringUtils.isNotEmpty(script)) { diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 4624067561..0c79ece917 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -297,10 +297,10 @@ public class ApiScenarioExecuteService { //对报告的envMap做过滤,过滤多余的key Map diffEnvMap = new HashMap<>(); Map envMap = runModeConfig.getEnvMap(); - planEnvMap.forEach((k,v)->{ - if (envMap != null && envMap.get(k)!=null){ + planEnvMap.forEach((k, v) -> { + if (envMap != null && envMap.get(k) != null) { - diffEnvMap.put(k,envMap.get(k)); + diffEnvMap.put(k, envMap.get(k)); } }); runModeConfig.setEnvMap(diffEnvMap); @@ -428,7 +428,7 @@ public class ApiScenarioExecuteService { BaseSystemConfigDTO baseInfo = systemParameterService.getBaseInfo(); runRequest.setPlatformUrl(GenerateHashTreeUtil.getPlatformUrl(baseInfo, runRequest, null)); } - if(CollectionUtils.isNotEmpty(projectIds)) { + if (CollectionUtils.isNotEmpty(projectIds)) { runRequest.getExtendedParameters().put(ExtendedParameter.PROJECT_ID, JSON.toJSONString(projectIds)); } jMeterService.run(runRequest); diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterThreadUtils.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterThreadUtils.java index 77131361d1..dced81036e 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterThreadUtils.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterThreadUtils.java @@ -15,7 +15,7 @@ public class JMeterThreadUtils { currentGroup.enumerate(lstThreads); StringBuilder threadNames = new StringBuilder(); for (int i = 0; i < noThreads; i++) { - if (lstThreads[i]!=null && StringUtils.isNotEmpty(lstThreads[i].getName()) && lstThreads[i].getName().startsWith(name)) { + if (lstThreads[i] != null && StringUtils.isNotEmpty(lstThreads[i].getName()) && lstThreads[i].getName().startsWith(name)) { LogUtil.error("异常强制处理线程编号:" + i + " = " + lstThreads[i].getName()); threadNames.append(lstThreads[i].getName()).append(";"); lstThreads[i].interrupt(); 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 9fc7f35997..e5ff5bc544 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 @@ -108,24 +108,24 @@ public class TestResult { 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_")){ + int errorStep = 0; + for (RequestResult item : result.getRequestResults()) { + if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) { formattedResult.add(item); - }else { - if(StringUtils.equalsAnyIgnoreCase(item.getName(),"PRE_PROCESSOR_ENV_false","POST_PROCESSOR_ENV_false")){ - if(item.isSuccess()){ + } else { + if (StringUtils.equalsAnyIgnoreCase(item.getName(), "PRE_PROCESSOR_ENV_false", "POST_PROCESSOR_ENV_false")) { + if (item.isSuccess()) { successStep++; - }else { + } else { errorStep++; } } } } result.setSuccess(result.getSuccess() - successStep); - result.setError(result.getError()-errorStep); + result.setError(result.getError() - errorStep); this.success = this.success - successStep; - this.error = this.error-errorStep; + this.error = this.error - errorStep; this.total = this.total - successStep - errorStep; result.setRequestResults(formattedResult); diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java index 607e68d9e3..9fc9dbfa39 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java @@ -34,7 +34,7 @@ public abstract class PostmanAbstractParserParser extends ApiImportAbstractPa requestDesc.getAuth(); // todo 认证方式等待优化 PostmanUrl url = requestDesc.getUrl(); MsHTTPSamplerProxy request = buildRequest(requestItem.getName(), url == null ? StringUtils.EMPTY : url.getRaw(), requestDesc.getMethod(), - (requestDesc.getBody()==null||requestDesc.getBody().get("jsonSchema") == null)? StringUtils.EMPTY : requestDesc.getBody().get("jsonSchema").textValue()); + (requestDesc.getBody() == null || requestDesc.getBody().get("jsonSchema") == null) ? StringUtils.EMPTY : requestDesc.getBody().get("jsonSchema").textValue()); request.setRest(parseKeyValue(requestDesc.getUrl().getVariable())); if (StringUtils.isNotBlank(request.getPath())) { String path = request.getPath().split("\\?")[0]; diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImport.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImport.java index 9e4508f519..251d87f1c7 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImport.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImport.java @@ -21,7 +21,7 @@ public class ApiDefinitionImport { private List cases = new ArrayList<>(); //ESB文件导入的附属数据类 - private Map esbApiParamsMap; + private Map esbApiParamsMap; //Mock数据相关 private List mocks; diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImportParserFactory.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImportParserFactory.java index ecc5e133d1..0a140f5f9e 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImportParserFactory.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/ApiDefinitionImportParserFactory.java @@ -12,9 +12,9 @@ public class ApiDefinitionImportParserFactory { return new PostmanDefinitionParser(); } else if (StringUtils.equals(ApiImportPlatform.Swagger2.name(), platform)) { return new Swagger2Parser(); - }else if (StringUtils.equals(ApiImportPlatform.Har.name(), platform)) { + } else if (StringUtils.equals(ApiImportPlatform.Har.name(), platform)) { return new HarParser(); - }else if (StringUtils.equals(ApiImportPlatform.ESB.name(), platform)) { + } else if (StringUtils.equals(ApiImportPlatform.ESB.name(), platform)) { return new ESBParser(); } else if (StringUtils.equals(ApiImportPlatform.Jmeter.name(), platform)) { return new JmeterDefinitionParser(); 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 b40cb41816..8479cd8c45 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 @@ -236,7 +236,6 @@ public class ESBParser extends EsbAbstractParser { setCellValue(StringUtils.EMPTY, row6.createCell(9), font, cellStyleMap.get(PropertyConstant.DEFAULT)); - XSSFRow row7 = sheet.createRow(6); setCellValue(StringUtils.EMPTY, row7.createCell(1), font, cellStyleMap.get(PropertyConstant.DEFAULT)); setCellValue(StringUtils.EMPTY, row7.createCell(2), font, cellStyleMap.get(PropertyConstant.DEFAULT)); diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/EsbAbstractParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/EsbAbstractParser.java index a2fdce3858..88ec261777 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/EsbAbstractParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/EsbAbstractParser.java @@ -20,7 +20,7 @@ public abstract class EsbAbstractParser extends ApiImportAbstractParser { +public abstract class HarAbstractParser extends ApiImportAbstractParser { } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java index 83903afebf..319b9215c4 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java @@ -103,7 +103,7 @@ public class Swagger3Parser extends SwaggerAbstractParser { authorizationValue.setType("header"); authorizationValue.setKeyName(keyValue.getName()); authorizationValue.setValue(keyValue.getValue()); - authorizationValue.setUrlMatcher((url)->true); + authorizationValue.setUrlMatcher((url) -> true); auths.add(authorizationValue); } } @@ -329,7 +329,7 @@ public class Swagger3Parser extends SwaggerAbstractParser { Set refSet = new HashSet<>(); Map infoMap = new HashMap(); Schema schema = mediaType.getSchema(); - if (StringUtils.isBlank(schema.get$ref()) && schema.getItems()==null && StringUtils.isNotBlank(schema.getType()) && StringUtils.equals(schema.getType(),"string")) { + if (StringUtils.isBlank(schema.get$ref()) && schema.getItems() == null && StringUtils.isNotBlank(schema.getType()) && StringUtils.equals(schema.getType(), "string")) { ObjectSchema objectSchema = new ObjectSchema(); objectSchema.setExample(schema.getExample()); schema = objectSchema; @@ -348,7 +348,7 @@ public class Swagger3Parser extends SwaggerAbstractParser { parseKvBody(schema, body, bodyData, infoMap); } else if (StringUtils.equals(contentType, org.springframework.http.MediaType.APPLICATION_JSON_VALUE)) { JsonSchemaItem jsonSchemaItem = parseSchema(schema, refSet); - if (jsonSchemaItem==null){ + if (jsonSchemaItem == null) { jsonSchemaItem = new JsonSchemaItem(); jsonSchemaItem.setType(schema.getType()); } @@ -705,7 +705,7 @@ public class Swagger3Parser extends SwaggerAbstractParser { swaggerParam.setIn(typeMap.get(type)); // 利用 map,根据 request 的 key 设置对应的参数类型 swaggerParam.setDescription(param.optString("description")); swaggerParam.setName(param.optString("name")); - swaggerParam.setRequired( param.optBoolean(PropertyConstant.REQUIRED)); + swaggerParam.setRequired(param.optBoolean(PropertyConstant.REQUIRED)); swaggerParam.setExample(param.optString("value")); JSONObject schema = new JSONObject(); schema.put(PropertyConstant.TYPE, PropertyConstant.STRING); diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/SwaggerAbstractParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/SwaggerAbstractParser.java index 7a76c6d1b3..131a274856 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/SwaggerAbstractParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/SwaggerAbstractParser.java @@ -36,7 +36,7 @@ public abstract class SwaggerAbstractParser extends ApiImportAbstractParser * http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class Har { - - public HarLog log; - @Override - public String toString() { - return "Har [log=" + log + "]"; - } + public HarLog log; + + @Override + public String toString() { + return "Har [log=" + log + "]"; + } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCache.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCache.java index b957b66b49..111e33662b 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCache.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCache.java @@ -1,32 +1,30 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarCache { - public HarCacheDetails beforeRequest; - - public HarCacheDetails afterRequest; - - public String comment; - + public HarCacheDetails beforeRequest; + + public HarCacheDetails afterRequest; + + public String comment; + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCacheDetails.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCacheDetails.java index 5382f4029a..f7ca66cde0 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCacheDetails.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCacheDetails.java @@ -1,36 +1,34 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarCacheDetails { - - public String expires; - - public String lastAccess; - - public String etag; - - public String hitCount; - - public String comment; + + public String expires; + + public String lastAccess; + + public String etag; + + public String hitCount; + + public String comment; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarContent.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarContent.java index 76b9bf4f45..853229d457 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarContent.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarContent.java @@ -1,38 +1,36 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarContent { - public long size; - - public String mimeType; - - public long compression; - - public String text; - - public String comment; - - public String encoding; - + public long size; + + public String mimeType; + + public long compression; + + public String text; + + public String comment; + + public String encoding; + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCookie.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCookie.java index a5fd296ba0..f325eecf51 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCookie.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCookie.java @@ -1,67 +1,65 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarCookie { - - public String name; - - public String value; - - public String path; - - public String expires; - - public boolean httpOnly; - - public boolean secure; - public String comment; - - @Override - public String toString() { - return "[Cookie: " + this.name + "=" + this.value + "]"; - } - - @Override - public int hashCode() { - if(this.name == null) { - return -1; - } - - return this.name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof HarCookie)) { - return false; - } - - if(this.name == null) { - return false; - } - - HarCookie harCookie = (HarCookie) obj; - return this.name.equals(harCookie.name); - } + public String name; + + public String value; + + public String path; + + public String expires; + + public boolean httpOnly; + + public boolean secure; + + public String comment; + + @Override + public String toString() { + return "[Cookie: " + this.name + "=" + this.value + "]"; + } + + @Override + public int hashCode() { + if (this.name == null) { + return -1; + } + + return this.name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof HarCookie)) { + return false; + } + + if (this.name == null) { + return false; + } + + HarCookie harCookie = (HarCookie) obj; + return this.name.equals(harCookie.name); + } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCreator.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCreator.java index 16b83d25d8..625d2c567c 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCreator.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarCreator.java @@ -1,39 +1,36 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarCreator { - - public String name; - - public String version; - - public String comment; - @Override - public String toString() { - return "HarCreator [name=" + name + ", version=" + version + ", comment=" + comment + "]"; - } - - + public String name; + + public String version; + + public String comment; + + @Override + public String toString() { + return "HarCreator [name=" + name + ", version=" + version + ", comment=" + comment + "]"; + } + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarEntry.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarEntry.java index f516ba6a37..e052982947 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarEntry.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarEntry.java @@ -1,66 +1,62 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarEntry implements Comparable { - public String pageref; - - public String startedDateTime; - - public double time; - - public HarRequest request; - - public HarResponse response; - - public HarCache cache; - - public HarTiming timings; - - public String serverIPAddress; - - public String connection; - - public String comment; - - + public String pageref; - @Override - public String toString() { - return "HarEntry [pageref=" + pageref + ", startedDateTime=" + startedDateTime + ", time=" + time + ", request=" - + request + ", response=" + response + ", cache=" + cache + ", timings=" + timings - + ", serverIPAddress=" + serverIPAddress + ", connection=" + connection + ", comment=" + comment + "]"; - } + public String startedDateTime; + + public double time; + + public HarRequest request; + + public HarResponse response; + + public HarCache cache; + + public HarTiming timings; + + public String serverIPAddress; + + public String connection; + + public String comment; + @Override + public String toString() { + return "HarEntry [pageref=" + pageref + ", startedDateTime=" + startedDateTime + ", time=" + time + ", request=" + + request + ", response=" + response + ", cache=" + cache + ", timings=" + timings + + ", serverIPAddress=" + serverIPAddress + ", connection=" + connection + ", comment=" + comment + "]"; + } + + + @Override + public int compareTo(HarEntry o) { + if (o == null) { + return -1; + } + // parse the time and then return + return this.startedDateTime.compareTo(o.startedDateTime); + } - @Override - public int compareTo(HarEntry o) { - if(o == null) { - return -1; - } - // parse the time and then return - return this.startedDateTime.compareTo(o.startedDateTime); - } - } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarHeader.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarHeader.java index 8e228aa220..4c32b875ac 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarHeader.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarHeader.java @@ -1,60 +1,58 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarHeader { - - public String name; - - public String value; - - public String comment; - - @Override - public String toString() { - return "[Header: " + this.name + "=" + this.value + "]"; - } - @Override - public int hashCode() { - if(this.name == null) { - return -1; - } - - return this.name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof HarHeader)) { - return false; - } - - if(this.name == null) { - return false; - } - - HarHeader harHeader = (HarHeader) obj; - return this.name.equals(harHeader.name); - } - + public String name; + + public String value; + + public String comment; + + @Override + public String toString() { + return "[Header: " + this.name + "=" + this.value + "]"; + } + + @Override + public int hashCode() { + if (this.name == null) { + return -1; + } + + return this.name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof HarHeader)) { + return false; + } + + if (this.name == null) { + return false; + } + + HarHeader harHeader = (HarHeader) obj; + return this.name.equals(harHeader.name); + } + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarLog.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarLog.java index 14f8d99def..c8c05feb04 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarLog.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarLog.java @@ -1,22 +1,20 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; @@ -24,27 +22,26 @@ package io.metersphere.api.parse.api.har.model; import java.util.List; public class HarLog { - - public static final String DEFAULT_HAR_VERSION = "1.2"; - - public String version = DEFAULT_HAR_VERSION; - - public HarCreator creator; - - public HarCreator browser; - - public List pages; - - public List entries; - - public String comment; - @Override - public String toString() { - return "HarLog [version=" + version + ", creator=" + creator + ", browser=" + browser + ", pages=" + pages - + ", entries=" + entries + ", comment=" + comment + "]"; - } - - + public static final String DEFAULT_HAR_VERSION = "1.2"; + + public String version = DEFAULT_HAR_VERSION; + + public HarCreator creator; + + public HarCreator browser; + + public List pages; + + public List entries; + + public String comment; + + @Override + public String toString() { + return "HarLog [version=" + version + ", creator=" + creator + ", browser=" + browser + ", pages=" + pages + + ", entries=" + entries + ", comment=" + comment + "]"; + } + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPage.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPage.java index 0e353451b2..75516590de 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPage.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPage.java @@ -1,22 +1,20 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; @@ -24,48 +22,47 @@ package io.metersphere.api.parse.api.har.model; import java.util.List; public class HarPage { - - public String startedDateTime; - - public String id; - - public String title; - - public HarPageTiming pageTimings; - - public String comment; - - public transient List entries; - - - @Override - public String toString() { - return "HarPage [startedDateTime=" + startedDateTime + ", id=" + id + ", title=" + title + ", pageTimings=" - + pageTimings + ", comment=" + comment + "]"; - } + public String startedDateTime; + + public String id; + + public String title; + + public HarPageTiming pageTimings; + + public String comment; + + public transient List entries; + + + @Override + public String toString() { + return "HarPage [startedDateTime=" + startedDateTime + ", id=" + id + ", title=" + title + ", pageTimings=" + + pageTimings + ", comment=" + comment + "]"; + } + + @Override + public int hashCode() { + if (this.id == null) { + return -1; + } + + return this.id.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof HarPage)) { + return false; + } + + if (this.id == null) { + return false; + } + + HarPage harPage = (HarPage) obj; + return this.id.equals(harPage.id); + } - @Override - public int hashCode() { - if(this.id == null) { - return -1; - } - - return this.id.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof HarPage)) { - return false; - } - - if(this.id == null) { - return false; - } - - HarPage harPage = (HarPage) obj; - return this.id.equals(harPage.id); - } - } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPageTiming.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPageTiming.java index 33d86f540b..1c50ca0b0f 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPageTiming.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPageTiming.java @@ -1,39 +1,36 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarPageTiming { - - public double onContentLoad; - - public double onLoad; - - public String comment; - @Override - public String toString() { - return "HarPageTiming [onContentLoad=" + onContentLoad + ", onLoad=" + onLoad + ", comment=" + comment + "]"; - } - - + public double onContentLoad; + + public double onLoad; + + public String comment; + + @Override + public String toString() { + return "HarPageTiming [onContentLoad=" + onContentLoad + ", onLoad=" + onLoad + ", comment=" + comment + "]"; + } + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostData.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostData.java index c97e9fe69d..a717fa30b6 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostData.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostData.java @@ -1,22 +1,20 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; @@ -24,13 +22,13 @@ package io.metersphere.api.parse.api.har.model; import java.util.List; public class HarPostData { - - public String mimeType; - - public List params; - - public String text; - - public String comment; + + public String mimeType; + + public List params; + + public String text; + + public String comment; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostParam.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostParam.java index 3b530f70b7..f64f89038c 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostParam.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarPostParam.java @@ -1,64 +1,62 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarPostParam { - - public String name; - - public String value; - - public String fileName; - - public String contentType; - - public String comment; - - @Override - public String toString() { - return "[Post Param: " + this.name + "=" + this.value + "]"; - } - @Override - public int hashCode() { - if(this.name == null) { - return -1; - } - - return this.name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof HarPostParam)) { - return false; - } - - if(this.name == null) { - return false; - } - - HarPostParam harPostParam = (HarPostParam) obj; - return this.name.equals(harPostParam.name); - } + public String name; + + public String value; + + public String fileName; + + public String contentType; + + public String comment; + + @Override + public String toString() { + return "[Post Param: " + this.name + "=" + this.value + "]"; + } + + @Override + public int hashCode() { + if (this.name == null) { + return -1; + } + + return this.name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof HarPostParam)) { + return false; + } + + if (this.name == null) { + return false; + } + + HarPostParam harPostParam = (HarPostParam) obj; + return this.name.equals(harPostParam.name); + } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParam.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParam.java index 372c847f04..a115bbf694 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParam.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarQueryParam.java @@ -1,60 +1,58 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarQueryParam { - - public String name; - - public String value; - - public String comment; - - @Override - public String toString() { - return "[Query Param: " + this.name + "=" + this.value + "]"; - } - @Override - public int hashCode() { - if(this.name == null) { - return -1; - } - - return this.name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof HarQueryParam)) { - return false; - } - - if(this.name == null) { - return false; - } - - HarQueryParam harQueryParam = (HarQueryParam) obj; - return this.name.equals(harQueryParam.name); - } - + public String name; + + public String value; + + public String comment; + + @Override + public String toString() { + return "[Query Param: " + this.name + "=" + this.value + "]"; + } + + @Override + public int hashCode() { + if (this.name == null) { + return -1; + } + + return this.name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof HarQueryParam)) { + return false; + } + + if (this.name == null) { + return false; + } + + 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 87fb2e53c7..b7cd6f4e6c 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 @@ -1,22 +1,20 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; @@ -26,30 +24,30 @@ import org.apache.commons.lang3.StringUtils; import java.util.List; public class HarRequest { - - public String method; - - public String url; - - public String httpVersion; - - public List cookies; - - public List headers; - public List queryString; - - public HarPostData postData; - - public long headersSize; - - public long bodySize; - - public String comment; - - @Override - public String toString() { - return this.method + StringUtils.SPACE + this.url + StringUtils.SPACE + this.httpVersion; - } - + public String method; + + public String url; + + public String httpVersion; + + public List cookies; + + public List headers; + + public List queryString; + + public HarPostData postData; + + public long headersSize; + + public long bodySize; + + public String comment; + + @Override + public String toString() { + return this.method + StringUtils.SPACE + this.url + StringUtils.SPACE + this.httpVersion; + } + } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarResponse.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarResponse.java index 9f948143b3..d7e28adce4 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarResponse.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarResponse.java @@ -1,22 +1,20 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; @@ -24,28 +22,28 @@ package io.metersphere.api.parse.api.har.model; import java.util.List; public class HarResponse { - - public int status; - - public String statusText; - - public String httpVersion; - - public List headers; - - public List cookies; - - public HarContent content; - - public String redirectURL; - - public long headersSize; - - public long bodySize; - @Override - public String toString() { - return "HTTP " + this.status + " (" + this.statusText + ")"; - } + public int status; + + public String statusText; + + public String httpVersion; + + public List headers; + + public List cookies; + + public HarContent content; + + public String redirectURL; + + public long headersSize; + + public long bodySize; + + @Override + public String toString() { + return "HTTP " + this.status + " (" + this.statusText + ")"; + } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarTiming.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarTiming.java index 35e451aae0..b0541a7380 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarTiming.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/har/model/HarTiming.java @@ -1,50 +1,47 @@ /** - * * har - HAR file reader, writer and viewer * Copyright (c) 2014, Sandeep Gupta - * + *

* http://sangupta.com/projects/har - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ package io.metersphere.api.parse.api.har.model; public class HarTiming { - - public double blocked; - - public double dns; - - public double connect; - - public double send; - - public double wait; - - public double receive; - - public double ssl; - - public String comment; - @Override - public String toString() { - return "HarTiming [blocked=" + blocked + ", dns=" + dns + ", connect=" + connect + ", send=" + send + ", wait=" - + wait + ", receive=" + receive + ", ssl=" + ssl + ", comment=" + comment + "]"; - } - - + public double blocked; + + public double dns; + + public double connect; + + public double send; + + public double wait; + + public double receive; + + public double ssl; + + public String comment; + + @Override + public String toString() { + return "HarTiming [blocked=" + blocked + ", dns=" + dns + ", connect=" + connect + ", send=" + send + ", wait=" + + wait + ", receive=" + receive + ", ssl=" + ssl + ", comment=" + comment + "]"; + } + } 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 34e19c209a..f658904a03 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 @@ -22,7 +22,7 @@ import io.metersphere.service.BaseCheckPermissionService; import io.metersphere.service.definition.ApiDefinitionService; import io.metersphere.service.definition.ApiTestCaseService; import io.metersphere.service.scenario.ApiScenarioModuleService; -import io.metersphere.service.scenario.dto.ApiScenarioParamDto; +import io.metersphere.api.dto.scenario.ApiScenarioParamDTO; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -161,7 +161,7 @@ public class ApiScenarioImportUtil { } } - public static void checkCase(JSONObject object, String versionId, String projectId, ApiScenarioParamDto apiScenarioParamDto) { + public static void checkCase(JSONObject object, String versionId, String projectId, ApiScenarioParamDTO apiScenarioParamDto) { Map definitionMap = apiScenarioParamDto.getDefinitionMap(); ApiTestCaseMapper apiTestCaseMapper = apiScenarioParamDto.getApiTestCaseMapper(); Map> apiIdCaseNameMap = apiScenarioParamDto.getApiIdCaseNameMap(); @@ -179,7 +179,7 @@ public class ApiScenarioImportUtil { request.setName(object.optString("name")); ApiTestCase sameCase = testCaseService.getSameCase(request); if (sameCase == null) { - structureCaseByJson(object, testCaseService, apiDefinition, apiTestCaseMapper,apiIdCaseNameMap); + structureCaseByJson(object, testCaseService, apiDefinition, apiTestCaseMapper, apiIdCaseNameMap); } else { object.put("id", sameCase.getId()); object.put("resourceId", sameCase.getId()); @@ -190,7 +190,7 @@ public class ApiScenarioImportUtil { } } else { ApiDefinitionResult apiDefinitionResult = structureApiDefinitionByJson(apiDefinitionService, object, versionId, projectId, apiScenarioParamDto.getApiDefinitionMapper(), definitionMap); - structureCaseByJson(object, testCaseService, apiDefinitionResult, apiTestCaseMapper,apiIdCaseNameMap); + structureCaseByJson(object, testCaseService, apiDefinitionResult, apiTestCaseMapper, apiIdCaseNameMap); } } } @@ -213,13 +213,13 @@ public class ApiScenarioImportUtil { } String id = UUID.randomUUID().toString(); test.setId(id); - if (MapUtils.isEmpty(definitionMap)){ + if (MapUtils.isEmpty(definitionMap)) { test.setNum(apiDefinitionService.getNextNum(projectId)); - }else { + } else { ArrayList apiDefinitions = new ArrayList<>(definitionMap.values()); List collect = apiDefinitions.stream().map(ApiDefinition::getNum).collect(Collectors.toList()); Collections.sort(collect); - test.setNum(collect.get(collect.size()-1)+1); + test.setNum(collect.get(collect.size() - 1) + 1); } test.setName(object.optString("name")); if (StringUtils.isBlank(object.optString("path"))) { @@ -268,10 +268,10 @@ public class ApiScenarioImportUtil { return test; } - public static void structureCaseByJson(JSONObject object, ApiTestCaseService testCaseService, ApiDefinition apiDefinition, ApiTestCaseMapper apiTestCaseMapper,Map> apiIdCaseNameMap) { + public static void structureCaseByJson(JSONObject object, ApiTestCaseService testCaseService, ApiDefinition apiDefinition, ApiTestCaseMapper apiTestCaseMapper, Map> apiIdCaseNameMap) { String caseMapKey = apiDefinition.getId(); Set caseNameSet = apiIdCaseNameMap.get(caseMapKey); - if (CollectionUtils.isNotEmpty(caseNameSet) && caseNameSet.contains(object.optString("name"))){ + if (CollectionUtils.isNotEmpty(caseNameSet) && caseNameSet.contains(object.optString("name"))) { return; } String projectId = apiDefinition.getProjectId(); @@ -289,10 +289,10 @@ public class ApiScenarioImportUtil { apiTestCase.setUpdateTime(System.currentTimeMillis()); apiTestCase.setVersionId(apiDefinition.getVersionId()); apiTestCase.setPriority("P0"); - if (CollectionUtils.isEmpty(caseNameSet)){ + if (CollectionUtils.isEmpty(caseNameSet)) { apiTestCase.setNum(testCaseService.getNextNum(apiTestCase.getApiDefinitionId(), apiDefinition.getNum(), projectId)); - }else { - apiTestCase.setNum(apiDefinition.getNum()*1000+caseNameSet.size()+1); + } else { + apiTestCase.setNum(apiDefinition.getNum() * 1000 + caseNameSet.size() + 1); } object.put("id", apiTestCase.getId()); object.put("resourceId", apiTestCase.getId()); @@ -308,11 +308,11 @@ public class ApiScenarioImportUtil { apiTestCase.setName(apiTestCase.getName().substring(0, 255)); } Set strings = apiIdCaseNameMap.get(caseMapKey); - if (CollectionUtils.isEmpty(strings)){ - SetaddCaseNameSet = new HashSet<>(); + if (CollectionUtils.isEmpty(strings)) { + Set addCaseNameSet = new HashSet<>(); addCaseNameSet.add(apiTestCase.getName()); - apiIdCaseNameMap.put(caseMapKey,addCaseNameSet); - }else { + apiIdCaseNameMap.put(caseMapKey, addCaseNameSet); + } else { strings.add(apiTestCase.getName()); } apiTestCaseMapper.insert(apiTestCase); diff --git a/api-test/backend/src/main/java/io/metersphere/api/tcp/TCPPool.java b/api-test/backend/src/main/java/io/metersphere/api/tcp/TCPPool.java index ce80a1ca9e..9598aba619 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/tcp/TCPPool.java +++ b/api-test/backend/src/main/java/io/metersphere/api/tcp/TCPPool.java @@ -14,27 +14,28 @@ import java.util.Map; */ public class TCPPool { - private static HashMap serverSockedMap = new HashMap<>(); + private static HashMap serverSockedMap = new HashMap<>(); - private TCPPool(){} + private TCPPool() { + } - public static String createTcp(int port){ + public static String createTcp(int port) { String returnString = StringUtils.EMPTY; - if(port > 0){ + if (port > 0) { TCPServer tcpServer = null; - if(serverSockedMap.containsKey(port)){ + if (serverSockedMap.containsKey(port)) { tcpServer = serverSockedMap.get(port); - }else { + } else { tcpServer = new TCPServer(port); - serverSockedMap.put(port,tcpServer); + serverSockedMap.put(port, tcpServer); } try { - if(!tcpServer.isSocketOpen()){ + if (!tcpServer.isSocketOpen()) { Thread t = new Thread(tcpServer); t.start(); } returnString = "OK"; - }catch (Exception e){ + } catch (Exception e) { returnString = e.getMessage(); LogUtil.error(e); MSException.throwException(e.getMessage()); @@ -44,28 +45,28 @@ public class TCPPool { return returnString; } - public static boolean isTcpOpen(int port){ + public static boolean isTcpOpen(int port) { TCPServer server = serverSockedMap.get(port); - if(server != null ){ - return server.isSocketOpen(); + if (server != null) { + return server.isSocketOpen(); } - return false; + return false; } public static String getTcpStatus() { - if(serverSockedMap.isEmpty()){ + if (serverSockedMap.isEmpty()) { return "null"; - }else { + } else { StringBuffer stringBuffer = new StringBuffer(); - for (Map.Entry entry:serverSockedMap.entrySet()) { + for (Map.Entry entry : serverSockedMap.entrySet()) { int port = entry.getKey(); TCPServer tcpServer = entry.getValue(); - if(tcpServer == null){ - stringBuffer.append("Port is "+port + ";"); + if (tcpServer == null) { + stringBuffer.append("Port is " + port + ";"); stringBuffer.append("Server is null;"); - }else { - stringBuffer.append("Port is "+port + ";"); - stringBuffer.append("Server is open: "+ tcpServer.isSocketOpen()+";"); + } else { + stringBuffer.append("Port is " + port + ";"); + stringBuffer.append("Server is open: " + tcpServer.isSocketOpen() + ";"); } } return stringBuffer.toString(); @@ -74,14 +75,14 @@ public class TCPPool { public static String closeTcp(int portNum) { TCPServer server = serverSockedMap.get(portNum); - if(server == null){ + if (server == null) { return "Tcp Is not create!"; - }else { + } else { String returnMsg = null; try { server.closeSocket(); returnMsg = "OK"; - }catch (Exception e){ + } catch (Exception e) { returnMsg = e.getMessage(); LogUtil.error(e); } diff --git a/api-test/backend/src/main/java/io/metersphere/api/tcp/server/TCPServer.java b/api-test/backend/src/main/java/io/metersphere/api/tcp/server/TCPServer.java index a52b4eb967..decb8b534a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/tcp/server/TCPServer.java +++ b/api-test/backend/src/main/java/io/metersphere/api/tcp/server/TCPServer.java @@ -15,7 +15,7 @@ public class TCPServer implements Runnable { private TCPService servicer; - public TCPServer(int port){ + public TCPServer(int port) { this.port = port; } @@ -25,7 +25,7 @@ public class TCPServer implements Runnable { while (true) { if (!this.serverSocket.isClosed()) { Socket socket = this.serverSocket.accept(); - servicer = new TCPService(socket,port); + servicer = new TCPService(socket, port); servicer.run(); } if (this.serverSocket.isClosed()) { @@ -34,17 +34,17 @@ public class TCPServer implements Runnable { } } - public boolean isSocketOpen(){ + public boolean isSocketOpen() { if (this.serverSocket != null && !this.serverSocket.isClosed()) { return true; - }else { + } else { return false; } } public void closeSocket() throws Exception { if (this.serverSocket != null && !this.serverSocket.isClosed()) { - if(servicer != null){ + if (servicer != null) { servicer.close(); } this.serverSocket.close(); diff --git a/api-test/backend/src/main/java/io/metersphere/commons/constants/RequestTypeConstants.java b/api-test/backend/src/main/java/io/metersphere/commons/constants/RequestTypeConstants.java index 59748813b9..72c27995da 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/constants/RequestTypeConstants.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/constants/RequestTypeConstants.java @@ -7,6 +7,6 @@ public class RequestTypeConstants { public static final String DUBBO = "DUBBO"; public static final String SQL = "SQL"; - + public static final String TCP = "TCP"; } diff --git a/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockTestDataUtil.java b/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockTestDataUtil.java index e25f33ed1b..97f3c20dc4 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockTestDataUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockTestDataUtil.java @@ -14,14 +14,15 @@ import java.util.List; public class MockTestDataUtil { public List parseTestDataByRequest(List testDataRequestList) { for (MockTestDataRequest request : testDataRequestList) { - try{ + try { request.setValue(this.getTestData(request)); - }catch (Exception e){ + } catch (Exception e) { LogUtil.error(e); } } return testDataRequestList; } + public String getTestData(MockTestDataRequest request) { if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.VALUE_EQUALS.name())) { return request.getValue(); @@ -35,9 +36,9 @@ public class MockTestDataUtil { return RandomStringUtils.randomAlphanumeric(length); } else if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.LENGTH_SHOT_THAN.name())) { int length = Integer.parseInt(request.getValue()); - if(length > 1){ - return RandomStringUtils.randomAlphanumeric(length-1); - }else { + if (length > 1) { + return RandomStringUtils.randomAlphanumeric(length - 1); + } else { return StringUtils.EMPTY; } } else if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.REGULAR_MATCH.name())) { @@ -45,7 +46,7 @@ public class MockTestDataUtil { Generex generex = new Generex(request.getValue()); String randomStr = generex.random(); return randomStr; - }else { + } else { return StringUtils.EMPTY; } } else { @@ -66,9 +67,9 @@ public class MockTestDataUtil { return RandomStringUtils.randomAlphanumeric(length); } else if (StringUtils.equals(MockApiUtils.parseCondition(condition.getCondition()), MockParamConditionEnums.LENGTH_SHOT_THAN.name())) { int length = Integer.parseInt(condition.getValue()); - if(length > 1){ + if (length > 1) { return RandomStringUtils.randomAlphanumeric(length); - }else { + } else { return StringUtils.EMPTY; } } else if (StringUtils.equals(MockApiUtils.parseCondition(condition.getCondition()), MockParamConditionEnums.REGULAR_MATCH.name())) { @@ -76,7 +77,7 @@ public class MockTestDataUtil { Generex generex = new Generex(condition.getValue()); String randomStr = generex.random(); return randomStr; - }else { + } else { return StringUtils.EMPTY; } } else { @@ -86,12 +87,12 @@ public class MockTestDataUtil { public List parseTestDataByTcpTreeTableData(List requestArray) { for (TcpTreeTableDataStruct request : requestArray) { - try{ + try { request.setValue(this.getTestData(request)); - if(!CollectionUtils.isEmpty(request.getChildren())){ + if (!CollectionUtils.isEmpty(request.getChildren())) { this.parseTestDataByTcpTreeTableData(request.getChildren()); } - }catch (Exception e){ + } catch (Exception e) { LogUtil.error(e); } } diff --git a/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiDefinitionExecResultController.java b/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiDefinitionExecResultController.java index 0a936a31aa..af8768af64 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiDefinitionExecResultController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiDefinitionExecResultController.java @@ -20,7 +20,7 @@ public class ApiDefinitionExecResultController { @PostMapping("/plan/report") public List selectForPlanReport(@RequestBody List apiReportIds) { - return apiDefinitionExecResultService.selectForPlanReport(apiReportIds); + return apiDefinitionExecResultService.selectForPlanReport(apiReportIds); } @PostMapping("/plan/status/map") diff --git a/api-test/backend/src/main/java/io/metersphere/controller/plan/TestPlanScenarioCaseController.java b/api-test/backend/src/main/java/io/metersphere/controller/plan/TestPlanScenarioCaseController.java index 690409942c..70ae0cddbd 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/plan/TestPlanScenarioCaseController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/plan/TestPlanScenarioCaseController.java @@ -230,6 +230,7 @@ public class TestPlanScenarioCaseController { public Map> getPlanProjectEnvMap(@RequestBody List resourceIds) { return testPlanScenarioCaseService.getPlanProjectEnvMap(resourceIds); } + @GetMapping("/get-scenario-id/{id}") public String getScenarioId(@PathVariable("id") String planScenarioId) { return testPlanScenarioCaseService.getScenarioId(planScenarioId); diff --git a/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java b/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java index 35d309f3c9..2a094360a2 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java @@ -413,6 +413,7 @@ public class ApiScenarioController { public List getEnvProjects(@RequestBody RunScenarioRequest request) { return apiAutomationService.getProjects(request); } + @PostMapping(value = "/env/map") public Map> getProjectEnvMap(@RequestBody RunScenarioRequest request) { return apiAutomationService.getProjectEnvMap(request); diff --git a/api-test/backend/src/main/java/io/metersphere/listener/TestPlanDeletedListener.java b/api-test/backend/src/main/java/io/metersphere/listener/TestPlanDeletedListener.java index 137b4c19fa..02c5042584 100644 --- a/api-test/backend/src/main/java/io/metersphere/listener/TestPlanDeletedListener.java +++ b/api-test/backend/src/main/java/io/metersphere/listener/TestPlanDeletedListener.java @@ -28,7 +28,8 @@ public class TestPlanDeletedListener { @KafkaListener(id = CONSUME_ID, topics = KafkaTopicConstants.TEST_PLAN_DELETED_TOPIC, groupId = "${spring.application.name}") public void consume(ConsumerRecord record) { try { - List planIds = objectMapper.readValue(record.value(), new TypeReference<>() {}); + List planIds = objectMapper.readValue(record.value(), new TypeReference<>() { + }); if (CollectionUtils.isEmpty(planIds)) { return; } diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/EsbImportService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/EsbImportService.java index b4e3d8820d..40de3fdf5c 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/EsbImportService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/EsbImportService.java @@ -19,7 +19,7 @@ public class EsbImportService { public void templateExport(HttpServletResponse response) { try { - ESBParser.export(response,"EsbTemplate"); + ESBParser.export(response, "EsbTemplate"); } catch (Exception e) { MSException.throwException(e); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/TcpApiParamService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/TcpApiParamService.java index 08af72470e..71eaca2aad 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/TcpApiParamService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/TcpApiParamService.java @@ -57,12 +57,12 @@ public class TcpApiParamService { if (testElement instanceof MsTCPSampler) { tcpSampler = (MsTCPSampler) testElement; String protocol = tcpSampler.getProtocol(); - if(StringUtils.equalsIgnoreCase(protocol,"esb")){ - if(CollectionUtils.isNotEmpty(tcpSampler.getEsbDataStruct())){ + if (StringUtils.equalsIgnoreCase(protocol, "esb")) { + if (CollectionUtils.isNotEmpty(tcpSampler.getEsbDataStruct())) { List keyValueList = esbApiParamService.genKeyValueListByDataStruct(tcpSampler, tcpSampler.getEsbDataStruct()); tcpSampler.setParameters(keyValueList); } - }else { + } else { String reportType = tcpSampler.getReportType(); if (StringUtils.isNotEmpty(reportType)) { switch (reportType) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/ext/ExtFileAssociationService.java b/api-test/backend/src/main/java/io/metersphere/service/ext/ExtFileAssociationService.java index 357e6cfe62..0291858e25 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/ext/ExtFileAssociationService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/ext/ExtFileAssociationService.java @@ -49,6 +49,7 @@ public class ExtFileAssociationService extends FileAssociationService { } } } + private void getHashTree(List testElements, List files) { testElements.forEach(item -> { if (StringUtils.equalsIgnoreCase(item.getType(), HTTPSamplerProxy.class.getSimpleName())) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index a559300722..80858793e4 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -56,7 +56,7 @@ import io.metersphere.service.definition.TcpApiParamService; import io.metersphere.service.ext.ExtApiScheduleService; import io.metersphere.service.ext.ExtFileAssociationService; import io.metersphere.service.plan.TestPlanScenarioCaseService; -import io.metersphere.service.scenario.dto.ApiScenarioParamDto; +import io.metersphere.api.dto.scenario.ApiScenarioParamDTO; import io.metersphere.xpack.api.service.ApiAutomationRelationshipEdgeService; import io.metersphere.xpack.quota.service.QuotaService; import org.apache.commons.collections.CollectionUtils; @@ -415,7 +415,7 @@ public class ApiScenarioService { return scenario; } - private void checkReferenceCase(ApiScenarioWithBLOBs scenario, ApiScenarioParamDto apiScenarioParamDto) { + private void checkReferenceCase(ApiScenarioWithBLOBs scenario, ApiScenarioParamDTO apiScenarioParamDto) { if (scenario == null || StringUtils.isEmpty(scenario.getScenarioDefinition())) { return; } @@ -1184,7 +1184,7 @@ public class ApiScenarioService { } } - private void _importCreate(List sameRequest, ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiScenarioParamDto apiScenarioParamDto) { + private void _importCreate(List sameRequest, ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiScenarioParamDTO apiScenarioParamDto) { ApiScenarioMapper batchMapper = apiScenarioParamDto.getBatchMapper(); ExtApiScenarioMapper extApiScenarioMapper = apiScenarioParamDto.getExtApiScenarioMapper(); if (CollectionUtils.isEmpty(sameRequest)) { @@ -1251,7 +1251,7 @@ public class ApiScenarioService { } } - private ApiScenarioWithBLOBs importCreate(ApiScenarioWithBLOBs request, ApiTestImportRequest apiTestImportRequest, List sameList, ApiScenarioParamDto apiScenarioParamDto) { + private ApiScenarioWithBLOBs importCreate(ApiScenarioWithBLOBs request, ApiTestImportRequest apiTestImportRequest, List sameList, ApiScenarioParamDTO apiScenarioParamDto) { final ApiScenarioWithBLOBs scenarioWithBLOBs = new ApiScenarioWithBLOBs(); ApiScenarioMapper batchMapper = apiScenarioParamDto.getBatchMapper(); ExtApiScenarioMapper extApiScenarioMapper = apiScenarioParamDto.getExtApiScenarioMapper(); @@ -1443,7 +1443,7 @@ public class ApiScenarioService { item.setUserId(SessionUtils.getUserId()); item.setPrincipal(SessionUtils.getUserId()); // 导入之后刷新latest - ApiScenarioParamDto apiScenarioParamDto = buildParamDto(batchMapper, extApiScenarioMapper, apiTestCaseMapper, apiDefinitionMapper, definitionMap, apiIdCaseNameMap); + ApiScenarioParamDTO apiScenarioParamDto = buildParamDto(batchMapper, extApiScenarioMapper, apiTestCaseMapper, apiDefinitionMapper, definitionMap, apiIdCaseNameMap); importCreate(item, request, sameList, apiScenarioParamDto); if (i % 300 == 0) { @@ -1458,8 +1458,8 @@ public class ApiScenarioService { } @NotNull - private static ApiScenarioParamDto buildParamDto(ApiScenarioMapper batchMapper, ExtApiScenarioMapper extApiScenarioMapper, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper, Map definitionMap, Map> apiIdCaseNameMap) { - ApiScenarioParamDto apiScenarioParamDto = new ApiScenarioParamDto(); + private static ApiScenarioParamDTO buildParamDto(ApiScenarioMapper batchMapper, ExtApiScenarioMapper extApiScenarioMapper, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper, Map definitionMap, Map> apiIdCaseNameMap) { + ApiScenarioParamDTO apiScenarioParamDto = new ApiScenarioParamDTO(); apiScenarioParamDto.setBatchMapper(batchMapper); apiScenarioParamDto.setExtApiScenarioMapper(extApiScenarioMapper); apiScenarioParamDto.setApiTestCaseMapper(apiTestCaseMapper); @@ -2115,7 +2115,7 @@ public class ApiScenarioService { return strings; } - private void setReferenced(JSONArray hashTree, String projectId, String versionId, ApiScenarioParamDto apiScenarioParamDto) { + private void setReferenced(JSONArray hashTree, String projectId, String versionId, ApiScenarioParamDTO apiScenarioParamDto) { // 将引用转成复制 if (hashTree == null) { return; diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/dto/ApiScenarioParamDto.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/dto/ApiScenarioParamDto.java deleted file mode 100644 index 697005432b..0000000000 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/dto/ApiScenarioParamDto.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.metersphere.service.scenario.dto; - -import io.metersphere.base.domain.ApiDefinition; -import io.metersphere.base.mapper.ApiDefinitionMapper; -import io.metersphere.base.mapper.ApiScenarioMapper; -import io.metersphere.base.mapper.ApiTestCaseMapper; -import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; -import lombok.Data; - -import java.util.Map; -import java.util.Set; - -@Data -public class ApiScenarioParamDto { - private ApiScenarioMapper batchMapper; - private ExtApiScenarioMapper extApiScenarioMapper; - private ApiTestCaseMapper apiTestCaseMapper; - private ApiDefinitionMapper apiDefinitionMapper; - private Map definitionMap; - private Map> apiIdCaseNameMap; -}