fix: 修复场景导入Har文件的问题、修复事务控制器勾选框无法取消的问题

修复场景导入Har文件的问题、修复事务控制器勾选框无法取消的问题
This commit is contained in:
song-tianyang 2021-05-21 15:21:10 +08:00 committed by 刘瑞斌
parent 3ef537b3f6
commit 5ad359315b
3 changed files with 12 additions and 21 deletions

View File

@ -11,11 +11,9 @@ import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.jmeter.RequestResult;
import io.metersphere.api.jmeter.ResponseResult;
import io.metersphere.api.parse.HarScenarioAbstractParser;
import io.metersphere.api.service.ApiScenarioModuleService;
import io.metersphere.base.domain.ApiScenarioModule;
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -92,14 +90,6 @@ public class HarScenarioParser extends HarScenarioAbstractParser<ScenarioImport>
scenario.setHashTree(results);
}
// private List<ScenarioVariable> parseScenarioVariable(List<PostmanKeyValue> postmanKeyValues) {
// if (postmanKeyValues == null) {
// return null;
// }
// List<ScenarioVariable> keyValues = new ArrayList<>();
// postmanKeyValues.forEach(item -> keyValues.add(new ScenarioVariable(item.getKey(), item.getValue(), item.getDescription(), VariableTypeConstants.CONSTANT.name())));
// return keyValues;
// }
private RequestResult getRequestResult(MsHTTPSamplerProxy samplerProxy,HarEntry harEntry) {
HarRequest request = harEntry.request;
HarResponse response = harEntry.response;
@ -128,21 +118,14 @@ private RequestResult getRequestResult(MsHTTPSamplerProxy samplerProxy,HarEntry
requestResult.setHeaders(JSONArray.toJSONString(request.headers));
requestResult.setRequestSize(request.bodySize);
// requestResult.setStartTime(result.getStartTime());
// requestResult.setEndTime(result.getEndTime());
// requestResult.setTotalAssertions(result.getAssertionResults().length);
// requestResult.setSuccess(result.isSuccessful());
// requestResult.setError(result.getErrorCount());
if(!ObjectUtils.isEmpty(request.cookies)){
requestResult.setCookies(JSONArray.toJSONString(request.cookies));
}
ResponseResult responseResult = requestResult.getResponseResult();
responseResult.setHeaders(JSONArray.toJSONString(response.headers));
// responseResult.setLatency(result.getLatency());
responseResult.setResponseCode(String.valueOf(response.status));
responseResult.setResponseSize(response.bodySize);
// responseResult.setResponseTime(result.getTime());
if(response.content != null && response.content.text != null){
responseResult.setBody(response.content.text);
responseResult.setResponseMessage(response.content.text);

View File

@ -63,7 +63,7 @@ public abstract class HarScenarioAbstractParser<T> extends ApiImportAbstractPars
return;
}
HarPostData content = requestBody.postData;
if (!StringUtils.equalsIgnoreCase("GET", requestBody.method) || requestBody.postData == null) {
if (!StringUtils.equalsIgnoreCase("GET", requestBody.method) && requestBody.postData == null) {
return;
}
String contentType = content.mimeType;

View File

@ -14,8 +14,8 @@
<template v-slot:headerLeft>
<el-input draggable size="mini" v-model="controller.name" style="width: 20%" :placeholder="$t('api_test.automation.transcation_controller')"/>
<el-checkbox v-model="controller.generateParentSample" style="margin-left: 20px">Generate Parent Sample</el-checkbox>
<el-checkbox v-model="controller.includeTimers">Include Timers</el-checkbox>
<el-checkbox v-model="controller.generateParentSample" style="margin-left: 20px" @change="changeGenerateParantSample">Generate Parent Sample</el-checkbox>
<el-checkbox v-model="controller.includeTimers" @change="changeIncludeTimers">Include Timers</el-checkbox>
</template>
</api-base-component>
@ -101,7 +101,15 @@
if (value.indexOf("empty") > 0 && !!this.controller.value) {
this.controller.value = "";
}
}
},
changeGenerateParantSample(value){
this.controller.generateParentSample = value;
this.$emit('refReload', this.controller, this.controller);
},
changeIncludeTimers(value){
this.controller.includeTimers = value;
this.$emit('refReload', this.controller, this.controller);
},
},
computed: {
hasEmptyOperator() {