refactor(接口测试): 统一规范代码格式化
This commit is contained in:
parent
8adb3bf69d
commit
ab63f3867e
|
@ -33,7 +33,7 @@ public class ApiCaseRelevanceRequest {
|
|||
*/
|
||||
private Map<String, List<String>> mapping;
|
||||
/**
|
||||
*测试评审ID
|
||||
* 测试评审ID
|
||||
*/
|
||||
private String reviewId;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package io.metersphere.api.dto;
|
||||
|
||||
import io.metersphere.request.BodyFile;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ public class GenScenarioRequest extends ApiScenarioWithBLOBs {
|
|||
|
||||
private String runMode;
|
||||
|
||||
/**测试情景和测试计划的关联ID*/
|
||||
/**
|
||||
* 测试情景和测试计划的关联ID
|
||||
*/
|
||||
private String planScenarioId;
|
||||
|
||||
private List<String> planCaseIds;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package io.metersphere.api.dto.datacount.request;
|
||||
|
||||
import io.metersphere.request.OrderRequest;
|
||||
import io.metersphere.request.TestPlanRequest;
|
||||
import lombok.Getter;
|
||||
|
|
|
@ -83,7 +83,7 @@ public class SaveApiDefinitionRequest {
|
|||
|
||||
//发送信息给场景创建人
|
||||
private Boolean scenarioCreator;
|
||||
|
||||
|
||||
//是否新建
|
||||
private Boolean newCreate;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,5 +11,5 @@ import java.util.Map;
|
|||
public class ApiDefinitionResponseDTO {
|
||||
private String returnData;
|
||||
private int returnCode = 404;
|
||||
private Map<String,String> headers = new HashMap<>();
|
||||
private Map<String, String> headers = new HashMap<>();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Setter;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class MockExpectConfigDTO{
|
||||
public class MockExpectConfigDTO {
|
||||
private String projectId;
|
||||
private MockExpectConfigWithBLOBs mockExpectConfig;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ import java.util.List;
|
|||
@Setter
|
||||
public class TestPlanScenarioStepCountSimpleDTO {
|
||||
private TestPlanScenarioStepCountDTO stepCount;
|
||||
private int underwayStepsCounts ;
|
||||
private int underwayStepsCounts;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -59,7 +59,7 @@ public class KeyValue {
|
|||
}
|
||||
|
||||
public boolean valueIsNotEmpty() {
|
||||
return StringUtils.isNotEmpty(this.getValue());
|
||||
return StringUtils.isNotEmpty(this.getValue());
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
|
|
|
@ -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<EnvAssertions> assertions;
|
||||
private boolean useErrorCode;
|
||||
private boolean higherThanSuccess;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package io.metersphere.api.dto.scenario.environment;
|
||||
|
||||
public enum GlobalScriptFilterRequest {
|
||||
HTTP,TCP,JDBC,DUBBO
|
||||
HTTP, TCP, JDBC, DUBBO
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package io.metersphere.api.dto.scenario.environment.item;
|
||||
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package io.metersphere.api.dto.share;
|
||||
|
||||
public enum ShareInfoType {
|
||||
Single,Batch
|
||||
Single, Batch
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -297,10 +297,10 @@ public class ApiScenarioExecuteService {
|
|||
//对报告的envMap做过滤,过滤多余的key
|
||||
Map<String, String> diffEnvMap = new HashMap<>();
|
||||
Map<String, String> 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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -108,24 +108,24 @@ public class TestResult {
|
|||
List<RequestResult> 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);
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class PostmanAbstractParserParser<T> 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];
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ApiDefinitionImport {
|
|||
private List<ApiTestCaseWithBLOBs> cases = new ArrayList<>();
|
||||
|
||||
//ESB文件导入的附属数据类
|
||||
private Map<String,EsbApiParamsWithBLOBs> esbApiParamsMap;
|
||||
private Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap;
|
||||
|
||||
//Mock数据相关
|
||||
private List<MockConfigImportDTO> mocks;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -20,7 +20,7 @@ public abstract class EsbAbstractParser extends ApiImportAbstractParser<ApiDefin
|
|||
ApiModule module = ApiDefinitionImportUtil.buildModule(parentModule, tag, this.projectId);
|
||||
apiDefinition.setModuleId(module.getId());
|
||||
});
|
||||
}else {
|
||||
} else {
|
||||
apiDefinition.setModuleId(parentModule.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@ import io.metersphere.api.parse.ApiImportAbstractParser;
|
|||
* @Date 2021/3/10 11:15 上午
|
||||
* @Description
|
||||
*/
|
||||
public abstract class HarAbstractParser extends ApiImportAbstractParser<ApiDefinitionImport> {
|
||||
public abstract class HarAbstractParser extends ApiImportAbstractParser<ApiDefinitionImport> {
|
||||
}
|
||||
|
|
|
@ -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<String> refSet = new HashSet<>();
|
||||
Map<String, Schema> 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);
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class SwaggerAbstractParser extends ApiImportAbstractParser<ApiD
|
|||
}
|
||||
|
||||
private ApiModule buildModule(ApiModule parentModule, ApiDefinitionWithBLOBs apiDefinition,
|
||||
String tag, String selectModulePath) {
|
||||
String tag, String selectModulePath) {
|
||||
ApiModule module = ApiDefinitionImportUtil.buildModule(parentModule, tag, this.projectId);
|
||||
apiDefinition.setModuleId(module.getId());
|
||||
if (StringUtils.isNotBlank(selectModulePath)) {
|
||||
|
|
|
@ -28,17 +28,17 @@ public class EsbSheetDataStruct {
|
|||
|
||||
|
||||
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("接口的交易码或服务名称不能都为空");
|
||||
}
|
||||
if(StringUtils.isNotEmpty(interfaceCode)){
|
||||
this.serviceName = interfaceCode+":"+interfaceName;
|
||||
}else {
|
||||
this.serviceName = interfaceName;
|
||||
}
|
||||
if (this.serviceName.endsWith(":")){
|
||||
this.serviceName = this.serviceName.substring(0,this.serviceName.length()-1);
|
||||
}
|
||||
this.serviceDesc = interfaceDesc;
|
||||
if (StringUtils.isNotEmpty(interfaceCode)) {
|
||||
this.serviceName = interfaceCode + ":" + interfaceName;
|
||||
} else {
|
||||
this.serviceName = interfaceName;
|
||||
}
|
||||
if (this.serviceName.endsWith(":")) {
|
||||
this.serviceName = this.serviceName.substring(0, this.serviceName.length() - 1);
|
||||
}
|
||||
this.serviceDesc = interfaceDesc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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 + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,36 +1,34 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,38 +1,36 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,67 +1,65 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +1,36 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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 + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,66 +1,62 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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<HarEntry> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,60 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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<HarPage> pages;
|
||||
|
||||
public List<HarEntry> 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<HarPage> pages;
|
||||
|
||||
public List<HarEntry> entries;
|
||||
|
||||
public String comment;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HarLog [version=" + version + ", creator=" + creator + ", browser=" + browser + ", pages=" + pages
|
||||
+ ", entries=" + entries + ", comment=" + comment + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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<HarEntry> 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<HarEntry> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,39 +1,36 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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 + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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<HarPostParam> params;
|
||||
|
||||
public String text;
|
||||
|
||||
public String comment;
|
||||
|
||||
public String mimeType;
|
||||
|
||||
public List<HarPostParam> params;
|
||||
|
||||
public String text;
|
||||
|
||||
public String comment;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,64 +1,62 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,60 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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<HarCookie> cookies;
|
||||
|
||||
public List<HarHeader> headers;
|
||||
|
||||
public List<HarQueryParam> 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<HarCookie> cookies;
|
||||
|
||||
public List<HarHeader> headers;
|
||||
|
||||
public List<HarQueryParam> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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<HarHeader> headers;
|
||||
|
||||
public List<HarCookie> 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<HarHeader> headers;
|
||||
|
||||
public List<HarCookie> cookies;
|
||||
|
||||
public HarContent content;
|
||||
|
||||
public String redirectURL;
|
||||
|
||||
public long headersSize;
|
||||
|
||||
public long bodySize;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HTTP " + this.status + " (" + this.statusText + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,50 +1,47 @@
|
|||
/**
|
||||
*
|
||||
* har - HAR file reader, writer and viewer
|
||||
* Copyright (c) 2014, Sandeep Gupta
|
||||
*
|
||||
* <p>
|
||||
* http://sangupta.com/projects/har
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
*
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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 + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, ApiDefinition> definitionMap = apiScenarioParamDto.getDefinitionMap();
|
||||
ApiTestCaseMapper apiTestCaseMapper = apiScenarioParamDto.getApiTestCaseMapper();
|
||||
Map<String, Set<String>> 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<ApiDefinition> apiDefinitions = new ArrayList<>(definitionMap.values());
|
||||
List<Integer> 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<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();
|
||||
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;
|
||||
}
|
||||
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<String> strings = apiIdCaseNameMap.get(caseMapKey);
|
||||
if (CollectionUtils.isEmpty(strings)){
|
||||
Set<String>addCaseNameSet = new HashSet<>();
|
||||
if (CollectionUtils.isEmpty(strings)) {
|
||||
Set<String> addCaseNameSet = new HashSet<>();
|
||||
addCaseNameSet.add(apiTestCase.getName());
|
||||
apiIdCaseNameMap.put(caseMapKey,addCaseNameSet);
|
||||
}else {
|
||||
apiIdCaseNameMap.put(caseMapKey, addCaseNameSet);
|
||||
} else {
|
||||
strings.add(apiTestCase.getName());
|
||||
}
|
||||
apiTestCaseMapper.insert(apiTestCase);
|
||||
|
|
|
@ -14,27 +14,28 @@ import java.util.Map;
|
|||
*/
|
||||
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;
|
||||
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<Integer, TCPServer> entry:serverSockedMap.entrySet()) {
|
||||
for (Map.Entry<Integer, TCPServer> 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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -14,14 +14,15 @@ import java.util.List;
|
|||
public class MockTestDataUtil {
|
||||
public List<MockTestDataRequest> parseTestDataByRequest(List<MockTestDataRequest> 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<TcpTreeTableDataStruct> parseTestDataByTcpTreeTableData(List<TcpTreeTableDataStruct> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ApiDefinitionExecResultController {
|
|||
|
||||
@PostMapping("/plan/report")
|
||||
public List<PlanReportCaseDTO> selectForPlanReport(@RequestBody List<String> apiReportIds) {
|
||||
return apiDefinitionExecResultService.selectForPlanReport(apiReportIds);
|
||||
return apiDefinitionExecResultService.selectForPlanReport(apiReportIds);
|
||||
}
|
||||
|
||||
@PostMapping("/plan/status/map")
|
||||
|
|
|
@ -230,6 +230,7 @@ public class TestPlanScenarioCaseController {
|
|||
public Map<String, List<String>> getPlanProjectEnvMap(@RequestBody List<String> resourceIds) {
|
||||
return testPlanScenarioCaseService.getPlanProjectEnvMap(resourceIds);
|
||||
}
|
||||
|
||||
@GetMapping("/get-scenario-id/{id}")
|
||||
public String getScenarioId(@PathVariable("id") String planScenarioId) {
|
||||
return testPlanScenarioCaseService.getScenarioId(planScenarioId);
|
||||
|
|
|
@ -413,6 +413,7 @@ public class ApiScenarioController {
|
|||
public List<String> getEnvProjects(@RequestBody RunScenarioRequest request) {
|
||||
return apiAutomationService.getProjects(request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/env/map")
|
||||
public Map<String, List<String>> getProjectEnvMap(@RequestBody RunScenarioRequest request) {
|
||||
return apiAutomationService.getProjectEnvMap(request);
|
||||
|
|
|
@ -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<?, String> record) {
|
||||
try {
|
||||
List<String> planIds = objectMapper.readValue(record.value(), new TypeReference<>() {});
|
||||
List<String> planIds = objectMapper.readValue(record.value(), new TypeReference<>() {
|
||||
});
|
||||
if (CollectionUtils.isEmpty(planIds)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<KeyValue> keyValueList = esbApiParamService.genKeyValueListByDataStruct(tcpSampler, tcpSampler.getEsbDataStruct());
|
||||
tcpSampler.setParameters(keyValueList);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
String reportType = tcpSampler.getReportType();
|
||||
if (StringUtils.isNotEmpty(reportType)) {
|
||||
switch (reportType) {
|
||||
|
|
|
@ -49,6 +49,7 @@ public class ExtFileAssociationService extends FileAssociationService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getHashTree(List<MsTestElement> testElements, List<BodyFile> files) {
|
||||
testElements.forEach(item -> {
|
||||
if (StringUtils.equalsIgnoreCase(item.getType(), HTTPSamplerProxy.class.getSimpleName())) {
|
||||
|
|
|
@ -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<ApiScenarioWithBLOBs> sameRequest, ApiScenarioWithBLOBs scenarioWithBLOBs, ApiTestImportRequest apiTestImportRequest, ApiScenarioParamDto apiScenarioParamDto) {
|
||||
private void _importCreate(List<ApiScenarioWithBLOBs> 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<ApiScenarioWithBLOBs> sameList, ApiScenarioParamDto apiScenarioParamDto) {
|
||||
private ApiScenarioWithBLOBs importCreate(ApiScenarioWithBLOBs request, ApiTestImportRequest apiTestImportRequest, List<ApiScenarioWithBLOBs> 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<String, ApiDefinition> definitionMap, Map<String, Set<String>> apiIdCaseNameMap) {
|
||||
ApiScenarioParamDto apiScenarioParamDto = new ApiScenarioParamDto();
|
||||
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.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;
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue