refactor(接口测试): 统一规范代码格式化

This commit is contained in:
fit2-zhao 2022-11-22 14:05:32 +08:00 committed by fit2-zhao
parent 8adb3bf69d
commit ab63f3867e
63 changed files with 623 additions and 655 deletions

View File

@ -33,7 +33,7 @@ public class ApiCaseRelevanceRequest {
*/ */
private Map<String, List<String>> mapping; private Map<String, List<String>> mapping;
/** /**
*测试评审ID * 测试评审ID
*/ */
private String reviewId; private String reviewId;

View File

@ -1,4 +1,5 @@
package io.metersphere.api.dto; package io.metersphere.api.dto;
import io.metersphere.request.BodyFile; import io.metersphere.request.BodyFile;
import lombok.Data; import lombok.Data;

View File

@ -20,11 +20,11 @@ public class ErrorReportLibraryParseDTO {
this.errorCodeList = new ArrayList<>(); this.errorCodeList = new ArrayList<>();
} }
public String getErrorCodeStr(){ public String getErrorCodeStr() {
if(CollectionUtils.isNotEmpty(this.errorCodeList)){ if (CollectionUtils.isNotEmpty(this.errorCodeList)) {
String errorCodeStr = StringUtils.join(this.errorCodeList,";"); String errorCodeStr = StringUtils.join(this.errorCodeList, ";");
return errorCodeStr; return errorCodeStr;
}else { } else {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }

View File

@ -22,7 +22,9 @@ public class GenScenarioRequest extends ApiScenarioWithBLOBs {
private String runMode; private String runMode;
/**测试情景和测试计划的关联ID*/ /**
* 测试情景和测试计划的关联ID
*/
private String planScenarioId; private String planScenarioId;
private List<String> planCaseIds; private List<String> planCaseIds;

View File

@ -1,4 +1,5 @@
package io.metersphere.api.dto.datacount.request; package io.metersphere.api.dto.datacount.request;
import io.metersphere.request.OrderRequest; import io.metersphere.request.OrderRequest;
import io.metersphere.request.TestPlanRequest; import io.metersphere.request.TestPlanRequest;
import lombok.Getter; import lombok.Getter;

View File

@ -11,7 +11,7 @@ import java.util.List;
@Getter @Getter
@Setter @Setter
public class SwaggerApiExportResult extends ApiExportResult{ public class SwaggerApiExportResult extends ApiExportResult {
private String openapi; private String openapi;
private SwaggerInfo info; private SwaggerInfo info;
private JsonNode externalDocs; private JsonNode externalDocs;

View File

@ -106,22 +106,22 @@ public class MsAssertions extends MsTestElement {
private ResponseAssertion responseAssertion(MsAssertionRegex assertionRegex) { private ResponseAssertion responseAssertion(MsAssertionRegex assertionRegex) {
ResponseAssertion assertion = null; ResponseAssertion assertion = null;
boolean isErrorReportAssertion = false; boolean isErrorReportAssertion = false;
if(StringUtils.startsWith(this.getName(),"ErrorReportAssertion:")){ if (StringUtils.startsWith(this.getName(), "ErrorReportAssertion:")) {
assertion = new ErrorReportAssertion(); assertion = new ErrorReportAssertion();
isErrorReportAssertion = true; isErrorReportAssertion = true;
}else { } else {
assertion = new ResponseAssertion(); assertion = new ResponseAssertion();
} }
assertion.setEnabled(this.isEnable()); assertion.setEnabled(this.isEnable());
if (StringUtils.isNotEmpty(assertionRegex.getDescription())) { if (StringUtils.isNotEmpty(assertionRegex.getDescription())) {
if(!isErrorReportAssertion){ if (!isErrorReportAssertion) {
//正常断言要在desc增加匹配信息用于接受结果后和误报断言进行匹配 //正常断言要在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()); assertion.setName(this.getName() + delimiter + assertionRegex.getDescription());
} else { } 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.TEST_CLASS, ResponseAssertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui")); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui"));

View File

@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class MsExtractCommon extends MsExtractType{ public class MsExtractCommon extends MsExtractType {
private String variable; private String variable;
private String value; private String value;
private String expression; private String expression;

View File

@ -48,7 +48,6 @@ public class MsDebugSampler extends MsTestElement {
} }
private DebugSampler debugSampler() { private DebugSampler debugSampler() {
DebugSampler debugSampler = new DebugSampler(); DebugSampler debugSampler = new DebugSampler();
debugSampler.setEnabled(this.isEnable()); debugSampler.setEnabled(this.isEnable());
@ -64,9 +63,9 @@ public class MsDebugSampler extends MsTestElement {
debugSampler.setDisplayJMeterProperties(this.displayJMeterProperties); debugSampler.setDisplayJMeterProperties(this.displayJMeterProperties);
//上面三行直接Set属性会导致DebugSampler构建时取不到值可能是JMeter的Bug,需要SetProperty //上面三行直接Set属性会导致DebugSampler构建时取不到值可能是JMeter的Bug,需要SetProperty
debugSampler.setProperty("displayJMeterProperties",this.displayJMeterProperties); debugSampler.setProperty("displayJMeterProperties", this.displayJMeterProperties);
debugSampler.setProperty("displayJMeterVariables",this.displayJMeterVariables); debugSampler.setProperty("displayJMeterVariables", this.displayJMeterVariables);
debugSampler.setProperty("displaySystemProperties",this.displaySystemProperties); debugSampler.setProperty("displaySystemProperties", this.displaySystemProperties);
return debugSampler; return debugSampler;
} }

View File

@ -11,5 +11,5 @@ import java.util.Map;
public class ApiDefinitionResponseDTO { public class ApiDefinitionResponseDTO {
private String returnData; private String returnData;
private int returnCode = 404; private int returnCode = 404;
private Map<String,String> headers = new HashMap<>(); private Map<String, String> headers = new HashMap<>();
} }

View File

@ -6,7 +6,7 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class MockExpectConfigDTO{ public class MockExpectConfigDTO {
private String projectId; private String projectId;
private MockExpectConfigWithBLOBs mockExpectConfig; private MockExpectConfigWithBLOBs mockExpectConfig;
} }

View File

@ -10,6 +10,6 @@ import java.util.List;
@Setter @Setter
public class TestPlanScenarioStepCountSimpleDTO { public class TestPlanScenarioStepCountSimpleDTO {
private TestPlanScenarioStepCountDTO stepCount; private TestPlanScenarioStepCountDTO stepCount;
private int underwayStepsCounts ; private int underwayStepsCounts;
} }

View File

@ -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<String, ApiDefinition> definitionMap;
private Map<String, Set<String>> apiIdCaseNameMap;
}

View File

@ -59,7 +59,7 @@ public class KeyValue {
} }
public boolean valueIsNotEmpty() { public boolean valueIsNotEmpty() {
return StringUtils.isNotEmpty(this.getValue()); return StringUtils.isNotEmpty(this.getValue());
} }
public boolean isValid() { public boolean isValid() {

View File

@ -32,7 +32,7 @@ public class EnvironmentConfig {
//全局前后置脚本都配置 //全局前后置脚本都配置
private GlobalScriptConfig globalScriptConfig; private GlobalScriptConfig globalScriptConfig;
private EnvAuthManager authManager; 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<EnvAssertions> assertions; private List<EnvAssertions> assertions;
private boolean useErrorCode; private boolean useErrorCode;
private boolean higherThanSuccess; private boolean higherThanSuccess;

View File

@ -1,5 +1,5 @@
package io.metersphere.api.dto.scenario.environment; package io.metersphere.api.dto.scenario.environment;
public enum GlobalScriptFilterRequest { public enum GlobalScriptFilterRequest {
HTTP,TCP,JDBC,DUBBO HTTP, TCP, JDBC, DUBBO
} }

View File

@ -1,4 +1,5 @@
package io.metersphere.api.dto.scenario.environment.item; package io.metersphere.api.dto.scenario.environment.item;
import io.metersphere.commons.constants.ElementConstants; import io.metersphere.commons.constants.ElementConstants;
import lombok.Data; import lombok.Data;

View File

@ -1,5 +1,5 @@
package io.metersphere.api.dto.share; package io.metersphere.api.dto.share;
public enum ShareInfoType { public enum ShareInfoType {
Single,Batch Single, Batch
} }

View File

@ -28,7 +28,7 @@ public class ScriptFilter {
} }
public static void verify(String language, String label, String script) { public static void verify(String language, String label, String script) {
if(language == null){ if (language == null) {
language = ""; language = "";
} }
if (StringUtils.isNotEmpty(script)) { if (StringUtils.isNotEmpty(script)) {

View File

@ -297,10 +297,10 @@ public class ApiScenarioExecuteService {
//对报告的envMap做过滤过滤多余的key //对报告的envMap做过滤过滤多余的key
Map<String, String> diffEnvMap = new HashMap<>(); Map<String, String> diffEnvMap = new HashMap<>();
Map<String, String> envMap = runModeConfig.getEnvMap(); Map<String, String> envMap = runModeConfig.getEnvMap();
planEnvMap.forEach((k,v)->{ planEnvMap.forEach((k, v) -> {
if (envMap != null && envMap.get(k)!=null){ if (envMap != null && envMap.get(k) != null) {
diffEnvMap.put(k,envMap.get(k)); diffEnvMap.put(k, envMap.get(k));
} }
}); });
runModeConfig.setEnvMap(diffEnvMap); runModeConfig.setEnvMap(diffEnvMap);
@ -428,7 +428,7 @@ public class ApiScenarioExecuteService {
BaseSystemConfigDTO baseInfo = systemParameterService.getBaseInfo(); BaseSystemConfigDTO baseInfo = systemParameterService.getBaseInfo();
runRequest.setPlatformUrl(GenerateHashTreeUtil.getPlatformUrl(baseInfo, runRequest, null)); runRequest.setPlatformUrl(GenerateHashTreeUtil.getPlatformUrl(baseInfo, runRequest, null));
} }
if(CollectionUtils.isNotEmpty(projectIds)) { if (CollectionUtils.isNotEmpty(projectIds)) {
runRequest.getExtendedParameters().put(ExtendedParameter.PROJECT_ID, JSON.toJSONString(projectIds)); runRequest.getExtendedParameters().put(ExtendedParameter.PROJECT_ID, JSON.toJSONString(projectIds));
} }
jMeterService.run(runRequest); jMeterService.run(runRequest);

View File

@ -15,7 +15,7 @@ public class JMeterThreadUtils {
currentGroup.enumerate(lstThreads); currentGroup.enumerate(lstThreads);
StringBuilder threadNames = new StringBuilder(); StringBuilder threadNames = new StringBuilder();
for (int i = 0; i < noThreads; i++) { 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()); LogUtil.error("异常强制处理线程编号:" + i + " = " + lstThreads[i].getName());
threadNames.append(lstThreads[i].getName()).append(""); threadNames.append(lstThreads[i].getName()).append("");
lstThreads[i].interrupt(); lstThreads[i].interrupt();

View File

@ -108,24 +108,24 @@ public class TestResult {
List<RequestResult> formattedResult = new ArrayList<>(); List<RequestResult> formattedResult = new ArrayList<>();
int successStep = 0; int successStep = 0;
int errorStep = 0; int errorStep = 0;
for (RequestResult item :result.getRequestResults()) { for (RequestResult item : result.getRequestResults()) {
if(!StringUtils.startsWithAny(item.getName(),"PRE_PROCESSOR_ENV_","POST_PROCESSOR_ENV_")){ if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
formattedResult.add(item); formattedResult.add(item);
}else { } else {
if(StringUtils.equalsAnyIgnoreCase(item.getName(),"PRE_PROCESSOR_ENV_false","POST_PROCESSOR_ENV_false")){ if (StringUtils.equalsAnyIgnoreCase(item.getName(), "PRE_PROCESSOR_ENV_false", "POST_PROCESSOR_ENV_false")) {
if(item.isSuccess()){ if (item.isSuccess()) {
successStep++; successStep++;
}else { } else {
errorStep++; errorStep++;
} }
} }
} }
} }
result.setSuccess(result.getSuccess() - successStep); result.setSuccess(result.getSuccess() - successStep);
result.setError(result.getError()-errorStep); result.setError(result.getError() - errorStep);
this.success = this.success - successStep; this.success = this.success - successStep;
this.error = this.error-errorStep; this.error = this.error - errorStep;
this.total = this.total - successStep - errorStep; this.total = this.total - successStep - errorStep;
result.setRequestResults(formattedResult); result.setRequestResults(formattedResult);

View File

@ -34,7 +34,7 @@ public abstract class PostmanAbstractParserParser<T> extends ApiImportAbstractPa
requestDesc.getAuth(); // todo 认证方式等待优化 requestDesc.getAuth(); // todo 认证方式等待优化
PostmanUrl url = requestDesc.getUrl(); PostmanUrl url = requestDesc.getUrl();
MsHTTPSamplerProxy request = buildRequest(requestItem.getName(), url == null ? StringUtils.EMPTY : url.getRaw(), requestDesc.getMethod(), 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())); request.setRest(parseKeyValue(requestDesc.getUrl().getVariable()));
if (StringUtils.isNotBlank(request.getPath())) { if (StringUtils.isNotBlank(request.getPath())) {
String path = request.getPath().split("\\?")[0]; String path = request.getPath().split("\\?")[0];

View File

@ -21,7 +21,7 @@ public class ApiDefinitionImport {
private List<ApiTestCaseWithBLOBs> cases = new ArrayList<>(); private List<ApiTestCaseWithBLOBs> cases = new ArrayList<>();
//ESB文件导入的附属数据类 //ESB文件导入的附属数据类
private Map<String,EsbApiParamsWithBLOBs> esbApiParamsMap; private Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap;
//Mock数据相关 //Mock数据相关
private List<MockConfigImportDTO> mocks; private List<MockConfigImportDTO> mocks;

View File

@ -12,9 +12,9 @@ public class ApiDefinitionImportParserFactory {
return new PostmanDefinitionParser(); return new PostmanDefinitionParser();
} else if (StringUtils.equals(ApiImportPlatform.Swagger2.name(), platform)) { } else if (StringUtils.equals(ApiImportPlatform.Swagger2.name(), platform)) {
return new Swagger2Parser(); return new Swagger2Parser();
}else if (StringUtils.equals(ApiImportPlatform.Har.name(), platform)) { } else if (StringUtils.equals(ApiImportPlatform.Har.name(), platform)) {
return new HarParser(); return new HarParser();
}else if (StringUtils.equals(ApiImportPlatform.ESB.name(), platform)) { } else if (StringUtils.equals(ApiImportPlatform.ESB.name(), platform)) {
return new ESBParser(); return new ESBParser();
} else if (StringUtils.equals(ApiImportPlatform.Jmeter.name(), platform)) { } else if (StringUtils.equals(ApiImportPlatform.Jmeter.name(), platform)) {
return new JmeterDefinitionParser(); return new JmeterDefinitionParser();

View File

@ -236,7 +236,6 @@ public class ESBParser extends EsbAbstractParser {
setCellValue(StringUtils.EMPTY, row6.createCell(9), font, cellStyleMap.get(PropertyConstant.DEFAULT)); setCellValue(StringUtils.EMPTY, row6.createCell(9), font, cellStyleMap.get(PropertyConstant.DEFAULT));
XSSFRow row7 = sheet.createRow(6); XSSFRow row7 = sheet.createRow(6);
setCellValue(StringUtils.EMPTY, row7.createCell(1), font, cellStyleMap.get(PropertyConstant.DEFAULT)); setCellValue(StringUtils.EMPTY, row7.createCell(1), font, cellStyleMap.get(PropertyConstant.DEFAULT));
setCellValue(StringUtils.EMPTY, row7.createCell(2), font, cellStyleMap.get(PropertyConstant.DEFAULT)); setCellValue(StringUtils.EMPTY, row7.createCell(2), font, cellStyleMap.get(PropertyConstant.DEFAULT));

View File

@ -20,7 +20,7 @@ public abstract class EsbAbstractParser extends ApiImportAbstractParser<ApiDefin
ApiModule module = ApiDefinitionImportUtil.buildModule(parentModule, tag, this.projectId); ApiModule module = ApiDefinitionImportUtil.buildModule(parentModule, tag, this.projectId);
apiDefinition.setModuleId(module.getId()); apiDefinition.setModuleId(module.getId());
}); });
}else { } else {
apiDefinition.setModuleId(parentModule.getId()); apiDefinition.setModuleId(parentModule.getId());
} }
} }

View File

@ -7,5 +7,5 @@ import io.metersphere.api.parse.ApiImportAbstractParser;
* @Date 2021/3/10 11:15 上午 * @Date 2021/3/10 11:15 上午
* @Description * @Description
*/ */
public abstract class HarAbstractParser extends ApiImportAbstractParser<ApiDefinitionImport> { public abstract class HarAbstractParser extends ApiImportAbstractParser<ApiDefinitionImport> {
} }

View File

@ -103,7 +103,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
authorizationValue.setType("header"); authorizationValue.setType("header");
authorizationValue.setKeyName(keyValue.getName()); authorizationValue.setKeyName(keyValue.getName());
authorizationValue.setValue(keyValue.getValue()); authorizationValue.setValue(keyValue.getValue());
authorizationValue.setUrlMatcher((url)->true); authorizationValue.setUrlMatcher((url) -> true);
auths.add(authorizationValue); auths.add(authorizationValue);
} }
} }
@ -329,7 +329,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
Set<String> refSet = new HashSet<>(); Set<String> refSet = new HashSet<>();
Map<String, Schema> infoMap = new HashMap(); Map<String, Schema> infoMap = new HashMap();
Schema schema = mediaType.getSchema(); 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 objectSchema = new ObjectSchema();
objectSchema.setExample(schema.getExample()); objectSchema.setExample(schema.getExample());
schema = objectSchema; schema = objectSchema;
@ -348,7 +348,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
parseKvBody(schema, body, bodyData, infoMap); parseKvBody(schema, body, bodyData, infoMap);
} else if (StringUtils.equals(contentType, org.springframework.http.MediaType.APPLICATION_JSON_VALUE)) { } else if (StringUtils.equals(contentType, org.springframework.http.MediaType.APPLICATION_JSON_VALUE)) {
JsonSchemaItem jsonSchemaItem = parseSchema(schema, refSet); JsonSchemaItem jsonSchemaItem = parseSchema(schema, refSet);
if (jsonSchemaItem==null){ if (jsonSchemaItem == null) {
jsonSchemaItem = new JsonSchemaItem(); jsonSchemaItem = new JsonSchemaItem();
jsonSchemaItem.setType(schema.getType()); jsonSchemaItem.setType(schema.getType());
} }
@ -705,7 +705,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
swaggerParam.setIn(typeMap.get(type)); // 利用 map根据 request key 设置对应的参数类型 swaggerParam.setIn(typeMap.get(type)); // 利用 map根据 request key 设置对应的参数类型
swaggerParam.setDescription(param.optString("description")); swaggerParam.setDescription(param.optString("description"));
swaggerParam.setName(param.optString("name")); swaggerParam.setName(param.optString("name"));
swaggerParam.setRequired( param.optBoolean(PropertyConstant.REQUIRED)); swaggerParam.setRequired(param.optBoolean(PropertyConstant.REQUIRED));
swaggerParam.setExample(param.optString("value")); swaggerParam.setExample(param.optString("value"));
JSONObject schema = new JSONObject(); JSONObject schema = new JSONObject();
schema.put(PropertyConstant.TYPE, PropertyConstant.STRING); schema.put(PropertyConstant.TYPE, PropertyConstant.STRING);

View File

@ -36,7 +36,7 @@ public abstract class SwaggerAbstractParser extends ApiImportAbstractParser<ApiD
} }
private ApiModule buildModule(ApiModule parentModule, ApiDefinitionWithBLOBs apiDefinition, private ApiModule buildModule(ApiModule parentModule, ApiDefinitionWithBLOBs apiDefinition,
String tag, String selectModulePath) { String tag, String selectModulePath) {
ApiModule module = ApiDefinitionImportUtil.buildModule(parentModule, tag, this.projectId); ApiModule module = ApiDefinitionImportUtil.buildModule(parentModule, tag, this.projectId);
apiDefinition.setModuleId(module.getId()); apiDefinition.setModuleId(module.getId());
if (StringUtils.isNotBlank(selectModulePath)) { if (StringUtils.isNotBlank(selectModulePath)) {

View File

@ -28,17 +28,17 @@ public class EsbSheetDataStruct {
public void setInterfaceInfo(String interfaceCode, String interfaceName, String interfaceDesc) { public void setInterfaceInfo(String interfaceCode, String interfaceName, String interfaceDesc) {
if(StringUtils.isEmpty(interfaceCode) && StringUtils.isEmpty(interfaceName)){ if (StringUtils.isEmpty(interfaceCode) && StringUtils.isEmpty(interfaceName)) {
MSException.throwException("接口的交易码或服务名称不能都为空"); MSException.throwException("接口的交易码或服务名称不能都为空");
} }
if(StringUtils.isNotEmpty(interfaceCode)){ if (StringUtils.isNotEmpty(interfaceCode)) {
this.serviceName = interfaceCode+":"+interfaceName; this.serviceName = interfaceCode + ":" + interfaceName;
}else { } else {
this.serviceName = interfaceName; this.serviceName = interfaceName;
} }
if (this.serviceName.endsWith(":")){ if (this.serviceName.endsWith(":")) {
this.serviceName = this.serviceName.substring(0,this.serviceName.length()-1); this.serviceName = this.serviceName.substring(0, this.serviceName.length() - 1);
} }
this.serviceDesc = interfaceDesc; this.serviceDesc = interfaceDesc;
} }
} }

View File

@ -1,32 +1,30 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class Har { public class Har {
public HarLog log; public HarLog log;
@Override @Override
public String toString() { public String toString() {
return "Har [log=" + log + "]"; return "Har [log=" + log + "]";
} }
} }

View File

@ -1,32 +1,30 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarCache { public class HarCache {
public HarCacheDetails beforeRequest; public HarCacheDetails beforeRequest;
public HarCacheDetails afterRequest; public HarCacheDetails afterRequest;
public String comment; public String comment;
} }

View File

@ -1,36 +1,34 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarCacheDetails { public class HarCacheDetails {
public String expires; public String expires;
public String lastAccess; public String lastAccess;
public String etag; public String etag;
public String hitCount; public String hitCount;
public String comment; public String comment;
} }

View File

@ -1,38 +1,36 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarContent { public class HarContent {
public long size; public long size;
public String mimeType; public String mimeType;
public long compression; public long compression;
public String text; public String text;
public String comment; public String comment;
public String encoding; public String encoding;
} }

View File

@ -1,67 +1,65 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarCookie { public class HarCookie {
public String name; public String name;
public String value; public String value;
public String path; public String path;
public String expires; public String expires;
public boolean httpOnly; public boolean httpOnly;
public boolean secure; public boolean secure;
public String comment; public String comment;
@Override @Override
public String toString() { public String toString() {
return "[Cookie: " + this.name + "=" + this.value + "]"; return "[Cookie: " + this.name + "=" + this.value + "]";
} }
@Override @Override
public int hashCode() { public int hashCode() {
if(this.name == null) { if (this.name == null) {
return -1; return -1;
} }
return this.name.hashCode(); return this.name.hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(!(obj instanceof HarCookie)) { if (!(obj instanceof HarCookie)) {
return false; return false;
} }
if(this.name == null) { if (this.name == null) {
return false; return false;
} }
HarCookie harCookie = (HarCookie) obj; HarCookie harCookie = (HarCookie) obj;
return this.name.equals(harCookie.name); return this.name.equals(harCookie.name);
} }
} }

View File

@ -1,39 +1,36 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarCreator { public class HarCreator {
public String name; public String name;
public String version; public String version;
public String comment; public String comment;
@Override
public String toString() {
return "HarCreator [name=" + name + ", version=" + version + ", comment=" + comment + "]";
}
@Override
public String toString() {
return "HarCreator [name=" + name + ", version=" + version + ", comment=" + comment + "]";
}
} }

View File

@ -1,66 +1,62 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarEntry implements Comparable<HarEntry> { public class HarEntry implements Comparable<HarEntry> {
public String pageref; public String pageref;
public String startedDateTime; public String startedDateTime;
public double time; public double time;
public HarRequest request; public HarRequest request;
public HarResponse response; public HarResponse response;
public HarCache cache; public HarCache cache;
public HarTiming timings; public HarTiming timings;
public String serverIPAddress; public String serverIPAddress;
public String connection; public String connection;
public String comment; public String comment;
@Override
@Override public String toString() {
public String toString() { return "HarEntry [pageref=" + pageref + ", startedDateTime=" + startedDateTime + ", time=" + time + ", request="
return "HarEntry [pageref=" + pageref + ", startedDateTime=" + startedDateTime + ", time=" + time + ", request=" + request + ", response=" + response + ", cache=" + cache + ", timings=" + timings
+ request + ", response=" + response + ", cache=" + cache + ", timings=" + timings + ", serverIPAddress=" + serverIPAddress + ", connection=" + connection + ", comment=" + comment + "]";
+ ", serverIPAddress=" + serverIPAddress + ", connection=" + connection + ", comment=" + comment + "]"; }
}
@Override
@Override public int compareTo(HarEntry o) {
public int compareTo(HarEntry o) { if (o == null) {
if(o == null) { return -1;
return -1; }
} // parse the time and then return
// parse the time and then return return this.startedDateTime.compareTo(o.startedDateTime);
return this.startedDateTime.compareTo(o.startedDateTime); }
}
} }

View File

@ -1,60 +1,58 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarHeader { public class HarHeader {
public String name; public String name;
public String value; public String value;
public String comment; public String comment;
@Override @Override
public String toString() { public String toString() {
return "[Header: " + this.name + "=" + this.value + "]"; return "[Header: " + this.name + "=" + this.value + "]";
} }
@Override @Override
public int hashCode() { public int hashCode() {
if(this.name == null) { if (this.name == null) {
return -1; return -1;
} }
return this.name.hashCode(); return this.name.hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(!(obj instanceof HarHeader)) { if (!(obj instanceof HarHeader)) {
return false; return false;
} }
if(this.name == null) { if (this.name == null) {
return false; return false;
} }
HarHeader harHeader = (HarHeader) obj; HarHeader harHeader = (HarHeader) obj;
return this.name.equals(harHeader.name); return this.name.equals(harHeader.name);
} }
} }

View File

@ -1,22 +1,20 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
@ -25,26 +23,25 @@ import java.util.List;
public class HarLog { public class HarLog {
public static final String DEFAULT_HAR_VERSION = "1.2"; public static final String DEFAULT_HAR_VERSION = "1.2";
public String version = DEFAULT_HAR_VERSION; public String version = DEFAULT_HAR_VERSION;
public HarCreator creator; public HarCreator creator;
public HarCreator browser; public HarCreator browser;
public List<HarPage> pages; public List<HarPage> pages;
public List<HarEntry> entries; public List<HarEntry> entries;
public String comment; public String comment;
@Override
public String toString() {
return "HarLog [version=" + version + ", creator=" + creator + ", browser=" + browser + ", pages=" + pages
+ ", entries=" + entries + ", comment=" + comment + "]";
}
@Override
public String toString() {
return "HarLog [version=" + version + ", creator=" + creator + ", browser=" + browser + ", pages=" + pages
+ ", entries=" + entries + ", comment=" + comment + "]";
}
} }

View File

@ -1,22 +1,20 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
@ -25,47 +23,46 @@ import java.util.List;
public class HarPage { public class HarPage {
public String startedDateTime; public String startedDateTime;
public String id; public String id;
public String title; public String title;
public HarPageTiming pageTimings; public HarPageTiming pageTimings;
public String comment; public String comment;
public transient List<HarEntry> entries; public transient List<HarEntry> entries;
@Override
public String toString() {
return "HarPage [startedDateTime=" + startedDateTime + ", id=" + id + ", title=" + title + ", pageTimings="
+ pageTimings + ", comment=" + comment + "]";
}
@Override @Override
public String toString() { public int hashCode() {
return "HarPage [startedDateTime=" + startedDateTime + ", id=" + id + ", title=" + title + ", pageTimings=" if (this.id == null) {
+ pageTimings + ", comment=" + comment + "]"; return -1;
} }
@Override return this.id.hashCode();
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;
}
@Override if (this.id == null) {
public boolean equals(Object obj) { return false;
if(!(obj instanceof HarPage)) { }
return false;
}
if(this.id == null) { HarPage harPage = (HarPage) obj;
return false; return this.id.equals(harPage.id);
} }
HarPage harPage = (HarPage) obj;
return this.id.equals(harPage.id);
}
} }

View File

@ -1,39 +1,36 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarPageTiming { public class HarPageTiming {
public double onContentLoad; public double onContentLoad;
public double onLoad; public double onLoad;
public String comment; public String comment;
@Override
public String toString() {
return "HarPageTiming [onContentLoad=" + onContentLoad + ", onLoad=" + onLoad + ", comment=" + comment + "]";
}
@Override
public String toString() {
return "HarPageTiming [onContentLoad=" + onContentLoad + ", onLoad=" + onLoad + ", comment=" + comment + "]";
}
} }

View File

@ -1,22 +1,20 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
@ -25,12 +23,12 @@ import java.util.List;
public class HarPostData { public class HarPostData {
public String mimeType; public String mimeType;
public List<HarPostParam> params; public List<HarPostParam> params;
public String text; public String text;
public String comment; public String comment;
} }

View File

@ -1,64 +1,62 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarPostParam { public class HarPostParam {
public String name; public String name;
public String value; public String value;
public String fileName; public String fileName;
public String contentType; public String contentType;
public String comment; public String comment;
@Override @Override
public String toString() { public String toString() {
return "[Post Param: " + this.name + "=" + this.value + "]"; return "[Post Param: " + this.name + "=" + this.value + "]";
} }
@Override @Override
public int hashCode() { public int hashCode() {
if(this.name == null) { if (this.name == null) {
return -1; return -1;
} }
return this.name.hashCode(); return this.name.hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(!(obj instanceof HarPostParam)) { if (!(obj instanceof HarPostParam)) {
return false; return false;
} }
if(this.name == null) { if (this.name == null) {
return false; return false;
} }
HarPostParam harPostParam = (HarPostParam) obj; HarPostParam harPostParam = (HarPostParam) obj;
return this.name.equals(harPostParam.name); return this.name.equals(harPostParam.name);
} }
} }

View File

@ -1,60 +1,58 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarQueryParam { public class HarQueryParam {
public String name; public String name;
public String value; public String value;
public String comment; public String comment;
@Override @Override
public String toString() { public String toString() {
return "[Query Param: " + this.name + "=" + this.value + "]"; return "[Query Param: " + this.name + "=" + this.value + "]";
} }
@Override @Override
public int hashCode() { public int hashCode() {
if(this.name == null) { if (this.name == null) {
return -1; return -1;
} }
return this.name.hashCode(); return this.name.hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(!(obj instanceof HarQueryParam)) { if (!(obj instanceof HarQueryParam)) {
return false; return false;
} }
if(this.name == null) { if (this.name == null) {
return false; return false;
} }
HarQueryParam harQueryParam = (HarQueryParam) obj; HarQueryParam harQueryParam = (HarQueryParam) obj;
return this.name.equals(harQueryParam.name); return this.name.equals(harQueryParam.name);
} }
} }

View File

@ -1,22 +1,20 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
@ -27,29 +25,29 @@ import java.util.List;
public class HarRequest { public class HarRequest {
public String method; public String method;
public String url; public String url;
public String httpVersion; public String httpVersion;
public List<HarCookie> cookies; public List<HarCookie> cookies;
public List<HarHeader> headers; public List<HarHeader> headers;
public List<HarQueryParam> queryString; public List<HarQueryParam> queryString;
public HarPostData postData; public HarPostData postData;
public long headersSize; public long headersSize;
public long bodySize; public long bodySize;
public String comment; public String comment;
@Override @Override
public String toString() { public String toString() {
return this.method + StringUtils.SPACE + this.url + StringUtils.SPACE + this.httpVersion; return this.method + StringUtils.SPACE + this.url + StringUtils.SPACE + this.httpVersion;
} }
} }

View File

@ -1,22 +1,20 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
@ -25,27 +23,27 @@ import java.util.List;
public class HarResponse { public class HarResponse {
public int status; public int status;
public String statusText; public String statusText;
public String httpVersion; public String httpVersion;
public List<HarHeader> headers; public List<HarHeader> headers;
public List<HarCookie> cookies; public List<HarCookie> cookies;
public HarContent content; public HarContent content;
public String redirectURL; public String redirectURL;
public long headersSize; public long headersSize;
public long bodySize; public long bodySize;
@Override @Override
public String toString() { public String toString() {
return "HTTP " + this.status + " (" + this.statusText + ")"; return "HTTP " + this.status + " (" + this.statusText + ")";
} }
} }

View File

@ -1,50 +1,47 @@
/** /**
*
* har - HAR file reader, writer and viewer * har - HAR file reader, writer and viewer
* Copyright (c) 2014, Sandeep Gupta * Copyright (c) 2014, Sandeep Gupta
* * <p>
* http://sangupta.com/projects/har * http://sangupta.com/projects/har
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*
*/ */
package io.metersphere.api.parse.api.har.model; package io.metersphere.api.parse.api.har.model;
public class HarTiming { public class HarTiming {
public double blocked; public double blocked;
public double dns; public double dns;
public double connect; public double connect;
public double send; public double send;
public double wait; public double wait;
public double receive; public double receive;
public double ssl; public double ssl;
public String comment; 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 + "]";
}
@Override
public String toString() {
return "HarTiming [blocked=" + blocked + ", dns=" + dns + ", connect=" + connect + ", send=" + send + ", wait="
+ wait + ", receive=" + receive + ", ssl=" + ssl + ", comment=" + comment + "]";
}
} }

View File

@ -22,7 +22,7 @@ import io.metersphere.service.BaseCheckPermissionService;
import io.metersphere.service.definition.ApiDefinitionService; import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService; import io.metersphere.service.definition.ApiTestCaseService;
import io.metersphere.service.scenario.ApiScenarioModuleService; 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.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; 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<String, ApiDefinition> definitionMap = apiScenarioParamDto.getDefinitionMap(); Map<String, ApiDefinition> definitionMap = apiScenarioParamDto.getDefinitionMap();
ApiTestCaseMapper apiTestCaseMapper = apiScenarioParamDto.getApiTestCaseMapper(); ApiTestCaseMapper apiTestCaseMapper = apiScenarioParamDto.getApiTestCaseMapper();
Map<String, Set<String>> apiIdCaseNameMap = apiScenarioParamDto.getApiIdCaseNameMap(); Map<String, Set<String>> apiIdCaseNameMap = apiScenarioParamDto.getApiIdCaseNameMap();
@ -179,7 +179,7 @@ public class ApiScenarioImportUtil {
request.setName(object.optString("name")); request.setName(object.optString("name"));
ApiTestCase sameCase = testCaseService.getSameCase(request); ApiTestCase sameCase = testCaseService.getSameCase(request);
if (sameCase == null) { if (sameCase == null) {
structureCaseByJson(object, testCaseService, apiDefinition, apiTestCaseMapper,apiIdCaseNameMap); structureCaseByJson(object, testCaseService, apiDefinition, apiTestCaseMapper, apiIdCaseNameMap);
} else { } else {
object.put("id", sameCase.getId()); object.put("id", sameCase.getId());
object.put("resourceId", sameCase.getId()); object.put("resourceId", sameCase.getId());
@ -190,7 +190,7 @@ public class ApiScenarioImportUtil {
} }
} else { } else {
ApiDefinitionResult apiDefinitionResult = structureApiDefinitionByJson(apiDefinitionService, object, versionId, projectId, apiScenarioParamDto.getApiDefinitionMapper(), definitionMap); 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(); String id = UUID.randomUUID().toString();
test.setId(id); test.setId(id);
if (MapUtils.isEmpty(definitionMap)){ if (MapUtils.isEmpty(definitionMap)) {
test.setNum(apiDefinitionService.getNextNum(projectId)); test.setNum(apiDefinitionService.getNextNum(projectId));
}else { } else {
ArrayList<ApiDefinition> apiDefinitions = new ArrayList<>(definitionMap.values()); ArrayList<ApiDefinition> apiDefinitions = new ArrayList<>(definitionMap.values());
List<Integer> collect = apiDefinitions.stream().map(ApiDefinition::getNum).collect(Collectors.toList()); List<Integer> collect = apiDefinitions.stream().map(ApiDefinition::getNum).collect(Collectors.toList());
Collections.sort(collect); Collections.sort(collect);
test.setNum(collect.get(collect.size()-1)+1); test.setNum(collect.get(collect.size() - 1) + 1);
} }
test.setName(object.optString("name")); test.setName(object.optString("name"));
if (StringUtils.isBlank(object.optString("path"))) { if (StringUtils.isBlank(object.optString("path"))) {
@ -268,10 +268,10 @@ public class ApiScenarioImportUtil {
return test; return test;
} }
public static void structureCaseByJson(JSONObject object, ApiTestCaseService testCaseService, ApiDefinition apiDefinition, ApiTestCaseMapper apiTestCaseMapper,Map<String, Set<String>> apiIdCaseNameMap) { public static void structureCaseByJson(JSONObject object, ApiTestCaseService testCaseService, ApiDefinition apiDefinition, ApiTestCaseMapper apiTestCaseMapper, Map<String, Set<String>> apiIdCaseNameMap) {
String caseMapKey = apiDefinition.getId(); String caseMapKey = apiDefinition.getId();
Set<String> caseNameSet = apiIdCaseNameMap.get(caseMapKey); Set<String> caseNameSet = apiIdCaseNameMap.get(caseMapKey);
if (CollectionUtils.isNotEmpty(caseNameSet) && caseNameSet.contains(object.optString("name"))){ if (CollectionUtils.isNotEmpty(caseNameSet) && caseNameSet.contains(object.optString("name"))) {
return; return;
} }
String projectId = apiDefinition.getProjectId(); String projectId = apiDefinition.getProjectId();
@ -289,10 +289,10 @@ public class ApiScenarioImportUtil {
apiTestCase.setUpdateTime(System.currentTimeMillis()); apiTestCase.setUpdateTime(System.currentTimeMillis());
apiTestCase.setVersionId(apiDefinition.getVersionId()); apiTestCase.setVersionId(apiDefinition.getVersionId());
apiTestCase.setPriority("P0"); apiTestCase.setPriority("P0");
if (CollectionUtils.isEmpty(caseNameSet)){ if (CollectionUtils.isEmpty(caseNameSet)) {
apiTestCase.setNum(testCaseService.getNextNum(apiTestCase.getApiDefinitionId(), apiDefinition.getNum(), projectId)); apiTestCase.setNum(testCaseService.getNextNum(apiTestCase.getApiDefinitionId(), apiDefinition.getNum(), projectId));
}else { } else {
apiTestCase.setNum(apiDefinition.getNum()*1000+caseNameSet.size()+1); apiTestCase.setNum(apiDefinition.getNum() * 1000 + caseNameSet.size() + 1);
} }
object.put("id", apiTestCase.getId()); object.put("id", apiTestCase.getId());
object.put("resourceId", apiTestCase.getId()); object.put("resourceId", apiTestCase.getId());
@ -308,11 +308,11 @@ public class ApiScenarioImportUtil {
apiTestCase.setName(apiTestCase.getName().substring(0, 255)); apiTestCase.setName(apiTestCase.getName().substring(0, 255));
} }
Set<String> strings = apiIdCaseNameMap.get(caseMapKey); Set<String> strings = apiIdCaseNameMap.get(caseMapKey);
if (CollectionUtils.isEmpty(strings)){ if (CollectionUtils.isEmpty(strings)) {
Set<String>addCaseNameSet = new HashSet<>(); Set<String> addCaseNameSet = new HashSet<>();
addCaseNameSet.add(apiTestCase.getName()); addCaseNameSet.add(apiTestCase.getName());
apiIdCaseNameMap.put(caseMapKey,addCaseNameSet); apiIdCaseNameMap.put(caseMapKey, addCaseNameSet);
}else { } else {
strings.add(apiTestCase.getName()); strings.add(apiTestCase.getName());
} }
apiTestCaseMapper.insert(apiTestCase); apiTestCaseMapper.insert(apiTestCase);

View File

@ -14,27 +14,28 @@ import java.util.Map;
*/ */
public class TCPPool { public class TCPPool {
private static HashMap<Integer, TCPServer> serverSockedMap = new HashMap<>(); private static HashMap<Integer, TCPServer> serverSockedMap = new HashMap<>();
private TCPPool(){} private TCPPool() {
}
public static String createTcp(int port){ public static String createTcp(int port) {
String returnString = StringUtils.EMPTY; String returnString = StringUtils.EMPTY;
if(port > 0){ if (port > 0) {
TCPServer tcpServer = null; TCPServer tcpServer = null;
if(serverSockedMap.containsKey(port)){ if (serverSockedMap.containsKey(port)) {
tcpServer = serverSockedMap.get(port); tcpServer = serverSockedMap.get(port);
}else { } else {
tcpServer = new TCPServer(port); tcpServer = new TCPServer(port);
serverSockedMap.put(port,tcpServer); serverSockedMap.put(port, tcpServer);
} }
try { try {
if(!tcpServer.isSocketOpen()){ if (!tcpServer.isSocketOpen()) {
Thread t = new Thread(tcpServer); Thread t = new Thread(tcpServer);
t.start(); t.start();
} }
returnString = "OK"; returnString = "OK";
}catch (Exception e){ } catch (Exception e) {
returnString = e.getMessage(); returnString = e.getMessage();
LogUtil.error(e); LogUtil.error(e);
MSException.throwException(e.getMessage()); MSException.throwException(e.getMessage());
@ -44,28 +45,28 @@ public class TCPPool {
return returnString; return returnString;
} }
public static boolean isTcpOpen(int port){ public static boolean isTcpOpen(int port) {
TCPServer server = serverSockedMap.get(port); TCPServer server = serverSockedMap.get(port);
if(server != null ){ if (server != null) {
return server.isSocketOpen(); return server.isSocketOpen();
} }
return false; return false;
} }
public static String getTcpStatus() { public static String getTcpStatus() {
if(serverSockedMap.isEmpty()){ if (serverSockedMap.isEmpty()) {
return "null"; return "null";
}else { } else {
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
for (Map.Entry<Integer, TCPServer> entry:serverSockedMap.entrySet()) { for (Map.Entry<Integer, TCPServer> entry : serverSockedMap.entrySet()) {
int port = entry.getKey(); int port = entry.getKey();
TCPServer tcpServer = entry.getValue(); TCPServer tcpServer = entry.getValue();
if(tcpServer == null){ if (tcpServer == null) {
stringBuffer.append("Port is "+port + ";"); stringBuffer.append("Port is " + port + ";");
stringBuffer.append("Server is null;"); stringBuffer.append("Server is null;");
}else { } else {
stringBuffer.append("Port is "+port + ";"); stringBuffer.append("Port is " + port + ";");
stringBuffer.append("Server is open: "+ tcpServer.isSocketOpen()+";"); stringBuffer.append("Server is open: " + tcpServer.isSocketOpen() + ";");
} }
} }
return stringBuffer.toString(); return stringBuffer.toString();
@ -74,14 +75,14 @@ public class TCPPool {
public static String closeTcp(int portNum) { public static String closeTcp(int portNum) {
TCPServer server = serverSockedMap.get(portNum); TCPServer server = serverSockedMap.get(portNum);
if(server == null){ if (server == null) {
return "Tcp Is not create!"; return "Tcp Is not create!";
}else { } else {
String returnMsg = null; String returnMsg = null;
try { try {
server.closeSocket(); server.closeSocket();
returnMsg = "OK"; returnMsg = "OK";
}catch (Exception e){ } catch (Exception e) {
returnMsg = e.getMessage(); returnMsg = e.getMessage();
LogUtil.error(e); LogUtil.error(e);
} }

View File

@ -15,7 +15,7 @@ public class TCPServer implements Runnable {
private TCPService servicer; private TCPService servicer;
public TCPServer(int port){ public TCPServer(int port) {
this.port = port; this.port = port;
} }
@ -25,7 +25,7 @@ public class TCPServer implements Runnable {
while (true) { while (true) {
if (!this.serverSocket.isClosed()) { if (!this.serverSocket.isClosed()) {
Socket socket = this.serverSocket.accept(); Socket socket = this.serverSocket.accept();
servicer = new TCPService(socket,port); servicer = new TCPService(socket, port);
servicer.run(); servicer.run();
} }
if (this.serverSocket.isClosed()) { 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()) { if (this.serverSocket != null && !this.serverSocket.isClosed()) {
return true; return true;
}else { } else {
return false; return false;
} }
} }
public void closeSocket() throws Exception { public void closeSocket() throws Exception {
if (this.serverSocket != null && !this.serverSocket.isClosed()) { if (this.serverSocket != null && !this.serverSocket.isClosed()) {
if(servicer != null){ if (servicer != null) {
servicer.close(); servicer.close();
} }
this.serverSocket.close(); this.serverSocket.close();

View File

@ -14,14 +14,15 @@ import java.util.List;
public class MockTestDataUtil { public class MockTestDataUtil {
public List<MockTestDataRequest> parseTestDataByRequest(List<MockTestDataRequest> testDataRequestList) { public List<MockTestDataRequest> parseTestDataByRequest(List<MockTestDataRequest> testDataRequestList) {
for (MockTestDataRequest request : testDataRequestList) { for (MockTestDataRequest request : testDataRequestList) {
try{ try {
request.setValue(this.getTestData(request)); request.setValue(this.getTestData(request));
}catch (Exception e){ } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
} }
} }
return testDataRequestList; return testDataRequestList;
} }
public String getTestData(MockTestDataRequest request) { public String getTestData(MockTestDataRequest request) {
if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.VALUE_EQUALS.name())) { if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.VALUE_EQUALS.name())) {
return request.getValue(); return request.getValue();
@ -35,9 +36,9 @@ public class MockTestDataUtil {
return RandomStringUtils.randomAlphanumeric(length); return RandomStringUtils.randomAlphanumeric(length);
} else if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.LENGTH_SHOT_THAN.name())) { } else if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.LENGTH_SHOT_THAN.name())) {
int length = Integer.parseInt(request.getValue()); int length = Integer.parseInt(request.getValue());
if(length > 1){ if (length > 1) {
return RandomStringUtils.randomAlphanumeric(length-1); return RandomStringUtils.randomAlphanumeric(length - 1);
}else { } else {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
} else if (StringUtils.equals(MockApiUtils.parseCondition(request.getCondition()), MockParamConditionEnums.REGULAR_MATCH.name())) { } 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()); Generex generex = new Generex(request.getValue());
String randomStr = generex.random(); String randomStr = generex.random();
return randomStr; return randomStr;
}else { } else {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
} else { } else {
@ -66,9 +67,9 @@ public class MockTestDataUtil {
return RandomStringUtils.randomAlphanumeric(length); return RandomStringUtils.randomAlphanumeric(length);
} else if (StringUtils.equals(MockApiUtils.parseCondition(condition.getCondition()), MockParamConditionEnums.LENGTH_SHOT_THAN.name())) { } else if (StringUtils.equals(MockApiUtils.parseCondition(condition.getCondition()), MockParamConditionEnums.LENGTH_SHOT_THAN.name())) {
int length = Integer.parseInt(condition.getValue()); int length = Integer.parseInt(condition.getValue());
if(length > 1){ if (length > 1) {
return RandomStringUtils.randomAlphanumeric(length); return RandomStringUtils.randomAlphanumeric(length);
}else { } else {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
} else if (StringUtils.equals(MockApiUtils.parseCondition(condition.getCondition()), MockParamConditionEnums.REGULAR_MATCH.name())) { } 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()); Generex generex = new Generex(condition.getValue());
String randomStr = generex.random(); String randomStr = generex.random();
return randomStr; return randomStr;
}else { } else {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
} else { } else {
@ -86,12 +87,12 @@ public class MockTestDataUtil {
public List<TcpTreeTableDataStruct> parseTestDataByTcpTreeTableData(List<TcpTreeTableDataStruct> requestArray) { public List<TcpTreeTableDataStruct> parseTestDataByTcpTreeTableData(List<TcpTreeTableDataStruct> requestArray) {
for (TcpTreeTableDataStruct request : requestArray) { for (TcpTreeTableDataStruct request : requestArray) {
try{ try {
request.setValue(this.getTestData(request)); request.setValue(this.getTestData(request));
if(!CollectionUtils.isEmpty(request.getChildren())){ if (!CollectionUtils.isEmpty(request.getChildren())) {
this.parseTestDataByTcpTreeTableData(request.getChildren()); this.parseTestDataByTcpTreeTableData(request.getChildren());
} }
}catch (Exception e){ } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
} }
} }

View File

@ -20,7 +20,7 @@ public class ApiDefinitionExecResultController {
@PostMapping("/plan/report") @PostMapping("/plan/report")
public List<PlanReportCaseDTO> selectForPlanReport(@RequestBody List<String> apiReportIds) { public List<PlanReportCaseDTO> selectForPlanReport(@RequestBody List<String> apiReportIds) {
return apiDefinitionExecResultService.selectForPlanReport(apiReportIds); return apiDefinitionExecResultService.selectForPlanReport(apiReportIds);
} }
@PostMapping("/plan/status/map") @PostMapping("/plan/status/map")

View File

@ -230,6 +230,7 @@ public class TestPlanScenarioCaseController {
public Map<String, List<String>> getPlanProjectEnvMap(@RequestBody List<String> resourceIds) { public Map<String, List<String>> getPlanProjectEnvMap(@RequestBody List<String> resourceIds) {
return testPlanScenarioCaseService.getPlanProjectEnvMap(resourceIds); return testPlanScenarioCaseService.getPlanProjectEnvMap(resourceIds);
} }
@GetMapping("/get-scenario-id/{id}") @GetMapping("/get-scenario-id/{id}")
public String getScenarioId(@PathVariable("id") String planScenarioId) { public String getScenarioId(@PathVariable("id") String planScenarioId) {
return testPlanScenarioCaseService.getScenarioId(planScenarioId); return testPlanScenarioCaseService.getScenarioId(planScenarioId);

View File

@ -413,6 +413,7 @@ public class ApiScenarioController {
public List<String> getEnvProjects(@RequestBody RunScenarioRequest request) { public List<String> getEnvProjects(@RequestBody RunScenarioRequest request) {
return apiAutomationService.getProjects(request); return apiAutomationService.getProjects(request);
} }
@PostMapping(value = "/env/map") @PostMapping(value = "/env/map")
public Map<String, List<String>> getProjectEnvMap(@RequestBody RunScenarioRequest request) { public Map<String, List<String>> getProjectEnvMap(@RequestBody RunScenarioRequest request) {
return apiAutomationService.getProjectEnvMap(request); return apiAutomationService.getProjectEnvMap(request);

View File

@ -28,7 +28,8 @@ public class TestPlanDeletedListener {
@KafkaListener(id = CONSUME_ID, topics = KafkaTopicConstants.TEST_PLAN_DELETED_TOPIC, groupId = "${spring.application.name}") @KafkaListener(id = CONSUME_ID, topics = KafkaTopicConstants.TEST_PLAN_DELETED_TOPIC, groupId = "${spring.application.name}")
public void consume(ConsumerRecord<?, String> record) { public void consume(ConsumerRecord<?, String> record) {
try { try {
List<String> planIds = objectMapper.readValue(record.value(), new TypeReference<>() {}); List<String> planIds = objectMapper.readValue(record.value(), new TypeReference<>() {
});
if (CollectionUtils.isEmpty(planIds)) { if (CollectionUtils.isEmpty(planIds)) {
return; return;
} }

View File

@ -19,7 +19,7 @@ public class EsbImportService {
public void templateExport(HttpServletResponse response) { public void templateExport(HttpServletResponse response) {
try { try {
ESBParser.export(response,"EsbTemplate"); ESBParser.export(response, "EsbTemplate");
} catch (Exception e) { } catch (Exception e) {
MSException.throwException(e); MSException.throwException(e);
} }

View File

@ -57,12 +57,12 @@ public class TcpApiParamService {
if (testElement instanceof MsTCPSampler) { if (testElement instanceof MsTCPSampler) {
tcpSampler = (MsTCPSampler) testElement; tcpSampler = (MsTCPSampler) testElement;
String protocol = tcpSampler.getProtocol(); String protocol = tcpSampler.getProtocol();
if(StringUtils.equalsIgnoreCase(protocol,"esb")){ if (StringUtils.equalsIgnoreCase(protocol, "esb")) {
if(CollectionUtils.isNotEmpty(tcpSampler.getEsbDataStruct())){ if (CollectionUtils.isNotEmpty(tcpSampler.getEsbDataStruct())) {
List<KeyValue> keyValueList = esbApiParamService.genKeyValueListByDataStruct(tcpSampler, tcpSampler.getEsbDataStruct()); List<KeyValue> keyValueList = esbApiParamService.genKeyValueListByDataStruct(tcpSampler, tcpSampler.getEsbDataStruct());
tcpSampler.setParameters(keyValueList); tcpSampler.setParameters(keyValueList);
} }
}else { } else {
String reportType = tcpSampler.getReportType(); String reportType = tcpSampler.getReportType();
if (StringUtils.isNotEmpty(reportType)) { if (StringUtils.isNotEmpty(reportType)) {
switch (reportType) { switch (reportType) {

View File

@ -49,6 +49,7 @@ public class ExtFileAssociationService extends FileAssociationService {
} }
} }
} }
private void getHashTree(List<MsTestElement> testElements, List<BodyFile> files) { private void getHashTree(List<MsTestElement> testElements, List<BodyFile> files) {
testElements.forEach(item -> { testElements.forEach(item -> {
if (StringUtils.equalsIgnoreCase(item.getType(), HTTPSamplerProxy.class.getSimpleName())) { if (StringUtils.equalsIgnoreCase(item.getType(), HTTPSamplerProxy.class.getSimpleName())) {

View File

@ -56,7 +56,7 @@ import io.metersphere.service.definition.TcpApiParamService;
import io.metersphere.service.ext.ExtApiScheduleService; import io.metersphere.service.ext.ExtApiScheduleService;
import io.metersphere.service.ext.ExtFileAssociationService; import io.metersphere.service.ext.ExtFileAssociationService;
import io.metersphere.service.plan.TestPlanScenarioCaseService; 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.api.service.ApiAutomationRelationshipEdgeService;
import io.metersphere.xpack.quota.service.QuotaService; import io.metersphere.xpack.quota.service.QuotaService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -415,7 +415,7 @@ public class ApiScenarioService {
return scenario; return scenario;
} }
private void checkReferenceCase(ApiScenarioWithBLOBs scenario, ApiScenarioParamDto apiScenarioParamDto) { private void checkReferenceCase(ApiScenarioWithBLOBs scenario, ApiScenarioParamDTO apiScenarioParamDto) {
if (scenario == null || StringUtils.isEmpty(scenario.getScenarioDefinition())) { if (scenario == null || StringUtils.isEmpty(scenario.getScenarioDefinition())) {
return; return;
} }
@ -1184,7 +1184,7 @@ public class ApiScenarioService {
} }
} }
private void _importCreate(List<ApiScenarioWithBLOBs> sameRequest, ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiScenarioParamDto apiScenarioParamDto) { private void _importCreate(List<ApiScenarioWithBLOBs> sameRequest, ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiScenarioParamDTO apiScenarioParamDto) {
ApiScenarioMapper batchMapper = apiScenarioParamDto.getBatchMapper(); ApiScenarioMapper batchMapper = apiScenarioParamDto.getBatchMapper();
ExtApiScenarioMapper extApiScenarioMapper = apiScenarioParamDto.getExtApiScenarioMapper(); ExtApiScenarioMapper extApiScenarioMapper = apiScenarioParamDto.getExtApiScenarioMapper();
if (CollectionUtils.isEmpty(sameRequest)) { if (CollectionUtils.isEmpty(sameRequest)) {
@ -1251,7 +1251,7 @@ public class ApiScenarioService {
} }
} }
private ApiScenarioWithBLOBs importCreate(ApiScenarioWithBLOBs request, ApiTestImportRequest apiTestImportRequest, List<ApiScenarioWithBLOBs> sameList, ApiScenarioParamDto apiScenarioParamDto) { private ApiScenarioWithBLOBs importCreate(ApiScenarioWithBLOBs request, ApiTestImportRequest apiTestImportRequest, List<ApiScenarioWithBLOBs> sameList, ApiScenarioParamDTO apiScenarioParamDto) {
final ApiScenarioWithBLOBs scenarioWithBLOBs = new ApiScenarioWithBLOBs(); final ApiScenarioWithBLOBs scenarioWithBLOBs = new ApiScenarioWithBLOBs();
ApiScenarioMapper batchMapper = apiScenarioParamDto.getBatchMapper(); ApiScenarioMapper batchMapper = apiScenarioParamDto.getBatchMapper();
ExtApiScenarioMapper extApiScenarioMapper = apiScenarioParamDto.getExtApiScenarioMapper(); ExtApiScenarioMapper extApiScenarioMapper = apiScenarioParamDto.getExtApiScenarioMapper();
@ -1443,7 +1443,7 @@ public class ApiScenarioService {
item.setUserId(SessionUtils.getUserId()); item.setUserId(SessionUtils.getUserId());
item.setPrincipal(SessionUtils.getUserId()); item.setPrincipal(SessionUtils.getUserId());
// 导入之后刷新latest // 导入之后刷新latest
ApiScenarioParamDto apiScenarioParamDto = buildParamDto(batchMapper, extApiScenarioMapper, apiTestCaseMapper, apiDefinitionMapper, definitionMap, apiIdCaseNameMap); ApiScenarioParamDTO apiScenarioParamDto = buildParamDto(batchMapper, extApiScenarioMapper, apiTestCaseMapper, apiDefinitionMapper, definitionMap, apiIdCaseNameMap);
importCreate(item, request, sameList, apiScenarioParamDto); importCreate(item, request, sameList, apiScenarioParamDto);
if (i % 300 == 0) { if (i % 300 == 0) {
@ -1458,8 +1458,8 @@ public class ApiScenarioService {
} }
@NotNull @NotNull
private static ApiScenarioParamDto buildParamDto(ApiScenarioMapper batchMapper, ExtApiScenarioMapper extApiScenarioMapper, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper, Map<String, ApiDefinition> definitionMap, Map<String, Set<String>> apiIdCaseNameMap) { private static ApiScenarioParamDTO buildParamDto(ApiScenarioMapper batchMapper, ExtApiScenarioMapper extApiScenarioMapper, ApiTestCaseMapper apiTestCaseMapper, ApiDefinitionMapper apiDefinitionMapper, Map<String, ApiDefinition> definitionMap, Map<String, Set<String>> apiIdCaseNameMap) {
ApiScenarioParamDto apiScenarioParamDto = new ApiScenarioParamDto(); ApiScenarioParamDTO apiScenarioParamDto = new ApiScenarioParamDTO();
apiScenarioParamDto.setBatchMapper(batchMapper); apiScenarioParamDto.setBatchMapper(batchMapper);
apiScenarioParamDto.setExtApiScenarioMapper(extApiScenarioMapper); apiScenarioParamDto.setExtApiScenarioMapper(extApiScenarioMapper);
apiScenarioParamDto.setApiTestCaseMapper(apiTestCaseMapper); apiScenarioParamDto.setApiTestCaseMapper(apiTestCaseMapper);
@ -2115,7 +2115,7 @@ public class ApiScenarioService {
return strings; 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) { if (hashTree == null) {
return; return;

View File

@ -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<String, ApiDefinition> definitionMap;
private Map<String, Set<String>> apiIdCaseNameMap;
}